5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-05 19:59:43 +08:00
wails/website/i18n/vi/docusaurus-plugin-content-docs/current/guides/manual-builds.mdx
github-actions[bot] a59f8b2cf3
docs: sync translations (#2893)
Co-authored-by: leaanthony <leaanthony@users.noreply.github.com>
2023-10-23 20:38:03 +11:00

96 lines
4.8 KiB
Plaintext

# Xây Dựng Ứng Dụng Một Cách Thủ Công
Các giao diện dòng lệnh (CLI) của Wails thực hiện rất nhiều công việc nặng nhọc nhất cho dự án của bạn, nhưng đôi khi bạn muốn xây dựng dự án theo một cách thủ công. Tài liệu tham khảo sau sẽ thảo luận về các cách khác nhau mà CLI có thể đạt được điều nêu trên.
## Quy Trình Xây Dựng
Khi dùng một trong hai câu lệnh `wails build` hoặc `wails dev`, CLI của Wails sẽ thực hiện các bước xây dựng sau đây:
- Cài đặt các tập tin cần thiết cho frontend
- Xây dựng frontend
- Tạo ra các tập tin hệ thống
- Biên dịch ứng dụng cho hệ điều hành
- [không bắt buộc] Nén ứng dụng
### Cài đặt các tập tin cần thiết cho frontend
#### Các Bước CLI
- Nếu lệnh phụ `-s` được đưa ra, bước này được lược bỏ
- Kiểm ra tệp `wails.json` xem nó đã được thêm vào câu lệnh `frontend:install` chưa
- Nếu chưa thì bước này được lược bỏ
- Nếu có thì tiếp tục kiểm tra xem tệp `package.json` có tồn tại trong thư mục frontend không. Nếu không có thì bước này được lược bỏ
- Tệp tin định dạng MD5 được tự tạo từ tệp tin `package.json` trong các tệp tin nội dung
- Nó kiểm tra sự tồn tại của tệp `package.json.md5` và nếu nó tồn tại, thì nó sẽ so sánh nội dung trong tập tin của chính mình (MD5 sum) với nội dung được tự tạo để xem nội dung có bị thay đổi hay không. Nếu chúng giống nhau thì bước này được bỏ qua
- Nếu tệp `package.json.md5` không tồn tại, nó sẽ tự động được tạo ra sử dụng nguồn từ tệp MD5 sum
- If a build is now required, or `node_modules` does not exist, or the `-f` flag is given, the install command is executed in the frontend directory
#### Manual Steps
This step could be done from the command line or a script with `npm install`.
### Xây dựng frontend
#### Wails CLI
- Nếu lệnh phụ `-s` được đưa ra, bước này được lược bỏ
- Checks `wails.json` to see if there is a build command in the key `frontend:build`
- Nếu chưa thì bước này được lược bỏ
- If there is, it is executed in the frontend directory
#### Manual Steps
This step could be done from the command line or a script with `npm run build` or whatever the frontend build script is.
### Generate assets
#### Wails CLI
- If `-nopackage` flag is set, this stage is skipped
- If the `build/appicon.png` file does not exist, a default one is created
- For Windows, see [Bundling for Windows](#windows)
- If `build/windows/icon.ico` does not exist, it will create it from the `build/appicon.png` image.
##### Windows
- If `build/windows/icon.ico` does not exist, it will create it from `build/appicon.png` using icon sizes of 256, 128, 64, 48, 32 and 16. This is done using [winicon](https://github.com/leaanthony/winicon).
- If the `build/windows/<projectname>.manifest` file does not exist, it creates it from a default version.
- Compiles the application as a production build (above)
- Uses [winres](https://github.com/tc-hib/winres) to bundle the icon and manifest into a `.syso` file ready for linking.
#### Manual Steps
- Create `icon.ico` using the [winicon](https://github.com/leaanthony/winicon) CLI tool (or any other tool).
- Create / Update a `.manifest` file for your application
- Use the [winres CLI](https://github.com/tc-hib/go-winres) to generate a `.syso` file.
### Biên dịch ứng dụng cho hệ điều hành
#### Wails CLI
- If the `-clean` flag is provided, the `build` directory is deleted and recreated
- For `wails dev`, the following default Go flags are used: `-tags dev -gcflags "all=-N -l"`
- For `wails build`, the following default Go flags are used: `-tags desktop,production -ldflags "-w -s"`
- On Windows, `-ldflags "-w -h -H windowsgui"`
- Additional tags passed to the CLI using `-tags` are added to the defaults
- Additional ldflags passed to the CLI using `-ldflags` are added to the defaults
- The `-o` flag is passed through
- The Go compiler specified by `-compiler` will be used for compilation
#### Manual steps
- For dev build, the minimum command would be: `go build -tags dev -gcflags "all=-N -l"`
- For production build, the minimum command would be: `go build -tags desktop,production -ldflags "-w -s -H windowsgui"`
- Ensure that you compile in the same directory as the `.syso` file
### Compress application
#### Wails CLI
- If the `-upx` flag has been given, the `upx` program will be run to compress the application with the default settings
- If `-upxflags` is also passed, these flags are used instead of the default ones
#### Manual steps
- Run `upx [flags]` manually to compress the application.