diff --git a/src/oj/api.ts b/src/oj/api.ts index 04602a3..efe618d 100644 --- a/src/oj/api.ts +++ b/src/oj/api.ts @@ -1,4 +1,4 @@ -import http, { type ApiResponse } from "utils/http" +import http from "utils/http" import { filterResult } from "oj/transforms" import type { Exercise, @@ -226,43 +226,16 @@ export function getMessageList(offset = 0, limit = 10) { } export function getReaction(problemID: number) { - return http - .get("reaction", { - params: { problem_id: problemID }, - }) - .then(normalizeReactionResponse) -} - -interface ReactionWireState { - mine: ReactionKey[] | ReactionKey | null - mine_type?: ReactionKey | null - counts: ReactionState["counts"] -} - -function normalizeReactionResponse( - res: ApiResponse, -): ApiResponse { - const legacyMine = Array.isArray(res.data.mine) - ? (res.data.mine[0] ?? null) - : res.data.mine - return { - ...res, - data: { - mine: res.data.mine_type ?? legacyMine, - counts: res.data.counts, - }, - } + return http.get("reaction", { + params: { problem_id: problemID }, + }) } export function setReaction(problemID: number, type: ReactionKey) { - return http - .post("reaction", { - problem_id: problemID, - type, - // 过渡期同时发送旧字段:新前端先上线时,旧后端也能接受单选提交。 - types: [type], - }) - .then(normalizeReactionResponse) + return http.post("reaction", { + problem_id: problemID, + type, + }) } // TODO: 这个API有问题 diff --git a/src/oj/problem/components/ProblemReaction.vue b/src/oj/problem/components/ProblemReaction.vue index afd9d26..efeeb8d 100644 --- a/src/oj/problem/components/ProblemReaction.vue +++ b/src/oj/problem/components/ProblemReaction.vue @@ -6,7 +6,7 @@ v-for="item in REACTIONS" :key="item.key" trigger="hover" - :disabled="solved && !locked" + :disabled="solved" > - {{ tooltipOf(item.label) }} + 完成本题后可以评价
@@ -55,12 +55,7 @@ const submitting = ref(null) const solved = computed(() => problem.value?.my_status === 0) // 评价一次定终身:后端已存在记录就锁死,只剩查看 -const locked = ref(false) - -function tooltipOf(label: string) { - if (!solved.value) return "完成本题后可以评价" - return `${label}(已评价,不能修改)` -} +const locked = computed(() => mine.value !== null) async function pick(key: ReactionKey) { if (!problem.value) return @@ -69,7 +64,6 @@ async function pick(key: ReactionKey) { const res = await setReaction(problem.value.id, key) mine.value = res.data.mine counts.value = res.data.counts - locked.value = true emit("submitted") } catch { message.error("提交失败,请重试") @@ -83,7 +77,6 @@ async function load() { const res = await getReaction(problem.value.id) mine.value = res.data.mine counts.value = res.data.counts - locked.value = res.data.mine !== null } onMounted(() => { diff --git a/src/oj/problem/components/SubmitCode.vue b/src/oj/problem/components/SubmitCode.vue index f537400..0140d81 100644 --- a/src/oj/problem/components/SubmitCode.vue +++ b/src/oj/problem/components/SubmitCode.vue @@ -40,9 +40,8 @@ const router = useRouter() const [commentPanel] = useToggle() const message = useMessage() -// 评价提交后停一下让用户看到选中态,再收起弹窗 function closeCommentPanel() { - setTimeout(() => (commentPanel.value = false), 800) + commentPanel.value = false } const { isDesktop } = useBreakpoints() @@ -266,6 +265,8 @@ watch( preset="card" title="恭喜你成功提交,说说你对这道题的感受吧" :mask-closable="false" + :closable="false" + :close-on-esc="false" :style="{ maxWidth: isDesktop && '50vw', maxHeight: '80vh' }" v-model:show="commentPanel" >