diff --git a/package.json b/package.json index 3d414aa5..8f12219d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "napcat", "private": true, "type": "module", - "version": "1.7.0", + "version": "1.7.1", "scripts": { "watch:dev": "vite --mode development", "watch:prod": "vite --mode production", diff --git a/script/BootWay05-utf8.ps1 b/script/BootWay05-utf8.ps1 new file mode 100644 index 00000000..a26103f5 --- /dev/null +++ b/script/BootWay05-utf8.ps1 @@ -0,0 +1,61 @@ +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 +} + +# 获取当前目录路径 +$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 +} + if (!(Test-Path $QQpath)) { + throw "provided QQ path is invalid: $QQpath" +} + +$commandInfo = Get-Command $QQpath -ErrorAction Stop +Start-Process powershell -ArgumentList "-noexit", "-noprofile", "-command &{& chcp 65001;& '$($commandInfo.Path)' --enable-logging $params}" \ No newline at end of file diff --git a/script/BootWay05.ps1 b/script/BootWay05.ps1 new file mode 100644 index 00000000..1b69d266 --- /dev/null +++ b/script/BootWay05.ps1 @@ -0,0 +1,61 @@ +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 +} + +# 获取当前目录路径 +$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 +} + if (!(Test-Path $QQpath)) { + throw "provided QQ path is invalid: $QQpath" +} + +$commandInfo = Get-Command $QQpath -ErrorAction Stop +Start-Process powershell -ArgumentList "-noexit", "-noprofile", "-command &{& '$($commandInfo.Path)' --enable-logging $params}" \ No newline at end of file diff --git a/script/dbghelp.dll b/script/dbghelp.dll new file mode 100644 index 00000000..93c9f8b8 Binary files /dev/null and b/script/dbghelp.dll differ diff --git a/src/onebot11/version.ts b/src/onebot11/version.ts index 61bffdb0..eff8d513 100644 --- a/src/onebot11/version.ts +++ b/src/onebot11/version.ts @@ -1 +1 @@ -export const version = '1.7.0'; +export const version = '1.7.1'; diff --git a/src/webui/ui/NapCat.ts b/src/webui/ui/NapCat.ts index ec901a5d..13d0308e 100644 --- a/src/webui/ui/NapCat.ts +++ b/src/webui/ui/NapCat.ts @@ -29,7 +29,7 @@ async function onSettingWindowCreated(view: Element) { SettingItem( 'Napcat', undefined, - SettingButton('V1.7.0', 'napcat-update-button', 'secondary') + SettingButton('V1.7.1', 'napcat-update-button', 'secondary') ), ]), SettingList([ diff --git a/static/assets/renderer.js b/static/assets/renderer.js index a67da123..8acbb2ba 100644 --- a/static/assets/renderer.js +++ b/static/assets/renderer.js @@ -163,7 +163,7 @@ async function onSettingWindowCreated(view) { SettingItem( 'Napcat', void 0, - SettingButton("V1.7.0", "napcat-update-button", "secondary") + SettingButton("V1.7.1", "napcat-update-button", "secondary") ) ]), SettingList([ diff --git a/vite.config.ts b/vite.config.ts index def187d9..7c1d81c0 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -26,7 +26,7 @@ if (process.env.NAPCAT_BUILDSYS == 'linux') { } else if (process.env.NAPCAT_BUILDSYS == 'win32') { if (process.env.NAPCAT_BUILDARCH == 'x64') { } - startScripts = ['./script/napcat.ps1', './script/napcat.bat', './script/napcat-utf8.bat', './script/napcat-utf8.ps1', './script/napcat-log.ps1', './script/NapCat.164.bat', './script/napcat-9912.ps1', './script/napcat-9912-utf8.ps1', './script/napcat-9912.bat', './script/napcat-9912-utf8.bat']; + startScripts = ['dbghelp.dll', './script/BootWay05-utf8.ps1', './script/BootWay05.ps1', './script/napcat-9912.ps1', './script/napcat-9912-utf8.ps1', './script/napcat-9912.bat', './script/napcat-9912-utf8.bat']; } else { startScripts = ['./script/napcat.sh', './script/napcat.ps1', './script/napcat.bat', './script/napcat-utf8.bat', './script/napcat-utf8.ps1', './script/napcat-log.ps1', './script/napcat-9912.ps1', './script/napcat-9912-utf8.ps1', './script/napcat-9912.bat', './script/napcat-9912-utf8.bat']; }