mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
feat: moehoo version checker
This commit is contained in:
parent
d66d42cb5d
commit
b7a7eeecd3
@ -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 {
|
||||
|
35
src/ntqqapi/native/moehoo/version.ts
Normal file
35
src/ntqqapi/native/moehoo/version.ts
Normal 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(', '))
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user