@@ -6,7 +6,6 @@ import { useConfigStore } from "shared/store/config"
|
||||
import { useConfigUpdate } from "shared/composables/configUpdate"
|
||||
import { useMaxKB } from "shared/composables/maxkb"
|
||||
import { useUserStore } from "shared/store/user"
|
||||
import LoginSummaryModal from "shared/components/LoginSummaryModal.vue"
|
||||
|
||||
const isDark = useDark()
|
||||
const configStore = useConfigStore()
|
||||
@@ -61,7 +60,6 @@ provide("hljs", hljsInstance)
|
||||
>
|
||||
<n-message-provider>
|
||||
<router-view></router-view>
|
||||
<LoginSummaryModal />
|
||||
</n-message-provider>
|
||||
</n-config-provider>
|
||||
</template>
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@ export const STORAGE_KEY = {
|
||||
LEARN_CURRENT_STEP: "learnStep",
|
||||
ADMIN_PROBLEM: "adminProblem",
|
||||
ADMIN_PROBLEM_TAGS: "adminProblemTags",
|
||||
LOGIN_SUMMARY_LAST_SHOWN: "login-summary-last-shown",
|
||||
}
|
||||
|
||||
export const DIFFICULTY = {
|
||||
@@ -205,8 +206,8 @@ const cTemplate = `//TEMPLATE BEGIN
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
printf("黄岩一职");
|
||||
return 0;
|
||||
printf("黄岩一职");
|
||||
return 0;
|
||||
}
|
||||
//TEMPLATE END`
|
||||
|
||||
@@ -214,7 +215,7 @@ const cppTemplate = `//TEMPLATE BEGIN
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
//TEMPLATE END`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user