jim800121chen 570e040a67 fix(local-tool): Wails 主視窗改為 splash + redirect 到 Next.js 主 UI
根因:visiona-local/frontend/ 是從 edge-ai-platform 複製過來的 installer wizard
HTML/JS/CSS,整組沒清理。main.go 的 //go:embed all:frontend 把這堆 wizard
直接當 Wails 主視窗內容,使用者開啟 app 看到的就是 "Edge AI Platform Installer"
而不是 Next.js 主 UI。macOS dmg 版本也有同樣問題,只是之前驗證時沒開 Wails
視窗而是用瀏覽器直連 localhost:3721 所以沒抓到。

修法:把 visiona-local/frontend/ 重寫為極簡 splash:
- index.html:splash 畫面
- app.js:import GetServerStatus / GetServerURL binding,輪詢直到 server ready,
  window.location.replace(url + '/') 跳到 Next.js 主 UI
- style.css:splash 樣式

Next.js 主 UI 不使用任何 Wails JS binding(純 HTTP API),所以從 wails://
跳到 http://127.0.0.1:<port>/ 後功能完整可用。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 03:32:31 +08:00

56 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// visionA Local — splash / bootstrap
// 職責:等 Go server 起來,拿到 URL 後跳轉到 Next.js 主 UI
import { GetServerStatus, GetServerURL } from './wailsjs/go/main/App.js';
const statusEl = document.getElementById('status');
const errorEl = document.getElementById('error');
const POLL_INTERVAL_MS = 500;
const MAX_WAIT_MS = 60_000;
const startTime = Date.now();
async function poll() {
if (Date.now() - startTime > MAX_WAIT_MS) {
showError('伺服器啟動逾時60 秒),請檢查 log 或重新啟動應用程式。');
return;
}
try {
const status = await GetServerStatus();
if (status && status.lastError) {
showError('伺服器啟動失敗:' + status.lastError);
return;
}
if (status && status.running && status.url) {
statusEl.textContent = '啟動完成,載入主介面...';
window.location.replace(status.url + '/');
return;
}
const url = await GetServerURL();
if (url) {
statusEl.textContent = '啟動完成,載入主介面...';
window.location.replace(url + '/');
return;
}
} catch (e) {
// binding 尚未就緒時會 throw忽略繼續輪詢
}
setTimeout(poll, POLL_INTERVAL_MS);
}
function showError(msg) {
statusEl.hidden = true;
errorEl.textContent = msg;
errorEl.hidden = false;
}
// 等 Wails runtime 就緒再開始輪詢
if (window.runtime) {
poll();
} else {
window.addEventListener('load', () => setTimeout(poll, 200));
}