根因: KP_ERROR_CONNECT_FAILED (error code 28) — Kneron USB 裝置預設沒綁定 WinUSB driver,SDK 無法開 handle。原 .iss 的 pnputil /add-driver 做法 需要 .cat 簽章(Windows 10/11 driver signing enforcement),我們沒有。 參考 edge-ai-platform/installer/platform_windows.go 的 installKneronDriverViaSDK: KneronPLUS SDK 內建 libwdi wrapper — kp.core.install_driver_for_windows(pid) libwdi 會自動用臨時自簽憑證,不需要 .cat 檔,只需要 UAC 提權。 實作: - server/internal/api/handlers/system_driver_windows.go(新): 組 Python script → kp.core.install_driver_for_windows 對 KL520/KL720/KL720_LEGACY → PowerShell Start-Process -Verb RunAs 提權執行 → 結果寫 temp 檔讀回 - server/internal/api/handlers/system_driver_other.go(新):非 Windows stub - system_handler.go: NewSystemHandler 新增 pythonBin 參數 + InstallDriver handler 先判斷 runtime.GOOS==windows 才執行 - router.go: 新增 POST /system/install-driver - main.go: 解析 pythonBin(VISIONA_PYTHON env var → cfg.PythonBin)傳入 前端: - frontend/src/app/devices/page.tsx:Windows only 多一個「安裝 USB Driver」按鈕 (用 navigator.userAgent 判斷平台) - frontend/src/stores/device-store.ts:connect 失敗訊息偵測 winusb / error 28 / KP_ERROR_CONNECT_FAILED 特徵字串,回一條明確的繁中提示引導使用者去點按鈕 Wails app 端: - visiona-local/app.go: 新增 InstallKneronDriver() binding 作為備用入口(目前前端沒用到, 因為前端跑在 http://127.0.0.1 不是 wails://,但保留給未來 splash 階段觸發用) - visiona-local/platform_{windows,darwin,linux}.go: installKneronWinUSBDriver 平台實作 / 跨平台 stub .iss: - 移除 pnputil /add-driver 的 [Run] entry(它是 silent-fail 的 dead code, 因為沒 .cat 簽章) - 新增註解說明:driver 安裝改由 app 端呼叫 libwdi 完成 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
119 lines
5.7 KiB
Plaintext
119 lines
5.7 KiB
Plaintext
; visionA-local Windows installer
|
||
; Inno Setup 6.x compatible
|
||
;
|
||
; 此檔案在 macOS 上只做語法檢視,實際編譯必須在 Windows runner 上跑:
|
||
; iscc installer\windows\visiona-local.iss
|
||
;
|
||
; 前置作業(在 Windows runner 上):
|
||
; 1. make payload-windows — 準備 payload/windows/
|
||
; 2. make wails-windows — build visiona-local/build/bin/visiona-local.exe
|
||
; 3. go build server/ — build payload/windows/bin/visiona-local-server.exe
|
||
; 4. make exe — 執行 iscc 編譯本檔
|
||
;
|
||
; 所有路徑相對於本 .iss 所在目錄 (installer/windows/)
|
||
; 因此 ..\.. 會指回專案根目錄 (local-tool/)
|
||
|
||
#define MyAppName "visionA Local"
|
||
#define MyAppVersion "0.1.0"
|
||
#define MyAppPublisher "Innovedus"
|
||
#define MyAppURL "https://github.com/Innovedus/visiona-local"
|
||
#define MyAppExeName "visiona-local.exe"
|
||
#define MyAppIcon "..\..\branding\icon.ico"
|
||
|
||
[Setup]
|
||
; AppId 固定 GUID(產品識別用,未來升級時不可更動)
|
||
AppId={{B7E5C4F3-1234-5678-90AB-CDEF12345678}
|
||
AppName={#MyAppName}
|
||
AppVersion={#MyAppVersion}
|
||
AppPublisher={#MyAppPublisher}
|
||
AppPublisherURL={#MyAppURL}
|
||
AppSupportURL={#MyAppURL}
|
||
AppUpdatesURL={#MyAppURL}
|
||
DefaultDirName={autopf}\visiona-local
|
||
DefaultGroupName={#MyAppName}
|
||
DisableProgramGroupPage=yes
|
||
; 需要管理員權限安裝 WinUSB driver
|
||
PrivilegesRequired=admin
|
||
PrivilegesRequiredOverridesAllowed=dialog
|
||
OutputDir=..\..\dist
|
||
OutputBaseFilename=visiona-local-{#MyAppVersion}-windows-x64
|
||
Compression=lzma2/ultra
|
||
SolidCompression=yes
|
||
WizardStyle=modern
|
||
ArchitecturesAllowed=x64compatible
|
||
ArchitecturesInstallIn64BitMode=x64compatible
|
||
; Installer 自身 icon
|
||
SetupIconFile={#MyAppIcon}
|
||
; 解除安裝程式在「設定 > 應用程式」顯示的 icon
|
||
UninstallDisplayIcon={app}\{#MyAppExeName}
|
||
; Windows 10 1809 以上(WinUSB / pnputil 需求)
|
||
MinVersion=10.0.17763
|
||
; 不需要 code signing(使用者決策 Q2=C)
|
||
; 解除安裝時不清使用者 %APPDATA% 資料
|
||
|
||
[Languages]
|
||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||
; 繁體中文語系:Inno Setup 6.3+ 官方只內建簡體中文(ChineseSimplified.isl)
|
||
; 繁體中文需額外從 https://jrsoftware.org/files/istrans/ 下載放到 Languages/
|
||
; 若存在則載入,不存在就只用英文(透過 -d 或環境變數 override 也可)
|
||
; 使用 /DWITH_TRAD_CHINESE=1 並確認 Languages\ChineseTraditional.isl 存在才啟用
|
||
#ifdef WITH_TRAD_CHINESE
|
||
Name: "tradchinese"; MessagesFile: "compiler:Languages\ChineseTraditional.isl"
|
||
#endif
|
||
|
||
[Tasks]
|
||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
||
|
||
[Files]
|
||
; ── Wails app binary ──────────────────────────────────────────────
|
||
Source: "..\..\visiona-local\build\bin\visiona-local.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||
|
||
; ── Server binary(Go build,必須在 Windows runner 上 GOOS=windows go build)──
|
||
Source: "..\..\payload\windows\bin\visiona-local-server.exe"; DestDir: "{app}\bin"; Flags: ignoreversion
|
||
|
||
; ── ffmpeg + yt-dlp ───────────────────────────────────────────────
|
||
Source: "..\..\payload\windows\bin\ffmpeg.exe"; DestDir: "{app}\bin"; Flags: ignoreversion
|
||
Source: "..\..\payload\windows\bin\yt-dlp.exe"; DestDir: "{app}\bin"; Flags: ignoreversion
|
||
|
||
; ── Python runtime tarball + wheels ───────────────────────────────
|
||
Source: "..\..\payload\windows\python\python.tar.gz"; DestDir: "{app}\python"; Flags: ignoreversion
|
||
Source: "..\..\payload\windows\wheels\*"; DestDir: "{app}\wheels"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||
|
||
; ── 預置模型與 scripts ────────────────────────────────────────────
|
||
Source: "..\..\payload\windows\data\*"; DestDir: "{app}\data"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||
Source: "..\..\payload\windows\scripts\*"; DestDir: "{app}\scripts"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||
|
||
; ── WinUSB driver(Kneron KL520/KL720)────────────────────────────
|
||
Source: "..\..\payload\windows\scripts\drivers\kneron_winusb.inf"; DestDir: "{app}\drivers"; Flags: ignoreversion
|
||
|
||
[Icons]
|
||
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
||
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
|
||
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
|
||
|
||
[Run]
|
||
; 注意:WinUSB driver 安裝**不在 installer 階段做**。
|
||
; 原因:inf-based 安裝需要 .cat + Microsoft attestation signing,未簽章的 .inf 會被
|
||
; Windows 10/11 的 driver signing enforcement 擋掉。
|
||
; 改為:Wails app 首次啟動時(或使用者手動點「安裝 driver」按鈕時)透過
|
||
; KneronPLUS SDK 的 kp.core.install_driver_for_windows() 呼叫 libwdi 完成,
|
||
; libwdi 會自動處理臨時自簽憑證,不需要 .cat 檔。
|
||
; 需要 UAC elevation,Wails app 會彈提權對話框。
|
||
|
||
; 安裝完畢選擇性啟動 app
|
||
Filename: "{app}\{#MyAppExeName}"; \
|
||
Description: "{cm:LaunchProgram,{#MyAppName}}"; \
|
||
Flags: nowait postinstall skipifsilent
|
||
|
||
[UninstallDelete]
|
||
; 解除安裝時清掉 Python 解壓後的目錄(首次啟動會重建)
|
||
; 但不動 %APPDATA%\visiona-local(使用者資料)
|
||
Type: filesandordirs; Name: "{app}\python\extracted"
|
||
|
||
[Code]
|
||
// 目前保留空殼,未來若要偵測舊版 edge-ai-platform 並建議移除可在此擴充
|
||
function InitializeSetup(): Boolean;
|
||
begin
|
||
Result := True;
|
||
end;
|