Hello Wails
# 前言
Wails
提供了将Go
代码和Web
前端一起打包成单个二进制文件的能力。通过提供的工具,可以很轻松的完成项目的创建、编译和打包。你所要做的就是发挥想象力!
# 项目地址
wailsapp/wails: Create beautiful applications using Go (opens new window)
# 安装
# 基础必备环境
xcode-select --install
1
Windows需要GCC和相关工具。 建议从http://tdm-gcc.tdragon.net/download下载,安装完成,您就可以开始了。
1
# Debian/Ubuntu
sudo apt install libgtk-3-dev libwebkit2gtk-4.0-dev
# Arch Linux / ArchLabs / Ctlos Linux
sudo pacman -S webkit2gtk gtk3
# Centos
sudo yum install webkitgtk3-devel gtk3-devel
# Fedora
sudo yum install webkit2gtk3-devel gtk3-devel
# VoidLinux & VoidLinux-musl
xbps-install gtk+3-devel webkit2gtk-devel
# Gentoo
sudo emerge gtk+:3 webkit-gtk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Make sure to add code blocks to your code group
# 安装Wails
安装
Go
环境安装
Wails
库
go install github.com/wailsapp/wails/v2/cmd/wails@latest
1
- 运行
wails doctor
来检查缺失的依赖,按提示操作剩余部分即可
# 创建项目
# 创建基础项目
wails init -n 项目名
1
# 创建模版项目
wails init -t 模版名 -n 项目名
1
# 内置模版
# 获取wails模版列表
wails init -l
# 输出
Wails CLI v2.0.0-beta.39.2
TEMPLATE SHORT NAME DESCRIPTION
Lit + Vite lit Lit + Vite development server
Lit + Vite (Typescript) lit-ts Lit + TS + Vite development server
Plain HTML/JS/CSS plain A simple template using only HTML/CSS/JS
Preact + Vite preact Preact + Vite development server
Preact + Vite (Typescript) preact-ts Preact + Vite development server
React + Vite react React + Vite development server
React + Vite (Typescript) react-ts React + Vite development server
Svelte + Vite svelte Svelte + Vite development server
Svelte + Vite (Typescript) svelte-ts Svelte + TS + Vite development server
Vanilla + Vite vanilla Vanilla + Vite development server
Vanilla + Vite (Typescript) vanilla-ts Vanilla + Vite development server
Vue + Vite vue Vue + Vite development server
Vue + Vite (Typescript) vue-ts Vue + Vite development server
If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 创建一个vue + vite模版项目
wails init -n 项目名 -t vue
1
2
2
# 运行项目
进入到项目文件夹下,运行wails dev
即可
# 注意事项
# v2.0.0-beta.39.2
运行
wails dev
出现ERROR: failed to find Vite server URL
- 再次运行一次即可
第二次运行
wails dev
出现窗口是空白的情况【macOS
】- 在
Info.plist
文件中将以下代码添加到</plist>
之前
... <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsLocalNetworking</key> <true/> </dict> <!-- 在这之前 --> </plist>
1
2
3
4
5
6
7
8- 在
更新时间: 2023/2/10 09:50:10