mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
refactor: change method signature in legacy WebUi
This commit is contained in:
parent
6b9307de2a
commit
7ddd4d6461
@ -55,7 +55,8 @@ export class NapCatOneBot11Adapter {
|
||||
FriendApi: new OneBotFriendApi(this, core),
|
||||
};
|
||||
this.networkManager = new OB11NetworkManager();
|
||||
this.InitOneBot().then().catch(e => this.context.logger.logError('初始化OneBot失败', e));
|
||||
this.InitOneBot()
|
||||
.catch(e => this.context.logger.logError('初始化OneBot失败', e));
|
||||
}
|
||||
|
||||
async InitOneBot() {
|
||||
@ -112,7 +113,7 @@ export class NapCatOneBot11Adapter {
|
||||
|
||||
await WebUiDataRuntime.setQQLoginUin(selfInfo.uin.toString());
|
||||
await WebUiDataRuntime.setQQLoginStatus(true);
|
||||
await WebUiDataRuntime.setOB11ConfigCall(async (ob11: OB11Config) => {
|
||||
await WebUiDataRuntime.setOnOB11ConfigChanged(async (ob11: OB11Config) => {
|
||||
this.configLoader.save(ob11);
|
||||
});
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ export async function NCoreInitShell() {
|
||||
WebUiDataRuntime.setQQQuickLoginList(res.LocalLoginInfoList.filter((item) => item.isQuickLogin).map((item) => item.uin.toString()));
|
||||
});
|
||||
|
||||
WebUiDataRuntime.setQQQuickLoginCall(async (uin: string) => {
|
||||
WebUiDataRuntime.setQuickLoginCall(async (uin: string) => {
|
||||
return await new Promise((resolve) => {
|
||||
if (uin) {
|
||||
logger.log('正在快速登录 ', uin);
|
||||
|
@ -53,7 +53,7 @@ export const QQSetQuickLoginHandler: RequestHandler = async (req, res) => {
|
||||
});
|
||||
return;
|
||||
}
|
||||
const { result, message } = await WebUiDataRuntime.getQQQuickLogin(uin);
|
||||
const { result, message } = await WebUiDataRuntime.requestQuickLogin(uin);
|
||||
if (!result) {
|
||||
res.send({
|
||||
code: -1,
|
||||
|
@ -7,8 +7,8 @@ interface LoginRuntimeType {
|
||||
QQQRCodeURL: string;
|
||||
QQLoginUin: string;
|
||||
NapCatHelper: {
|
||||
CoreQuickLoginCall: (uin: string) => Promise<{ result: boolean, message: string }>;
|
||||
SetOb11ConfigCall: (ob11: OB11Config) => Promise<void>;
|
||||
onQuickLoginRequested: (uin: string) => Promise<{ result: boolean, message: string }>;
|
||||
onOB11ConfigChanged: (ob11: OB11Config) => Promise<void>;
|
||||
QQLoginList: string[]
|
||||
};
|
||||
}
|
||||
@ -20,10 +20,10 @@ const LoginRuntime: LoginRuntimeType = {
|
||||
QQQRCodeURL: '',
|
||||
QQLoginUin: '',
|
||||
NapCatHelper: {
|
||||
SetOb11ConfigCall: async (ob11: OB11Config) => {
|
||||
onOB11ConfigChanged: async () => {
|
||||
return;
|
||||
},
|
||||
CoreQuickLoginCall: async (uin: string) => {
|
||||
onQuickLoginRequested: async () => {
|
||||
return { result: false, message: '' };
|
||||
},
|
||||
QQLoginList: [],
|
||||
@ -39,51 +39,54 @@ export const WebUiDataRuntime = {
|
||||
LoginRuntime.LoginCurrentTime = Date.now();
|
||||
return true;
|
||||
}
|
||||
if (LoginRuntime.LoginCurrentRate <= RateLimit) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
,
|
||||
return LoginRuntime.LoginCurrentRate <= RateLimit;
|
||||
},
|
||||
|
||||
getQQLoginStatus: async function(): Promise<boolean> {
|
||||
return LoginRuntime.QQLoginStatus;
|
||||
}
|
||||
,
|
||||
},
|
||||
|
||||
setQQLoginStatus: async function(status: boolean): Promise<void> {
|
||||
LoginRuntime.QQLoginStatus = status;
|
||||
}
|
||||
,
|
||||
},
|
||||
|
||||
setQQLoginQrcodeURL: async function(url: string): Promise<void> {
|
||||
LoginRuntime.QQQRCodeURL = url;
|
||||
}
|
||||
,
|
||||
},
|
||||
|
||||
getQQLoginQrcodeURL: async function(): Promise<string> {
|
||||
return LoginRuntime.QQQRCodeURL;
|
||||
}
|
||||
,
|
||||
},
|
||||
|
||||
setQQLoginUin: async function(uin: string): Promise<void> {
|
||||
LoginRuntime.QQLoginUin = uin;
|
||||
}
|
||||
,
|
||||
},
|
||||
|
||||
getQQLoginUin: async function(): Promise<string> {
|
||||
return LoginRuntime.QQLoginUin;
|
||||
},
|
||||
|
||||
getQQQuickLoginList: async function(): Promise<any[]> {
|
||||
return LoginRuntime.NapCatHelper.QQLoginList;
|
||||
},
|
||||
|
||||
setQQQuickLoginList: async function(list: string[]): Promise<void> {
|
||||
LoginRuntime.NapCatHelper.QQLoginList = list;
|
||||
},
|
||||
setQQQuickLoginCall(func: (uin: string) => Promise<{ result: boolean, message: string }>): void {
|
||||
LoginRuntime.NapCatHelper.CoreQuickLoginCall = func;
|
||||
|
||||
setQuickLoginCall(func: (uin: string) => Promise<{ result: boolean, message: string }>): void {
|
||||
LoginRuntime.NapCatHelper.onQuickLoginRequested = func;
|
||||
},
|
||||
getQQQuickLogin: async function(uin: string): Promise<{ result: boolean, message: string }> {
|
||||
return await LoginRuntime.NapCatHelper.CoreQuickLoginCall(uin);
|
||||
|
||||
requestQuickLogin: async function(uin: string): Promise<{ result: boolean, message: string }> {
|
||||
return await LoginRuntime.NapCatHelper.onQuickLoginRequested(uin);
|
||||
},
|
||||
setOB11ConfigCall: async function(func: (ob11: OB11Config) => Promise<void>): Promise<void> {
|
||||
LoginRuntime.NapCatHelper.SetOb11ConfigCall = func;
|
||||
|
||||
setOnOB11ConfigChanged: async function(func: (ob11: OB11Config) => Promise<void>): Promise<void> {
|
||||
LoginRuntime.NapCatHelper.onOB11ConfigChanged = func;
|
||||
},
|
||||
|
||||
setOB11Config: async function(ob11: OB11Config): Promise<void> {
|
||||
await LoginRuntime.NapCatHelper.SetOb11ConfigCall(ob11);
|
||||
await LoginRuntime.NapCatHelper.onOB11ConfigChanged(ob11);
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user