mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
chore: Support 多账户
This commit is contained in:
parent
dde093d321
commit
fd226c45f6
@ -1,7 +1,6 @@
|
||||
//LiteLoader需要提供部分IPC接口,以便于其他插件调用
|
||||
const { ipcMain } = require('electron');
|
||||
const fs = require('fs');
|
||||
const napcat= require('./napcat.cjs');
|
||||
ipcMain.handle("napcat_get_webtoken", async (event, arg) => {
|
||||
return "http://127.0.0.1:6099/webui/?token=" + JSON.parse(fs.readFileSync(__dirname + '/config/webui.json', 'utf-8').toString()).token;
|
||||
return napcat.NCgetWebUiUrl();
|
||||
});
|
||||
require('./napcat.cjs');
|
@ -27,7 +27,7 @@ process.dlopen = (module, filename, flags = os.constants.dlopen.RTLD_LAZY) => {
|
||||
if (args[ArgIndex] instanceof Object) {
|
||||
let HookArg = {};
|
||||
for (let ListenerName in args[ArgIndex]) {
|
||||
HookArg[ListenerName] = function(...ListenerData) {
|
||||
HookArg[ListenerName] = function (...ListenerData) {
|
||||
try {
|
||||
if (ListenerName === 'onSessionInitComplete') {
|
||||
//回调成功
|
||||
@ -116,13 +116,14 @@ async function fetchServices(timeout = 10000) {
|
||||
Promise.reject(),
|
||||
);
|
||||
}
|
||||
|
||||
let getWebUiUrlFunc = undefined;
|
||||
async function NCInit() {
|
||||
console.log('[NapCat] [Info] 开始初始化NapCat');
|
||||
|
||||
try {
|
||||
const { wrapperSession, wrapperLoginService } = await fetchServices();
|
||||
const { NCoreInitFramework } = await import('file://' + path.join(currentPath, './napcat.mjs'));
|
||||
const { NCoreInitFramework, getWebUiUrl } = await import('file://' + path.join(currentPath, './napcat.mjs'));
|
||||
getWebUiUrlFunc = getWebUiUrl;
|
||||
//传入LoginService Session 其余自载入
|
||||
await NCoreInitFramework(wrapperSession, wrapperLoginService, registerInitCallback);
|
||||
//console.log("[NapCat] [Info] NapCat初始化完成");
|
||||
@ -132,3 +133,12 @@ async function NCInit() {
|
||||
}
|
||||
|
||||
NCInit();
|
||||
module.exports = {
|
||||
NCgetWebUiUrl: async () => {
|
||||
if (getWebUiUrlFunc === undefined) {
|
||||
console.log('[NapCat] [Error] 未初始化完成');
|
||||
return '';
|
||||
}
|
||||
return await getWebUiUrlFunc();
|
||||
}
|
||||
};
|
@ -8,10 +8,14 @@ import { SelfInfo } from '@/core/entities';
|
||||
import { LoginListener } from '@/core/listeners';
|
||||
import { NodeIKernelLoginService } from '@/core/services';
|
||||
import { NodeIQQNTWrapperSession, WrapperNodeApi } from '@/core/wrapper/wrapper';
|
||||
import { InitWebUi } from '@/webui';
|
||||
import { InitWebUi, WebUiConfig } from '@/webui';
|
||||
import { NapCatOneBot11Adapter } from '@/onebot';
|
||||
|
||||
//Framework ES入口文件
|
||||
export async function getWebUiUrl() {
|
||||
let WebUiConfigData = (await WebUiConfig.GetWebUIConfig());
|
||||
return "http://127.0.0.1:" + WebUiConfigData.port + '/webui/?token=' + WebUiConfigData.token;
|
||||
}
|
||||
export async function NCoreInitFramework(
|
||||
session: NodeIQQNTWrapperSession,
|
||||
loginService: NodeIKernelLoginService,
|
||||
|
Loading…
x
Reference in New Issue
Block a user