diff --git a/index.html b/index.html index f530cbb..448ea7c 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ - + \ No newline at end of file diff --git a/src/query-mark.ts b/src/query-mark.ts index 1378ee4..6ee4b99 100644 --- a/src/query-mark.ts +++ b/src/query-mark.ts @@ -27,6 +27,7 @@ export type Mark = { tags: string[]; createdAt: string; updatedAt: string; + version: number; }; export type ShowMarkPick = Pick; @@ -103,9 +104,33 @@ export class QueryMarkBase { async getMark(id: string, opts?: DataOpts) { return this.post>({ key: 'get', id }, opts); } + async getVersion(id: string, opts?: DataOpts) { + return this.post>({ 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>({ key: 'update', id, data }, opts); + async updateMark(data: any, opts?: DataOpts) { + return this.post>({ key: 'update', data }, opts); } async deleteMark(id: string, opts?: DataOpts) {