mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
commit
31d963c4d1
@ -22,9 +22,14 @@ export abstract class ConfigBase<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getConfigPath(pathName: string | undefined): string {
|
getConfigPath(pathName: string | undefined): string {
|
||||||
const suffix = pathName ? `_${pathName}` : '';
|
if (!pathName) {
|
||||||
const filename = `${this.name}${suffix}.json`;
|
const filename = `${this.name}.json`;
|
||||||
return path.join(this.configPath, filename);
|
const mainPath = this.core.context.pathWrapper.binaryPath;
|
||||||
|
return path.join(mainPath, 'config', filename);
|
||||||
|
} else {
|
||||||
|
const filename = `${this.name}_${pathName}.json`;
|
||||||
|
return path.join(this.configPath, filename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
read(): T {
|
read(): T {
|
||||||
|
@ -37,7 +37,7 @@ export class FileNapCatOneBotUUID {
|
|||||||
if (!uuid.startsWith('NapCatOneBot|ModelIdFile|')) return undefined;
|
if (!uuid.startsWith('NapCatOneBot|ModelIdFile|')) return undefined;
|
||||||
const data = uuid.split('|');
|
const data = uuid.split('|');
|
||||||
if (data.length !== 6) return undefined;
|
if (data.length !== 6) return undefined;
|
||||||
const [, , chatType, peerUid, modelId,fileId] = data;
|
const [, , chatType, peerUid, modelId, fileId] = data;
|
||||||
return {
|
return {
|
||||||
peer: {
|
peer: {
|
||||||
chatType: chatType as any,
|
chatType: chatType as any,
|
||||||
@ -156,10 +156,22 @@ export function getDefaultQQVersionConfigInfo(): QQVersionConfigType {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getQQPackageInfoPath(exePath: string = ''): string {
|
||||||
|
if (os.platform() === 'darwin') {
|
||||||
|
return path.join(path.dirname(exePath), '..', 'Resources', 'app', 'package.json');
|
||||||
|
} else {
|
||||||
|
return path.join(path.dirname(exePath), 'resources', 'app', 'package.json');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function getQQVersionConfigPath(exePath: string = ''): string | undefined {
|
export function getQQVersionConfigPath(exePath: string = ''): string | undefined {
|
||||||
let configVersionInfoPath;
|
let configVersionInfoPath;
|
||||||
if (os.platform() !== 'linux') {
|
if (os.platform() === 'win32') {
|
||||||
configVersionInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'versions', 'config.json');
|
configVersionInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'versions', 'config.json');
|
||||||
|
} else if (os.platform() === 'darwin') {
|
||||||
|
const userPath = os.homedir();
|
||||||
|
const appDataPath = path.resolve(userPath, './Library/Application Support/QQ');
|
||||||
|
configVersionInfoPath = path.resolve(appDataPath, './versions/config.json');
|
||||||
} else {
|
} else {
|
||||||
const userPath = os.homedir();
|
const userPath = os.homedir();
|
||||||
const appDataPath = path.resolve(userPath, './.config/QQ');
|
const appDataPath = path.resolve(userPath, './.config/QQ');
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import path, { dirname } from 'path';
|
import path, { dirname } from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
import os from 'os';
|
||||||
|
|
||||||
export class NapCatPathWrapper {
|
export class NapCatPathWrapper {
|
||||||
binaryPath: string;
|
binaryPath: string;
|
||||||
@ -11,17 +12,23 @@ export class NapCatPathWrapper {
|
|||||||
|
|
||||||
constructor(mainPath: string = dirname(fileURLToPath(import.meta.url))) {
|
constructor(mainPath: string = dirname(fileURLToPath(import.meta.url))) {
|
||||||
this.binaryPath = mainPath;
|
this.binaryPath = mainPath;
|
||||||
this.logsPath = path.join(this.binaryPath, 'logs');
|
let writePath: string;
|
||||||
this.configPath = path.join(this.binaryPath, 'config');
|
if (os.platform() === 'darwin') {
|
||||||
this.cachePath = path.join(this.binaryPath, 'cache');
|
writePath = path.join(os.homedir(), 'Library', 'Application Support', 'QQ', 'NapCat');
|
||||||
|
} else {
|
||||||
|
writePath = this.binaryPath;
|
||||||
|
}
|
||||||
|
this.logsPath = path.join(writePath, 'logs');
|
||||||
|
this.configPath = path.join(writePath, 'config');
|
||||||
|
this.cachePath = path.join(writePath, 'cache');
|
||||||
this.staticPath = path.join(this.binaryPath, 'static');
|
this.staticPath = path.join(this.binaryPath, 'static');
|
||||||
if (fs.existsSync(this.logsPath)) {
|
if (!fs.existsSync(this.logsPath)) {
|
||||||
fs.mkdirSync(this.logsPath, { recursive: true });
|
fs.mkdirSync(this.logsPath, { recursive: true });
|
||||||
}
|
}
|
||||||
if (fs.existsSync(this.configPath)) {
|
if (!fs.existsSync(this.configPath)) {
|
||||||
fs.mkdirSync(this.configPath, { recursive: true });
|
fs.mkdirSync(this.configPath, { recursive: true });
|
||||||
}
|
}
|
||||||
if (fs.existsSync(this.cachePath)) {
|
if (!fs.existsSync(this.cachePath)) {
|
||||||
fs.mkdirSync(this.cachePath, { recursive: true });
|
fs.mkdirSync(this.cachePath, { recursive: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import path from 'node:path';
|
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import { systemPlatform } from '@/common/system';
|
import { systemPlatform } from '@/common/system';
|
||||||
import { getDefaultQQVersionConfigInfo, getQQVersionConfigPath } from './helper';
|
import { getDefaultQQVersionConfigInfo, getQQPackageInfoPath, getQQVersionConfigPath } from './helper';
|
||||||
import AppidTable from '@/core/external/appid.json';
|
import AppidTable from '@/core/external/appid.json';
|
||||||
import { LogWrapper } from './log';
|
import { LogWrapper } from './log';
|
||||||
|
|
||||||
@ -20,7 +19,7 @@ export class QQBasicInfoWrapper {
|
|||||||
//基础目录获取
|
//基础目录获取
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.QQMainPath = process.execPath;
|
this.QQMainPath = process.execPath;
|
||||||
this.QQPackageInfoPath = path.join(path.dirname(this.QQMainPath), 'resources', 'app', 'package.json');
|
this.QQPackageInfoPath = getQQPackageInfoPath(this.QQMainPath);
|
||||||
this.QQVersionConfigPath = getQQVersionConfigPath(this.QQMainPath);
|
this.QQVersionConfigPath = getQQVersionConfigPath(this.QQMainPath);
|
||||||
|
|
||||||
//基础信息获取 无快更则启用默认模板填充
|
//基础信息获取 无快更则启用默认模板填充
|
||||||
@ -53,9 +52,25 @@ export class QQBasicInfoWrapper {
|
|||||||
|
|
||||||
//此方法不要直接使用
|
//此方法不要直接使用
|
||||||
getQUAInternal() {
|
getQUAInternal() {
|
||||||
return systemPlatform === 'linux'
|
switch (systemPlatform) {
|
||||||
? `V1_LNX_NQ_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`
|
case 'linux':
|
||||||
: `V1_WIN_NQ_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`;
|
return `V1_LNX_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`;
|
||||||
|
case 'darwin':
|
||||||
|
return `V1_MAC_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`;
|
||||||
|
default:
|
||||||
|
return `V1_WIN_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getAppidInternal() {
|
||||||
|
switch (systemPlatform) {
|
||||||
|
case 'linux':
|
||||||
|
return '537243600';
|
||||||
|
case 'darwin':
|
||||||
|
return '537243441';
|
||||||
|
default:
|
||||||
|
return '537243538';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getAppidV2(): { appid: string; qua: string } {
|
getAppidV2(): { appid: string; qua: string } {
|
||||||
@ -71,6 +86,6 @@ export class QQBasicInfoWrapper {
|
|||||||
// else
|
// else
|
||||||
this.context.logger.log(`[QQ版本兼容性检测] 获取Appid异常 请检测NapCat/QQNT是否正常`);
|
this.context.logger.log(`[QQ版本兼容性检测] 获取Appid异常 请检测NapCat/QQNT是否正常`);
|
||||||
this.context.logger.log(`[QQ版本兼容性检测] ${fullVersion} 版本兼容性不佳,可能会导致一些功能无法正常使用`,);
|
this.context.logger.log(`[QQ版本兼容性检测] ${fullVersion} 版本兼容性不佳,可能会导致一些功能无法正常使用`,);
|
||||||
return { appid: systemPlatform === 'linux' ? '537243600' : '537243441', qua: this.getQUAInternal() };
|
return { appid: this.getAppidInternal(), qua: this.getQUAInternal() };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
src/core/external/appid.json
vendored
4
src/core/external/appid.json
vendored
@ -6,5 +6,9 @@
|
|||||||
"9.9.15-27597": {
|
"9.9.15-27597": {
|
||||||
"appid": 537243441,
|
"appid": 537243441,
|
||||||
"qua": "V1_WIN_NQ_9.9.15_27597_GW_B"
|
"qua": "V1_WIN_NQ_9.9.15_27597_GW_B"
|
||||||
|
},
|
||||||
|
"6.9.53-27597": {
|
||||||
|
"appid": 537243538,
|
||||||
|
"qua": "V1_MAC_NQ_6.9.53_27597_GW_B"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,15 @@ export enum NapCatCoreWorkingEnv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function loadQQWrapper(QQVersion: string): WrapperNodeApi {
|
export function loadQQWrapper(QQVersion: string): WrapperNodeApi {
|
||||||
let wrapperNodePath = path.resolve(path.dirname(process.execPath), './resources/app/wrapper.node');
|
let appPath;
|
||||||
|
if (os.platform() === 'darwin') {
|
||||||
|
appPath = path.resolve(path.dirname(process.execPath), '../Resources/app');
|
||||||
|
} else {
|
||||||
|
appPath = path.resolve(path.dirname(process.execPath), './resources/app');
|
||||||
|
}
|
||||||
|
let wrapperNodePath = path.resolve(appPath, 'wrapper.node');
|
||||||
if (!fs.existsSync(wrapperNodePath)) {
|
if (!fs.existsSync(wrapperNodePath)) {
|
||||||
wrapperNodePath = path.join(path.dirname(process.execPath), `resources/app/versions/${QQVersion}/wrapper.node`);
|
wrapperNodePath = path.join(appPath, `versions/${QQVersion}/wrapper.node`);
|
||||||
}
|
}
|
||||||
const nativemodule: any = { exports: {} };
|
const nativemodule: any = { exports: {} };
|
||||||
process.dlopen(nativemodule, wrapperNodePath);
|
process.dlopen(nativemodule, wrapperNodePath);
|
||||||
|
@ -49,12 +49,20 @@ export async function NCoreInitShell() {
|
|||||||
const session = new wrapper.NodeIQQNTWrapperSession();
|
const session = new wrapper.NodeIQQNTWrapperSession();
|
||||||
|
|
||||||
// from get dataPath
|
// from get dataPath
|
||||||
let dataPath = wrapper.NodeQQNTWrapperUtil.getNTUserDataInfoConfig();
|
const [dataPath, dataPathGlobal] = (() => {
|
||||||
if (!dataPath) {
|
if (os.platform() === 'darwin') {
|
||||||
dataPath = path.resolve(os.homedir(), './.config/QQ');
|
const userPath = os.homedir();
|
||||||
fs.mkdirSync(dataPath, { recursive: true });
|
const appDataPath = path.resolve(userPath, './Library/Application Support/QQ');
|
||||||
}
|
return [appDataPath, path.join(appDataPath, 'global')];
|
||||||
const dataPathGlobal = path.resolve(dataPath, './nt_qq/global');
|
}
|
||||||
|
let dataPath = wrapper.NodeQQNTWrapperUtil.getNTUserDataInfoConfig();
|
||||||
|
if (!dataPath) {
|
||||||
|
dataPath = path.resolve(os.homedir(), './.config/QQ');
|
||||||
|
fs.mkdirSync(dataPath, { recursive: true });
|
||||||
|
}
|
||||||
|
const dataPathGlobal = path.resolve(dataPath, './nt_qq/global');
|
||||||
|
return [dataPath, dataPathGlobal];
|
||||||
|
})();
|
||||||
|
|
||||||
// from initConfig
|
// from initConfig
|
||||||
engine.initWithDeskTopConfig(
|
engine.initWithDeskTopConfig(
|
||||||
@ -115,7 +123,7 @@ export async function NCoreInitShell() {
|
|||||||
const realBase64 = pngBase64QrcodeData.replace(/^data:image\/\w+;base64,/, '');
|
const realBase64 = pngBase64QrcodeData.replace(/^data:image\/\w+;base64,/, '');
|
||||||
const buffer = Buffer.from(realBase64, 'base64');
|
const buffer = Buffer.from(realBase64, 'base64');
|
||||||
logger.logWarn('请扫描下面的二维码,然后在手Q上授权登录:');
|
logger.logWarn('请扫描下面的二维码,然后在手Q上授权登录:');
|
||||||
const qrcodePath = path.join(pathWrapper.binaryPath, 'qrcode.png');
|
const qrcodePath = path.join(pathWrapper.cachePath, 'qrcode.png');
|
||||||
qrcode.generate(qrcodeUrl, { small: true }, (res) => {
|
qrcode.generate(qrcodeUrl, { small: true }, (res) => {
|
||||||
logger.logWarn([
|
logger.logWarn([
|
||||||
'\n',
|
'\n',
|
||||||
@ -191,7 +199,7 @@ export async function NCoreInitShell() {
|
|||||||
logger.log(`可用于快速登录的 QQ:\n${historyLoginList
|
logger.log(`可用于快速登录的 QQ:\n${historyLoginList
|
||||||
.map((u, index) => `${index + 1}. ${u.uin} ${u.nickName}`)
|
.map((u, index) => `${index + 1}. ${u.uin} ${u.nickName}`)
|
||||||
.join('\n')
|
.join('\n')
|
||||||
}`);
|
}`);
|
||||||
}
|
}
|
||||||
loginService.getQRCodePicture();
|
loginService.getQRCodePicture();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user