From 85df3794e85bbde684c599283666a146d8cc43c2 Mon Sep 17 00:00:00 2001 From: idranme Date: Sun, 4 Aug 2024 22:07:55 +0800 Subject: [PATCH] optimise --- README.md | 2 +- electron.vite.config.ts | 3 ++- manifest.json | 4 ++-- package.json | 1 - scripts/gen-manifest.ts | 38 ++++++++++++++++++++++++++++++++++++++ scripts/gen-version.ts | 22 ---------------------- src/global.d.ts | 2 +- src/renderer/index.ts | 9 +++++---- 8 files changed, 49 insertions(+), 32 deletions(-) create mode 100644 scripts/gen-manifest.ts delete mode 100644 scripts/gen-version.ts diff --git a/README.md b/README.md index 838902d..d64dc4e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # LLOneBot -LiteLoaderQQNT 插件,实现 OneBot 11 协议进行 QQ 机器人开发 +LiteLoaderQQNT 插件,实现 OneBot 11 协议,帮助进行 QQ 机器人开发 > [!CAUTION]\ > **请不要在 QQ 官方群聊和任何影响力较大的简中互联网平台(包括但不限于:B站,微博,知乎,抖音等)发布和讨论*任何*与本插件存在相关性的信息** diff --git a/electron.vite.config.ts b/electron.vite.config.ts index 7fa9507..1259f35 100644 --- a/electron.vite.config.ts +++ b/electron.vite.config.ts @@ -1,6 +1,6 @@ import cp from 'vite-plugin-cp' -import './scripts/gen-version' import path from 'node:path' +import './scripts/gen-manifest' const external = [ 'silk-wasm', @@ -32,6 +32,7 @@ let config = { external, input: 'src/main/main.ts', }, + minify: true, }, resolve: { alias: { diff --git a/manifest.json b/manifest.json index 0344957..f6e8266 100644 --- a/manifest.json +++ b/manifest.json @@ -1,9 +1,9 @@ { "manifest_version": 4, "type": "extension", - "name": "LLOneBot v3.27.4", + "name": "LLOneBot", "slug": "LLOneBot", - "description": "使你的NTQQ支持OneBot11协议进行QQ机器人开发", + "description": "实现 OneBot 11 协议,帮助进行 QQ 机器人开发", "version": "3.27.4", "icon": "./icon.webp", "authors": [ diff --git a/package.json b/package.json index cf08773..d4f13ae 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ "@types/ws": "^8.5.12", "electron": "^29.0.1", "electron-vite": "^2.3.0", - "ts-node": "^10.9.2", "typescript": "^5.5.4", "vite": "^5.3.5", "vite-plugin-cp": "^4.0.8" diff --git a/scripts/gen-manifest.ts b/scripts/gen-manifest.ts new file mode 100644 index 0000000..58f8674 --- /dev/null +++ b/scripts/gen-manifest.ts @@ -0,0 +1,38 @@ +import { version } from '../src/version' +import { writeFileSync } from 'node:fs' + +const manifest = { + manifest_version: 4, + type: 'extension', + name: 'LLOneBot', + slug: 'LLOneBot', + description: '实现 OneBot 11 协议,帮助进行 QQ 机器人开发', + version, + icon: './icon.webp', + authors: [ + { + name: 'linyuchen', + link: 'https://github.com/linyuchen' + } + ], + repository: { + repo: 'linyuchen/LiteLoaderQQNT-OneBotApi', + branch: 'main', + release: { + tag: 'latest', + name: 'LLOneBot.zip' + } + }, + platform: [ + 'win32', + 'linux', + 'darwin' + ], + injects: { + renderer: './renderer/index.js', + main: './main/main.cjs', + preload: './preload/preload.cjs' + } +} + +writeFileSync('manifest.json', JSON.stringify(manifest, null, 2)) \ No newline at end of file diff --git a/scripts/gen-version.ts b/scripts/gen-version.ts deleted file mode 100644 index b702dee..0000000 --- a/scripts/gen-version.ts +++ /dev/null @@ -1,22 +0,0 @@ -import fs from 'fs' -import path from 'path' -import { version } from '../src/version' - -const manifestPath = path.join(__dirname, '../manifest.json') - -function readManifest(): any { - if (fs.existsSync(manifestPath)) { - return JSON.parse(fs.readFileSync(manifestPath, 'utf-8')) - } -} - -function writeManifest(manifest: any) { - fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2)) -} - -const manifest = readManifest() -if (version !== manifest.version) { - manifest.version = version - manifest.name = `LLOneBot v${version}` - writeManifest(manifest) -} diff --git a/src/global.d.ts b/src/global.d.ts index 6f1eb56..1baf170 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -3,6 +3,6 @@ import { type LLOneBot } from './preload' declare global { interface Window { llonebot: LLOneBot - LiteLoader: any + LiteLoader: Record } } diff --git a/src/renderer/index.ts b/src/renderer/index.ts index eb1be0d..d0429fa 100644 --- a/src/renderer/index.ts +++ b/src/renderer/index.ts @@ -4,6 +4,7 @@ import { SettingButton, SettingItem, SettingList, SettingSwitch, SettingSelect } // @ts-ignore import StyleRaw from './style.css?raw' import { iconSvg } from './icon' +import { version } from '../version' // 打开设置界面时触发 @@ -53,8 +54,8 @@ async function onSettingWindowCreated(view: Element) { '
', ``, ` -
-
`, +
+ `, SettingList([ SettingItem( '正在检查 LLOneBot 更新', @@ -399,7 +400,7 @@ async function onSettingWindowCreated(view: Element) { const buttonDom = view.querySelector('#llonebot-update-button')! if (ResultVersion.version === '') { - titleDom.innerHTML = '检查更新失败' + titleDom.innerHTML = `当前版本为 v${version},检查更新失败` buttonDom.innerHTML = '点击重试' buttonDom.addEventListener('click', async () => { @@ -412,7 +413,7 @@ async function onSettingWindowCreated(view: Element) { titleDom.innerHTML = '当前已是最新版本 v' + ResultVersion.version buttonDom.innerHTML = '无需更新' } else { - titleDom.innerHTML = '已检测到最新版本 v' + ResultVersion.version + titleDom.innerHTML = `当前版本为 v${version},最新版本为 v${ResultVersion.version}` buttonDom.innerHTML = '点击更新' buttonDom.dataset.type = 'primary'