为用户主页添加强制刷新的按钮

This commit is contained in:
2024-07-04 09:20:42 +08:00
parent 07398bd04d
commit c84d103418
2 changed files with 21 additions and 5 deletions

View File

@@ -208,3 +208,7 @@ export function getComment(problemID: number) {
export function getCommentStatistics(problemID: number) {
return http.get("comment/statistics", { params: { problem_id: problemID } })
}
export function refreshUserProblemDisplayIds() {
return http.get("profile/fresh_display_id")
}

View File

@@ -1,6 +1,7 @@
<script setup lang="ts">
import { getProfile } from "~/shared/api"
import { Profile } from "~/utils/types"
import { refreshUserProblemDisplayIds } from "../api"
const route = useRoute()
const router = useRouter()
@@ -17,9 +18,9 @@ async function init() {
const oi = res.data.oi_problems_status.problems || {}
const ac: string[] = []
for (let problems of [acm, oi]) {
Object.keys(problems).forEach((problemID) => {
if (problems[problemID]["status"] === 0) {
ac.push(problems[problemID]["_id"])
Object.keys(problems).forEach((id) => {
if (problems[id]["status"] === 0) {
ac.push(problems[id]["_id"])
}
})
}
@@ -30,6 +31,11 @@ async function init() {
}
}
async function refresh() {
await refreshUserProblemDisplayIds()
init()
}
onMounted(init)
</script>
<template>
@@ -57,7 +63,13 @@ onMounted(init)
<n-descriptions-item label="总提交数">
{{ profile.submission_number }}
</n-descriptions-item>
<n-descriptions-item v-if="problems.length" label="已解决的题目" :span="2">
<n-descriptions-item v-if="problems.length" :span="2">
<template #label>
<n-flex align="center">
已解决的题目
<n-button size="small" @click="refresh">强制刷新</n-button>
</n-flex>
</template>
<n-space>
<n-button
v-for="id in problems"
@@ -77,7 +89,7 @@ onMounted(init)
</template>
<style scoped>
.wrapper {
max-width: 600px;
max-width: 610px;
margin: 16px auto 0;
}