This commit is contained in:
@@ -2,21 +2,13 @@
|
||||
<n-grid :cols="isDesktop ? 5: 1" :x-gap="20">
|
||||
<n-gi :span="2">
|
||||
<n-flex vertical size="large">
|
||||
<n-flex align="center">
|
||||
<n-flex align="center" justify="space-between">
|
||||
<n-h3 style="margin: 0;">请选择时间范围,智能分析学习情况</n-h3>
|
||||
<n-select
|
||||
style="width: 140px"
|
||||
:options="options"
|
||||
v-model:value="aiStore.duration"
|
||||
/>
|
||||
<n-flex>
|
||||
<n-input
|
||||
clearable
|
||||
style="width: 140px"
|
||||
v-if="userStore.isSuperAdmin"
|
||||
v-model:value="username"
|
||||
/>
|
||||
<n-button @click="search">查询</n-button>
|
||||
</n-flex>
|
||||
</n-flex>
|
||||
<Details :start="start" :end="end" />
|
||||
</n-flex>
|
||||
@@ -35,15 +27,12 @@ import { formatISO, sub, type Duration } from "date-fns"
|
||||
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 options: SelectOption[] = [
|
||||
{ label: "一节课内", value: "hours:1" },
|
||||
@@ -70,9 +59,5 @@ function updateRange() {
|
||||
start.value = formatISO(sub(current, subOptions.value))
|
||||
}
|
||||
|
||||
function search() {
|
||||
aiStore.username = username.value
|
||||
}
|
||||
|
||||
watch(() => aiStore.duration, updateRange, { immediate: true })
|
||||
</script>
|
||||
|
||||
@@ -129,9 +129,9 @@ const greeting = computed(() => {
|
||||
})
|
||||
|
||||
watch(
|
||||
() => [aiStore.duration, aiStore.username],
|
||||
() => aiStore.duration,
|
||||
() => {
|
||||
aiStore.fetchDetailsData(props.start, props.end, aiStore.username)
|
||||
aiStore.fetchDetailsData(props.start, props.end)
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
@@ -121,9 +121,9 @@ const options = computed<ChartOptions<"bar" | "line">>(() => {
|
||||
})
|
||||
|
||||
watch(
|
||||
() => [aiStore.duration, aiStore.username],
|
||||
() => aiStore.duration,
|
||||
() => {
|
||||
aiStore.fetchWeeklyData(props.end, aiStore.duration, aiStore.username)
|
||||
aiStore.fetchWeeklyData(props.end, aiStore.duration)
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
@@ -245,14 +245,13 @@ export function getTutorials() {
|
||||
return http.get("tutorials")
|
||||
}
|
||||
|
||||
export function getAIDetailData(start: string, end: string, username?: string) {
|
||||
return http.get("ai/detail", { params: { start, end, username } })
|
||||
export function getAIDetailData(start: string, end: string) {
|
||||
return http.get("ai/detail", { params: { start, end } })
|
||||
}
|
||||
|
||||
export function getAIWeeklyData(
|
||||
end: string,
|
||||
duration: string,
|
||||
username?: string,
|
||||
) {
|
||||
return http.get("ai/weekly", { params: { end, duration, username } })
|
||||
return http.get("ai/weekly", { params: { end, duration } })
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import { getCSRFToken } from "~/utils/functions"
|
||||
|
||||
export const useAIStore = defineStore("ai", () => {
|
||||
const duration = ref("months:6")
|
||||
const username = ref("")
|
||||
const weeklyData = ref<WeeklyData[]>([])
|
||||
const detailsData = reactive<DetailsData>({
|
||||
start: "",
|
||||
@@ -26,17 +25,14 @@ export const useAIStore = defineStore("ai", () => {
|
||||
|
||||
const mdContent = ref("")
|
||||
|
||||
const theFirstPerson = computed(() => {
|
||||
return !!username.value ? username.value : "你"
|
||||
})
|
||||
const theFirstPerson = "你"
|
||||
|
||||
async function fetchDetailsData(
|
||||
start: string,
|
||||
end: string,
|
||||
username?: string,
|
||||
) {
|
||||
loading.details = true
|
||||
const res = await getAIDetailData(start, end, username)
|
||||
const res = await getAIDetailData(start, end)
|
||||
detailsData.start = res.data.start
|
||||
detailsData.end = res.data.end
|
||||
detailsData.solved = res.data.solved
|
||||
@@ -51,10 +47,9 @@ export const useAIStore = defineStore("ai", () => {
|
||||
async function fetchWeeklyData(
|
||||
end: string,
|
||||
duration: string,
|
||||
username?: string,
|
||||
) {
|
||||
loading.weekly = true
|
||||
const res = await getAIWeeklyData(end, duration, username)
|
||||
const res = await getAIWeeklyData(end, duration)
|
||||
weeklyData.value = res.data
|
||||
loading.weekly = false
|
||||
}
|
||||
@@ -145,7 +140,6 @@ export const useAIStore = defineStore("ai", () => {
|
||||
weeklyData,
|
||||
detailsData,
|
||||
duration,
|
||||
username,
|
||||
theFirstPerson,
|
||||
loading,
|
||||
mdContent,
|
||||
|
||||
Reference in New Issue
Block a user