refactor: minor lint and consistency fixes
Apply a collection of small code cleanups across the repo for consistency and lint-safety. Changes include: - Use strict equality (===) where appropriate (GetEmojiLikes, about page checks). - Replace Array.map used for side effects with Array.forEach (GetMsg). - Rename unused catch parameters to underscore-prefixed names to avoid lint warnings (multiple backend/middleware files). - Replace void with undefined in an actions.call invocation (builtin plugin index). - Remove an unused loadedCount variable when reading .env (napcat-shell). - Rename promise resolver parameter to `resolve` for clarity in tests and keep setTimeout usage (rpc.test.ts). - Strengthen external shims types by changing generic parameter names to _T and update inversify ServiceIdentifier generic param (external-shims.d.ts). - Simplify post-build script imports and comment out an external-type mapping block; fix a regex character class bug (post-build.mjs). - Prefix several unused test stub variables with underscore to indicate intentional unused status (test-dist.ts). - Minor JSX formatting/indentation fixes in password_login component and UI text indentation in system_info. - Misc: SSE/config and plugin config handlers adjusted to consistent catch parameter naming; update mirror/download error catch variable name. These edits are non-functional refactors focused on code style, lint compliance and small robustness/clarity improvements.
This commit is contained in:
1 parent
974528fe7e
commit
b15d02535e
19 files changed
+49
-65
No files matched your search
@@ -66,7 +66,7 @@ export class GetEmojiLikes extends OneBotAction<PayloadType, ReturnType> {
|
|||||||
const emojiType = payload.emoji_type ?? (payload.emoji_id.length > 3 ? '2' : '1');
|
const emojiType = payload.emoji_type ?? (payload.emoji_id.length > 3 ? '2' : '1');
|
||||||
const emojiLikeList: Array<{ user_id: string; nick_name: string; }> = [];
|
const emojiLikeList: Array<{ user_id: string; nick_name: string; }> = [];
|
||||||
let cookie = '';
|
let cookie = '';
|
||||||
const needFetchCount = payload.count == 0 ? 200 : Math.ceil(payload.count / 15);
|
const needFetchCount = payload.count === 0 ? 200 : Math.ceil(payload.count / 15);
|
||||||
for (let page = 0; page < needFetchCount; page++) {
|
for (let page = 0; page < needFetchCount; page++) {
|
||||||
const res = await this.core.apis.MsgApi.getMsgEmojiLikesList(
|
const res = await this.core.apis.MsgApi.getMsgEmojiLikesList(
|
||||||
peer, msg.msgSeq, payload.emoji_id.toString(), emojiType, cookie, 15
|
peer, msg.msgSeq, payload.emoji_id.toString(), emojiType, cookie, 15
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class GetMsg extends OneBotAction<PayloadType, ReturnType> {
|
|||||||
const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg, config.messagePostFormat);
|
const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg, config.messagePostFormat);
|
||||||
if (!retMsg) throw Error('消息为空');
|
if (!retMsg) throw Error('消息为空');
|
||||||
retMsg.emoji_likes_list = [];
|
retMsg.emoji_likes_list = [];
|
||||||
msg.emojiLikesList?.map(emoji => {
|
msg.emojiLikesList?.forEach(emoji => {
|
||||||
retMsg.emoji_likes_list?.push({
|
retMsg.emoji_likes_list?.push({
|
||||||
emoji_id: emoji.emojiId,
|
emoji_id: emoji.emojiId,
|
||||||
emoji_type: emoji.emojiType,
|
emoji_type: emoji.emojiType,
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ export class PluginLoader {
|
|||||||
if (pkg.name === pluginId) {
|
if (pkg.name === pluginId) {
|
||||||
return item.name;
|
return item.name;
|
||||||
}
|
}
|
||||||
} catch (e) { }
|
} catch (_e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果目录名就是 ID
|
// 如果目录名就是 ID
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ async function getVersionInfo (actions: ActionMap, adapter: string, config: Netw
|
|||||||
if (!actions) return null;
|
if (!actions) return null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = await actions.call('get_version_info', void 0, adapter, config);
|
const data = await actions.call('get_version_info', undefined, adapter, config);
|
||||||
return {
|
return {
|
||||||
appName: data.app_name,
|
appName: data.app_name,
|
||||||
appVersion: data.app_version,
|
appVersion: data.app_version,
|
||||||
|
|||||||
@@ -14,36 +14,20 @@ export abstract class NapCatProtocolApiBase {
|
|||||||
|
|
||||||
// 消息 API
|
// 消息 API
|
||||||
export class NapCatProtocolMsgApi extends NapCatProtocolApiBase {
|
export class NapCatProtocolMsgApi extends NapCatProtocolApiBase {
|
||||||
constructor (adapter: NapCatProtocolAdapter, core: NapCatCore) {
|
|
||||||
super(adapter, core);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 消息相关 API 方法可以在这里实现
|
// 消息相关 API 方法可以在这里实现
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户 API
|
// 用户 API
|
||||||
export class NapCatProtocolUserApi extends NapCatProtocolApiBase {
|
export class NapCatProtocolUserApi extends NapCatProtocolApiBase {
|
||||||
constructor (adapter: NapCatProtocolAdapter, core: NapCatCore) {
|
|
||||||
super(adapter, core);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 用户相关 API 方法可以在这里实现
|
// 用户相关 API 方法可以在这里实现
|
||||||
}
|
}
|
||||||
|
|
||||||
// 群组 API
|
// 群组 API
|
||||||
export class NapCatProtocolGroupApi extends NapCatProtocolApiBase {
|
export class NapCatProtocolGroupApi extends NapCatProtocolApiBase {
|
||||||
constructor (adapter: NapCatProtocolAdapter, core: NapCatCore) {
|
|
||||||
super(adapter, core);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 群组相关 API 方法可以在这里实现
|
// 群组相关 API 方法可以在这里实现
|
||||||
}
|
}
|
||||||
|
|
||||||
// 好友 API
|
// 好友 API
|
||||||
export class NapCatProtocolFriendApi extends NapCatProtocolApiBase {
|
export class NapCatProtocolFriendApi extends NapCatProtocolApiBase {
|
||||||
constructor (adapter: NapCatProtocolAdapter, core: NapCatCore) {
|
|
||||||
super(adapter, core);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 好友相关 API 方法可以在这里实现
|
// 好友相关 API 方法可以在这里实现
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,6 @@ const envPath = path.join(__dirname, 'config', '.env');
|
|||||||
if (fs.existsSync(envPath)) {
|
if (fs.existsSync(envPath)) {
|
||||||
try {
|
try {
|
||||||
const data = fs.readFileSync(envPath, 'utf8');
|
const data = fs.readFileSync(envPath, 'utf8');
|
||||||
let loadedCount = 0;
|
|
||||||
data.split(/\r?\n/).forEach(line => {
|
data.split(/\r?\n/).forEach(line => {
|
||||||
line = line.trim();
|
line = line.trim();
|
||||||
if (line && !line.startsWith('#')) {
|
if (line && !line.startsWith('#')) {
|
||||||
@@ -26,7 +25,6 @@ if (fs.existsSync(envPath)) {
|
|||||||
const value = parts.slice(1).join('=').trim();
|
const value = parts.slice(1).join('=').trim();
|
||||||
if (key && value) {
|
if (key && value) {
|
||||||
process.env[key] = value;
|
process.env[key] = value;
|
||||||
loadedCount++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -611,7 +611,7 @@ describe('napcat-rpc RPC', () => {
|
|||||||
const proxy = createDeepProxy<typeof target>({ transport });
|
const proxy = createDeepProxy<typeof target>({ transport });
|
||||||
|
|
||||||
const processor = vi.fn(async (x: number) => {
|
const processor = vi.fn(async (x: number) => {
|
||||||
await new Promise(r => setTimeout(r, 1));
|
await new Promise(resolve => setTimeout(resolve, 1));
|
||||||
return x * 10;
|
return x * 10;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -781,7 +781,7 @@ describe('napcat-rpc RPC', () => {
|
|||||||
return { id, name: `User${id}` };
|
return { id, name: `User${id}` };
|
||||||
},
|
},
|
||||||
async delay (ms: number) {
|
async delay (ms: number) {
|
||||||
await new Promise(r => setTimeout(r, ms));
|
await new Promise(resolve => setTimeout(resolve, ms));
|
||||||
return 'done';
|
return 'done';
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
+5
-5
@@ -68,10 +68,10 @@ declare module 'napcat-protobuf' {
|
|||||||
encode (value: any): Uint8Array;
|
encode (value: any): Uint8Array;
|
||||||
}
|
}
|
||||||
export function ProtoField (...args: any[]): any;
|
export function ProtoField (...args: any[]): any;
|
||||||
export type NapProtoEncodeStructType<T> = any;
|
export type NapProtoEncodeStructType<_T> = any;
|
||||||
export type NapProtoDecodeStructType<T> = any;
|
export type NapProtoDecodeStructType<_T> = any;
|
||||||
export type ScalarProtoFieldType<T> = any;
|
export type ScalarProtoFieldType<_T> = any;
|
||||||
export type MessageProtoFieldType<T> = any;
|
export type MessageProtoFieldType<_T> = any;
|
||||||
export const ScalarType: {
|
export const ScalarType: {
|
||||||
STRING: any;
|
STRING: any;
|
||||||
INT64: any;
|
INT64: any;
|
||||||
@@ -91,7 +91,7 @@ declare module 'inversify' {
|
|||||||
}
|
}
|
||||||
export function injectable (...args: any[]): any;
|
export function injectable (...args: any[]): any;
|
||||||
export function inject (...args: any[]): any;
|
export function inject (...args: any[]): any;
|
||||||
export interface ServiceIdentifier<T = any> { }
|
export interface ServiceIdentifier<_T = any> { }
|
||||||
const _inversify_default: any;
|
const _inversify_default: any;
|
||||||
export default _inversify_default;
|
export default _inversify_default;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { readdir, readFile, writeFile, rename } from 'node:fs/promises';
|
import { readdir, readFile, writeFile, rename } from 'node:fs/promises';
|
||||||
import { join, extname, basename } from 'node:path';
|
import { join } from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
const __dirname = fileURLToPath(new URL('../', import.meta.url));
|
const __dirname = fileURLToPath(new URL('../', import.meta.url));
|
||||||
@@ -11,6 +11,7 @@ const ALLOWED_PACKAGES = [
|
|||||||
'node:', // node: 前缀的内置模块
|
'node:', // node: 前缀的内置模块
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/*
|
||||||
// 外部包类型到 any 的映射
|
// 外部包类型到 any 的映射
|
||||||
const EXTERNAL_TYPE_REPLACEMENTS = {
|
const EXTERNAL_TYPE_REPLACEMENTS = {
|
||||||
// winston
|
// winston
|
||||||
@@ -41,6 +42,7 @@ const EXTERNAL_TYPE_REPLACEMENTS = {
|
|||||||
'NapProtoDecodeStructType<T>': 'any',
|
'NapProtoDecodeStructType<T>': 'any',
|
||||||
'NapProtoEncodeStructType<T>': 'any',
|
'NapProtoEncodeStructType<T>': 'any',
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
function isAllowedImport (importPath) {
|
function isAllowedImport (importPath) {
|
||||||
return ALLOWED_PACKAGES.some(pkg => importPath.startsWith(pkg));
|
return ALLOWED_PACKAGES.some(pkg => importPath.startsWith(pkg));
|
||||||
@@ -87,7 +89,7 @@ function replaceExternalTypes (content) {
|
|||||||
// 使用类型上下文的模式匹配
|
// 使用类型上下文的模式匹配
|
||||||
const typeContextPatterns = [
|
const typeContextPatterns = [
|
||||||
// : Type
|
// : Type
|
||||||
/:\s*(WebSocket|WebSocketServer|RawData|Ajv|AnySchema|ValidateFunction|Container|NapProtoDecodeStructType|NapProtoEncodeStructType|Express|Request|Response|NextFunction)(?=\s*[;,)\]\}|&]|$)/g,
|
/:\s*(WebSocket|WebSocketServer|RawData|Ajv|AnySchema|ValidateFunction|Container|NapProtoDecodeStructType|NapProtoEncodeStructType|Express|Request|Response|NextFunction)(?=\s*[;,)\]}|&]|$)/g,
|
||||||
// <Type>
|
// <Type>
|
||||||
/<(WebSocket|WebSocketServer|RawData|Ajv|AnySchema|ValidateFunction|Container|NapProtoDecodeStructType|NapProtoEncodeStructType|Express|Request|Response|NextFunction)>/g,
|
/<(WebSocket|WebSocketServer|RawData|Ajv|AnySchema|ValidateFunction|Container|NapProtoDecodeStructType|NapProtoEncodeStructType|Express|Request|Response|NextFunction)>/g,
|
||||||
// Type[]
|
// Type[]
|
||||||
|
|||||||
@@ -16,15 +16,15 @@ console.log('ChatType.KCHATTYPEGROUP:', ChatType.KCHATTYPEGROUP); // 应输出 2
|
|||||||
console.log('ElementType.TEXT:', ElementType.TEXT); // 应输出 1
|
console.log('ElementType.TEXT:', ElementType.TEXT); // 应输出 1
|
||||||
|
|
||||||
// 2. 测试类型 (Core)
|
// 2. 测试类型 (Core)
|
||||||
const coreStub = {} as NapCatCore;
|
const _coreStub = {} as NapCatCore;
|
||||||
const apiStub = {} as NTQQMsgApi;
|
const _apiStub = {} as NTQQMsgApi;
|
||||||
console.log('Core types access check: OK');
|
console.log('Core types access check: OK');
|
||||||
|
|
||||||
// 3. 测试类和类型 (OneBot)
|
// 3. 测试类和类型 (OneBot)
|
||||||
const obAdapterStub = {} as NapCatOneBot11Adapter;
|
const _obAdapterStub = {} as NapCatOneBot11Adapter;
|
||||||
const obMsgStub = {} as OB11Message;
|
const _obMsgStub = {} as OB11Message;
|
||||||
const baseMessageEventStub = {} as OB11BaseMessageEvent;
|
const _baseMessageEventStub = {} as OB11BaseMessageEvent;
|
||||||
const baseMetaEventStub = {} as OB11BaseMetaEvent;
|
const _baseMetaEventStub = {} as OB11BaseMetaEvent;
|
||||||
console.log('OneBot types and events access check: OK');
|
console.log('OneBot types and events access check: OK');
|
||||||
|
|
||||||
// 4. 验证导出完整性
|
// 4. 验证导出完整性
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ export const getAllReleasesHandler: RequestHandler = async (req, res) => {
|
|||||||
},
|
},
|
||||||
mirror: usedMirror,
|
mirror: usedMirror,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (_error) {
|
||||||
res.status(500).json({ error: 'Failed to fetch releases' });
|
res.status(500).json({ error: 'Failed to fetch releases' });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ export const GetPluginConfigHandler: RequestHandler = async (req, res) => {
|
|||||||
if (plugin.runtime.module?.plugin_get_config && plugin.runtime.context) {
|
if (plugin.runtime.module?.plugin_get_config && plugin.runtime.context) {
|
||||||
try {
|
try {
|
||||||
config = await plugin.runtime.module?.plugin_get_config(plugin.runtime.context);
|
config = await plugin.runtime.module?.plugin_get_config(plugin.runtime.context);
|
||||||
} catch (e) { }
|
} catch (_e) { }
|
||||||
} else {
|
} else {
|
||||||
// Default behavior: read from default config path
|
// Default behavior: read from default config path
|
||||||
try {
|
try {
|
||||||
@@ -254,7 +254,7 @@ export const GetPluginConfigHandler: RequestHandler = async (req, res) => {
|
|||||||
if (fs.existsSync(configPath)) {
|
if (fs.existsSync(configPath)) {
|
||||||
config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
||||||
}
|
}
|
||||||
} catch (e) { }
|
} catch (_e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取静态 schema
|
// 获取静态 schema
|
||||||
@@ -312,7 +312,7 @@ export const PluginConfigSSEHandler: RequestHandler = (req, res): void => {
|
|||||||
if (initialConfigStr) {
|
if (initialConfigStr) {
|
||||||
try {
|
try {
|
||||||
currentConfig = JSON.parse(initialConfigStr);
|
currentConfig = JSON.parse(initialConfigStr);
|
||||||
} catch (e) { }
|
} catch (_e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送 SSE 消息的辅助函数
|
// 发送 SSE 消息的辅助函数
|
||||||
@@ -387,7 +387,7 @@ export const PluginConfigSSEHandler: RequestHandler = (req, res): void => {
|
|||||||
if (session?.cleanup) {
|
if (session?.cleanup) {
|
||||||
try {
|
try {
|
||||||
session.cleanup();
|
session.cleanup();
|
||||||
} catch (e) { }
|
} catch (_e) { }
|
||||||
}
|
}
|
||||||
activeConfigSessions.delete(sessionId);
|
activeConfigSessions.delete(sessionId);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ export const QQResetDeviceIDHandler: RequestHandler = async (_, res) => {
|
|||||||
// 自动备份
|
// 自动备份
|
||||||
try {
|
try {
|
||||||
await Registry20Utils.backup(registryPath);
|
await Registry20Utils.backup(registryPath);
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
// 忽略备份错误(例如文件不存在)
|
// 忽略备份错误(例如文件不存在)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ export const UpdateNapCatHandler: RequestHandler = async (req, res) => {
|
|||||||
customMirror: mirror,
|
customMirror: mirror,
|
||||||
});
|
});
|
||||||
webUiLogger?.log(`[NapCat Update] Using download URL: ${downloadUrl}`);
|
webUiLogger?.log(`[NapCat Update] Using download URL: ${downloadUrl}`);
|
||||||
} catch (error) {
|
} catch (_error) {
|
||||||
// 如果镜像都不可用,直接使用原始 URL
|
// 如果镜像都不可用,直接使用原始 URL
|
||||||
webUiLogger?.logWarn('[NapCat Update] All nightly.link mirrors failed, using original URL');
|
webUiLogger?.logWarn('[NapCat Update] All nightly.link mirrors failed, using original URL');
|
||||||
downloadUrl = baseUrl;
|
downloadUrl = baseUrl;
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ function matchIPv6CIDR (ip: string, cidr: string): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (_error) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ function expandIPv6 (ip: string): number[] | null {
|
|||||||
if (segments.length !== 8) return null;
|
if (segments.length !== 8) return null;
|
||||||
|
|
||||||
return segments.map(s => parseInt(s || '0', 16));
|
return segments.map(s => parseInt(s || '0', 16));
|
||||||
} catch (error) {
|
} catch (_error) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,24 +133,24 @@ const PasswordLogin: React.FC<PasswordLoginProps> = ({ onSubmit, onCaptchaSubmit
|
|||||||
>
|
>
|
||||||
{(item) => (
|
{(item) => (
|
||||||
<DropdownItem key={item.uin} textValue={item.uin}>
|
<DropdownItem key={item.uin} textValue={item.uin}>
|
||||||
<div className='flex items-center gap-2'>
|
<div className='flex items-center gap-2'>
|
||||||
<Avatar
|
<Avatar
|
||||||
alt={item.uin}
|
alt={item.uin}
|
||||||
className='flex-shrink-0'
|
className='flex-shrink-0'
|
||||||
size='sm'
|
size='sm'
|
||||||
src={
|
src={
|
||||||
isQQQuickNewItem(item)
|
isQQQuickNewItem(item)
|
||||||
? item.faceUrl
|
? item.faceUrl
|
||||||
: `https://q1.qlogo.cn/g?b=qq&nk=${item.uin}&s=1`
|
: `https://q1.qlogo.cn/g?b=qq&nk=${item.uin}&s=1`
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<div className='flex flex-col'>
|
<div className='flex flex-col'>
|
||||||
{isQQQuickNewItem(item)
|
{isQQQuickNewItem(item)
|
||||||
? `${item.nickName}(${item.uin})`
|
? `${item.nickName}(${item.uin})`
|
||||||
: item.uin}
|
: item.uin}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
)}
|
)}
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ const VersionSelectDialogContent: React.FC<VersionSelectDialogProps> = ({
|
|||||||
} else {
|
} else {
|
||||||
setMirrorLatency(null);
|
setMirrorLatency(null);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
setMirrorLatency(null);
|
setMirrorLatency(null);
|
||||||
} finally {
|
} finally {
|
||||||
setMirrorTesting(false);
|
setMirrorTesting(false);
|
||||||
@@ -672,8 +672,8 @@ const VersionSelectDialogContent: React.FC<VersionSelectDialogProps> = ({
|
|||||||
<div className='flex items-center gap-2'>
|
<div className='flex items-center gap-2'>
|
||||||
<span className='truncate max-w-[300px]'>
|
<span className='truncate max-w-[300px]'>
|
||||||
{version.type === 'action'
|
{version.type === 'action'
|
||||||
? (version.workflowTitle || version.artifactName || version.tag)
|
? (version.workflowTitle || version.artifactName || version.tag)
|
||||||
: version.tag}
|
: version.tag}
|
||||||
</span>
|
</span>
|
||||||
{version.type === 'prerelease' && (
|
{version.type === 'prerelease' && (
|
||||||
<Chip size='sm' color='secondary' variant='flat'>预发布</Chip>
|
<Chip size='sm' color='secondary' variant='flat'>预发布</Chip>
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ function NapCatFileHash () {
|
|||||||
const isSelectedValid = selectedUin && accounts.some(acc => acc.uin === selectedUin);
|
const isSelectedValid = selectedUin && accounts.some(acc => acc.uin === selectedUin);
|
||||||
|
|
||||||
if (!isSelectedValid) {
|
if (!isSelectedValid) {
|
||||||
if (loginData?.uin && accounts.some((acc) => acc.uin == loginData.uin)) {
|
if (loginData?.uin && accounts.some((acc) => acc.uin === loginData.uin)) {
|
||||||
setSelectedUin(loginData.uin);
|
setSelectedUin(loginData.uin);
|
||||||
} else {
|
} else {
|
||||||
setSelectedUin(accounts[0].uin);
|
setSelectedUin(accounts[0].uin);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ const parseLoginError = (errorStr: string) => {
|
|||||||
|
|
||||||
return `${info.message || errorStr}${codeStr}`;
|
return `${info.message || errorStr}${codeStr}`;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
// 忽略解析错误
|
// 忽略解析错误
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user