chore: run a full eslint

This commit is contained in:
Wesley F. Young
2024-08-10 19:58:31 +08:00
parent 9a9511aad6
commit 116a04e081
198 changed files with 8187 additions and 7744 deletions

View File

@@ -2,12 +2,14 @@ import BaseAction from '../BaseAction';
import { ActionName, BaseCheckResult } from '../types';
import * as fs from 'node:fs';
import { checkFileReceived, uri2local } from '@/common/utils/file';
interface Payload {
file: string
file: string;
}
export default class SetAvatar extends BaseAction<Payload, null> {
actionName = ActionName.SetQQAvatar;
// 用不着复杂检测
protected async check(payload: Payload): Promise<BaseCheckResult> {
if (!payload.file || typeof payload.file != 'string') {
@@ -20,6 +22,7 @@ export default class SetAvatar extends BaseAction<Payload, null> {
valid: true,
};
}
protected async _handle(payload: Payload): Promise<null> {
const NTQQUserApi = this.CoreContext.getApiContext().UserApi;
const { path, isLocal, errMsg, success } = (await uri2local(this.CoreContext.NapCatTempPath, payload.file));
@@ -30,7 +33,8 @@ export default class SetAvatar extends BaseAction<Payload, null> {
await checkFileReceived(path, 5000); // 文件不存在QQ会崩溃需要提前判断
const ret = await NTQQUserApi.setQQAvatar(path);
if (!isLocal) {
fs.unlink(path, () => { });
fs.unlink(path, () => {
});
}
if (!ret) {
throw `头像${payload.file}设置失败,api无返回`;
@@ -43,7 +47,8 @@ export default class SetAvatar extends BaseAction<Payload, null> {
}
} else {
if (!isLocal) {
fs.unlink(path, () => { });
fs.unlink(path, () => {
});
}
throw `头像${payload.file}设置失败,无法获取头像,文件可能不存在`;
}