This commit is contained in:
手瓜一十雪 committed 2026-10-30 14:17:03 +08:00
1 parent 162c6db1ac
commit 093b3bf4aa
5 files changed
+41 -20

No files matched your search

+1 -18
View File
@@ -42,6 +42,7 @@ import { QQBasicInfoWrapper } from '@/napcat-core/helper/qq-basic-info';
import { statusHelperSubscription } from '@/napcat-core/helper/status';
import { applyPendingUpdates } from '@/napcat-webui-backend/src/api/UpdateNapCat';
import { migrateLegacyGlobalPath } from './global-migrate';
import { getDataPaths } from './data-path';
import { connectToNamedPipe } from './pipe';
// NapCat Shell App ES 入口文件
@@ -54,24 +55,6 @@ async function handleUncaughtExceptions (logger: LogWrapper) {
});
}
function getDataPaths (wrapper: WrapperNodeApi): [string, string] {
if (os.platform() === 'darwin') {
const userPath = os.homedir();
const appDataPath = path.resolve(userPath, './Library/Application Support/QQ');
return [appDataPath, path.join(appDataPath, 'global')];
}
let dataPath = wrapper.NodeQQNTWrapperUtil.getNTUserDataInfoConfig();
if (!dataPath) {
dataPath = path.resolve(os.homedir(), './.config/QQ');
fs.mkdirSync(dataPath, { recursive: true });
}
// Linux: global 直接位于数据目录下; Windows: global 位于 nt_qq 子目录下
const dataPathGlobal = os.platform() === 'linux'
? path.resolve(dataPath, './global')
: path.resolve(dataPath, './nt_qq/global');
return [dataPath, dataPathGlobal];
}
function getPlatformType (): PlatformType {
const platformMapping: Partial<Record<NodeJS.Platform, PlatformType>> = {
win32: PlatformType.KWINDOWS,
+28
View File
@@ -0,0 +1,28 @@
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { getQQDataDirOverride } from 'napcat-common/src/path';
import type { WrapperNodeApi } from 'napcat-core';
export function getDataPaths (wrapper: WrapperNodeApi): [string, string] {
const platform = os.platform();
let dataPath = getQQDataDirOverride();
if (dataPath) {
// 自定义目录必须在初始化内核前存在;创建失败时不能回退到桌面 QQ。
fs.mkdirSync(dataPath, { recursive: true });
} else if (platform === 'darwin') {
dataPath = path.resolve(os.homedir(), './Library/Application Support/QQ');
} else {
dataPath = wrapper.NodeQQNTWrapperUtil.getNTUserDataInfoConfig();
if (!dataPath) {
dataPath = path.resolve(os.homedir(), './.config/QQ');
fs.mkdirSync(dataPath, { recursive: true });
}
}
// Linux/macOS: global 直接位于数据目录下;Windows: 位于 nt_qq 子目录下。
// 此处不创建 global,以免阻止后续 Linux 旧目录迁移。
const dataPathGlobal = platform === 'linux' || platform === 'darwin'
? path.resolve(dataPath, 'global')
: path.resolve(dataPath, 'nt_qq', 'global');
return [dataPath, dataPathGlobal];
}
+1 -1
View File
@@ -12,7 +12,6 @@ import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const pathWrapper = new NapCatPathWrapper();
const envPath = path.join(__dirname, 'config', '.env');
if (fs.existsSync(envPath)) {
try {
@@ -32,6 +31,7 @@ if (fs.existsSync(envPath)) {
console.log('[NapCat] Failed to load .env file:', e);
}
}
const pathWrapper = new NapCatPathWrapper();
// 环境变量配置
const ENV = {