diff --git a/src/oj/ai/analysis.vue b/src/oj/ai/analysis.vue
index 668571e..dbd13d5 100644
--- a/src/oj/ai/analysis.vue
+++ b/src/oj/ai/analysis.vue
@@ -6,7 +6,7 @@
查询
-
+
-
+
+
+
+
@@ -41,17 +35,16 @@ import { formatISO, sub, type Duration } from "date-fns"
import { NButton } from "naive-ui"
import WeeklyChart from "./components/WeeklyChart.vue"
import Details from "./components/Details.vue"
+import AI from "./components/AI.vue"
import { useUserStore } from "~/shared/store/user"
+import { useAIStore } from "../store/ai"
const userStore = useUserStore()
+const aiStore = useAIStore()
const start = ref("")
const end = ref("")
const username = ref("")
-const query = reactive({
- username: "",
- duration: "months:6",
-})
const options: SelectOption[] = [
{ label: "一节课内", value: "hours:1" },
@@ -65,7 +58,7 @@ const options: SelectOption[] = [
]
const subOptions = computed(() => {
- let dur = options.find((it) => it.value === query.duration) ?? options[0]
+ let dur = options.find((it) => it.value === aiStore.duration) ?? options[0]
const x = dur.value!.toString().split(":")
const unit = x[0]
const n = x[1]
@@ -79,8 +72,8 @@ function updateRange() {
}
function search() {
- query.username = username.value
+ aiStore.username = username.value
}
-watch(() => query.duration, updateRange, { immediate: true })
+watch(() => aiStore.duration, updateRange, { immediate: true })
diff --git a/src/oj/ai/components/AI.vue b/src/oj/ai/components/AI.vue
new file mode 100644
index 0000000..4325cfb
--- /dev/null
+++ b/src/oj/ai/components/AI.vue
@@ -0,0 +1,25 @@
+
+
+ AI 小助手友情提醒
+
+
+
diff --git a/src/oj/ai/components/Details.vue b/src/oj/ai/components/Details.vue
index f91e5e3..9b4b6f7 100644
--- a/src/oj/ai/components/Details.vue
+++ b/src/oj/ai/components/Details.vue
@@ -1,33 +1,40 @@
-
+
-
+
{{ durationLabel }},
- {{ !!username ? username : "你" }}一共解决
- {{ solvedProblems.length }}
+ {{ aiStore.theFirstPerson }}一共解决
+ {{ aiStore.detailsData.solved.length }}
道题,
-
+
并且参加
- {{ contest_count }} 次比赛,
+ {{ aiStore.detailsData.contest_count }}
+ 次比赛,
综合评价给到
-
+
{{ greeting }}
-
+
+
+
+
-
-
+
+
@@ -39,43 +46,18 @@ import Grade from "./Grade.vue"
import TagsChart from "./TagsChart.vue"
import DifficultyChart from "./DifficultyChart.vue"
import TagTitle from "./TagTitle.vue"
+import AI from "./AI.vue"
import { parseTime } from "~/utils/functions"
-import { getAIDetailData } from "~/oj/api"
+import { SolvedProblem } from "~/utils/types"
+import { useAIStore } from "~/oj/store/ai"
const props = defineProps<{
start: string
end: string
- duration: string
- username: string
}>()
const router = useRouter()
-
-interface SolvedProblem {
- problem: {
- title: string
- display_id: string
- contest_title: string
- contest_id: number
- }
- ac_time: string
- rank: number
- ac_count: number
- grade: "S" | "A" | "B" | "C"
-}
-
-const detailLoading = ref(false)
-
-const startLabel = ref("")
-const endLabel = ref("")
-
-const grade = ref<"S" | "A" | "B" | "C">("B")
-const class_name = ref("")
-const tags = ref<{ [key: string]: number }>({})
-const difficulty = ref<{ [key: string]: number }>({})
-const contest_count = ref(0)
-
-const solvedProblems = ref([])
+const aiStore = useAIStore()
const columns: DataTableColumn[] = [
{
@@ -109,7 +91,7 @@ const columns: DataTableColumn[] = [
),
},
{
- title: () => (class_name ? "班级排名" : "全服排名"),
+ title: () => (aiStore.detailsData.class_name ? "班级排名" : "全服排名"),
key: "rank",
width: 100,
align: "center",
@@ -124,17 +106,17 @@ const columns: DataTableColumn[] = [
]
const durationLabel = computed(() => {
- if (props.duration.includes("hours")) {
- return `在 ${parseTime(startLabel.value, "HH:mm")} - ${parseTime(endLabel.value, "HH:mm")} 期间`
- } else if (props.duration.includes("days")) {
- return `在 ${parseTime(endLabel.value, "MM月DD日")}`
+ if (aiStore.duration.includes("hours")) {
+ return `在 ${parseTime(aiStore.detailsData.start, "HH:mm")} - ${parseTime(aiStore.detailsData.end, "HH:mm")} 期间`
+ } else if (aiStore.duration.includes("days")) {
+ return `在 ${parseTime(aiStore.detailsData.end, "MM月DD日")}`
} else if (
- props.duration.includes("weeks") ||
- props.duration.includes("months")
+ aiStore.duration.includes("weeks") ||
+ aiStore.duration.includes("months")
) {
- return `在 ${parseTime(startLabel.value, "MM月DD日")} - ${parseTime(endLabel.value, "MM月DD日")} 期间`
+ return `在 ${parseTime(aiStore.detailsData.start, "MM月DD日")} - ${parseTime(aiStore.detailsData.end, "MM月DD日")} 期间`
} else {
- return `在 ${parseTime(startLabel.value, "YYYY年MM月DD日")} - ${parseTime(endLabel.value, "YYYY年MM月DD日")} 期间`
+ return `在 ${parseTime(aiStore.detailsData.start, "YYYY年MM月DD日")} - ${parseTime(aiStore.detailsData.end, "YYYY年MM月DD日")} 期间`
}
})
@@ -144,25 +126,16 @@ const greeting = computed(() => {
A: "你很棒,继续保持!",
B: "请再接再厉!",
C: "你还需要努力!",
- }[grade.value]
+ }[aiStore.detailsData.grade]
})
-async function getDetail() {
- detailLoading.value = true
- const res = await getAIDetailData(props.start, props.end, props.username)
- detailLoading.value = false
-
- startLabel.value = res.data.start
- endLabel.value = res.data.end
- solvedProblems.value = res.data.solved
- grade.value = res.data.grade
- class_name.value = res.data.class_name
- tags.value = res.data.tags
- difficulty.value = res.data.difficulty
- contest_count.value = res.data.contest_count
-}
-
-watch(() => [props.duration, props.username], getDetail, { immediate: true })
+watch(
+ () => [aiStore.duration, aiStore.username],
+ () => {
+ aiStore.fetchDetailsData(props.start, props.end, aiStore.username)
+ },
+ { immediate: true },
+)