@@ -8,14 +8,12 @@ import { parseTime } from "utils/functions"
|
||||
const loginSummaryStore = useLoginSummaryStore()
|
||||
const { isDesktop } = useBreakpoints()
|
||||
|
||||
const rangeText = computed(() => {
|
||||
const lastLoginTime = computed(() => {
|
||||
const summary = loginSummaryStore.summary
|
||||
if (!summary?.start || !summary?.end) {
|
||||
if (!summary?.start) {
|
||||
return ""
|
||||
}
|
||||
const start = parseTime(summary.start, "YYYY-MM-DD HH:mm")
|
||||
const end = parseTime(summary.end, "YYYY-MM-DD HH:mm")
|
||||
return `${start} - ${end}`
|
||||
return parseTime(summary.start, "YYYY-MM-DD HH:mm")
|
||||
})
|
||||
|
||||
const hasAnalysis = computed(() => !!loginSummaryStore.analysis)
|
||||
@@ -31,7 +29,7 @@ const hasAnalysis = computed(() => !!loginSummaryStore.analysis)
|
||||
>
|
||||
<n-spin :show="loginSummaryStore.loading" size="small">
|
||||
<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-gi>
|
||||
<n-statistic
|
||||
@@ -79,7 +77,7 @@ const hasAnalysis = computed(() => !!loginSummaryStore.analysis)
|
||||
/>
|
||||
<n-empty
|
||||
v-else
|
||||
description="提交数少于 3 次,暂不生成 AI 分析"
|
||||
description="期间提交数少于 3 次,暂不生成 AI 分析"
|
||||
/>
|
||||
</n-flex>
|
||||
</n-spin>
|
||||
|
||||
@@ -3,6 +3,7 @@ import Beian from "../components/Beian.vue"
|
||||
import Header from "../components/Header.vue"
|
||||
import Login from "../components/Login.vue"
|
||||
import Signup from "../components/Signup.vue"
|
||||
import LoginSummaryModal from "../components/LoginSummaryModal.vue"
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -17,6 +18,7 @@ import Signup from "../components/Signup.vue"
|
||||
</n-layout-content>
|
||||
<Login />
|
||||
<Signup />
|
||||
<LoginSummaryModal />
|
||||
<Beian />
|
||||
</n-layout>
|
||||
</template>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { getAILoginSummary } from "oj/api"
|
||||
import { STORAGE_KEY } from "utils/constants"
|
||||
import storage from "utils/storage"
|
||||
|
||||
interface LoginSummary {
|
||||
start: string
|
||||
@@ -17,6 +19,14 @@ export const useLoginSummaryStore = defineStore("loginSummary", () => {
|
||||
const analysis = 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() {
|
||||
loading.value = true
|
||||
analysis.value = ""
|
||||
@@ -34,6 +44,12 @@ export const useLoginSummaryStore = defineStore("loginSummary", () => {
|
||||
}
|
||||
|
||||
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
|
||||
await fetchSummary()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user