mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
feat: #780
This commit is contained in:
@@ -9,7 +9,7 @@ export const NapcatConfigSchema = Type.Object({
|
|||||||
fileLogLevel: Type.String({ default: 'debug' }),
|
fileLogLevel: Type.String({ default: 'debug' }),
|
||||||
consoleLogLevel: Type.String({ default: 'info' }),
|
consoleLogLevel: Type.String({ default: 'info' }),
|
||||||
packetBackend: Type.String({ default: 'auto' }),
|
packetBackend: Type.String({ default: 'auto' }),
|
||||||
packetServer: Type.String({ default: '' })
|
packetServer: Type.String({ default: '' }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type NapcatConfig = Static<typeof NapcatConfigSchema>;
|
export type NapcatConfig = Static<typeof NapcatConfigSchema>;
|
||||||
|
@@ -28,6 +28,7 @@ export let WebUiConfig: WebUiConfigWrapper;
|
|||||||
export let webUiPathWrapper: NapCatPathWrapper;
|
export let webUiPathWrapper: NapCatPathWrapper;
|
||||||
const MAX_PORT_TRY = 100;
|
const MAX_PORT_TRY = 100;
|
||||||
import * as net from 'node:net';
|
import * as net from 'node:net';
|
||||||
|
import { WebUiDataRuntime } from './src/helper/Data';
|
||||||
|
|
||||||
export async function InitPort(parsedConfig: WebUiConfigType): Promise<[string, number, string]> {
|
export async function InitPort(parsedConfig: WebUiConfigType): Promise<[string, number, string]> {
|
||||||
try {
|
try {
|
||||||
@@ -48,7 +49,20 @@ export async function InitWebUi(logger: LogWrapper, pathWrapper: NapCatPathWrapp
|
|||||||
logger.log('[NapCat] [WebUi] Current WebUi is not run.');
|
logger.log('[NapCat] [WebUi] Current WebUi is not run.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setTimeout(async () => {
|
||||||
|
let autoLoginAccount = process.env['NAPCAT_QUICK_ACCOUNT'] || WebUiConfig.getAutoLoginAccount();
|
||||||
|
if (autoLoginAccount) {
|
||||||
|
try {
|
||||||
|
const { result, message } = await WebUiDataRuntime.requestQuickLogin(autoLoginAccount);
|
||||||
|
if (!result) {
|
||||||
|
throw new Error(message);
|
||||||
|
}
|
||||||
|
console.log(`[NapCat] [WebUi] Auto login account: ${autoLoginAccount}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(`[NapCat] [WebUi] Auto login account failed.` + error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 30000);
|
||||||
// ------------注册中间件------------
|
// ------------注册中间件------------
|
||||||
// 使用express的json中间件
|
// 使用express的json中间件
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
@@ -13,6 +13,7 @@ const WebUiConfigSchema = Type.Object({
|
|||||||
port: Type.Number({ default: 6099 }),
|
port: Type.Number({ default: 6099 }),
|
||||||
token: Type.String({ default: 'napcat' }),
|
token: Type.String({ default: 'napcat' }),
|
||||||
loginRate: Type.Number({ default: 10 }),
|
loginRate: Type.Number({ default: 10 }),
|
||||||
|
autoLoginAccount: Type.String({ default: '' }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type WebUiConfigType = Static<typeof WebUiConfigSchema>;
|
export type WebUiConfigType = Static<typeof WebUiConfigSchema>;
|
||||||
@@ -125,4 +126,8 @@ export class WebUiConfigWrapper {
|
|||||||
public static GetWebUIFontPath(): string {
|
public static GetWebUIFontPath(): string {
|
||||||
return resolve(webUiPathWrapper.configPath, './fonts/webui.woff');
|
return resolve(webUiPathWrapper.configPath, './fonts/webui.woff');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getAutoLoginAccount(): string | undefined {
|
||||||
|
return this.WebUiConfigData?.autoLoginAccount;
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user