@@ -6,7 +6,6 @@ import { useConfigStore } from "shared/store/config"
|
|||||||
import { useConfigUpdate } from "shared/composables/configUpdate"
|
import { useConfigUpdate } from "shared/composables/configUpdate"
|
||||||
import { useMaxKB } from "shared/composables/maxkb"
|
import { useMaxKB } from "shared/composables/maxkb"
|
||||||
import { useUserStore } from "shared/store/user"
|
import { useUserStore } from "shared/store/user"
|
||||||
import LoginSummaryModal from "shared/components/LoginSummaryModal.vue"
|
|
||||||
|
|
||||||
const isDark = useDark()
|
const isDark = useDark()
|
||||||
const configStore = useConfigStore()
|
const configStore = useConfigStore()
|
||||||
@@ -61,7 +60,6 @@ provide("hljs", hljsInstance)
|
|||||||
>
|
>
|
||||||
<n-message-provider>
|
<n-message-provider>
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
<LoginSummaryModal />
|
|
||||||
</n-message-provider>
|
</n-message-provider>
|
||||||
</n-config-provider>
|
</n-config-provider>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -8,14 +8,12 @@ import { parseTime } from "utils/functions"
|
|||||||
const loginSummaryStore = useLoginSummaryStore()
|
const loginSummaryStore = useLoginSummaryStore()
|
||||||
const { isDesktop } = useBreakpoints()
|
const { isDesktop } = useBreakpoints()
|
||||||
|
|
||||||
const rangeText = computed(() => {
|
const lastLoginTime = computed(() => {
|
||||||
const summary = loginSummaryStore.summary
|
const summary = loginSummaryStore.summary
|
||||||
if (!summary?.start || !summary?.end) {
|
if (!summary?.start) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
const start = parseTime(summary.start, "YYYY-MM-DD HH:mm")
|
return parseTime(summary.start, "YYYY-MM-DD HH:mm")
|
||||||
const end = parseTime(summary.end, "YYYY-MM-DD HH:mm")
|
|
||||||
return `${start} - ${end}`
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const hasAnalysis = computed(() => !!loginSummaryStore.analysis)
|
const hasAnalysis = computed(() => !!loginSummaryStore.analysis)
|
||||||
@@ -31,7 +29,7 @@ const hasAnalysis = computed(() => !!loginSummaryStore.analysis)
|
|||||||
>
|
>
|
||||||
<n-spin :show="loginSummaryStore.loading" size="small">
|
<n-spin :show="loginSummaryStore.loading" size="small">
|
||||||
<n-flex vertical size="large">
|
<n-flex vertical size="large">
|
||||||
<n-text v-if="rangeText">统计区间:{{ rangeText }}</n-text>
|
<n-text v-if="lastLoginTime">上次登录时间:{{ lastLoginTime }}</n-text>
|
||||||
<n-grid :cols="isDesktop ? 3 : 1" :x-gap="16" :y-gap="16">
|
<n-grid :cols="isDesktop ? 3 : 1" :x-gap="16" :y-gap="16">
|
||||||
<n-gi>
|
<n-gi>
|
||||||
<n-statistic
|
<n-statistic
|
||||||
@@ -79,7 +77,7 @@ const hasAnalysis = computed(() => !!loginSummaryStore.analysis)
|
|||||||
/>
|
/>
|
||||||
<n-empty
|
<n-empty
|
||||||
v-else
|
v-else
|
||||||
description="提交数少于 3 次,暂不生成 AI 分析"
|
description="期间提交数少于 3 次,暂不生成 AI 分析"
|
||||||
/>
|
/>
|
||||||
</n-flex>
|
</n-flex>
|
||||||
</n-spin>
|
</n-spin>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import Beian from "../components/Beian.vue"
|
|||||||
import Header from "../components/Header.vue"
|
import Header from "../components/Header.vue"
|
||||||
import Login from "../components/Login.vue"
|
import Login from "../components/Login.vue"
|
||||||
import Signup from "../components/Signup.vue"
|
import Signup from "../components/Signup.vue"
|
||||||
|
import LoginSummaryModal from "../components/LoginSummaryModal.vue"
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -17,6 +18,7 @@ import Signup from "../components/Signup.vue"
|
|||||||
</n-layout-content>
|
</n-layout-content>
|
||||||
<Login />
|
<Login />
|
||||||
<Signup />
|
<Signup />
|
||||||
|
<LoginSummaryModal />
|
||||||
<Beian />
|
<Beian />
|
||||||
</n-layout>
|
</n-layout>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { getAILoginSummary } from "oj/api"
|
import { getAILoginSummary } from "oj/api"
|
||||||
|
import { STORAGE_KEY } from "utils/constants"
|
||||||
|
import storage from "utils/storage"
|
||||||
|
|
||||||
interface LoginSummary {
|
interface LoginSummary {
|
||||||
start: string
|
start: string
|
||||||
@@ -17,6 +19,14 @@ export const useLoginSummaryStore = defineStore("loginSummary", () => {
|
|||||||
const analysis = ref("")
|
const analysis = ref("")
|
||||||
const analysisError = ref("")
|
const analysisError = ref("")
|
||||||
|
|
||||||
|
function getTodayKey() {
|
||||||
|
const now = new Date()
|
||||||
|
const year = now.getFullYear()
|
||||||
|
const month = String(now.getMonth() + 1).padStart(2, "0")
|
||||||
|
const day = String(now.getDate()).padStart(2, "0")
|
||||||
|
return `${year}-${month}-${day}`
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchSummary() {
|
async function fetchSummary() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
analysis.value = ""
|
analysis.value = ""
|
||||||
@@ -34,6 +44,12 @@ export const useLoginSummaryStore = defineStore("loginSummary", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function open() {
|
async function open() {
|
||||||
|
const today = getTodayKey()
|
||||||
|
const lastShown = storage.get(STORAGE_KEY.LOGIN_SUMMARY_LAST_SHOWN)
|
||||||
|
if (lastShown === today) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
storage.set(STORAGE_KEY.LOGIN_SUMMARY_LAST_SHOWN, today)
|
||||||
show.value = true
|
show.value = true
|
||||||
await fetchSummary()
|
await fetchSummary()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ export const STORAGE_KEY = {
|
|||||||
LEARN_CURRENT_STEP: "learnStep",
|
LEARN_CURRENT_STEP: "learnStep",
|
||||||
ADMIN_PROBLEM: "adminProblem",
|
ADMIN_PROBLEM: "adminProblem",
|
||||||
ADMIN_PROBLEM_TAGS: "adminProblemTags",
|
ADMIN_PROBLEM_TAGS: "adminProblemTags",
|
||||||
|
LOGIN_SUMMARY_LAST_SHOWN: "login-summary-last-shown",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DIFFICULTY = {
|
export const DIFFICULTY = {
|
||||||
@@ -205,8 +206,8 @@ const cTemplate = `//TEMPLATE BEGIN
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
printf("黄岩一职");
|
printf("黄岩一职");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//TEMPLATE END`
|
//TEMPLATE END`
|
||||||
|
|
||||||
@@ -214,7 +215,7 @@ const cppTemplate = `//TEMPLATE BEGIN
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//TEMPLATE END`
|
//TEMPLATE END`
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user