feat: moehoo version checker

This commit is contained in:
linyuchen 2024-11-17 17:19:17 +08:00
parent d66d42cb5d
commit b7a7eeecd3
2 changed files with 36 additions and 1 deletions

View File

@ -34,7 +34,7 @@ export class Native {
}
const platform = process.platform + '.' + process.arch
try {
const fileName = 'MoeHoo.' + platform + '.node'
const fileName = 'MoeHoo.' + platform + '.node' // todo: 需要加入版本号或者hash不然多开QQ时会导致copyFile失败从而无法进行在线更新
const src = path.join(__dirname, 'Moehoo', fileName)
const dest = path.join(TEMP_DIR, fileName)
try {

View File

@ -0,0 +1,35 @@
import os from 'os'
import offset from '@/ntqqapi/helper/offset.json'
import { getFullVersion } from '@/common/utils'
function getSupportVersions() {
let fullVersionStart: string = ''
switch (os.platform()) {
case 'linux':
fullVersionStart = '3'
break
case 'darwin':
fullVersionStart = '6'
break
case 'win32':
fullVersionStart = '9'
break
}
const supportVersions: string[] = []
for (const offsetKey in offset) {
if (offsetKey.startsWith(fullVersionStart) && offsetKey.endsWith(os.arch())) {
supportVersions.push(offsetKey)
}
}
return supportVersions
}
export function checkSupportVersion(){
// 检查当前 QQ 版本是否支持,不支持则抛出异常
const qqFullVersion = getFullVersion() // todo: 去除llqqnt依赖
const _ = offset[qqFullVersion + '-' + os.arch()]
if (!_) {
const supportVersion = getSupportVersions()
throw new Error('当前 QQ 版本不支持, 只支持: ' + supportVersion.join(', '))
}
}