mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix
This commit is contained in:
parent
fedb77e304
commit
714f8327ea
@ -3,7 +3,6 @@ import { resolve } from 'node:path';
|
|||||||
import * as net from 'node:net';
|
import * as net from 'node:net';
|
||||||
import { dirname } from 'node:path';
|
import { dirname } from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import { logError } from '@/common/utils/log';
|
|
||||||
|
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
@ -96,7 +95,7 @@ class WebUiConfigWrapper {
|
|||||||
try {
|
try {
|
||||||
defaultconfig.token = Math.random().toString(36).slice(2); //生成随机密码
|
defaultconfig.token = Math.random().toString(36).slice(2); //生成随机密码
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logError('随机密码生成失败', e);
|
console.log('随机密码生成失败', e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const configPath = resolve(__dirname, './config/webui.json');
|
const configPath = resolve(__dirname, './config/webui.json');
|
||||||
@ -118,14 +117,14 @@ class WebUiConfigWrapper {
|
|||||||
// 查询主机地址是否可用
|
// 查询主机地址是否可用
|
||||||
const [host_err, host] = await tryUseHost(parsedConfig.host).then(data => [null, data as string]).catch(err => [err, null]);
|
const [host_err, host] = await tryUseHost(parsedConfig.host).then(data => [null, data as string]).catch(err => [err, null]);
|
||||||
if (host_err) {
|
if (host_err) {
|
||||||
logError('host不可用', host_err);
|
console.log('host不可用', host_err);
|
||||||
parsedConfig.port = 0; // 设置为0,禁用WebUI
|
parsedConfig.port = 0; // 设置为0,禁用WebUI
|
||||||
} else {
|
} else {
|
||||||
parsedConfig.host = host;
|
parsedConfig.host = host;
|
||||||
// 修正端口占用情况
|
// 修正端口占用情况
|
||||||
const [port_err, port] = await tryUsePort(parsedConfig.port, parsedConfig.host).then(data => [null, data as number]).catch(err => [err, null]);
|
const [port_err, port] = await tryUsePort(parsedConfig.port, parsedConfig.host).then(data => [null, data as number]).catch(err => [err, null]);
|
||||||
if (port_err) {
|
if (port_err) {
|
||||||
logError('port不可用', port_err);
|
console.log('port不可用', port_err);
|
||||||
parsedConfig.port = 0; // 设置为0,禁用WebUI
|
parsedConfig.port = 0; // 设置为0,禁用WebUI
|
||||||
} else {
|
} else {
|
||||||
parsedConfig.port = port;
|
parsedConfig.port = port;
|
||||||
@ -134,7 +133,7 @@ class WebUiConfigWrapper {
|
|||||||
this.WebUiConfigData = parsedConfig;
|
this.WebUiConfigData = parsedConfig;
|
||||||
return this.WebUiConfigData;
|
return this.WebUiConfigData;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logError('读取配置文件失败', e);
|
console.log('读取配置文件失败', e);
|
||||||
}
|
}
|
||||||
return defaultconfig; // 理论上这行代码到不了,到了只能返回默认配置了
|
return defaultconfig; // 理论上这行代码到不了,到了只能返回默认配置了
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user