diff --git a/client/src/pages/Showcase.vue b/client/src/pages/Showcase.vue index 76302b8..305f036 100644 --- a/client/src/pages/Showcase.vue +++ b/client/src/pages/Showcase.vue @@ -1,167 +1,455 @@ diff --git a/client/src/utils/type.ts b/client/src/utils/type.ts index 711855f..16e4737 100644 --- a/client/src/utils/type.ts +++ b/client/src/utils/type.ts @@ -261,6 +261,7 @@ export interface ShowcaseItem { username: string task_title: string task_display: number + task_type: TASK_TYPE score: number view_count: number html: string | null @@ -306,6 +307,7 @@ export interface ShowcaseSubmissionLookupOut { username: string task_title: string task_display: number + task_type: TASK_TYPE score: number view_count: number has_prompt_chain: boolean @@ -317,6 +319,7 @@ export interface AwardItemManageOut { username: string task_title: string task_display: number + task_type: TASK_TYPE score: number view_count: number sort_order: number @@ -330,6 +333,7 @@ export interface ShowcaseDetail { username: string task_title: string task_display: number + task_type: TASK_TYPE score: number view_count: number html: string | null diff --git a/server/src/routes/showcase.ts b/server/src/routes/showcase.ts index c342fb9..faaa3b9 100644 --- a/server/src/routes/showcase.ts +++ b/server/src/routes/showcase.ts @@ -20,7 +20,7 @@ const ORDER_BY: Record = { const HAS_CHAIN = `EXISTS (SELECT 1 FROM prompt_message m WHERE m.submission_id = s.id) AS has_prompt_chain` const ITEM_SELECT = `SELECT sa.id, sa.submission_id, sa.sort_order, sa.awarded_at, sa.is_stale, - u.username, t.title AS task_title, t.display AS task_display, + u.username, t.title AS task_title, t.display AS task_display, t.task_type, s.score, s.view_count, s.html, s.css, s.js, ${HAS_CHAIN} FROM submission_submissionaward sa JOIN submission_submission s ON s.id = sa.submission_id @@ -34,6 +34,7 @@ function itemManageOut(r: any) { username: r.username, task_title: r.task_title, task_display: r.task_display, + task_type: r.task_type, score: r.score, view_count: r.view_count, sort_order: r.sort_order, @@ -104,6 +105,7 @@ router.get("/", (c) => { username: r.username, task_title: r.task_title, task_display: r.task_display, + task_type: r.task_type, score: r.score, view_count: r.view_count, html: r.html, @@ -167,7 +169,7 @@ router.get("/manage/submissions/:submission_id", (c) => { const id = uuidParam(c, "submission_id") const s = orNotFound( get( - `SELECT s.id, u.username, t.title AS task_title, t.display AS task_display, + `SELECT s.id, u.username, t.title AS task_title, t.display AS task_display, t.task_type, s.score, s.view_count, ${HAS_CHAIN} FROM submission_submission s JOIN account_user u ON u.id = s.user_id @@ -181,6 +183,7 @@ router.get("/manage/submissions/:submission_id", (c) => { username: s.username, task_title: s.task_title, task_display: s.task_display, + task_type: s.task_type, score: s.score, view_count: s.view_count, has_prompt_chain: bool(s.has_prompt_chain), @@ -301,7 +304,7 @@ router.get("/:submission_id", (c) => { assertAwarded(id) const s = orNotFound( get( - `SELECT s.id, u.username, t.title AS task_title, t.display AS task_display, + `SELECT s.id, u.username, t.title AS task_title, t.display AS task_display, t.task_type, s.score, s.view_count, s.html, s.css, s.js, ${HAS_CHAIN} FROM submission_submission s JOIN account_user u ON u.id = s.user_id @@ -320,6 +323,7 @@ router.get("/:submission_id", (c) => { username: s.username, task_title: s.task_title, task_display: s.task_display, + task_type: s.task_type, score: s.score, view_count: s.view_count, html: s.html, diff --git a/server/tests/api.test.ts b/server/tests/api.test.ts index d150648..eaf27ef 100644 --- a/server/tests/api.test.ts +++ b/server/tests/api.test.ts @@ -415,7 +415,7 @@ describe("作品展", () => { const author1 = await client("author") expect((await author1("GET", "/api/submission/showcase/")).json).toHaveLength(1) - expect((await author1("GET", `/api/submission/showcase/${uuid(sub)}/`)).json.awards).toEqual(["最佳"]) + expect((await author1("GET", `/api/submission/showcase/${uuid(sub)}/`)).json).toMatchObject({ awards: ["最佳"], task_type: "challenge" }) await adm("PUT", `/api/submission/showcase/manage/awards/${award.id}`, { name: "最佳", is_active: false }) expect((await author1("GET", "/api/submission/showcase/")).json).toEqual([])