diff --git a/launcher/NapCatWinBootHook.dll b/launcher/NapCatWinBootHook.dll new file mode 100644 index 00000000..ee797fc9 Binary files /dev/null and b/launcher/NapCatWinBootHook.dll differ diff --git a/launcher/NapCatWinBootMain.exe b/launcher/NapCatWinBootMain.exe new file mode 100644 index 00000000..50992702 Binary files /dev/null and b/launcher/NapCatWinBootMain.exe differ diff --git a/launcher/launcher.bat b/launcher/launcher.bat new file mode 100644 index 00000000..19a3f935 --- /dev/null +++ b/launcher/launcher.bat @@ -0,0 +1,40 @@ +@echo off +chcp 65001 +net session >nul 2>&1 +if %errorLevel% == 0 ( + echo Administrator mode detected. +) else ( + echo Please run this script in administrator mode. + REM 以管理员权限启动脚本 并保留工作目录 + powershell -Command "Start-Process 'wt.exe' -ArgumentList 'cmd /c cd /d \"%cd%\" && \"%~f0\"' -Verb runAs" + exit +) + +set NAPCAT_PATCH_PATH=%cd%\patchNapCat.js +set NAPCAT_LOAD_PATH=%cd%\loadNapCat.js +set NAPCAT_INJECT_PATH=%cd%\NapCatWinBootHook.dll +set NAPCAT_LAUNCHER_PATH=%cd%\NapCatWinBootMain.exe +set NAPCAT_MAIN_PATH=%cd%\napcat.mjs +:loop_read +for /f "tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\QQ" /v "UninstallString"') do ( + set RetString=%%b + goto :napcat_boot +) + +:napcat_boot +for %%a in (%RetString%) do ( + set "pathWithoutUninstall=%%~dpa" +) + +SET QQPath=%pathWithoutUninstall%QQ.exe + +REM 拿不到QQ路径则退出 +if not exist "%QQpath%" ( + echo provided QQ path is invalid: %QQpath% + pause + exit /b +) +set NAPCAT_MAIN_PATH=%NAPCAT_MAIN_PATH:\=/% +echo (async () =^> {await import("file:///%NAPCAT_MAIN_PATH%")})() > %NAPCAT_LOAD_PATH% + +"%NAPCAT_LAUNCHER_PATH%" "%QQPath%" "%NAPCAT_INJECT_PATH%" \ No newline at end of file diff --git a/launcher/loadNapCat.js b/launcher/loadNapCat.js new file mode 100644 index 00000000..81af5e6e --- /dev/null +++ b/launcher/loadNapCat.js @@ -0,0 +1,5 @@ +const path = require('path'); +const CurrentPath = path.dirname(__filename); +(async () => { + await import("file://" + path.join(CurrentPath, './napcat/napcat.mjs')); +})(); \ No newline at end of file diff --git a/launcher/patchNapCat.js b/launcher/patchNapCat.js new file mode 100644 index 00000000..83a04e1f --- /dev/null +++ b/launcher/patchNapCat.js @@ -0,0 +1 @@ +require('./launcher.node').load('external_index', module); \ No newline at end of file diff --git a/manifest.json b/manifest.json index 01315720..a01452e1 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "name": "NapCatQQ", "slug": "NapCat.Framework", "description": "高性能的 OneBot 11 协议实现", - "version": "2.2.46", + "version": "2.2.47", "icon": "./logo.png", "authors": [ { diff --git a/package.json b/package.json index 4a34f75e..78d802a1 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "napcat", "private": true, "type": "module", - "version": "2.2.46", + "version": "2.2.47", "scripts": { "build:framework": "vite build --mode framework", "build:shell": "vite build --mode shell", diff --git a/src/common/version.ts b/src/common/version.ts index 073fb870..3c1caf38 100644 --- a/src/common/version.ts +++ b/src/common/version.ts @@ -1 +1 @@ -export const napCatVersion = '2.2.46'; +export const napCatVersion = '2.2.47'; diff --git a/src/webui/ui/NapCat.ts b/src/webui/ui/NapCat.ts index e5ab2d16..3f77f79b 100644 --- a/src/webui/ui/NapCat.ts +++ b/src/webui/ui/NapCat.ts @@ -30,7 +30,7 @@ async function onSettingWindowCreated(view: Element) { SettingItem( 'Napcat', undefined, - SettingButton('V2.2.46', 'napcat-update-button', 'secondary'), + SettingButton('V2.2.47', 'napcat-update-button', 'secondary'), ), ]), SettingList([ diff --git a/static/assets/renderer.js b/static/assets/renderer.js index ad823661..7df30e44 100644 --- a/static/assets/renderer.js +++ b/static/assets/renderer.js @@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) { SettingItem( 'Napcat', void 0, - SettingButton("V2.2.46", "napcat-update-button", "secondary") + SettingButton("V2.2.47", "napcat-update-button", "secondary") ) ]), SettingList([ diff --git a/vite.config.ts b/vite.config.ts index 8db2538f..be7379ef 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -11,7 +11,6 @@ const nodeModules = [...builtinModules, builtinModules.map(m => `node:${m}`)].fl function genCpModule(module: string) { return { src: `./node_modules/${module}`, dest: `dist/node_modules/${module}`, flatten: false }; } - let startScripts: string[] | undefined = undefined; if (process.env.NAPCAT_BUILDSYS == 'linux') { if (process.env.NAPCAT_BUILDARCH == 'x64') { @@ -82,6 +81,7 @@ const ShellBaseConfigPlugin: PluginOption[] = [ { src: './src/core/external/napcat.json', dest: 'dist/config/' }, { src: './src/onebot/config/onebot11.json', dest: 'dist/config/' }, { src: './package.json', dest: 'dist' }, + { src: './launcher/', dest: 'dist', flatten: true }, // { src: './README.md', dest: 'dist' }, // { src: './logo.png', dest: 'dist/logs' }, ...(startScripts.map((startScript) => {