From 9502c297075dc2a8de8faf90feac4c13265cce61 Mon Sep 17 00:00:00 2001 From: KishinZW Date: Sun, 9 Mar 2025 14:22:31 +0800 Subject: [PATCH 1/3] feat: applying owner name to content queries --- server/trpc/controllers/content.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/trpc/controllers/content.ts b/server/trpc/controllers/content.ts index 4ab5f40..96c5fa6 100644 --- a/server/trpc/controllers/content.ts +++ b/server/trpc/controllers/content.ts @@ -1,6 +1,6 @@ import { TRPCError } from '@trpc/server'; import { eq } from 'drizzle-orm'; -import type { TNewContent } from '../../db/db'; +import type { TNewContent, TRawContent } from '../../db/db'; import { db } from '../../db/db'; import { contents } from '../../db/schema'; import { UserController } from './user'; @@ -13,15 +13,15 @@ export class ContentController { this.userController = new UserController(); } - private async fetchOwner(res: TNewContent[]) { - const seq: (TNewContent & { owner: string })[] = []; + private async fetchOwner(res: TRawContent[]) { + const named_res: (TRawContent & { owner: string })[] = []; res.forEach(async (cnt) => { - seq.push({ + named_res.push({ ...cnt, owner: (await this.userController.getProfile(cnt.ownerId)).username, }); }); - return seq; + return named_res; } async create(newContent: TNewContent) { @@ -52,21 +52,21 @@ export class ContentController { async getList() { const res = await db.query.contents.findMany(); - return res; + return await this.fetchOwner(res); } async getListByOwner(ownerId: number) { const res = await db.query.contents.findMany({ where: eq(contents.ownerId, ownerId), }); - return res; + return await this.fetchOwner(res); } async getListByCategory(categoryId: number) { const res = await db.query.contents.findMany({ where: eq(contents.categoryId, categoryId), }); - return res; + return await this.fetchOwner(res); } async updateAuditStatus(id: number, state: ContentState, reviewNotes?: string) { From 7a0f2530da06a71c805613089ff3fa356108af26 Mon Sep 17 00:00:00 2001 From: KishinZW Date: Sun, 9 Mar 2025 17:53:15 +0800 Subject: [PATCH 2/3] style: change review button to justify-left & lint fixes --- components/ui/button/Button.vue | 34 ++++++++-------- components/ui/button/index.ts | 8 ++-- components/ui/calendar/Calendar.vue | 38 +++++++++--------- components/ui/calendar/CalendarCell.vue | 32 +++++++-------- .../ui/calendar/CalendarCellTrigger.vue | 34 ++++++++-------- components/ui/calendar/CalendarGrid.vue | 32 +++++++-------- components/ui/calendar/CalendarGridBody.vue | 12 +++--- components/ui/calendar/CalendarGridHead.vue | 14 +++---- components/ui/calendar/CalendarGridRow.vue | 28 ++++++------- components/ui/calendar/CalendarHeadCell.vue | 28 ++++++------- components/ui/calendar/CalendarHeader.vue | 28 ++++++------- components/ui/calendar/CalendarHeading.vue | 40 +++++++++---------- components/ui/calendar/CalendarNextButton.vue | 36 ++++++++--------- components/ui/calendar/CalendarPrevButton.vue | 36 ++++++++--------- components/ui/calendar/index.ts | 24 +++++------ lib/utils.ts | 12 +++--- pages/content/index.vue | 4 +- pages/device.vue | 2 +- server/trpc/controllers/device.ts | 1 + 19 files changed, 222 insertions(+), 221 deletions(-) diff --git a/components/ui/button/Button.vue b/components/ui/button/Button.vue index 17dc84d..52459d9 100644 --- a/components/ui/button/Button.vue +++ b/components/ui/button/Button.vue @@ -1,20 +1,3 @@ - - + + diff --git a/components/ui/button/index.ts b/components/ui/button/index.ts index aa6014c..80cd812 100644 --- a/components/ui/button/index.ts +++ b/components/ui/button/index.ts @@ -1,6 +1,6 @@ -import { cva, type VariantProps } from 'class-variance-authority' +import { type VariantProps, cva } from 'class-variance-authority'; -export { default as Button } from './Button.vue' +export { default as Button } from './Button.vue'; export const buttonVariants = cva( 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0', @@ -30,6 +30,6 @@ export const buttonVariants = cva( size: 'default', }, }, -) +); -export type ButtonVariants = VariantProps +export type ButtonVariants = VariantProps; diff --git a/components/ui/calendar/Calendar.vue b/components/ui/calendar/Calendar.vue index abd7691..4a0da43 100644 --- a/components/ui/calendar/Calendar.vue +++ b/components/ui/calendar/Calendar.vue @@ -1,22 +1,3 @@ - - + + diff --git a/components/ui/calendar/CalendarCell.vue b/components/ui/calendar/CalendarCell.vue index 2bf95fc..56bb2c9 100644 --- a/components/ui/calendar/CalendarCell.vue +++ b/components/ui/calendar/CalendarCell.vue @@ -1,19 +1,3 @@ - - + + diff --git a/components/ui/calendar/CalendarCellTrigger.vue b/components/ui/calendar/CalendarCellTrigger.vue index 57a3190..6c2cd79 100644 --- a/components/ui/calendar/CalendarCellTrigger.vue +++ b/components/ui/calendar/CalendarCellTrigger.vue @@ -1,20 +1,3 @@ - -