From 39f0d7c566584811b73c027fb3eb43075d74ee1f Mon Sep 17 00:00:00 2001 From: xion Date: Fri, 28 Mar 2025 09:39:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/query-mark.ts | 50 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/src/query-mark.ts b/src/query-mark.ts index b641730..1378ee4 100644 --- a/src/query-mark.ts +++ b/src/query-mark.ts @@ -3,13 +3,39 @@ import type { Result, DataOpts } from '@kevisual/query/query'; import { setBaseResponse } from '@kevisual/query/query'; export type SimpleObject = Record; +export const markType = ['simple', 'md', 'mdx', 'wallnote', 'excalidraw'] as const; +export type MarkType = (typeof markType)[number]; +export type MarkData = { + nodes?: any[]; + edges?: any[]; + elements?: any[]; + permission?: any; + + [key: string]: any; +}; +export type Mark = { + id: string; + title: string; + description: string; + markType: MarkType; + link: string; + data?: MarkData; + uid: string; + puid: string; + summary: string; + thumbnail?: string; + tags: string[]; + createdAt: string; + updatedAt: string; +}; +export type ShowMarkPick = Pick; export type SearchOpts = { page: number; pageSize: number; search?: string; sort?: string; // DESC, ASC - markType?: string; // 类型 + markType?: MarkType; // 类型 [key: string]: any; }; @@ -19,6 +45,14 @@ export type QueryMarkOpts = { onLoad?: () => void; } & T; +export type ResultMarkList = { + list: Mark[]; + pagination: { + pageSize: number; + current: number; + total: number; + }; +}; export type QueryMarkData = { id?: string; title?: string; @@ -51,9 +85,9 @@ export class QueryMarkBase { this.onLoad?.(); } - async post(data: any, opts?: DataOpts) { + async post>(data: any, opts?: DataOpts): Promise { try { - return this.query.post({ path: 'mark', ...data }, opts); + return this.query.post({ path: 'mark', ...data }, opts) as Promise; } catch (error) { console.log('error', error); return { @@ -63,15 +97,19 @@ export class QueryMarkBase { } async getMarkList(search: SearchOpts, opts?: DataOpts) { - return this.post({ key: 'list', ...search }, opts); + return this.post>({ key: 'list', ...search }, opts); } async getMark(id: string, opts?: DataOpts) { - return this.post({ key: 'get', id }, opts); + return this.post>({ key: 'get', id }, opts); } async updateMark(id: string, data: any, opts?: DataOpts) { - return this.post({ key: 'update', id, ...data }, opts); + return this.post>({ key: 'update', id, data }, opts); + } + + async deleteMark(id: string, opts?: DataOpts) { + return this.post>({ key: 'delete', id }, opts); } } export class QueryMark extends QueryMarkBase {