This commit is contained in:
@@ -2,21 +2,13 @@
|
|||||||
<n-grid :cols="isDesktop ? 5: 1" :x-gap="20">
|
<n-grid :cols="isDesktop ? 5: 1" :x-gap="20">
|
||||||
<n-gi :span="2">
|
<n-gi :span="2">
|
||||||
<n-flex vertical size="large">
|
<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
|
<n-select
|
||||||
style="width: 140px"
|
style="width: 140px"
|
||||||
:options="options"
|
:options="options"
|
||||||
v-model:value="aiStore.duration"
|
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>
|
</n-flex>
|
||||||
<Details :start="start" :end="end" />
|
<Details :start="start" :end="end" />
|
||||||
</n-flex>
|
</n-flex>
|
||||||
@@ -35,15 +27,12 @@ import { formatISO, sub, type Duration } from "date-fns"
|
|||||||
import WeeklyChart from "./components/WeeklyChart.vue"
|
import WeeklyChart from "./components/WeeklyChart.vue"
|
||||||
import Details from "./components/Details.vue"
|
import Details from "./components/Details.vue"
|
||||||
import AI from "./components/AI.vue"
|
import AI from "./components/AI.vue"
|
||||||
import { useUserStore } from "~/shared/store/user"
|
|
||||||
import { useAIStore } from "../store/ai"
|
import { useAIStore } from "../store/ai"
|
||||||
|
|
||||||
const userStore = useUserStore()
|
|
||||||
const aiStore = useAIStore()
|
const aiStore = useAIStore()
|
||||||
|
|
||||||
const start = ref("")
|
const start = ref("")
|
||||||
const end = ref("")
|
const end = ref("")
|
||||||
const username = ref("")
|
|
||||||
|
|
||||||
const options: SelectOption[] = [
|
const options: SelectOption[] = [
|
||||||
{ label: "一节课内", value: "hours:1" },
|
{ label: "一节课内", value: "hours:1" },
|
||||||
@@ -70,9 +59,5 @@ function updateRange() {
|
|||||||
start.value = formatISO(sub(current, subOptions.value))
|
start.value = formatISO(sub(current, subOptions.value))
|
||||||
}
|
}
|
||||||
|
|
||||||
function search() {
|
|
||||||
aiStore.username = username.value
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(() => aiStore.duration, updateRange, { immediate: true })
|
watch(() => aiStore.duration, updateRange, { immediate: true })
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -129,9 +129,9 @@ const greeting = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [aiStore.duration, aiStore.username],
|
() => aiStore.duration,
|
||||||
() => {
|
() => {
|
||||||
aiStore.fetchDetailsData(props.start, props.end, aiStore.username)
|
aiStore.fetchDetailsData(props.start, props.end)
|
||||||
},
|
},
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -121,9 +121,9 @@ const options = computed<ChartOptions<"bar" | "line">>(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [aiStore.duration, aiStore.username],
|
() => aiStore.duration,
|
||||||
() => {
|
() => {
|
||||||
aiStore.fetchWeeklyData(props.end, aiStore.duration, aiStore.username)
|
aiStore.fetchWeeklyData(props.end, aiStore.duration)
|
||||||
},
|
},
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -245,14 +245,13 @@ export function getTutorials() {
|
|||||||
return http.get("tutorials")
|
return http.get("tutorials")
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAIDetailData(start: string, end: string, username?: string) {
|
export function getAIDetailData(start: string, end: string) {
|
||||||
return http.get("ai/detail", { params: { start, end, username } })
|
return http.get("ai/detail", { params: { start, end } })
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAIWeeklyData(
|
export function getAIWeeklyData(
|
||||||
end: string,
|
end: string,
|
||||||
duration: 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", () => {
|
export const useAIStore = defineStore("ai", () => {
|
||||||
const duration = ref("months:6")
|
const duration = ref("months:6")
|
||||||
const username = ref("")
|
|
||||||
const weeklyData = ref<WeeklyData[]>([])
|
const weeklyData = ref<WeeklyData[]>([])
|
||||||
const detailsData = reactive<DetailsData>({
|
const detailsData = reactive<DetailsData>({
|
||||||
start: "",
|
start: "",
|
||||||
@@ -26,17 +25,14 @@ export const useAIStore = defineStore("ai", () => {
|
|||||||
|
|
||||||
const mdContent = ref("")
|
const mdContent = ref("")
|
||||||
|
|
||||||
const theFirstPerson = computed(() => {
|
const theFirstPerson = "你"
|
||||||
return !!username.value ? username.value : "你"
|
|
||||||
})
|
|
||||||
|
|
||||||
async function fetchDetailsData(
|
async function fetchDetailsData(
|
||||||
start: string,
|
start: string,
|
||||||
end: string,
|
end: string,
|
||||||
username?: string,
|
|
||||||
) {
|
) {
|
||||||
loading.details = true
|
loading.details = true
|
||||||
const res = await getAIDetailData(start, end, username)
|
const res = await getAIDetailData(start, end)
|
||||||
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
|
||||||
@@ -51,10 +47,9 @@ export const useAIStore = defineStore("ai", () => {
|
|||||||
async function fetchWeeklyData(
|
async function fetchWeeklyData(
|
||||||
end: string,
|
end: string,
|
||||||
duration: string,
|
duration: string,
|
||||||
username?: string,
|
|
||||||
) {
|
) {
|
||||||
loading.weekly = true
|
loading.weekly = true
|
||||||
const res = await getAIWeeklyData(end, duration, username)
|
const res = await getAIWeeklyData(end, duration)
|
||||||
weeklyData.value = res.data
|
weeklyData.value = res.data
|
||||||
loading.weekly = false
|
loading.weekly = false
|
||||||
}
|
}
|
||||||
@@ -145,7 +140,6 @@ export const useAIStore = defineStore("ai", () => {
|
|||||||
weeklyData,
|
weeklyData,
|
||||||
detailsData,
|
detailsData,
|
||||||
duration,
|
duration,
|
||||||
username,
|
|
||||||
theFirstPerson,
|
theFirstPerson,
|
||||||
loading,
|
loading,
|
||||||
mdContent,
|
mdContent,
|
||||||
|
|||||||
Reference in New Issue
Block a user