refactor: Appid的获取

This commit is contained in:
手瓜一十雪
2024-08-04 14:35:26 +08:00
parent 4b92254945
commit 9793e5741a
3 changed files with 62 additions and 1 deletions

View File

@@ -2,6 +2,8 @@ import path from 'node:path';
import fs from 'node:fs';
import { systemPlatform } from '@/common/utils/system';
import { getDefaultQQVersionConfigInfo, getQQVersionConfigPath } from './helper';
import AppidTable from '@/core/external/appid.json';
import { logNotice } from '@/onebot11/log';
//基础目录获取
export let QQMainPath = process.execPath;
@@ -9,7 +11,7 @@ export let QQPackageInfoPath: string = path.join(path.dirname(QQMainPath), 'reso
export let QQVersionConfigPath: string | undefined = getQQVersionConfigPath(QQMainPath);
//基础信息获取 无快更则启用默认模板填充
export let QQVersionAppid: string = systemPlatform === 'linux' ? '537237950' : '537237765';
export let QQVersionAppid: string = getAppidV2().appid;
export let isQuickUpdate: boolean = !!QQVersionConfigPath;
export let QQVersionConfig: QQVersionConfigType = isQuickUpdate ? JSON.parse(fs.readFileSync(QQVersionConfigPath!).toString()) : getDefaultQQVersionConfigInfo();
export let QQPackageInfo: QQPackageInfoType = JSON.parse(fs.readFileSync(QQPackageInfoPath).toString());
@@ -27,6 +29,20 @@ export function requireMinNTQQBuild(buildStr: string) {
export function getQUA() {
return systemPlatform === 'linux' ? `V1_LNX_NQ_${getFullQQVesion()}_${getQQBuildStr()}_GW_B` : `V1_WIN_NQ_${getFullQQVesion()}_${getQQBuildStr()}_GW_B`;
}
export function getAppidV2(): { appid: string, qua: string } {
let appidTbale = AppidTable as unknown as QQAppidTableType;
try {
let data = appidTbale[getFullQQVesion()];
if (data) {
return data;
}
}
catch (e) {
logNotice('[QQ版本兼容性检测] 版本兼容性不佳,可能会导致一些功能无法正常使用');
}
// 以下是兜底措施
return { appid: systemPlatform === 'linux' ? '537237950' : '537237765', qua: getQUA() };
}
// platform_type: 3,
// app_type: 4,
// app_version: '9.9.12-25765',