为用户主页添加强制刷新的按钮
This commit is contained in:
@@ -208,3 +208,7 @@ export function getComment(problemID: number) {
|
|||||||
export function getCommentStatistics(problemID: number) {
|
export function getCommentStatistics(problemID: number) {
|
||||||
return http.get("comment/statistics", { params: { problem_id: problemID } })
|
return http.get("comment/statistics", { params: { problem_id: problemID } })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function refreshUserProblemDisplayIds() {
|
||||||
|
return http.get("profile/fresh_display_id")
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getProfile } from "~/shared/api"
|
import { getProfile } from "~/shared/api"
|
||||||
import { Profile } from "~/utils/types"
|
import { Profile } from "~/utils/types"
|
||||||
|
import { refreshUserProblemDisplayIds } from "../api"
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -17,9 +18,9 @@ async function init() {
|
|||||||
const oi = res.data.oi_problems_status.problems || {}
|
const oi = res.data.oi_problems_status.problems || {}
|
||||||
const ac: string[] = []
|
const ac: string[] = []
|
||||||
for (let problems of [acm, oi]) {
|
for (let problems of [acm, oi]) {
|
||||||
Object.keys(problems).forEach((problemID) => {
|
Object.keys(problems).forEach((id) => {
|
||||||
if (problems[problemID]["status"] === 0) {
|
if (problems[id]["status"] === 0) {
|
||||||
ac.push(problems[problemID]["_id"])
|
ac.push(problems[id]["_id"])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -30,6 +31,11 @@ async function init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function refresh() {
|
||||||
|
await refreshUserProblemDisplayIds()
|
||||||
|
init()
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(init)
|
onMounted(init)
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
@@ -57,7 +63,13 @@ onMounted(init)
|
|||||||
<n-descriptions-item label="总提交数">
|
<n-descriptions-item label="总提交数">
|
||||||
{{ profile.submission_number }}
|
{{ profile.submission_number }}
|
||||||
</n-descriptions-item>
|
</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-space>
|
||||||
<n-button
|
<n-button
|
||||||
v-for="id in problems"
|
v-for="id in problems"
|
||||||
@@ -77,7 +89,7 @@ onMounted(init)
|
|||||||
</template>
|
</template>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.wrapper {
|
.wrapper {
|
||||||
max-width: 600px;
|
max-width: 610px;
|
||||||
margin: 16px auto 0;
|
margin: 16px auto 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user