From d17a3b996369dd25c9c4684ad54e6882ddaa2e49 Mon Sep 17 00:00:00 2001 From: Tlntin Date: Wed, 8 Mar 2023 12:34:54 +0800 Subject: [PATCH] update powershell file for windows --- package.json | 2 +- script/build.ps1 | 54 +++++++++++++++++-------------- src-tauri/tauri.conf.json | 6 ++-- src-tauri/tauri.windows.conf.json | 6 ++-- 4 files changed, 36 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 7eccf9f..eacef42 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "build": "npm run tauri build --release", "build:mac": "npm run tauri build -- --target universal-apple-darwin", "build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh", - "build:all-windows": "pwsh .\\script\\build.ps1", + "build:all-windows": "pwsh ./script/build.ps1", "tauri": "tauri", "cli": "rollup -c rollup.config.js --watch", "cli:build": "cross-env NODE_ENV=production rollup -c rollup.config.js", diff --git a/script/build.ps1 b/script/build.ps1 index af09480..eb4aefb 100644 --- a/script/build.ps1 +++ b/script/build.ps1 @@ -10,6 +10,9 @@ if (-not (Test-Path output)) { if (-not (Test-Path output\windows)) { New-Item -ItemType Directory -Path output\windows +} else { + Remove-Item output\windows -Recurse -Force + New-Item -ItemType Directory -Path output\windows } Write-Host "`n=======================" @@ -41,7 +44,7 @@ ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) { Write-Host "==========================" # -- replace url -- # clear url with regex - (Get-Content -Path $common_conf_path -Raw) -replace '"url":\s*"[^"]*"', '"url": ""' | Set-Content -Path $common_conf_path + .\script\sd.exe "`"url`":\s`"(.*?)`"" '"url": ""' $common_conf_path # replace url with no regex .\script\sd.exe -s '"url": ""' "`"url`": `"${url}`"" $common_conf_path @@ -53,19 +56,22 @@ ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) { # -- replace icon -- # clear icon path with regex - (Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"icon":\s*\[[^\]]*\]', '"icon": []' | Set-Content -Path $windows_conf_path + # (Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"icon":\s*\[[^\]]*\]', '"icon": []' | Set-Content -Path $windows_conf_path + .\script\sd.exe "`"icon`":\s(.*)`]" '"icon": []' $windows_conf_path # replace icon path with no regex .\script\sd.exe -s '"icon": []' "`"icon`": [`"png/${name}_256.ico`", `"png/${name}_32.ico`"]" $windows_conf_path # -- replace identifier -- # clear identifier with regex - (Get-Content -Path $windows_conf_path -Raw) -replace '"identifier":\s*"[^"]*"', '"identifier": ""' | Set-Content -Path $windows_conf_path + # (Get-Content -Path $windows_conf_path -Raw) -replace '"identifier":\s*"[^"]*"', '"identifier": ""' | Set-Content -Path $windows_conf_path + .\script\sd.exe "`"identifier`":\s`"(.*?)`"" '"identifier": ""' $windows_conf_path # -- replace identifier with no regex -- .\script\sd.exe -s '"identifier": ""' "`"identifier`": `"${identifier_prefix}.${name}`"" $windows_conf_path # -- replace icon resources -- # clear resources with regex - (Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"resources":\s*\[[^\]]*\]', '"resources": []' | Set-Content -Path $windows_conf_path + #(Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"resources":\s*\[[^\]]*\]', '"resources": []' | Set-Content -Path $windows_conf_path + .\script\sd.exe "`"resources`":\s(.*)`]" '"resources": []' $windows_conf_path # replace resources with no regex .\script\sd.exe -s '"resources": []' "`"resources`": [`"png/${name}_32.ico`"]" $windows_conf_path @@ -93,27 +99,27 @@ ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) { Write-Host "package build success!" Write-Host "" $index++ - # strip blank line for common_conf_path - $lines = Get-Content ${common_conf_path} - $lastNonEmptyLineIndex = ($lines.Count - 1) - while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { - $lastNonEmptyLineIndex-- - } - if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { - $lines = $lines[0..$lastNonEmptyLineIndex] - } - Set-Content -Path ${common_conf_path} -Value $lines + # # strip blank line for common_conf_path + # $lines = Get-Content ${common_conf_path} + # $lastNonEmptyLineIndex = ($lines.Count - 1) + # while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { + # $lastNonEmptyLineIndex-- + # } + # if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { + # $lines = $lines[0..$lastNonEmptyLineIndex] + # } + # Set-Content -Path ${common_conf_path} -Value $lines - # strip blank line for windows conf_path - $lines = Get-Content ${windows_conf_path} - $lastNonEmptyLineIndex = ($lines.Count - 1) - while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { - $lastNonEmptyLineIndex-- - } - if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { - $lines = $lines[0..$lastNonEmptyLineIndex] - } - Set-Content -Path ${windows_conf_path} -Value $lines + # # strip blank line for windows conf_path + # $lines = Get-Content ${windows_conf_path} + # $lastNonEmptyLineIndex = ($lines.Count - 1) + # while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { + # $lastNonEmptyLineIndex-- + # } + # if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { + # $lines = $lines[0..$lastNonEmptyLineIndex] + # } + # Set-Content -Path ${windows_conf_path} -Value $lines } Write-Host "output dir is output\windows" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index cad1afa..bd260ec 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,12 +1,12 @@ { "package": { - "productName": "", + "productName": "WeRead", "version": "1.0.0" }, "tauri": { "windows": [ { - "url": "https://riju.codes/", + "url": "https://weread.qq.com/", "transparent": true, "fullscreen": false, "width": 1200, @@ -28,5 +28,3 @@ "beforeDevCommand": "" } } - - diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json index ca3d017..c95e88d 100644 --- a/src-tauri/tauri.windows.conf.json +++ b/src-tauri/tauri.windows.conf.json @@ -1,14 +1,14 @@ { "tauri": { "bundle": { - "icon": ["png/coderunner_256.ico", "png/coderunner_32.ico"], - "identifier": "com.tw93.coderunner", + "icon": ["png/weread_256.ico", "png/weread_32.ico"], + "identifier": "com.tw93.weread", "active": true, "category": "DeveloperTool", "copyright": "", "externalBin": [], "longDescription": "", - "resources": ["png/coderunner_32.ico"], + "resources": ["png/weread_32.ico"], "shortDescription": "", "targets": ["msi"], "windows": {