fix: Compatible with win7

This commit is contained in:
linyuchen 2024-05-12 20:36:27 +08:00
parent 9692bf6ec6
commit a3fc018186
6 changed files with 54 additions and 48 deletions

View File

@ -1,10 +1,10 @@
{ {
"manifest_version": 4, "manifest_version": 4,
"type": "extension", "type": "extension",
"name": "LLOneBot v3.24.3", "name": "LLOneBot v3.24.4",
"slug": "LLOneBot", "slug": "LLOneBot",
"description": "使你的NTQQ支持OneBot11协议进行QQ机器人开发, 不支持商店在线更新", "description": "使你的NTQQ支持OneBot11协议进行QQ机器人开发, 不支持商店在线更新",
"version": "3.24.3", "version": "3.24.4",
"icon": "./icon.jpg", "icon": "./icon.jpg",
"authors": [ "authors": [
{ {

View File

@ -8,6 +8,8 @@ export const exePath = process.execPath;
export const pkgInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'package.json'); export const pkgInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'package.json');
let configVersionInfoPath; let configVersionInfoPath;
if (os.platform() !== 'linux') { if (os.platform() !== 'linux') {
configVersionInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'versions', 'config.json'); configVersionInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'versions', 'config.json');
} else { } else {

View File

@ -4,7 +4,7 @@ import path from 'node:path';
export const systemPlatform = os.platform(); export const systemPlatform = os.platform();
export const cpuArch = os.arch(); export const cpuArch = os.arch();
export const systemVersion = os.release(); export const systemVersion = os.release();
export const hostname = os.hostname(); // export const hostname = os.hostname(); // win7不支持
const homeDir = os.homedir(); const homeDir = os.homedir();
export const downloadsPath = path.join(homeDir, 'Downloads'); export const downloadsPath = path.join(homeDir, 'Downloads');
export const systemName = os.type(); export const systemName = os.type();

View File

@ -1,54 +1,58 @@
import {log} from "../../../common/utils"; import { log } from '../../../common/utils'
import {NTQQApi} from "../../ntcall"; import { NTQQApi } from '../../ntcall'
import {cpModule} from "../cpmodule"; import { cpModule } from '../cpmodule'
type PokeHandler = (id: string, isGroup: boolean) => void type PokeHandler = (id: string, isGroup: boolean) => void
type CrychicHandler = (event: string, id: string, isGroup: boolean) => void type CrychicHandler = (event: string, id: string, isGroup: boolean) => void
let pokeRecords: Record<string, number> = {} let pokeRecords: Record<string, number> = {}
class Crychic{ class Crychic {
private crychic: any = undefined private crychic: any = undefined
loadNode(){ loadNode() {
if (!this.crychic){ if (!this.crychic) {
try { try {
cpModule('crychic'); cpModule('crychic')
this.crychic = require("./crychic.node") this.crychic = require('./crychic.node')
this.crychic.init() this.crychic.init()
}catch (e) { } catch (e) {
log("crychic加载失败", e) log('crychic加载失败', e)
} }
}
}
registerPokeHandler(fn: PokeHandler) {
this.registerHandler((event, id, isGroup) => {
if (event === 'poke') {
let existTime = pokeRecords[id]
if (existTime) {
if (Date.now() - existTime < 1500) {
return
}
} }
} pokeRecords[id] = Date.now()
registerPokeHandler(fn: PokeHandler){ fn(id, isGroup)
this.registerHandler((event, id, isGroup)=>{ }
if (event === "poke"){ })
let existTime = pokeRecords[id] }
if (existTime) {
if (Date.now() - existTime < 1500) { registerHandler(fn: CrychicHandler) {
return if (!this.crychic) return
} this.crychic.setCryHandler(fn)
} }
pokeRecords[id] = Date.now()
fn(id, isGroup); sendFriendPoke(friendUid: string) {
} if (!this.crychic) return
}) this.crychic.sendFriendPoke(parseInt(friendUid))
} NTQQApi.fetchUnitedCommendConfig().then()
registerHandler(fn: CrychicHandler){ }
if (!this.crychic) return;
this.crychic.setCryHandler(fn) sendGroupPoke(groupCode: string, memberUin: string) {
} if (!this.crychic) return
sendFriendPoke(friendUid: string){ this.crychic.sendGroupPoke(parseInt(memberUin), parseInt(groupCode))
if (!this.crychic) return; NTQQApi.fetchUnitedCommendConfig().then()
this.crychic.sendFriendPoke(parseInt(friendUid)) }
NTQQApi.fetchUnitedCommendConfig().then()
}
sendGroupPoke(groupCode: string, memberUin: string){
if (!this.crychic) return;
this.crychic.sendGroupPoke(parseInt(memberUin), parseInt(groupCode))
NTQQApi.fetchUnitedCommendConfig().then()
}
} }
export const crychic = new Crychic() export const crychic = new Crychic()

View File

@ -30,4 +30,4 @@ class HookApi {
} }
} }
export const hookApi = new HookApi(); // export const hookApi = new HookApi();

View File

@ -1 +1 @@
export const version = '3.24.3' export const version = '3.24.4'