feat(desktop): 迁移 Wails v2 → v3(架构/目录/绑定重写)[WIP]
从 wails/v2 v2.12.0 迁到 v3 v3.0.0-alpha2.117,采用 v3 工程规范:
Go 侧:
- main.go:wails.Run(options.App) → application.New(Options{Services,Assets,Mac})
+ app.Window.NewWithOptions(WebviewWindowOptions) + app.Run();窗口选项照搬
(1440×900/min 1100×700/#0b0d12/Mac TitleBarHiddenInset)
- app.go:App 结构体绑定 → v3 Service(application.NewService);去 startup/ctx 注入;
SaveFileDialog 改 v3 链式 API(application.Get().Dialog.SaveFile().SetFilename().
AddFilter().PromptForSingleSelection());5 个原生方法保留
- go.mod wails/v2→v3、go 1.25
构建:
- wails.json → Taskfile.yml + build/(config.yml 填产品信息 + 各平台配置)
- 删移动端脚手架(ios/android),桌面端只留 darwin/windows/linux
- .gitignore 改为只忽略 build/bin(build/ 构建系统需提交)
前端:
- vite.config 接 @wailsio/runtime/plugins/vite 插件 + WAILS_VITE_PORT
- package.json 加 @wailsio/runtime;wails3 generate bindings → frontend/bindings/
- desktop.ts:window.go.main.App → import { App } from bindings;桌面态检测改
window._wails.environment(原生注入);isMacDesktop 用 System.IsMac()
- version.ts:runtime.BrowserOpenURL → @wailsio/runtime Browser.OpenURL;测试同步更新
- tsconfig 加 allowJs(消费 JSDoc 绑定)
验证进度:Go 编译过 + tsc 干净 + 48 前端测试绿 + 前端 vite build 通过。
**未完成:整体 wails3 build/dev 原生窗口实跑 + 原生能力(另存为/打开/外链)联调**——下次续。
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
// @ts-check
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
/**
|
||||
* App 经 Wails v3 的 Service 绑定暴露给前端,承载只有桌面端能做的原生能力:
|
||||
* 文件读写、系统"另存为"框、用系统默认应用打开、原生通知。
|
||||
* v3 中不再需要注入 ctx——对话框经 application.Get().Dialog 获取。
|
||||
* @module
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
import { Call as $Call, CancellablePromise as $CancellablePromise, Create as $Create } from "@wailsio/runtime";
|
||||
|
||||
/**
|
||||
* Notify 弹一条系统通知(best-effort:macOS 用 osascript,其它平台暂静默)。
|
||||
* @param {string} title
|
||||
* @param {string} body
|
||||
* @returns {$CancellablePromise<void>}
|
||||
*/
|
||||
export function Notify(title, body) {
|
||||
return $Call.ByID(2739682372, title, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* OpenReport 把报告下载到临时目录,并用系统默认应用(Word/Pages/WPS)打开。
|
||||
* @param {string} url
|
||||
* @param {string} filename
|
||||
* @returns {$CancellablePromise<void>}
|
||||
*/
|
||||
export function OpenReport(url, filename) {
|
||||
return $Call.ByID(802670751, url, filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ping 供前端探活 Go 桥是否就绪。
|
||||
* @returns {$CancellablePromise<string>}
|
||||
*/
|
||||
export function Ping() {
|
||||
return $Call.ByID(1003072145);
|
||||
}
|
||||
|
||||
/**
|
||||
* ReadLocalFile 读取本地文件内容(本地文件系统 I/O)。
|
||||
* @param {string} path
|
||||
* @returns {$CancellablePromise<string>}
|
||||
*/
|
||||
export function ReadLocalFile(path) {
|
||||
return $Call.ByID(4016121990, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* SaveReportAs 弹原生"另存为"对话框,把 url 指向的报告(.docx)下载到用户选定路径。
|
||||
* 返回保存路径;用户取消则返回空串。
|
||||
* @param {string} url
|
||||
* @param {string} filename
|
||||
* @returns {$CancellablePromise<string>}
|
||||
*/
|
||||
export function SaveReportAs(url, filename) {
|
||||
return $Call.ByID(1437856486, url, filename);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// @ts-check
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
import * as App from "./app.js";
|
||||
export {
|
||||
App
|
||||
};
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
//@ts-check
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
import { Create as $Create } from "@wailsio/runtime";
|
||||
|
||||
Object.freeze($Create.Events);
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
Reference in New Issue
Block a user