add csrf
Some checks failed
Deploy / deploy (build, debian, 22, /root/OJDeploy/data/clientnext) (push) Has been cancelled
Deploy / deploy (build:staging, school, 8822, /root/OJ/data/dist) (push) Has been cancelled

This commit is contained in:
2026-05-08 04:58:06 -06:00
parent 900457574f
commit 40d895d8c7
6 changed files with 42 additions and 8 deletions

View File

@@ -1,7 +1,9 @@
<template>
<n-card title="同期解题排名分布" size="small" v-if="show">
<template #header-extra>
<n-text depth="3" style="font-size: 12px">了解同期解题速度和竞争力</n-text>
<n-text depth="3" style="font-size: 12px">
了解同期解题速度和竞争力
</n-text>
</template>
<div style="height: 300px">
<Pie :data="data" :options="options" />

View File

@@ -96,7 +96,12 @@ const columns: DataTableColumn<SolvedProblem>[] = [
{
title: () =>
h(NTooltip, null, {
trigger: () => h("span", { style: "cursor:help; border-bottom: 1px dashed" }, "等级"),
trigger: () =>
h(
"span",
{ style: "cursor:help; border-bottom: 1px dashed" },
"等级",
),
default: () =>
h("div", null, [
h("div", null, "基于同时段排名的百分位:"),

View File

@@ -1,7 +1,9 @@
<template>
<n-card title="时间活跃度分析" size="small" v-if="show">
<template #header-extra>
<n-text depth="3" style="font-size: 12px">基于 AC 时间发现解题高峰时段</n-text>
<n-text depth="3" style="font-size: 12px">
基于 AC 时间发现解题高峰时段
</n-text>
</template>
<div style="height: 300px">
<Bar :data="data" :options="options" />

View File

@@ -291,7 +291,11 @@ export function getAIDetailData(start: string, end: string, username?: string) {
return http.get("ai/detail", { params: { start, end, username } })
}
export function getAIDurationData(end: string, duration: string, username?: string) {
export function getAIDurationData(
end: string,
duration: string,
username?: string,
) {
return http.get("ai/duration", { params: { end, duration, username } })
}

View File

@@ -1,6 +1,10 @@
<script setup lang="ts">
import { JUDGE_STATUS, SubmissionStatus } from "utils/constants"
import { submissionMemoryFormat, submissionTimeFormat } from "utils/functions"
import {
getCSRFToken,
submissionMemoryFormat,
submissionTimeFormat,
} from "utils/functions"
import type { Submission } from "utils/types"
import SubmissionResultTag from "shared/components/SubmissionResultTag.vue"
import { useProblemStore } from "oj/store/problem"
@@ -61,9 +65,18 @@ async function fetchHint(submissionId: string) {
hintError.value = ""
try {
const headers: Record<string, string> = {
"Content-Type": "application/json",
}
const csrfToken = getCSRFToken()
if (csrfToken) {
headers["X-CSRFToken"] = csrfToken
}
const response = await fetch("/api/ai/hint", {
method: "POST",
headers: { "Content-Type": "application/json" },
headers,
body: JSON.stringify({ submission_id: submissionId }),
})

View File

@@ -29,7 +29,11 @@ export const useAIStore = defineStore("ai", () => {
const mdContent = ref("")
async function fetchDetailsData(start: string, end: string) {
const res = await getAIDetailData(start, end, targetUsername.value || undefined)
const res = await getAIDetailData(
start,
end,
targetUsername.value || undefined,
)
detailsData.start = res.data.start
detailsData.end = res.data.end
detailsData.solved = res.data.solved
@@ -42,7 +46,11 @@ export const useAIStore = defineStore("ai", () => {
}
async function fetchDurationData(end: string, duration: string) {
const res = await getAIDurationData(end, duration, targetUsername.value || undefined)
const res = await getAIDurationData(
end,
duration,
targetUsername.value || undefined,
)
durationData.value = res.data
}