add csrf
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<n-card title="同期解题排名分布" size="small" v-if="show">
|
<n-card title="同期解题排名分布" size="small" v-if="show">
|
||||||
<template #header-extra>
|
<template #header-extra>
|
||||||
<n-text depth="3" style="font-size: 12px">了解同期解题速度和竞争力</n-text>
|
<n-text depth="3" style="font-size: 12px">
|
||||||
|
了解同期解题速度和竞争力
|
||||||
|
</n-text>
|
||||||
</template>
|
</template>
|
||||||
<div style="height: 300px">
|
<div style="height: 300px">
|
||||||
<Pie :data="data" :options="options" />
|
<Pie :data="data" :options="options" />
|
||||||
|
|||||||
@@ -96,7 +96,12 @@ const columns: DataTableColumn<SolvedProblem>[] = [
|
|||||||
{
|
{
|
||||||
title: () =>
|
title: () =>
|
||||||
h(NTooltip, null, {
|
h(NTooltip, null, {
|
||||||
trigger: () => h("span", { style: "cursor:help; border-bottom: 1px dashed" }, "等级"),
|
trigger: () =>
|
||||||
|
h(
|
||||||
|
"span",
|
||||||
|
{ style: "cursor:help; border-bottom: 1px dashed" },
|
||||||
|
"等级",
|
||||||
|
),
|
||||||
default: () =>
|
default: () =>
|
||||||
h("div", null, [
|
h("div", null, [
|
||||||
h("div", null, "基于同时段排名的百分位:"),
|
h("div", null, "基于同时段排名的百分位:"),
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<n-card title="时间活跃度分析" size="small" v-if="show">
|
<n-card title="时间活跃度分析" size="small" v-if="show">
|
||||||
<template #header-extra>
|
<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>
|
</template>
|
||||||
<div style="height: 300px">
|
<div style="height: 300px">
|
||||||
<Bar :data="data" :options="options" />
|
<Bar :data="data" :options="options" />
|
||||||
|
|||||||
@@ -291,7 +291,11 @@ export function getAIDetailData(start: string, end: string, username?: string) {
|
|||||||
return http.get("ai/detail", { params: { start, end, username } })
|
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 } })
|
return http.get("ai/duration", { params: { end, duration, username } })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { JUDGE_STATUS, SubmissionStatus } from "utils/constants"
|
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 type { Submission } from "utils/types"
|
||||||
import SubmissionResultTag from "shared/components/SubmissionResultTag.vue"
|
import SubmissionResultTag from "shared/components/SubmissionResultTag.vue"
|
||||||
import { useProblemStore } from "oj/store/problem"
|
import { useProblemStore } from "oj/store/problem"
|
||||||
@@ -61,9 +65,18 @@ async function fetchHint(submissionId: string) {
|
|||||||
hintError.value = ""
|
hintError.value = ""
|
||||||
|
|
||||||
try {
|
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", {
|
const response = await fetch("/api/ai/hint", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers,
|
||||||
body: JSON.stringify({ submission_id: submissionId }),
|
body: JSON.stringify({ submission_id: submissionId }),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,11 @@ export const useAIStore = defineStore("ai", () => {
|
|||||||
const mdContent = ref("")
|
const mdContent = ref("")
|
||||||
|
|
||||||
async function fetchDetailsData(start: string, end: string) {
|
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.start = res.data.start
|
||||||
detailsData.end = res.data.end
|
detailsData.end = res.data.end
|
||||||
detailsData.solved = res.data.solved
|
detailsData.solved = res.data.solved
|
||||||
@@ -42,7 +46,11 @@ export const useAIStore = defineStore("ai", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function fetchDurationData(end: string, duration: string) {
|
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
|
durationData.value = res.data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user