wails
约 3 分钟阅读
- wailsapp/wailsGitHubwailsapp/wailswailsapp/wails · MIT, Go · 基于 Webview 的应用封装 · WML · Windows - WebView2 · macOS - Safari · Linux - gcc,libgtk3,libwebkit · 可使用 upx 压缩, nsis 打包笔记:wails
- MIT, Go
- 基于 Webview 的应用封装
- WML
- Windows - WebView2
- macOS - Safari
- Linux - gcc,libgtk3,libwebkit
- 可使用 upx 压缩, nsis 打包
- 开发环境
- Vite
- Roadmap #1484GitHubwailsapp/wails/discussions/1484
- 不支持多 WebView #1452GitHubwailsapp/wails/discussions/1452
- 目前只有 electron 支持
- DnD 获取真实文件路径 #1090GitHub Issuewailsapp/wails#1090
- 自升级 #1178GitHub Issuewailsapp/wails#1178
# for V2
go install github.com/wailsapp/wails/v2/cmd/wails@latest
brew install upx nsis # macOS 开发额外依赖
wails doctor # 检查系统环境
wails init -n my-wails -t react-ts
cd ./my-wails/
wails dev
# -platform Download, Embed, Browser, Error
# -clean 清空 build/bin
# -debug 允许 inspect
wails build -trimpath -upx -platform windows/amd64 -webview2 Embed -nsis
wails build -trimpath -upx -platform darwin/amd64- 生命周期
- OnStartup
- OnDomReady
- OnBeforeClose
- OnShutdown
Binding/Bridge
- window.runtime
- Log{Print,Trace,Debug,Info,Warning,Error,Fatal}
- Events{On,OnMultiple,Off,Once,Emit}
- Window{Reload,ReloadApp,SetSystemDefaultTheme,SetLightTheme,SetDarkTheme}
- Window Center/Fullscreen/Maximise/ToggleMaximise/Unmaximise/Minimise/Unminimise
- Window Get/Set Size/MaxSize/MinSize/Position
- Window Hide/Show
- Window SetRGBA
- BrowserOpenURL
- Environment
- Quit - 退出应用
- Go Runtime
- Dialog
- Menu
export function Greet(arg1) {
return window['go']['main']['App']['Greet'](arg1);
}app
- 注入内容
- /wails/runtime.js
- /wails/ipc.js
<div data-wails-drag>->style="--wails-dragable:drag"style="--wails-draggable:no-drag"
<!-- noautoinjectruntime, noautoinjectipc, noautoinject -->
<meta name="wails-options" content="[options]" />window._wails;
window.wails;wails v3
- v3
- 声明式 -> 过程式
- 多窗口
- 集成 系统托盘
- 优化 bindings 实现和生成逻辑
- 使用 taskfile 构建
- 优化事件
- WML - Wails Markup Language
- 有点类似 htmx
- element 特殊属性
wlm-window- 操作窗口- Center,Close,Minimize,Maximize,UnMaximize,FullScreen,UnFullScreen,Restore
wlm-event- emit 事件wlm-trigger- 触发条件- 例如 mouseover
- Wails v3 Alpha SourceGitHub 文件wailsapp/wails/tree/v3-alpha
- Wails v3 Alpha Docs
- events
- 三种类型
- ApplicationEvent
- WindowEvent
- CustomEvent - 字符串
- ApplicationEvent, WindowEvent 和 js 交互的时候会做 字符串 uint 的 mapping
- events.Common.ApplicationStarted
- events.Mac.ApplicationDidFinishLaunching
- events.Windows.ApplicationStarted
- events.Common.WindowRuntimeReady
- WebView runtime
- 三种类型
go install -v github.com/wailsapp/wails/v3/cmd/wails3@latest
wails3 version
wails3 init -n my-app
cd my-app
wails3 build
./bin/my-appsyso
- 使用 tc-hib/winresGitHubtc-hib/winres
- info.json
- res.SetVersionInfo
- RT_VERSION
- langId
- learn.microsoft.com/en-us/windows/win32/intl/language-identifiers
- GetUserDefaultLocaleName
- GetSystemDefaultLocaleName
- cloudfoundry-attic/jibber_jabberGitHubcloudfoundry-attic/jibber_jabber
- wails.exe.manifest
{
"fixed": {
"file_version": "",
"product_version": "",
"flags": "", // debug, prerelease, patched, privatebuild, specialbuild
"type": "", // app, dll
"timestamp": ""
},
"info": {
// langID
"000": {
"file_version": "",
"product_version": "",
"flags": "",
"type": "",
"KEY": "Value"
}
}
}# wails3 generate syso -arch {{.ARCH}} -icon icon.ico -manifest wails.exe.manifest -info info.json -out ../wails.syso// AppManifest describes an application manifest.
//
// Its zero value corresponds to the most common case.
type AppManifest struct {
Identity AssemblyIdentity `json:"identity"`
Description string `json:"description"`
Compatibility SupportedOS `json:"minimum-os"`
ExecutionLevel ExecutionLevel `json:"execution-level"`
UIAccess bool `json:"ui-access"` // Require access to other applications' UI elements
AutoElevate bool `json:"auto-elevate"`
DPIAwareness DPIAwareness `json:"dpi-awareness"`
DisableTheming bool `json:"disable-theming"`
DisableWindowFiltering bool `json:"disable-window-filtering"`
HighResolutionScrollingAware bool `json:"high-resolution-scrolling-aware"`
UltraHighResolutionScrollingAware bool `json:"ultra-high-resolution-scrolling-aware"`
LongPathAware bool `json:"long-path-aware"`
PrinterDriverIsolation bool `json:"printer-driver-isolation"`
GDIScaling bool `json:"gdi-scaling"`
SegmentHeap bool `json:"segment-heap"`
UseCommonControlsV6 bool `json:"use-common-controls-v6"` // Application requires Common Controls V6 (V5 remains the default)
}
// AssemblyIdentity defines the side-by-side assembly identity of the executable.
//
// It should not be needed unless another assembly depends on this one.
//
// If the Name field is empty, the <assemblyIdentity> element will be omitted.
type AssemblyIdentity struct {
Name string
Version [4]uint16
}关联信息
反向链接、本文链接的其他页面和外部资料。
反向链接
- Go GUI Awesome笔记 · wailsapp/wails
fyne - 如果限制能满足 · libui - 如果不需要基于 web 的界面 · 打开 本地浏览器 - 使用 tray · sciter - 集成浏览器,基础 web 功能 · walk - 如果只需支持 windows 且界面简单 · go-astilectron - 完整 web 功能 + 扩展
- Web Awesome笔记 · wails
https://www.c82.net/iconography/ · https://www.photopea.com/ · ryohey/signal · MIT, TS · Online MIDI Editor: signal · http://oskarstalberg.com/Townscaper/
参考资料
GitHub10 条
- cloudfoundry-attic/jibber_jabbergithub.com/cloudfoundry-attic/jibber_jabber
- tc-hib/winresgithub.com/tc-hib/winres
- tc-hib/winres/manifest.gogithub.com/tc-hib/winres/blob/master/manifest.go
- wailsapp/wailsgithub.com/wailsapp/wails
- wailsapp/wails/discussions/1452github.com/wailsapp/wails/discussions/1452
- wailsapp/wails/discussions/1484github.com/wailsapp/wails/discussions/1484
- wailsapp/wails/tree/v3-alphagithub.com/wailsapp/wails/tree/v3-alpha
- wailsapp/wails/v3/internal/runtime/desktopgithub.com/wailsapp/wails/tree/v3-alpha/v3/internal/runtime/desktop
- wailsapp/wails#1090github.com/wailsapp/wails/issues/1090
- wailsapp/wails#1178github.com/wailsapp/wails/issues/1178
其他外链3 条
- developer.microsoft.com/en-us/microsoft-edge/webview2developer.microsoft.com/en-us/microsoft-edge/webview2
- learn.microsoft.com/en-us/windows/win32/intl/language-identifierslearn.microsoft.com/en-us/windows/win32/intl/language-identifiers
- v3alpha.wails.iov3alpha.wails.io/