@@ -1,6 +1,5 @@
import { Query } from '@kevisual/query' ;
import type { Result , DataOpts } from '@kevisual/query/query' ;
import { setBaseResponse } from '@kevisual/query/query' ;
export type SimpleObject = Record < string , any > ;
export const markType = [ 'simple' , 'md' , 'mdx' , 'wallnote' , 'excalidraw' ] as const ;
@@ -27,6 +26,7 @@ export type Mark = {
tags : string [ ] ;
createdAt : string ;
updatedAt : string ;
version : number ;
} ;
export type ShowMarkPick = Pick < Mark , 'id' | 'title' | 'description' | 'summary' | 'link' | 'tags' | 'thumbnail' | 'updatedAt' > ;
@@ -103,9 +103,33 @@ export class QueryMarkBase<T extends SimpleObject = SimpleObject> {
async getMark ( id : string , opts? : DataOpts ) {
return this . post < Result < Mark > > ( { key : 'get' , id } , opts ) ;
}
async getVersion ( id : string , opts? : DataOpts ) {
return this . post < Result < { version : number ; id : string } > > ( { key : 'getVersion' , id } , opts ) ;
}
/**
* 检查版本
* 当需要更新时, 返回true
* @param id
* @param version
* @param opts
* @returns
*/
async checkVersion ( id : string , version? : number , opts? : DataOpts ) {
if ( ! version ) {
return true ;
}
const res = await this . getVersion ( id , opts ) ;
if ( res . code === 200 ) {
if ( res . data . version > version ) {
return true ;
}
return false ;
}
return true ;
}
async updateMark ( id : string , data : any , opts? : DataOpts ) {
return this . post < Result < Mark > > ( { key : 'update' , id , data } , opts ) ;
async updateMark ( data : any , opts? : DataOpts ) {
return this . post < Result < Mark > > ( { key : 'update' , data } , opts ) ;
}
async deleteMark ( id : string , opts? : DataOpts ) {