返回 AiToEarn
comment.ts
1 /*
2 * @Author: nevin
3 * @Date: 2025-02-05 17:43:14
4 * @LastEditTime: 2025-02-17 17:50:44
5 * @LastEditors: nevin
6 * @Description:
7 */
8
9 import { PubRecordModel as PubRecordModelLast } from '../../../electron/db/models/pubRecord';
10 import { AccountStatus } from '../../../commont/AccountEnum';
11 import { ipcUpdateAccountStatus } from '../../icp/account';
12 import { AccountInfo } from '../account/comment';
13
14 export type PubRecordModel = PubRecordModelLast;
15
16 // 接口失效处理
17 export async function accountFailureDispose<T>(
18 {
19 status,
20 data,
21 }: {
22 status: number;
23 data?: T;
24 },
25 account: AccountInfo,
26 callback: (account: AccountInfo) => void,
27 ) {
28 if (status !== 200 && status !== 201) {
29 if (status === 401) {
30 account.status = AccountStatus.DISABLE;
31 callback(account);
32 await ipcUpdateAccountStatus(account.id, AccountStatus.DISABLE);
33 }
34 return [];
35 }
36 return data || [];
37 }
38
38 lines TYPESCRIPT