feat: add info mark version

This commit is contained in:
abearxiong 2025-03-29 23:17:11 +08:00
parent 39f0d7c566
commit 757be9fc2f
2 changed files with 28 additions and 3 deletions

View File

@ -5,7 +5,7 @@
</head>
<body>
<script src="src/test/login.ts" type="module"></script>
<!-- <script src="src/test/login.ts" type="module"></script> -->
</body>
</html>

View File

@ -27,6 +27,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 +104,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) {