From 9793e5741aae4f874027445231ad6ab7f5fc44b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sun, 4 Aug 2024 14:35:26 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20Appid=E7=9A=84=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/utils/QQBasicInfo.ts | 18 +++++++++++++- src/common/utils/type.ts | 3 +++ src/core/src/external/appid.json | 42 ++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/core/src/external/appid.json diff --git a/src/common/utils/QQBasicInfo.ts b/src/common/utils/QQBasicInfo.ts index 39ec7132..87a2940c 100644 --- a/src/common/utils/QQBasicInfo.ts +++ b/src/common/utils/QQBasicInfo.ts @@ -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', diff --git a/src/common/utils/type.ts b/src/common/utils/type.ts index cf95f60d..7e62606c 100644 --- a/src/common/utils/type.ts +++ b/src/common/utils/type.ts @@ -11,4 +11,7 @@ type QQVersionConfigType = { prevVersion: string; onErrorVersions: Array; buildId: string; +} +type QQAppidTableType = { + [key: string]: { appid: string, qua: string }; } \ No newline at end of file diff --git a/src/core/src/external/appid.json b/src/core/src/external/appid.json new file mode 100644 index 00000000..29223226 --- /dev/null +++ b/src/core/src/external/appid.json @@ -0,0 +1,42 @@ +{ + "3.1.2-13107": { + "appid": 537146866, + "qua": "V1_LNX_NQ_3.1.2-13107_RDM_B" + }, + "3.2.10-25765": { + "appid": 537234773, + "qua": "V1_LNX_NQ_3.2.10_25765_GW_B" + }, + "3.2.12-26702": { + "appid": 537237950, + "qua": "V1_LNX_NQ_3.2.12_26702_GW_B" + }, + "9.9.11-24815": { + "appid": 537226656, + "qua": "V1_WIN_NQ_9.9.11_24815_GW_B" + }, + "9.9.12-25493": { + "appid": 537231759, + "qua": "V1_WIN_NQ_9.9.12_25493_GW_B" + }, + "9.9.12-25765": { + "appid": 537234702, + "qua": "V1_WIN_NQ_9.9.12_25765_GW_B" + }, + "9.9.12-26299": { + "appid": 537234826, + "qua": "V1_WIN_NQ_9.9.12_26299_GW_B" + }, + "9.9.12-26339": { + "appid": 537234826, + "qua": "V1_WIN_NQ_9.9.12_26339_GW_B" + }, + "9.9.12-26466": { + "appid": 537234826, + "qua": "V1_WIN_NQ_9.9.12_26466_GW_B" + }, + "9.9.15-26702": { + "appid": 537237765, + "qua": "V1_WIN_NQ_9.9.15_26702_GW_B" + } +} \ No newline at end of file