From d68ef60ab9c8ecaaa89b60e5e209809a69b63864 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Wed, 18 Mar 2026 14:50:20 +0800 Subject: [PATCH] update --- components.d.ts | 6 +- src/api.ts | 56 ++- src/components/Editors.vue | 2 + src/components/Login.vue | 228 +++++++-- src/components/Preview.vue | 2 +- src/components/PromptPanel.vue | 112 ++++- src/components/Toolbar.vue | 16 + src/components/submissions/ChainModal.vue | 148 ++++++ src/components/submissions/CodeModal.vue | 35 ++ .../submissions/ExpandedSubTable.vue | 107 +++++ src/components/submissions/FlagCell.vue | 61 +++ src/pages/ChallengeHome.vue | 5 +- src/pages/Ranking.vue | 222 +++++++++ src/pages/Submissions.vue | 433 +++++++----------- src/router.ts | 6 + src/store/prompt.ts | 69 ++- src/utils/type.ts | 13 + 17 files changed, 1207 insertions(+), 314 deletions(-) create mode 100644 src/components/submissions/ChainModal.vue create mode 100644 src/components/submissions/CodeModal.vue create mode 100644 src/components/submissions/ExpandedSubTable.vue create mode 100644 src/components/submissions/FlagCell.vue create mode 100644 src/pages/Ranking.vue diff --git a/components.d.ts b/components.d.ts index 80e9452..a9afd05 100644 --- a/components.d.ts +++ b/components.d.ts @@ -11,9 +11,13 @@ export {} /* prettier-ignore */ declare module 'vue' { export interface GlobalComponents { + ChainModal: typeof import('./src/components/submissions/ChainModal.vue')['default'] Challenge: typeof import('./src/components/Challenge.vue')['default'] + CodeModal: typeof import('./src/components/submissions/CodeModal.vue')['default'] Editor: typeof import('./src/components/Editor.vue')['default'] Editors: typeof import('./src/components/Editors.vue')['default'] + ExpandedSubTable: typeof import('./src/components/submissions/ExpandedSubTable.vue')['default'] + FlagCell: typeof import('./src/components/submissions/FlagCell.vue')['default'] Login: typeof import('./src/components/Login.vue')['default'] MarkdownEditor: typeof import('./src/components/dashboard/MarkdownEditor.vue')['default'] NAlert: typeof import('naive-ui')['NAlert'] @@ -21,7 +25,6 @@ declare module 'vue' { NCard: typeof import('naive-ui')['NCard'] NCode: typeof import('naive-ui')['NCode'] NConfigProvider: typeof import('naive-ui')['NConfigProvider'] - NDataTable: typeof import('naive-ui')['NDataTable'] NDialogProvider: typeof import('naive-ui')['NDialogProvider'] NDropdown: typeof import('naive-ui')['NDropdown'] NEmpty: typeof import('naive-ui')['NEmpty'] @@ -34,7 +37,6 @@ declare module 'vue' { NMessageProvider: typeof import('naive-ui')['NMessageProvider'] NModal: typeof import('naive-ui')['NModal'] NModalProvider: typeof import('naive-ui')['NModalProvider'] - NPagination: typeof import('naive-ui')['NPagination'] NPopover: typeof import('naive-ui')['NPopover'] NRate: typeof import('naive-ui')['NRate'] NSelect: typeof import('naive-ui')['NSelect'] diff --git a/src/api.ts b/src/api.ts index ab9255f..a9207b0 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,6 +1,6 @@ import axios from "axios" import { router } from "./router" -import type { TutorialIn, ChallengeIn, FlagType } from "./utils/type" +import type { TutorialIn, ChallengeIn, FlagType, SubmissionOut, PromptMessage } from "./utils/type" import { BASE_URL, STORAGE_KEY } from "./utils/const" const http = axios.create({ @@ -72,6 +72,18 @@ export const Account = { const res = await http.get("/account/leaderboard") return res.data as { rank: number; username: string; total_score: number }[] }, + + async listClasses(): Promise { + const res = await http.get("/account/classes") + return res.data + }, + + async listNamesByClass( + classname: string, + ): Promise<{ name: string; username: string }[]> { + const res = await http.get("/account/names", { params: { classname } }) + return res.data + }, } export const Tutorial = { @@ -156,18 +168,44 @@ export const Submission = { return res.data }, - async list(query: { page: number }) { + async list(query: { + page: number + page_size?: number + username?: string + user_id?: number + flag?: string | null + task_id?: number + task_type?: string + score_min?: number + score_max_exclusive?: number + score_lt_threshold?: number + nominated?: boolean + ordering?: string + grouped?: boolean + }) { const res = await http.get("/submission", { params: query, }) return res.data }, + async listByUserTask(userId: number, taskId: number) { + const res = await http.get("/submission/by-user-task", { + params: { user_id: userId, task_id: taskId }, + }) + return res.data as SubmissionOut[] + }, + async get(id: string) { const res = await http.get("/submission/" + id) return res.data }, + async delete(id: string) { + const res = await http.delete("/submission/" + id) + return res.data + }, + async updateScore(id: string, score: number) { const res = await http.put(`/submission/${id}/score`, { score }) return res.data @@ -178,6 +216,16 @@ export const Submission = { return res.data }, + async clearAllFlags() { + const res = await http.delete(`/submission/flags`) + return res.data as { cleared: number } + }, + + async nominate(id: string) { + const res = await http.put(`/submission/${id}/nominate`) + return res.data as { nominated: boolean } + }, + async myScores() { const res = await http.get("/submission/my-scores") return res.data as { @@ -199,9 +247,9 @@ export const Prompt = { return (await http.get("/prompt/conversations/", { params })).data }, - async getMessages(conversationId: string) { + async getMessages(conversationId: string): Promise { return ( - await http.get(`/prompt/conversations/${conversationId}/messages/`) + await http.get(`/prompt/conversations/${conversationId}/messages/`) ).data }, } diff --git a/src/components/Editors.vue b/src/components/Editors.vue index a92a458..83733fe 100644 --- a/src/components/Editors.vue +++ b/src/components/Editors.vue @@ -86,6 +86,7 @@ import Editor from "./Editor.vue" import Toolbar from "./Toolbar.vue" import { html, css, js, tab, size, reset } from "../store/editors" import { taskId } from "../store/task" +import { conversationId } from "../store/prompt" import { Submission } from "../api" import { NCode, useDialog, useMessage } from "naive-ui" import { h, ref } from "vue" @@ -145,6 +146,7 @@ async function doSubmit() { html: html.value, css: css.value, js: js.value, + conversationId: conversationId.value || undefined, }) message.success("提交成功") } catch (err) { diff --git a/src/components/Login.vue b/src/components/Login.vue index 2f9525f..8b81cc1 100644 --- a/src/components/Login.vue +++ b/src/components/Login.vue @@ -2,62 +2,216 @@ - - - - - - - - - - 登录 - - + + + + + + + + + + + + + + + + + 登录 + + + + + + + + + + + + + + + 登录 + + + + + + diff --git a/src/components/Preview.vue b/src/components/Preview.vue index 2504383..6293a86 100644 --- a/src/components/Preview.vue +++ b/src/components/Preview.vue @@ -7,7 +7,7 @@ 清空 代码 - 复制链接 + 链接 代码 diff --git a/src/components/PromptPanel.vue b/src/components/PromptPanel.vue index 79b2717..f0d1d83 100644 --- a/src/components/PromptPanel.vue +++ b/src/components/PromptPanel.vue @@ -1,13 +1,21 @@