mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
fix: login timer / add:不规范的promise
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
export class NodeIKernelLoginListener {
|
export class NodeIKernelLoginListener {
|
||||||
onLoginConnected(...args: any[]): any {
|
onLoginConnected(): Promise<void> | void {
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoginDisConnected(...args: any[]): any {
|
onLoginDisConnected(...args: any[]): any {
|
||||||
|
@@ -60,7 +60,10 @@ export interface QuickLoginResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface NodeIKernelLoginService {
|
export interface NodeIKernelLoginService {
|
||||||
|
getMsfStatus: () => number;
|
||||||
|
|
||||||
setLoginMiscData(arg0: string, value: string): unknown;
|
setLoginMiscData(arg0: string, value: string): unknown;
|
||||||
|
|
||||||
getMachineGuid(): string;
|
getMachineGuid(): string;
|
||||||
|
|
||||||
get(): NodeIKernelLoginService;
|
get(): NodeIKernelLoginService;
|
||||||
|
@@ -30,6 +30,7 @@ import { InitWebUi } from '@/webui';
|
|||||||
import { WebUiDataRuntime } from '@/webui/src/helper/Data';
|
import { WebUiDataRuntime } from '@/webui/src/helper/Data';
|
||||||
import { napCatVersion } from '@/common/version';
|
import { napCatVersion } from '@/common/version';
|
||||||
import { NodeIO3MiscListener } from '@/core/listeners/NodeIO3MiscListener';
|
import { NodeIO3MiscListener } from '@/core/listeners/NodeIO3MiscListener';
|
||||||
|
import { sleep } from '@/common/helper';
|
||||||
// NapCat Shell App ES 入口文件
|
// NapCat Shell App ES 入口文件
|
||||||
async function handleUncaughtExceptions(logger: LogWrapper) {
|
async function handleUncaughtExceptions(logger: LogWrapper) {
|
||||||
process.on('uncaughtException', (err) => {
|
process.on('uncaughtException', (err) => {
|
||||||
@@ -113,7 +114,7 @@ async function handleLogin(
|
|||||||
quickLoginUin: string | undefined,
|
quickLoginUin: string | undefined,
|
||||||
historyLoginList: LoginListItem[]
|
historyLoginList: LoginListItem[]
|
||||||
): Promise<SelfInfo> {
|
): Promise<SelfInfo> {
|
||||||
return new Promise<SelfInfo>((resolve) => {
|
return new Promise<SelfInfo>(async (resolve) => {
|
||||||
const loginListener = new NodeIKernelLoginListener();
|
const loginListener = new NodeIKernelLoginListener();
|
||||||
let isLogined = false;
|
let isLogined = false;
|
||||||
|
|
||||||
@@ -199,11 +200,15 @@ async function handleLogin(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
let network_ok = false;
|
||||||
|
while (!network_ok) {
|
||||||
|
network_ok = loginService.getMsfStatus() === 0;
|
||||||
|
logger.log('等待网络连接...');
|
||||||
|
await sleep(500);
|
||||||
|
}
|
||||||
if (quickLoginUin) {
|
if (quickLoginUin) {
|
||||||
if (historyLoginList.some(u => u.uin === quickLoginUin)) {
|
if (historyLoginList.some(u => u.uin === quickLoginUin)) {
|
||||||
logger.log('正在快速登录 ', quickLoginUin);
|
logger.log('正在快速登录 ', quickLoginUin);
|
||||||
setTimeout(() => {
|
|
||||||
loginService.quickLoginWithUin(quickLoginUin)
|
loginService.quickLoginWithUin(quickLoginUin)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result.loginErrorInfo.errMsg) {
|
if (result.loginErrorInfo.errMsg) {
|
||||||
@@ -212,7 +217,6 @@ async function handleLogin(
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch();
|
.catch();
|
||||||
}, 1000);
|
|
||||||
} else {
|
} else {
|
||||||
logger.logError('快速登录失败,未找到该 QQ 历史登录记录,将使用二维码登录方式');
|
logger.logError('快速登录失败,未找到该 QQ 历史登录记录,将使用二维码登录方式');
|
||||||
if (!isLogined) loginService.getQRCodePicture();
|
if (!isLogined) loginService.getQRCodePicture();
|
||||||
|
Reference in New Issue
Block a user