diff --git a/manifest.json b/manifest.json index de431b15..039890c0 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "name": "NapCatQQ", "slug": "NapCat.Framework", "description": "高性能的 OneBot 11 协议实现", - "version": "2.5.5", + "version": "2.6.0", "icon": "./logo.png", "authors": [ { diff --git a/package.json b/package.json index 1be22bf9..ce99f23c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "napcat", "private": true, "type": "module", - "version": "2.5.5", + "version": "2.6.0", "scripts": { "build:framework": "vite build --mode framework", "build:shell": "vite build --mode shell", @@ -11,9 +11,6 @@ "depend": "cd dist && npm install --omit=dev" }, "devDependencies": { - "@babel/core": "^7.24.7", - "@babel/plugin-proposal-class-properties": "^7.18.6", - "@babel/plugin-proposal-decorators": "^7.24.7", "@babel/preset-typescript": "^7.24.7", "@log4js-node/log4js-api": "^1.0.2", "@protobuf-ts/plugin": "^2.9.4", @@ -21,9 +18,7 @@ "@rollup/plugin-typescript": "^11.1.6", "@types/cors": "^2.8.17", "@types/express": "^4.17.21", - "@types/figlet": "^1.5.8", "@types/fluent-ffmpeg": "^2.1.24", - "@types/jest": "^29.5.12", "@types/node": "^22.0.1", "@types/qrcode-terminal": "^0.12.2", "@types/ws": "^8.5.12", @@ -32,14 +27,8 @@ "eslint": "^8.57.0", "eslint-import-resolver-typescript": "^3.6.1", "eslint-plugin-import": "^2.29.1", - "i": "^0.3.7", - "javascript-obfuscator": "^4.1.0", - "rollup": "^4.13.2", - "rollup-plugin-dts": "^6.1.0", - "rollup-plugin-obfuscator": "^1.1.0", "typescript": "^5.3.3", "vite": "^5.2.6", - "vite-plugin-babel": "^1.2.0", "vite-plugin-cp": "^4.0.8", "vite-plugin-dts": "^3.8.2", "vite-tsconfig-paths": "^4.3.2" diff --git a/script/BootWay.03.ps1 b/script/BootWay.03.ps1 deleted file mode 100644 index d4fb6707..00000000 --- a/script/BootWay.03.ps1 +++ /dev/null @@ -1,45 +0,0 @@ -# Dont Use This Script -# 2024.7.3 -function Get-QQpath { - try { - $key = Get-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\QQ" - $uninstallString = $key.UninstallString - return [System.IO.Path]::GetDirectoryName($uninstallString) + "\QQ.exe" - } - catch { - throw "get QQ path error: $_" - } -} -function Select-QQPath { - Add-Type -AssemblyName System.Windows.Forms - [System.Windows.Forms.Application]::EnableVisualStyles() - - $dialogTitle = "Select QQ.exe" - - $filePicker = New-Object System.Windows.Forms.OpenFileDialog - $filePicker.Title = $dialogTitle - $filePicker.Filter = "Executable Files (*.exe)|*.exe|All Files (*.*)|*.*" - $filePicker.FilterIndex = 1 - $null = $filePicker.ShowDialog() - if (-not ($filePicker.FileName)) { - throw "User did not select an .exe file." - } - return $filePicker.FileName -} - -$params = $args -join " " -Try { - $QQpath = Get-QQpath -} -Catch { - $QQpath = Select-QQPath -} - -if (!(Test-Path $QQpath)) { - throw "provided QQ path is invalid: $QQpath" -} - -$Bootfile = Join-Path $PSScriptRoot "napcat.mjs" -$env:ELECTRON_RUN_AS_NODE = 1 -$commandInfo = Get-Command $QQpath -ErrorAction Stop -Start-Process powershell -ArgumentList "-noexit", "-noprofile", "-command &{& chcp 65001;& '$($commandInfo.Path)' --enable-logging }" \ No newline at end of file diff --git a/script/BootWay05.bat b/script/BootWay05.bat deleted file mode 100644 index 06d2ee3b..00000000 --- a/script/BootWay05.bat +++ /dev/null @@ -1,90 +0,0 @@ -@echo off -REM 检查当前会话是否具有管理员权限 -openfiles >nul 2>&1 -if %errorlevel% neq 0 ( - REM 如果不是管理员,则重新启动脚本以管理员模式运行 - echo 请求管理员权限... - powershell -Command "Start-Process cmd -ArgumentList '/c %~f0 %*' -Verb RunAs" - exit /b -) - -REM 设置当前工作目录 -cd /d %~dp0 - -REM 获取当前目录路径 -set currentPath=%cd% -set currentPath=%currentPath:\=/% - -REM 生成JavaScript代码 -set "jsCode=(async () =^>await import('file:///%currentPath%/napcat.mjs'))();" - -REM 将JavaScript代码保存到文件中 -echo %jsCode% > loadScript.js -echo JavaScript code has been generated and saved to loadScript.js - -REM 设置NAPCAT_PATH环境变量为 当前目录的loadScript.js地址 -set NAPCAT_PATH=%cd%\loadScript.js - -REM 获取QQ路径 - - -: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 -) - -REM 收集dbghelp.dll路径和HASH信息 -set QQdir=%~dp0 -set oldDllPath=%QQdir%dbghelp.dll -set newDllPath=%currentPath%\dbghelp.dll - -for /f "tokens=*" %%A in ('certutil -hashfile "%oldDllPath%" MD5') do ( - if not defined oldDllHash set oldDllHash=%%A -) -for /f "tokens=*" %%A in ('certutil -hashfile "%newDllPath%" MD5') do ( - if not defined newDllHash set newDllHash=%%A -) - -REM 如果文件一致则跳过 -if "%oldDllHash%" neq "%newDllHash%" ( - tasklist /fi "imagename eq QQ.exe" 2>nul | find /i "QQ.exe" >nul - if %errorlevel% equ 0 ( - REM 文件占用则退出 - echo dbghelp.dll is in use, cannot continue. - ) else ( - REM 文件未占用则尝试覆盖 - copy /y "%newDllPath%" "%oldDllPath%" - if %errorlevel% neq 0 ( - echo Failed to copy dbghelp.dll - pause - exit /b - ) else ( - echo dbghelp.dll has been copied to %QQdir% - ) - ) -) - -REM 带参数启动QQ -REM 判断wt是否存在,存在则通过wt启动,不存在则通过cmd启动 -REM %QQPath% --enable-logging %* -where wt >nul 2>nul -if %errorlevel% equ 0 ( - wt "cmd" /c "%QQPath%" --enable-logging %* -) else ( - "%QQPath%" --enable-logging %* -) diff --git a/script/BootWay05.ps1 b/script/BootWay05.ps1 deleted file mode 100644 index 862281ef..00000000 --- a/script/BootWay05.ps1 +++ /dev/null @@ -1,123 +0,0 @@ -# 检查当前会话是否具有管理员权限 -function Test-Administrator { - $user = [Security.Principal.WindowsIdentity]::GetCurrent() - (New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) -} - -if (-not (Test-Administrator)) { - # 如果不是管理员,则重新启动脚本以管理员模式运行 - $scriptPath = $myInvocation.MyCommand.Path - if (-not $scriptPath) { - $scriptPath = $PSCommandPath - } - $newProcess = New-Object System.Diagnostics.ProcessStartInfo "powershell"; - $newProcess.Arguments = "-File `"$scriptPath`" $args" - $newProcess.Verb = "runas"; - [System.Diagnostics.Process]::Start($newProcess); - exit -} - -function Get-QQpath { - try { - $key = Get-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\QQ" - $uninstallString = $key.UninstallString - return [System.IO.Path]::GetDirectoryName($uninstallString) + "\QQ.exe" - } - catch { - throw "get QQ path error: $_" - } -} -function Select-QQPath { - Add-Type -AssemblyName System.Windows.Forms - [System.Windows.Forms.Application]::EnableVisualStyles() - - $dialogTitle = "Select QQ.exe" - - $filePicker = New-Object System.Windows.Forms.OpenFileDialog - $filePicker.Title = $dialogTitle - $filePicker.Filter = "Executable Files (*.exe)|*.exe|All Files (*.*)|*.*" - $filePicker.FilterIndex = 1 - $null = $filePicker.ShowDialog() - if (-not ($filePicker.FileName)) { - throw "User did not select an .exe file." - } - return $filePicker.FileName -} - -# 设置当前工作目录 -$scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent -Set-Location $scriptDirectory - -# 获取当前目录路径 -$currentPath = Get-Location - -# 替换\为/ -$currentPath = $currentPath -replace '\\', '/' - -# 生成JavaScript代码 -$jsCode = @" -(async () => { - await import('file:///$currentPath/napcat.mjs'); -})(); -"@ - -# 将JavaScript代码保存到文件中 -$jsFilePath = Join-Path $currentPath "loadScript.js" -$jsCode | Out-File -FilePath $jsFilePath -Encoding UTF8 - -Write-Output "JavaScript code has been generated and saved to $jsFilePath" -# 设置NAPCAT_PATH环境变量为 当前目录的loadScript.js地址 -$env:NAPCAT_PATH = $jsFilePath - -$params = $args -join " " -Try { - $QQpath = Get-QQpath -} -Catch { - $QQpath = Select-QQPath -} -# 拿不到QQ路径则退出 -if (!(Test-Path $QQpath)) { - Write-Output "provided QQ path is invalid: $QQpath" - Read-Host "Press any key to continue..." - exit -} - -$commandInfo = Get-Command $QQpath -ErrorAction Stop - -# 收集dbghelp.dll路径和HASH信息 -$QQpath = Split-Path $QQpath -$oldDllPath = Join-Path $QQpath "dbghelp.dll" -$oldDllHash = Get-FileHash $oldDllPath -Algorithm MD5 -$newDllPath = Join-Path $currentPath "dbghelp.dll" -$newDllHash = Get-FileHash $newDllPath -Algorithm MD5 -# 如果文件一致则跳过 -if ($oldDllHash.Hash -ne $newDllHash.Hash) { - $processes = Get-Process -Name QQ -ErrorAction SilentlyContinue - if ($processes) { - # 文件占用则退出 - Write-Output "dbghelp.dll is in use by the following processes:" - $processes | ForEach-Object { Write-Output "$($_.Id) $($_.Name) $($_.Path)" } - Write-Output "dbghelp.dll is in use, cannot continue." - Read-Host "Press any key to continue..." - exit - } else { - # 文件未占用则尝试覆盖 - try { - Copy-Item -Path "$newDllPath" -Destination "$oldDllPath" -Force - Write-Output "dbghelp.dll has been copied to $QQpath" - } catch { - Write-Output "Failed to copy dbghelp.dll: $_" - Read-Host "Press any key to continue..." - exit - } - } -} - -# 带参数启动QQ -try { - Start-Process powershell -ArgumentList '-noexit', '-noprofile', "-command &{& chcp 65001;& '$($commandInfo.Path)' --enable-logging $params}" -NoNewWindow -ErrorAction Stop -} catch { - Write-Output "Failed to start process as administrator: $_" - Read-Host "Press any key to continue..." -} \ No newline at end of file diff --git a/script/BootWay05.utf8.bat b/script/BootWay05.utf8.bat deleted file mode 100644 index 2836a38a..00000000 --- a/script/BootWay05.utf8.bat +++ /dev/null @@ -1,93 +0,0 @@ -@echo off -REM 检查当前会话是否具有管理员权限 -openfiles >nul 2>&1 -if %errorlevel% neq 0 ( - REM 如果不是管理员,则重新启动脚本以管理员模式运行 - echo 请求管理员权限... - where wt >nul 2>nul - if %errorlevel% equ 0 ( - powershell -Command "Start-Process cmd -ArgumentList ' /c %~f0 %*' -Verb RunAs" - ) else ( - powershell -Command "Start-Process wt -ArgumentList 'cmd /c %~f0 %*' -Verb RunAs" - ) - - REM wt "cmd" /c "%~f0 %*" - exit /b -) - -REM 设置当前工作目录 -cd /d %~dp0 - -REM 获取当前目录路径 -set currentPath=%cd% -set currentPath=%currentPath:\=/% - -REM 生成JavaScript代码 -set "jsCode=(async () =^>await import('file:///%currentPath%/napcat.mjs'))();" - -REM 将JavaScript代码保存到文件中 -echo %jsCode% > loadScript.js -echo JavaScript code has been generated and saved to loadScript.js - -REM 设置NAPCAT_PATH环境变量为 当前目录的loadScript.js地址 -set NAPCAT_PATH=%cd%\loadScript.js - -REM 获取QQ路径 - - -: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 -) - -REM 收集dbghelp.dll路径和HASH信息 -set QQdir=%~dp0 -set oldDllPath=%QQdir%dbghelp.dll -set newDllPath=%currentPath%\dbghelp.dll - -for /f "tokens=*" %%A in ('certutil -hashfile "%oldDllPath%" MD5') do ( - if not defined oldDllHash set oldDllHash=%%A -) -for /f "tokens=*" %%A in ('certutil -hashfile "%newDllPath%" MD5') do ( - if not defined newDllHash set newDllHash=%%A -) - -REM 如果文件一致则跳过 -if "%oldDllHash%" neq "%newDllHash%" ( - tasklist /fi "imagename eq QQ.exe" 2>nul | find /i "QQ.exe" >nul - if %errorlevel% equ 0 ( - REM 文件占用则退出 - echo dbghelp.dll is in use, cannot continue. - ) else ( - REM 文件未占用则尝试覆盖 - copy /y "%newDllPath%" "%oldDllPath%" - if %errorlevel% neq 0 ( - echo Failed to copy dbghelp.dll - pause - exit /b - ) else ( - echo dbghelp.dll has been copied to %QQdir% - ) - ) -) - -REM 带参数启动QQ -REM 判断wt是否存在,存在则通过wt启动,不存在则通过cmd启动 -REM %QQPath% --enable-logging %* -chcp 65001 -"%QQPath%" --enable-logging %* diff --git a/script/BootWay05_init.bat b/script/BootWay05_init.bat deleted file mode 100644 index 654f80fe..00000000 --- a/script/BootWay05_init.bat +++ /dev/null @@ -1,77 +0,0 @@ -@echo off -REM Check if the script is running as administrator -openfiles >nul 2>&1 -if %errorlevel% neq 0 ( - REM If not, restart the script in administrator mode - echo Requesting administrator privileges... - powershell -Command "Start-Process cmd -ArgumentList '/c %~f0 %*' -Verb RunAs" - exit /b -) - -cd /d %~dp0 - -set currentPath=%cd% -set currentPath=%currentPath:\=/% - -REM Generate JavaScript code -set "jsCode=(async () =^>await import('file:///%currentPath%/napcat.mjs'))();" - -REM Save JavaScript code to a file -echo %jsCode% > loadScript.js -echo JavaScript code has been generated and saved to loadScript.js - -REM Set NAPCAT_PATH environment variable to the address of loadScript.js in the current directory -set NAPCAT_PATH=%cd%\loadScript.js - -REM Get QQ path and cache it -: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" -) - -set "pathWithoutUninstall=%RetString:Uninstall.exe=%" - -SET QQPath=%pathWithoutUninstall%QQ.exe -echo %QQPath%>qq_path_cache.txt -echo QQ path %QQPath% has been cached to qq_path_cache.txt - -REM Exit if QQ path is invalid -if not exist "%QQpath%" ( - echo provided QQ path is invalid: %QQpath% - pause - exit /b -) - -REM Collect dbghelp.dll path and HASH information -set QQdir=%~dp0 -set oldDllPath=%QQdir%dbghelp.dll -set newDllPath=%currentPath%\dbghelp.dll - -for /f "tokens=*" %%A in ('certutil -hashfile "%oldDllPath%" MD5') do ( - if not defined oldDllHash set oldDllHash=%%A -) -for /f "tokens=*" %%A in ('certutil -hashfile "%newDllPath%" MD5') do ( - if not defined newDllHash set newDllHash=%%A -) - -REM Compare the HASH of the old and new dbghelp.dll, and replace the old one if they are different -if "%oldDllHash%" neq "%newDllHash%" ( - tasklist /fi "imagename eq QQ.exe" 2>nul | find /i "QQ.exe" >nul - if %errorlevel% equ 0 ( - REM If the file is in use, prompt the user to close QQ - echo dbghelp.dll is in use, please close QQ first. - ) else ( - copy /y "%newDllPath%" "%oldDllPath%" - if %errorlevel% neq 0 ( - echo Copy dbghelp.dll failed, please check and try again. - pause - exit /b - ) else ( - echo dbghelp.dll has been updated. - echo Please run BootWay05_run.bat to start QQ. - echo If you update QQ in the future, please run BootWay05_init.bat again. - pause - exit /b - ) - ) -) diff --git a/script/BootWay05_run.bat b/script/BootWay05_run.bat deleted file mode 100644 index db9b2fa7..00000000 --- a/script/BootWay05_run.bat +++ /dev/null @@ -1,10 +0,0 @@ -@echo off -set /p QQPath= { diff --git a/src/webui/ui/NapCat.ts b/src/webui/ui/NapCat.ts index 0f912154..b744c571 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.5.5', 'napcat-update-button', 'secondary'), + SettingButton('V2.6.0', 'napcat-update-button', 'secondary'), ), ]), SettingList([ diff --git a/static/assets/renderer.js b/static/assets/renderer.js index fb7280d0..69c8712a 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.5.5", "napcat-update-button", "secondary") + SettingButton("V2.6.0", "napcat-update-button", "secondary") ) ]), SettingList([ diff --git a/vite.config.ts b/vite.config.ts index be7379ef..5cb7aa27 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -15,15 +15,13 @@ let startScripts: string[] | undefined = undefined; if (process.env.NAPCAT_BUILDSYS == 'linux') { if (process.env.NAPCAT_BUILDARCH == 'x64') { } - startScripts = ['./script/napcat.sh']; + startScripts = []; } else if (process.env.NAPCAT_BUILDSYS == 'win32') { if (process.env.NAPCAT_BUILDARCH == 'x64') { } - startScripts = ['./script/BootWay05.ps1', './script/dbghelp.dll', - './script/BootWay05_init.bat', './script/BootWay05_run.bat', './script/BootWay05_run.utf8.bat', './script/KillQQ.bat']; + startScripts = ['./script/KillQQ.bat']; } else { - startScripts = ['./script/BootWay05.ps1', './script/dbghelp.dll', - './script/BootWay05_init.bat', './script/BootWay05_run.bat', './script/BootWay05_run.utf8.bat', './script/KillQQ.bat']; + startScripts = ['./script/KillQQ.bat']; } const FrameworkBaseConfigPlugin: PluginOption[] = [ // PreprocessorDirectives(),