chore: 二维码登录与刷新1

This commit is contained in:
手瓜一十雪 2024-08-11 23:27:28 +08:00
parent 35e75be0d0
commit ca5abc635c

View File

@ -109,6 +109,9 @@ export async function NCoreInitShell() {
});
loginListener.onQRCodeGetPicture = ({ pngBase64QrcodeData, qrcodeUrl }) => {
//设置WebuiQrcode
WebUiDataRuntime.setQQLoginQrcodeURL(qrcodeUrl);
const realBase64 = pngBase64QrcodeData.replace(/^data:image\/\w+;base64,/, '');
const buffer = Buffer.from(realBase64, 'base64');
logger.logWarn('请扫描下面的二维码然后在手Q上授权登录');
@ -125,6 +128,16 @@ export async function NCoreInitShell() {
});
});
};
loginListener.onQRCodeSessionFailed = (errType: number, errCode: number, errMsg: string) => {
logger.logError('登录失败(onQRCodeSessionFailed)', errMsg);
if (errType == 1 && errCode == 3) {
// 二维码过期刷新
}
loginService.getQRCodePicture();
};
loginListener.onLoginFailed = (args) => {
logger.logError('登录失败(onLoginFailed)', args);
};
loginService.addKernelLoginListener(new wrapper.NodeIKernelLoginListener(
proxiedListenerOf(loginListener, logger)));