From dec0ad4cb5ff95aed7d5a4661baa03ef9498e796 Mon Sep 17 00:00:00 2001 From: zyj Date: Thu, 27 Nov 2025 16:19:22 +0800 Subject: [PATCH] Fix the issue of slow startup when using wails3 dev --- build/config.yml | 22 ++++++++++------------ build/wait.ps1 | 28 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 build/wait.ps1 diff --git a/build/config.yml b/build/config.yml index aaa3240..1829028 100644 --- a/build/config.yml +++ b/build/config.yml @@ -5,19 +5,19 @@ version: '3' # This information is used to generate the build assets. info: - companyName: "My Company" # The name of the company - productName: "My Product" # The name of the application - productIdentifier: "com.mycompany.myproduct" # The unique product identifier - description: "A program that does X" # The application description - copyright: "(c) 2025, My Company" # Copyright text - comments: "Some Product Comments" # Comments + companyName: "Twitter Account" # The name of the company + productName: "Twitter Account Manager" # The name of the application + productIdentifier: "com.twitteraccount.app" # The unique product identifier + description: "Twitter account management application" # The application description + copyright: "(c) 2025, Twitter Account" # Copyright text + comments: "Twitter Account Manager" # Comments version: "0.0.1" # The application version # Dev mode configuration dev_mode: root_path: . log_level: warn - debounce: 1000 + debounce: 300 ignore: dir: - .git @@ -32,12 +32,10 @@ dev_mode: - "*.go" git_ignore: true executes: - - cmd: wails3 task common:install:frontend:deps - type: once - cmd: wails3 task common:dev:frontend - type: background - - cmd: go mod tidy - type: blocking + type: background # 改回 background,让它持续运行 + - cmd: powershell.exe -ExecutionPolicy Bypass -File build/wait.ps1 -Seconds 15 + type: blocking # 等待 15 秒让前端完全启动 - cmd: wails3 task build type: blocking - cmd: wails3 task run diff --git a/build/wait.ps1 b/build/wait.ps1 new file mode 100644 index 0000000..7979217 --- /dev/null +++ b/build/wait.ps1 @@ -0,0 +1,28 @@ +# Wait for a specified number of seconds and check the frontend server +param( + [int]$Seconds = 5, + [string]$Url = "http://localhost:9245" +) + +Write-Host "Waiting for frontend to start..." -ForegroundColor Yellow + +$elapsed = 0 +$interval = 1 + +while ($elapsed -lt $Seconds) { + try { + $response = Invoke-WebRequest -Uri $Url -Method Head -TimeoutSec 1 -ErrorAction SilentlyContinue + if ($response.StatusCode -eq 200) { + Write-Host "✓ Frontend server is ready ($elapsed seconds)" -ForegroundColor Green + exit 0 + } + } catch { + # Continue waiting + } + + Start-Sleep -Seconds $interval + $elapsed += $interval + Write-Host " Waiting... ($elapsed/$Seconds seconds)" -ForegroundColor Gray +} + +Write-Host "✓ Waiting finished (up to $Seconds seconds)" -ForegroundColor Green