创建项目
项目生成
现在 CLI 已经安装,你可以使用 wails init
命令生成一个新项目。
选择你最喜欢的框架
- Svelte
- React
- Vue
- Preact
- Lit
- Vanilla
使用 JavaScript 生成一个 Svelte 项目,使用
wails init -n myproject -t svelte
如果你更喜欢使用 TypeScript
wails init -n myproject -t svelte-ts
使用 JavaScript 生成一个 React 项目,使用
wails init -n myproject -t react
如果你更喜欢使用 TypeScript
wails init -n myproject -t react-ts
使用 JavaScript 生成一个 Vue 项目,使用
wails init -n myproject -t vue
如果你更喜欢使用 TypeScript
wails init -n myproject -t vue-ts
使用 JavaScript 生成一个 Preact 项目,使用
wails init -n myproject -t preact
如果你更喜欢使用 TypeScript
wails init -n myproject -t preact-ts
使用 JavaScript 生成一个 Lit 项目,使用
wails init -n myproject -t lit
如果你更喜欢使用 TypeScript
wails init -n myproject -t lit-ts
使用 JavaScript 生成一个 Vanilla 项目,使用
wails init -n myproject -t vanilla
如果你更喜欢使用 TypeScript
wails init -n myproject -t vanilla-ts
还提供 社区模板,它们提供不同的功能和框架。
要查看其他可用选项,可以运行 wails init -help
。更多详细信息可以在 CLI 参考 中找到。
项目布局
Wails 项目具有以下布局
.
├── build/
│ ├── appicon.png
│ ├── darwin/
│ └── windows/
├── frontend/
├── go.mod
├── go.sum
├── main.go
└── wails.json
项目结构概述
/main.go
- 主应用程序/frontend/
- 前端项目文件/build/
- 项目构建目录/build/appicon.png
- 应用程序图标/build/darwin/
- Mac 特定的项目文件/build/windows/
- Windows 特定的项目文件/wails.json
- 项目配置/go.mod
- Go 模块文件/go.sum
- Go 模块校验和文件
frontend
目录没有针对 Wails 的特定内容,可以是你选择的任何前端项目。
build
目录在构建过程中使用。这些文件可能会更新以自定义你的构建。如果从构建目录中删除文件,将重新生成默认版本。
go.mod
中的默认模块名称为“changeme”。你应该将其更改为更合适的名称。