5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 19:31:20 +08:00

docs: sync documents (#2063)

* docs: sync documents

* docs: fix document escape syntax
This commit is contained in:
Misite Bao 2022-11-09 03:25:18 +08:00 committed by GitHub
parent 8ee493f48d
commit 4c840c07f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 249 additions and 75 deletions

View File

@ -27,7 +27,7 @@ If you are unsure about a template, inspect `package.json` and `wails.json` for
- [wails-vite-vue-ts](https://github.com/codydbentley/wails-vite-vue-ts) - Vue 3 TypeScript with Vite (and instructions to add features)
- [wails-vite-vue-the-works](https://github.com/codydbentley/wails-vite-vue-the-works) - Vue 3 TypeScript with Vite, Vuex, Vue Router, Sass, and ESLint + Prettier
- [wails-template-quasar-js](https://github.com/sgosiaco/wails-template-quasar-js) - A template using JavaScript + Quasar V2 (Vue 3, Vite, Sass, Pinia, ESLint, Prettier)
- [wails-template-quasar-ts](https://github.com/sgosiaco/wails-template-quasar-ts) - A template using TypeScript + Quasar V2 (Vue 3, Vite, Sass, Pinia, ESLint, Prettier, Composition API with <script setup>)
- [wails-template-quasar-ts](https://github.com/sgosiaco/wails-template-quasar-ts) - A template using TypeScript + Quasar V2 (Vue 3, Vite, Sass, Pinia, ESLint, Prettier, Composition API with &lt;script setup&gt;)
## Angular

View File

@ -25,6 +25,8 @@ sidebar_position: 1
- [wails-template-vue](https://github.com/misitebao/wails-template-vue) - VueのエコシステムをベースにしたWailsテンプレート (TypeScript、ダークテーマ、i18n、シングルページルーティング、TailwindCSSを統合)
- [wails-vite-vue-ts](https://github.com/codydbentley/wails-vite-vue-ts) - Viteを使用したVue 3 TypeScript (および機能を追加する手順)
- [wails-vite-vue-the-works](https://github.com/codydbentley/wails-vite-vue-the-works) - Vite、Vuex、Vue Router、SaaS、ESLint + Prettier を使用した Vue 3 TypeScript
- [wails-template-quasar-js](https://github.com/sgosiaco/wails-template-quasar-js) - A template using JavaScript + Quasar V2 (Vue 3, Vite, Sass, Pinia, ESLint, Prettier)
- [wails-template-quasar-ts](https://github.com/sgosiaco/wails-template-quasar-ts) - A template using TypeScript + Quasar V2 (Vue 3, Vite, Sass, Pinia, ESLint, Prettier, Composition API with &lt;script setup&gt;)
## Angular

View File

@ -0,0 +1,14 @@
# Angular
Wailsでは、Angular向けのテンプレートは用意されていませんが、Angular自体を使用することはできます。
## 開発モード
Angularで開発モードを使用するには、`wails.json`で下記のように設定してください:
```json
"frontend:build": "npx ng build",
"frontend:install": "npm install",
"frontend:dev:watcher": "npx ng serve",
"frontend:dev:serverUrl": "http://localhost:4200",
```

View File

@ -16,6 +16,7 @@ import (
"fmt"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"net/http"
"os"
"strings"
@ -54,10 +55,12 @@ func main() {
Title: "helloworld",
Width: 1024,
Height: 768,
AssetServer: &assetserver.Options{
Assets: assets,
Handler: NewFileLoader(),
},
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 255},
OnStartup: app.startup,
AssetsHandler: NewFileLoader(),
Bind: []interface{}{
app,
},

View File

@ -33,6 +33,7 @@ import (
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
)
//go:embed all:frontend/dist
@ -47,7 +48,9 @@ func main() {
Title: "alwaysontop",
Width: 1024,
Height: 768,
AssetServer: &assetserver.Options{
Assets: assets,
},
Frameless: true,
CSSDragProperty: "widows",
CSSDragValue: "1",

View File

@ -30,7 +30,9 @@ In v2, there is just a single method, `wails.Run()`, that accepts [application o
Title: "MyApp",
Width: 800,
Height: 600,
AssetServer: &assetserver.Options{
Assets: assets,
},
Bind: []interface{}{
basic,
},
@ -151,7 +153,9 @@ var assets embed.FS
func main() {
err := wails.Run(&options.App{
/* Other Options */
AssetServer: &assetserver.Options{
Assets: assets,
},
})
}
```

View File

@ -145,7 +145,15 @@ In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/Sy
This is _normally_ due to a mismatch with the OS version you are running and the version of the XCode Command Line Tools installed. If you see an error like this, try upgrading your XCode Command Line Tools to the latest version.
Source: https://github.com/wailsapp/wails/issues/1806
If reinstalling Xcode Command Tools still fails, you can check the path where the toolkit is located using:
`xcode-select -p`
If `/Applications/Xcode.app/Contents/Developer` is displayed, run `sudo xcode-select --switch /Library/Developer/CommandLineTools`
Sources: https://github.com/wailsapp/wails/issues/1806 and https://github.com/wailsapp/wails/issues/1140#issuecomment-1290446496
--
## Cannot start service: Host version "x.x.x does not match binary version "x.x.x"

View File

@ -27,6 +27,7 @@ import (
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
)
//go:embed all:frontend/dist
@ -40,7 +41,9 @@ func main() {
Title: "Basic Demo",
Width: 1024,
Height: 768,
Assets: &assets,
AssetServer: &assetserver.Options{
Assets: assets,
},
OnStartup: app.startup,
OnShutdown: app.shutdown,
Bind: []interface{}{
@ -123,6 +126,7 @@ import (
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
)
//go:embed all:frontend/dist
@ -136,7 +140,9 @@ func main() {
Title: "Basic Demo",
Width: 1024,
Height: 768,
Assets: &assets,
AssetServer: &assetserver.Options{
Assets: assets,
},
Bind: []interface{}{
app,
},
@ -164,7 +170,9 @@ func (a *App) Greet(name string) string {
Title: "Basic Demo",
Width: 1024,
Height: 768,
Assets: &assets,
AssetServer: &assetserver.Options{
Assets: assets,
},
Bind: []interface{}{
app,
&mystruct1{},

View File

@ -9,7 +9,13 @@ sidebar_position: 3
The `Options.App` struct contains the application configuration. It is passed to the `wails.Run()` method:
```go title="Example"
import "github.com/wailsapp/wails/v2/pkg/options"
import (
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"github.com/wailsapp/wails/v2/pkg/options/linux"
"github.com/wailsapp/wails/v2/pkg/options/mac"
"github.com/wailsapp/wails/v2/pkg/options/windows"
)
func main() {
@ -28,8 +34,11 @@ func main() {
HideWindowOnClose: false,
BackgroundColour: &options.RGBA{R: 0, G: 0, B: 0, A: 255},
AlwaysOnTop: false,
AssetServer: &assetserver.Options{
Assets: assets,
AssetsHandler: assetsHandler,
Handler: assetsHandler,
Middleware: assetsMidldeware,
},
Menu: app.applicationMenu(),
Logger: nil,
LogLevel: logger.DEBUG,
@ -188,17 +197,19 @@ Indicates that the window should stay above other windows when losing focus.
### Assets
The frontend assets to be used by the application. Requires an `index.html` file.
名前: Assets<br/> データ型: `embed.FS`
Deprecated: Please use Assets on [AssetServer specific options](#assetserver).
### AssetsHandler
<img src="http://badges.github.io/stability-badges/dist/experimental.svg" />
Deprecated: Please use AssetsHandler on [AssetServer specific options](#assetserver).
The assets handler is a generic `http.Handler` which will be called for any non GET request on the assets server and for GET requests which can not be served from the `assets` because the file is not found.
### AssetServer
| 値 | Win | Mac | Lin |
This defines AssetServer specific options. It allows to customize the AssetServer with static assets, serving assets dynamically with an `http.Handler` or hook into the request chain with an `assetserver.Middleware`.
Not all features of an `http.Request` are currently supported, please see the following feature matrix:
| Feature | Win | Mac | Lin |
| ----------------------- | --- | --- | --- |
| GET | ✅ | ✅ | ✅ |
| POST | ✅ | ✅ | ❌ |
@ -212,13 +223,44 @@ The assets handler is a generic `http.Handler` which will be called for any non
| Response Headers | ✅ | ✅ | ❌ |
| Response Body | ✅ | ✅ | ✅ |
| Response Body Streaming | ❌ | ❌ | ✅ |
| WebSockets | ❌ | ❌ | ❌ |
NOTE: Linux is currently very limited due to targeting a WebKit2GTK Version < 2.36.0. In the future some features will be supported by the introduction of WebKit2GTK 2.36.0+ support.
Name: AssetServer<br/> Type: `*assetserver.Options`
#### Assets
The static frontend assets to be used by the application.
A GET request is first tried to be served from this `fs.FS`. If the `fs.FS` returns `os.ErrNotExist` for that file, the request handling will fallback to the [Handler](#handler) and tries to serve the GET request from it.
If set to nil, all GET requests will be forwarded to [Handler](#handler).
Name: Assets<br/> Type: `fs.FS`
#### Handler
The assets handler is a generic `http.Handler` for fallback handling of assets that can't be found.
The handler will be called for every GET request that can't be served from [Assets](#assets), due to `os.ErrNotExist`. Furthermore all non GET requests will always be served from this Handler.
If not defined, the result is the following in cases where the Handler would have been called:
- GET request: `http.StatusNotFound`
- Other request: `http.StatusMethodNotAllowed`
NOTE: When used in combination with a Frontend DevServer there might be limitations, eg. Vite serves the index.html on every path, that does not contain a file extension.
名前: AssetsHandler<br/> データ型: `http.Handler`
#### Middleware
Middleware is a HTTP Middleware which allows to hook into the AssetServer request chain. It allows to skip the default request handler dynamically, e.g. implement specialized Routing etc. The Middleware is called to build a new `http.Handler` used by the AssetSever and it also receives the default handler used by the AssetServer as an argument.
If not defined, the default AssetServer request chain is executed.
Name: Middleware<br/> Type: `assetserver.Middleware`
### Menu
The menu to be used by the application. More details about Menus in the [Menu Reference](../reference/runtime/menu.mdx).

View File

@ -38,9 +38,9 @@ Go: `WindowReload(ctx context.Context)`<br/> JS: `WindowReload()`
### WindowExecJS
Executes arbitrary JS code in the window.
ウィンドウ内で、任意のJSコードを実行します。
This method runs the code in the browser asynchronously and returns immediately. If the script causes any errors, they will only be available in the browser console.
このメソッドは、ブラウザ上で非同期にコードを実行し、すぐにリターンされます。 スクリプトでエラーが発生した場合、エラーログはブラウザコンソールでのみ確認できます。
Go: `WindowExecJS(ctx context.Context, js string)`

View File

@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## v2.1.0 - 2022-10-18
### Removed
* The `RGBA` option in `options.App` has now been removed. Use `BackgroundColour` instead.
### Added
* [Support for defaulting to No button in Windows dialogs](https://wails.io/docs/reference/runtime/dialog/#windows) - @leaanthony in https://github.com/wailsapp/wails/pull/1875
* Add missing resize for frameless window on Linux - @Lyimmi in https://github.com/wailsapp/wails/pull/1918

View File

@ -25,6 +25,8 @@ sidebar_position: 1
- [wails-template-vue](https://github.com/misitebao/wails-template-vue) - 基于 Vue 生态的 Wails 模板(集成 TypeScript、黑暗主题、国际化、单页路由、TailwindCSS
- [wails-vite-vue-ts](https://github.com/codydbentley/wails-vite-vue-ts) - 使用 Vite 的 Vue 3 TypeScript以及添加功能的说明
- [wails-vite-vue-the-works](https://github.com/codydbentley/wails-vite-vue-the-works) - 使用 Vite, Vuex, Vue Router, Sass, 和 ESLint + Prettier 的 Vue 3 TypeScript
- [wails-template-quasar-js](https://github.com/sgosiaco/wails-template-quasar-js) - 使用 JavaScript + Quasar V2Vue 3, Vite, Sass, Pinia, ESLint, Prettier的模板
- [wails-template-quasar-ts](https://github.com/sgosiaco/wails-template-quasar-ts) - 使用 TypeScript + Quasar V2Vue 3、Vite、Sass、Pinia、ESLint、Prettier、带 &lt;script setup&gt; 的Composition API的模板
## Angular

View File

@ -0,0 +1,14 @@
# Angular
虽然 Wails 没有 Angular 模板,但可以将 Angular 与 Wails 一起使用。
## 开发模式
要让开发模式与 Angular 一起工作,您需要将以下内容添加到您的 `wails.json` 中:
```json
"frontend:build": "npx ng build",
"frontend:install": "npm install",
"frontend:dev:watcher": "npx ng serve",
"frontend:dev:serverUrl": "http://localhost:4200",
```

View File

@ -16,6 +16,7 @@ import (
"fmt"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"net/http"
"os"
"strings"
@ -54,10 +55,12 @@ func main() {
Title: "helloworld",
Width: 1024,
Height: 768,
AssetServer: &assetserver.Options{
Assets: assets,
Handler: NewFileLoader(),
},
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 255},
OnStartup: app.startup,
AssetsHandler: NewFileLoader(),
Bind: []interface{}{
app,
},

View File

@ -33,6 +33,7 @@ import (
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
)
//go:embed all:frontend/dist
@ -47,7 +48,9 @@ func main() {
Title: "alwaysontop",
Width: 1024,
Height: 768,
AssetServer: &assetserver.Options{
Assets: assets,
},
Frameless: true,
CSSDragProperty: "widows",
CSSDragValue: "1",

View File

@ -30,7 +30,9 @@ Wails v2 与 v1 相比有重大变化。 本文档旨在重点介绍迁移现有
Title: "MyApp",
Width: 800,
Height: 600,
AssetServer: &assetserver.Options{
Assets: assets,
},
Bind: []interface{}{
basic,
},
@ -153,7 +155,9 @@ var assets embed.FS
func main() {
err := wails.Run(&options.App{
/* Other Options */
AssetServer: &assetserver.Options{
Assets: assets,
},
})
}
```

View File

@ -145,7 +145,15 @@ In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/Sy
这 _通常_ 是由于您正在运行的操作系统版本和安装的 XCode 命令行工具的版本不匹配。 如果您看到这样的错误,请尝试将您的 XCode 命令行工具升级到最新版本。
来源https://github.com/wailsapp/wails/issues/1806
如果重新安装 Xcode 命令工具仍然失败,您可以通过以下方式检查工具包所在的路径:
`xcode-select -p`
如果显示 `/Applications/Xcode.app/Contents/Developer` ,运行 `sudo xcode-select --twitter /Library/Developer/CommandLineTools`
来源https://github.com/wailsapp/wails/issues/1806 和 https://github.com/wailsapp/wails/issues/1140#issuecomment-1290446496
--
## 无法启动服务主机版本“x.x.x”与二进制版本“x.x.x”不匹配

View File

@ -27,6 +27,7 @@ import (
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
)
//go:embed all:frontend/dist
@ -40,7 +41,9 @@ func main() {
Title: "Basic Demo",
Width: 1024,
Height: 768,
Assets: &assets,
AssetServer: &assetserver.Options{
Assets: assets,
},
OnStartup: app.startup,
OnShutdown: app.shutdown,
Bind: []interface{}{
@ -123,6 +126,7 @@ import (
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
)
//go:embed all:frontend/dist
@ -136,7 +140,9 @@ func main() {
Title: "Basic Demo",
Width: 1024,
Height: 768,
Assets: &assets,
AssetServer: &assetserver.Options{
Assets: assets,
},
Bind: []interface{}{
app,
},
@ -164,7 +170,9 @@ func (a *App) Greet(name string) string {
Title: "Basic Demo",
Width: 1024,
Height: 768,
Assets: &assets,
AssetServer: &assetserver.Options{
Assets: assets,
},
Bind: []interface{}{
app,
&mystruct1{},

View File

@ -9,7 +9,13 @@ sidebar_position: 3
该 `Options.App` 结构包含应用程序配置。 它被传递给 `wails.Run()` 方法:
```go title="Example"
import "github.com/wailsapp/wails/v2/pkg/options"
import (
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"github.com/wailsapp/wails/v2/pkg/options/linux"
"github.com/wailsapp/wails/v2/pkg/options/mac"
"github.com/wailsapp/wails/v2/pkg/options/windows"
)
func main() {
@ -28,8 +34,11 @@ func main() {
HideWindowOnClose: false,
BackgroundColour: &options.RGBA{R: 0, G: 0, B: 0, A: 255},
AlwaysOnTop: false,
AssetServer: &assetserver.Options{
Assets: assets,
AssetsHandler: assetsHandler,
Handler: assetsHandler,
Middleware: assetsMidldeware,
},
Menu: app.applicationMenu(),
Logger: nil,
LogLevel: logger.DEBUG,
@ -188,17 +197,19 @@ func main() {
### 资产
应用程序要使用的前端资源。 需要一个 `index.html` 文件。
名称Assets<br/> 类型:`embed.FS`
已弃用:请在 [AssetServer 特定选项](#资产服务器) 上使用资产。
### 资产处理程序
<img src="http://badges.github.io/stability-badges/dist/experimental.svg" />
已弃用:请在 [AssetServer 特定选项](#资产服务器) 上使用资产处理程序。
资产处理程序是一个通用的 `http.Handler` ,对于资产服务器上的任何非 GET 请求和 `assets` 由于找不到文件而无法从 GET 请求提供服务的 GET 请求都将被调用。
### 资产服务器
| 值 | Win | Mac | Lin |
这定义了资产服务器特定的选项。 它允许使用静态资产自定义资产服务器,使用 `http.Handler` 动态地提供资产或使用 `assetsserver.Middleware` 钩到请求链。
并非当前支持 `http.Request` 的所有功能,请参阅以下功能矩阵:
| 功能 | Win | Mac | Lin |
| ----------------------- | --- | --- | --- |
| GET | ✅ | ✅ | ✅ |
| POST | ✅ | ✅ | ❌ |
@ -212,13 +223,44 @@ func main() {
| Response Headers | ✅ | ✅ | ❌ |
| Response Body | ✅ | ✅ | ✅ |
| Response Body Streaming | ❌ | ❌ | ✅ |
| WebSockets | ❌ | ❌ | ❌ |
注意Linux 当前非常有限,因为目标是 WebKit2GTK 版本 < 2.36.0。 将来,一些特性将通过引入 WebKit2GTK 2.36.0+ 支持来支持。
名称: AssetServer<br/> 类型: `*assetserver.Options`
#### 资产
应用程序要使用的静态前端资产。
首先尝试从 `fs.FS` 提供 GET 请求。 如果 `fs.FS` 为该文件返回 `os.ErrNotExist`,则请求处理将回退到 [处理程序](#处理程序) 并尝试服务来自它的 GET 请求。
如果设置为 nil则所有 GET 请求都将转发给 [处理程序](#处理程序)。
名称: Assets<br/> 类型: `fs.FS`
#### 处理程序
资产处理程序是一个通用的 `http.Handler`,用于对无法找到的资产进行后备处理。
由于 `os.ErrNotExist`,对于每个无法从 [资产](#资产) 提供服务的 GET 请求,都会调用该处理程序。 此外,所有非 GET 请求将始终从此处理程序提供服务。
如果未定义,则调用处理程序的结果如下:
- GET 请求: `http.StatusNotFound`
- 其他请求: `http.StatusMethodNotAllowed`
注意:当与前端 DevServer 结合使用时,可能会有一些限制,例如。 Vite 在不包含文件扩展名的每个路径上提供 index.html。
名称AssetsHandler<br/> 类型:`http.Handler`
#### 中间件
中间件是一个 HTTP 中间件,它允许挂钩到资产服务器请求链。 它允许动态跳过默认请求处理程序,例如实现专门的路由等。 调用中间件来构建资产服务器使用的新 `http.Handler`,它还接收资产服务器使用的默认处理程序作为参数。
如果未定义,则执行默认的资产服务器请求链。
名称: Middleware<br/> 类型: `assetserver.Middleware`
### 菜单
应用程序要使用的菜单。 [菜单参考](../reference/runtime/menu) 中有关菜单的更多详细信息。

View File

@ -6,6 +6,9 @@
## v2.1.0 - 2022-10-18
### 移除
* `options.App<code> 中的 <code>RGBA` 选项现已被删除。 使用 `BackgroundColour` 代替。
### 新增
* [Support for defaulting to No button in Windows dialogs](https://wails.io/docs/reference/runtime/dialog/#windows) - @leaanthony in https://github.com/wailsapp/wails/pull/1875
* Add missing resize for frameless window on Linux - @Lyimmi in https://github.com/wailsapp/wails/pull/1918