Fix the issue of slow startup when using wails3 dev

This commit is contained in:
zyj
2025-11-27 16:19:22 +08:00
parent 0abc387c23
commit dec0ad4cb5
2 changed files with 38 additions and 12 deletions

View File

@@ -5,19 +5,19 @@ version: '3'
# This information is used to generate the build assets. # This information is used to generate the build assets.
info: info:
companyName: "My Company" # The name of the company companyName: "Twitter Account" # The name of the company
productName: "My Product" # The name of the application productName: "Twitter Account Manager" # The name of the application
productIdentifier: "com.mycompany.myproduct" # The unique product identifier productIdentifier: "com.twitteraccount.app" # The unique product identifier
description: "A program that does X" # The application description description: "Twitter account management application" # The application description
copyright: "(c) 2025, My Company" # Copyright text copyright: "(c) 2025, Twitter Account" # Copyright text
comments: "Some Product Comments" # Comments comments: "Twitter Account Manager" # Comments
version: "0.0.1" # The application version version: "0.0.1" # The application version
# Dev mode configuration # Dev mode configuration
dev_mode: dev_mode:
root_path: . root_path: .
log_level: warn log_level: warn
debounce: 1000 debounce: 300
ignore: ignore:
dir: dir:
- .git - .git
@@ -32,12 +32,10 @@ dev_mode:
- "*.go" - "*.go"
git_ignore: true git_ignore: true
executes: executes:
- cmd: wails3 task common:install:frontend:deps
type: once
- cmd: wails3 task common:dev:frontend - cmd: wails3 task common:dev:frontend
type: background type: background # 改回 background让它持续运行
- cmd: go mod tidy - cmd: powershell.exe -ExecutionPolicy Bypass -File build/wait.ps1 -Seconds 15
type: blocking type: blocking # 等待 15 秒让前端完全启动
- cmd: wails3 task build - cmd: wails3 task build
type: blocking type: blocking
- cmd: wails3 task run - cmd: wails3 task run

28
build/wait.ps1 Normal file
View File

@@ -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