feat: add info mark version
This commit is contained in:
parent
39f0d7c566
commit
757be9fc2f
@ -5,7 +5,7 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<script src="src/test/login.ts" type="module"></script>
|
<!-- <script src="src/test/login.ts" type="module"></script> -->
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -27,6 +27,7 @@ export type Mark = {
|
|||||||
tags: string[];
|
tags: string[];
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
|
version: number;
|
||||||
};
|
};
|
||||||
export type ShowMarkPick = Pick<Mark, 'id' | 'title' | 'description' | 'summary' | 'link' | 'tags' | 'thumbnail' | 'updatedAt'>;
|
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) {
|
async getMark(id: string, opts?: DataOpts) {
|
||||||
return this.post<Result<Mark>>({ key: 'get', id }, opts);
|
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) {
|
async updateMark(data: any, opts?: DataOpts) {
|
||||||
return this.post<Result<Mark>>({ key: 'update', id, data }, opts);
|
return this.post<Result<Mark>>({ key: 'update', data }, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteMark(id: string, opts?: DataOpts) {
|
async deleteMark(id: string, opts?: DataOpts) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user