diff --git a/v2/tools/release/release.go b/v2/tools/release/release.go index 006fbad98..e372ec36b 100644 --- a/v2/tools/release/release.go +++ b/v2/tools/release/release.go @@ -19,8 +19,8 @@ func checkError(err error) { } } +// TODO:This can be replaced with "https://github.com/coreos/go-semver/blob/main/semver/semver.go" func updateVersion() string { - currentVersionData, err := os.ReadFile(versionFile) checkError(err) currentVersion := string(currentVersionData) @@ -35,6 +35,14 @@ func updateVersion() string { return newVersion } +func runCommand(name string, arg ...string) { + cmd := exec.Command(name, arg...) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + err := cmd.Run() + checkError(err) +} + func main() { var newVersion string if len(os.Args) > 1 { @@ -42,15 +50,20 @@ func main() { } else { newVersion = updateVersion() } + s.CD("../../../website") s.ECHO("Generating new Docs for version: " + newVersion) - cmd := exec.Command("npm", "run", "docusaurus", "docs:version", newVersion) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - err := cmd.Run() - checkError(err) - // Load the version list + runCommand("npm", "run", "docusaurus", "docs:version", newVersion) + + // For the default language identifier, please refer to: https://github.com/facebook/docusaurus/tree/main/packages/docusaurus-theme-translations/locales + languages := []string{"en", "ja", "ko", "ru", "zh-Hans"} + + for _, lang := range languages { + runCommand("npm", "run", "write-translations", "--", "--locale", lang) + } + + // Load the version list/* versionsData, err := os.ReadFile("versions.json") checkError(err) var versions []string @@ -70,9 +83,6 @@ func main() { s.CD("../versioned_sidebars") s.RM("version-" + oldestVersion + "-sidebars.json") s.CD("..") - cmd = exec.Command("npm", "run", "build") - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - err = cmd.Run() - checkError(err) + + runCommand("npm", "run", "build") } diff --git a/website/.prettierrc b/website/.prettierrc new file mode 100644 index 000000000..9c1c6d2d4 --- /dev/null +++ b/website/.prettierrc @@ -0,0 +1,22 @@ +{ + "arrowParens": "always", + "bracketSpacing": true, + "endOfLine": "lf", + "htmlWhitespaceSensitivity": "css", + "insertPragma": false, + "singleAttributePerLine": false, + "bracketSameLine": false, + "jsxBracketSameLine": false, + "jsxSingleQuote": false, + "printWidth": 80, + "proseWrap": "preserve", + "quoteProps": "as-needed", + "requirePragma": false, + "semi": true, + "singleQuote": false, + "tabWidth": 2, + "trailingComma": "es5", + "useTabs": false, + "vueIndentScriptAndStyle": false, + "parser": "mdx" +} diff --git a/website/blog/2021-09-27-v2-beta1-release-notes.mdx b/website/blog/2021-09-27-v2-beta1-release-notes.mdx index a23bc7652..413a3be01 100644 --- a/website/blog/2021-09-27-v2-beta1-release-notes.mdx +++ b/website/blog/2021-09-27-v2-beta1-release-notes.mdx @@ -5,6 +5,7 @@ authors: [leaanthony] tags: [wails, v2] --- +```mdx-code-block

+``` When I first announced Wails on Reddit, just over 2 years ago from a train in Sydney, I did not expect it to get much attention. A few days later, a prolific tech vlogger released a tutorial video, gave it a positive review and from that @@ -45,6 +47,7 @@ possible, but also being open to someone taking those projects and building on t ### WebView2 Chromium Renderer +```mdx-code-block

+``` Finally, Windows developers get a first class rendering engine for their applications! Gone are the days of contorting your frontend code to work on Windows. On top of that, you get a first-class developer tools experience! @@ -69,6 +73,7 @@ Gophers rejoice! The single binary dream lives on! ### New Features +```mdx-code-block

+``` There were a lot of requests for native menu support. Wails has finally got you covered. Application menus are now available and include support for most native menu features. This includes standard menu items, checkboxes, radio groups, submenus @@ -91,6 +97,7 @@ There is now the option to generate IDE configuration along with your project. T in a supported IDE, it will already be configured for building and debugging your application. Currently VSCode is supported but we hope to support other IDEs such as Goland soon. +```mdx-code-block

+``` ### No requirement to bundle assets @@ -117,6 +125,7 @@ They don't even need to be in the top directory - Wails will just work it out fo ### New Development Experience +```mdx-code-block

+``` Now that assets don't need to be bundled, it's enabled a whole new development experience. The new `wails dev` command will build and run your application, but instead of using the assets in the `embed.FS`, it loads them directly @@ -150,6 +160,7 @@ auto-imported when hitting tab in an auto-generated module wrapping your Go code ### Remote Templates +```mdx-code-block

+``` Getting an application up and running quickly was always a key goal for the Wails project. When we launched, we tried to cover a lot of the modern frameworks at the time: react, vue and angular. The world of frontend development is very diff --git a/website/blog/2021-11-08-v2-beta2-release-notes.mdx b/website/blog/2021-11-08-v2-beta2-release-notes.mdx index d472c7d08..9883ce006 100644 --- a/website/blog/2021-11-08-v2-beta2-release-notes.mdx +++ b/website/blog/2021-11-08-v2-beta2-release-notes.mdx @@ -5,6 +5,7 @@ authors: [leaanthony] tags: [wails, v2] --- +```mdx-code-block

+``` Today marks the first beta release of Wails v2 for Mac! It's taken quite a while to get to this point and I'm hoping that today's release will give you something that's reasonably useful. There have been a number of twists and turns @@ -27,6 +29,7 @@ So what's new for Wails v2 for Mac vs v1? Hint: It's pretty similar to the Windo ### New Features +```mdx-code-block

+``` There were a lot of requests for native menu support. Wails has finally got you covered. Application menus are now available and include support for most native menu features. This includes standard menu items, checkboxes, radio groups, submenus @@ -95,6 +99,7 @@ auto-imported when hitting tab in an auto-generated module wrapping your Go code ### Remote Templates +```mdx-code-block

+``` Getting an application up and running quickly was always a key goal for the Wails project. When we launched, we tried to cover a lot of the modern frameworks at the time: react, vue and angular. The world of frontend development is very @@ -120,6 +126,7 @@ community can create! Thanks to the amazing support of [Mat Ryer](https://github.com/matryer/), the Wails project now supports M1 native builds: +```mdx-code-block

+``` You can also specify `darwin/amd64` as a target too: +```mdx-code-block

+``` Oh, I almost forgot.... you can also do `darwin/universal`.... :wink: +```mdx-code-block

+``` ### Cross Compilation to Windows Because Wails v2 for Windows is pure Go, you can target Windows builds without docker. +```mdx-code-block

+``` ### WKWebView Renderer diff --git a/website/blog/2022-02-22-v2-beta3-release-notes.mdx b/website/blog/2022-02-22-v2-beta3-release-notes.mdx index a3e65520f..71d7efd5a 100644 --- a/website/blog/2022-02-22-v2-beta3-release-notes.mdx +++ b/website/blog/2022-02-22-v2-beta3-release-notes.mdx @@ -5,6 +5,7 @@ authors: [leaanthony] tags: [wails, v2] --- +```mdx-code-block

+``` I'm pleased to finally announce that Wails v2 is now in beta for Linux! It is somewhat ironic that the very first experiments with v2 was on Linux and yet it has ended up as the last release. That being said, the v2 we have today @@ -20,6 +22,7 @@ is very different from those first experiments. So without further ado, let's go ### New Features +```mdx-code-block

+``` There were a lot of requests for native menu support. Wails has finally got you covered. Application menus are now available and include support for most native menu features. This includes standard menu items, checkboxes, radio groups, submenus @@ -79,6 +83,7 @@ auto-imported when hitting tab in an auto-generated module wrapping your Go code ### Remote Templates +```mdx-code-block

+``` Getting an application up and running quickly was always a key goal for the Wails project. When we launched, we tried to cover a lot of the modern frameworks at the time: react, vue and angular. The world of frontend development is very @@ -103,14 +109,16 @@ community can create! Because Wails v2 for Windows is pure Go, you can target Windows builds without docker. +```mdx-code-block

+``` ### In Conclusion diff --git a/website/crowdin.yml b/website/crowdin.yml new file mode 100644 index 000000000..51b6968e0 --- /dev/null +++ b/website/crowdin.yml @@ -0,0 +1,21 @@ +project_id: 531392 +api_token_env: CROWDIN_PERSONAL_TOKEN +preserve_hierarchy: true +commit_message: "[ci skip]" +files: + - source: /docs/**/* + translation: /i18n/%two_letters_code%/docusaurus-plugin-content-docs/current/**/%original_file_name% + ignore: + - /**/*.json + - source: /blog/**/* + translation: /i18n/%two_letters_code%/docusaurus-plugin-content-blog/**/%original_file_name% + - source: /src/pages/**/* + translation: /i18n/%two_letters_code%/docusaurus-plugin-content-pages/**/%original_file_name% + ignore: + - /**/*.js + - /**/*.jsx + - /**/*.ts + - /**/*.tsx + - /**/*.css + - source: /i18n/en/**/*.json + translation: /i18n/%two_letters_code%/**/%original_file_name% diff --git a/website/docs/community/showcase/emailit.mdx b/website/docs/community/showcase/emailit.mdx index 4a1ebe835..04150ba28 100644 --- a/website/docs/community/showcase/emailit.mdx +++ b/website/docs/community/showcase/emailit.mdx @@ -1,8 +1,10 @@ # EmailIt +```mdx-code-block


+``` [EmailIt](https://github.com/raguay/EmailIt/) is a Wails 2 program that is a markdown based email sender only with nine notepads, scripts to manipulate the text, and templates. It also has a builtin [Node-Red](https://nodered.org/) server, scripts terminal, and the [ScriptBar](https://github.com/raguay/ScriptBarApp) program for displaying results from Node-Red or a script on your system. Documentation is very scarce, but the programs works. It’s built using Wails2 and Svelte, and the download is a universal macOS application. diff --git a/website/docs/community/showcase/encrypteasy.mdx b/website/docs/community/showcase/encrypteasy.mdx index 13c2d8345..7504950ea 100644 --- a/website/docs/community/showcase/encrypteasy.mdx +++ b/website/docs/community/showcase/encrypteasy.mdx @@ -1,9 +1,11 @@ # EncryptEasy +```mdx-code-block


+``` **[EncryptEasy](https://www.encrypteasy.app) is a simple and easy to use PGP encryption tool, managing all your and your contacts keys. Encryption should be simple. Developed with Wails.** diff --git a/website/docs/community/showcase/filehound.mdx b/website/docs/community/showcase/filehound.mdx index 741c14034..2d0961f21 100644 --- a/website/docs/community/showcase/filehound.mdx +++ b/website/docs/community/showcase/filehound.mdx @@ -1,9 +1,11 @@ # FileHound Export Utility +```mdx-code-block


+``` [FileHound Export Utility](https://www.filehound.co.uk/) FileHound is a cloud document management platform made for secure file retention, business process automation and SmartCapture capabilities. diff --git a/website/docs/community/showcase/minecraftupdater.mdx b/website/docs/community/showcase/minecraftupdater.mdx index 11247339d..2f6c7c72b 100644 --- a/website/docs/community/showcase/minecraftupdater.mdx +++ b/website/docs/community/showcase/minecraftupdater.mdx @@ -1,10 +1,14 @@ # Minecraft Updater +```mdx-code-block


+``` [Minecraft Updater](https://github.com/Gurkengewuerz/MinecraftModUpdater) is a utility tool to update and synchronize Minecraft mods for your userbase. It’s built using Wails2 and React with [antd](https://ant.design/) as frontend framework. diff --git a/website/docs/community/showcase/modalfilemanager.mdx b/website/docs/community/showcase/modalfilemanager.mdx index a7ae8c492..f8e2bcd66 100644 --- a/website/docs/community/showcase/modalfilemanager.mdx +++ b/website/docs/community/showcase/modalfilemanager.mdx @@ -1,11 +1,13 @@ # Modal File Manager +```mdx-code-block


+``` [Modal File Manager](https://github.com/raguay/ModalFileManager) is a dual pane file manager using web technologies. My original design was based on NW.js and can be found [here](https://github.com/raguay/ModalFileManager-NWjs). This version uses the same Svelte based frontend code (but it has be greatly modified since the departure from NW.js), but the backend is a [Wails 2](https://wails.io/) implementation. By using this implementation, I no longer use command line `rm`, `cp`, etc. commands. It is fully coded using Go and runs much faster than the previous versions. diff --git a/website/docs/community/showcase/mollywallet.mdx b/website/docs/community/showcase/mollywallet.mdx index 534b097ca..5d846d06d 100644 --- a/website/docs/community/showcase/mollywallet.mdx +++ b/website/docs/community/showcase/mollywallet.mdx @@ -1,8 +1,10 @@ # Molley Wallet +```mdx-code-block


+``` [Molly Wallet](https://github.com/grvlle/constellation_wallet/) the official $DAG wallet of the Constellation Network. It'll let users interact with the Hypergraph Network in various ways, not limited to producing $DAG transactions. diff --git a/website/docs/community/showcase/october.mdx b/website/docs/community/showcase/october.mdx index 889d2dd9e..66d634dc5 100644 --- a/website/docs/community/showcase/october.mdx +++ b/website/docs/community/showcase/october.mdx @@ -1,9 +1,11 @@ # October +```mdx-code-block


+``` [October](https://october.utf9k.net) is a small Wails application that makes it really easy to extract highlights from [Kobo eReaders](https://en.wikipedia.org/wiki/Kobo_eReader) and then forward them to [Readwise](https://readwise.io). diff --git a/website/docs/community/showcase/optimus.mdx b/website/docs/community/showcase/optimus.mdx index c3eb79507..4f87479d6 100644 --- a/website/docs/community/showcase/optimus.mdx +++ b/website/docs/community/showcase/optimus.mdx @@ -1,8 +1,10 @@ # Optimus +```mdx-code-block


+``` [Optimus](https://github.com/splode/optimus) is a desktop image optimization application. It supports conversion and compression between WebP, JPEG, and PNG image formats. diff --git a/website/docs/community/showcase/portfall.mdx b/website/docs/community/showcase/portfall.mdx index 4cc2c63c9..03e740f4c 100644 --- a/website/docs/community/showcase/portfall.mdx +++ b/website/docs/community/showcase/portfall.mdx @@ -1,8 +1,10 @@ # Portfall +```mdx-code-block


+``` [Portfall](https://github.com/rekon-oss/portfall) - A desktop k8s port-forwarding portal for easy access to all your cluster UIs diff --git a/website/docs/community/showcase/restic-browser.mdx b/website/docs/community/showcase/restic-browser.mdx index 1505ce07a..3646384ec 100644 --- a/website/docs/community/showcase/restic-browser.mdx +++ b/website/docs/community/showcase/restic-browser.mdx @@ -1,10 +1,12 @@ # Restic Browser +```mdx-code-block


+``` [Restic-Browser](https://github.com/emuell/restic-browser) - A simple, cross-platform [restic](https://github.com/restic/restic) backup GUI for browsing and restoring restic repositories. diff --git a/website/docs/community/showcase/riftshare.mdx b/website/docs/community/showcase/riftshare.mdx index 5223e88cf..9928b4785 100644 --- a/website/docs/community/showcase/riftshare.mdx +++ b/website/docs/community/showcase/riftshare.mdx @@ -1,9 +1,11 @@ # RiftShare +```mdx-code-block


+``` Easy, Secure, and Free file sharing for everyone. Learn more at [Riftshare.app](https://riftshare.app) diff --git a/website/docs/community/showcase/scriptbar.mdx b/website/docs/community/showcase/scriptbar.mdx index aaa556f92..2ccb2acb4 100644 --- a/website/docs/community/showcase/scriptbar.mdx +++ b/website/docs/community/showcase/scriptbar.mdx @@ -1,8 +1,10 @@ # ScriptBar +```mdx-code-block


+``` [ScriptBar](https://GitHub.com/raguay/ScriptBarApp) is a program to show the output of the embedded [Node-Red](https://nodered.org) server in the [EmailIt](https://GitHub.com/raguay/EmailIt) application. It also displays the output of scripts on your system. ScriptBar doesn't put them in the menubar, but has them all in a convient window for easy viewing. You can have multiple tabs to have many different things show. You can also keep the links to your most visited web sites. diff --git a/website/docs/community/showcase/surge.mdx b/website/docs/community/showcase/surge.mdx index 2d895dc29..c3b3fb4c0 100644 --- a/website/docs/community/showcase/surge.mdx +++ b/website/docs/community/showcase/surge.mdx @@ -1,8 +1,10 @@ # Surge +```mdx-code-block


+``` [Surge](https://getsurge.io/) is a p2p filesharing app designed to utilize blockchain technologies to enable 100% anonymous file transfers. Surge is end-to-end encrypted, decentralized and open source. diff --git a/website/docs/community/showcase/wally.mdx b/website/docs/community/showcase/wally.mdx index 2a2498f40..7408aa585 100644 --- a/website/docs/community/showcase/wally.mdx +++ b/website/docs/community/showcase/wally.mdx @@ -1,8 +1,10 @@ # Wally +```mdx-code-block


+``` [Wally](https://ergodox-ez.com/pages/wally) is the official firmware flasher for [Ergodox](https://ergodox-ez.com/) keyboards. It looks great and is a fantastic example of what you can achieve with Wails: the ability to combine the power of Go and the rich graphical tools of the web development world. diff --git a/website/docs/community/showcase/wombat.mdx b/website/docs/community/showcase/wombat.mdx index 54cedacea..f100c55e2 100644 --- a/website/docs/community/showcase/wombat.mdx +++ b/website/docs/community/showcase/wombat.mdx @@ -1,8 +1,10 @@ # Wombat +```mdx-code-block


+``` [Wombat](https://github.com/rogchap/wombat) is a cross platform gRPC client. diff --git a/website/docs/community/showcase/ytd.mdx b/website/docs/community/showcase/ytd.mdx index 178ff0529..5db428f72 100644 --- a/website/docs/community/showcase/ytd.mdx +++ b/website/docs/community/showcase/ytd.mdx @@ -1,8 +1,10 @@ # Ytd +```mdx-code-block


+``` [Ytd](https://github.com/marcio199226/ytd/tree/v2-wails) is an app for downloading tracks from youtube, creating offline playlists and share them with your friends, your friends will be able to playback your playlists or download them for offline listening, has an built-in player. diff --git a/website/docs/community/templates.mdx b/website/docs/community/templates.mdx index 80551784c..5b0cddafe 100644 --- a/website/docs/community/templates.mdx +++ b/website/docs/community/templates.mdx @@ -50,4 +50,4 @@ If you are unsure about a template, inspect `package.json` and `wails.json` for ## Pure JavaScript (Vanilla) -- [wails-pure-js-template](https://github.com/KiddoV/wails-pure-js-template) - A template with nothing but just basic JavaScript, HTML, and CSS \ No newline at end of file +- [wails-pure-js-template](https://github.com/KiddoV/wails-pure-js-template) - A template with nothing but just basic JavaScript, HTML, and CSS diff --git a/website/docs/gettingstarted/building.mdx b/website/docs/gettingstarted/building.mdx index 33e19b144..2668b19da 100644 --- a/website/docs/gettingstarted/building.mdx +++ b/website/docs/gettingstarted/building.mdx @@ -9,6 +9,7 @@ This will compile your project and save the production-ready binary in the `buil If you run the binary, you should see the default application: +```mdx-code-block

+``` For more details on compilation options, please refer to the [CLI Reference](../reference/cli.mdx#build). diff --git a/website/docs/gettingstarted/firstproject.mdx b/website/docs/gettingstarted/firstproject.mdx index 883b3dde6..6fc5c8039 100644 --- a/website/docs/gettingstarted/firstproject.mdx +++ b/website/docs/gettingstarted/firstproject.mdx @@ -10,8 +10,7 @@ Now that the CLI is installed, you can generate a new project by using the `wail Pick your favourite framework: - - +```mdx-code-block import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; @@ -87,8 +86,7 @@ If you would rather use Typescript:
- - +```
diff --git a/website/docs/gettingstarted/installation.mdx b/website/docs/gettingstarted/installation.mdx index 1b8c7439b..70ef0ded5 100644 --- a/website/docs/gettingstarted/installation.mdx +++ b/website/docs/gettingstarted/installation.mdx @@ -37,8 +37,7 @@ Run `npm --version` to verify. You will also need to install platform specific dependencies: - - +```mdx-code-block import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; @@ -52,31 +51,16 @@ import TabItem from "@theme/TabItem"; > Wails requires that the xcode command line tools are installed. This can be - done by running:
- xcode-select --install + done by running xcode-select --install.
- Wails requires that the{" "} - - WebView2 - {" "} - runtime is installed. Some Windows installations will already have this - installed. You can check using the wails doctor command (see - below). + Wails requires that the WebView2 runtime is installed. Some Windows installations will already have this installed. You can check using the wails doctor command. - Linux required the standard gcc build tools plus{" "} - libgtk3 and libwebkit. Rather than list a ton of - commands for different distros, Wails can try to determine what the - installation commands are for your specific distribution. Run{" "} - wails doctor after installation to be shown how to install the - dependencies. If your distro/package manager is not supported, please - consult the{" "} - Add Linux Distro guide. + Linux required the standard gcc build tools plus libgtk3 and libwebkit. Rather than list a ton of commands for different distros, Wails can try to determine what the installation commands are for your specific distribution. Run wails doctor after installation to be shown how to install the dependencies. If your distro/package manager is not supported, please consult the Add Linux Distro guide. - - +``` ## Optional Dependencies diff --git a/website/docs/guides/bleeding-edge.mdx b/website/docs/guides/bleeding-edge.mdx index 908242edd..691b1249a 100644 --- a/website/docs/guides/bleeding-edge.mdx +++ b/website/docs/guides/bleeding-edge.mdx @@ -12,11 +12,11 @@ it's possible to use the latest "bleeding edge" version using the following step NOTE: The directory that you cloned the project into will now be called "clonedir". -The Wails CLI will now be at the very latest version. +The Wails CLI will now be at the very latest version. ### Updating your project -To update projects to use the latest version of the Wails library, update the project's +To update projects to use the latest version of the Wails library, update the project's `go.mod` and ensure the following line is at the bottom of the file: `replace github.com/wailsapp/wails/v2 => ` diff --git a/website/docs/guides/dynamic-assets.mdx b/website/docs/guides/dynamic-assets.mdx index 36b10133b..07202e0a4 100644 --- a/website/docs/guides/dynamic-assets.mdx +++ b/website/docs/guides/dynamic-assets.mdx @@ -93,17 +93,21 @@ let response = await fetch('does-not-exist.txt'); This will generate an error in the devtools. We can see that the error is what we expect, returned by our custom assets handler: +```mdx-code-block

+``` However, if we request `go.mod`, we will see the following output: +```mdx-code-block

+``` This technique can be used to load images directly into the page. If we updated our default vanilla template and replaced the logo image: @@ -120,14 +124,18 @@ with: Then we would see the following: +```mdx-code-block

+``` :::warning + Exposing your filesystem in this way is a security risk. It is recommended that you properly manage access to your filesystem. + ::: diff --git a/website/docs/guides/frameless.mdx b/website/docs/guides/frameless.mdx index f60c2fd7f..4d5798474 100644 --- a/website/docs/guides/frameless.mdx +++ b/website/docs/guides/frameless.mdx @@ -7,7 +7,6 @@ Wails offers a simple solution for dragging the window: Any HTML element that ha act as a "drag handle". This property applies to all child elements. If you need to indicate that a nested element should not drag, then use the attribute '--wails-draggable:no-drag' on that element. - ```html @@ -71,19 +70,20 @@ func main() { ```html title=index.html - - - + + + alwaysontop - - -
- - + + +
+ + - ``` :::info Fullscreen + If you allow your application to go fullscreen, this drag functionality will be disabled. + ::: diff --git a/website/docs/guides/ides.mdx b/website/docs/guides/ides.mdx index aa6841879..f22aefe9e 100644 --- a/website/docs/guides/ides.mdx +++ b/website/docs/guides/ides.mdx @@ -7,12 +7,14 @@ Currently, we support [Visual Studio Code](https://code.visualstudio.com/) but a ## Visual Studio Code +```mdx-code-block

+``` When generating a project using the `-ide vscode` flags, IDE files will be created alongside the other project files. These files are placed into the `.vscode` directory and provide the correct configuration for debugging your application. diff --git a/website/docs/guides/linux-distro-support.mdx b/website/docs/guides/linux-distro-support.mdx index 5ec628f2e..b64ed0c03 100644 --- a/website/docs/guides/linux-distro-support.mdx +++ b/website/docs/guides/linux-distro-support.mdx @@ -104,5 +104,7 @@ type PackageManager interface { Take a look at the other package managers code to get an idea how this works. :::info Remember + If you add support for a new package manager, don't forget to also update this page! + ::: diff --git a/website/docs/guides/obfuscated.mdx b/website/docs/guides/obfuscated.mdx index 7d0e78def..142a3203d 100644 --- a/website/docs/guides/obfuscated.mdx +++ b/website/docs/guides/obfuscated.mdx @@ -1,12 +1,13 @@ # Obfuscated Builds -Wails includes support for obfuscating your application using [garble](https://github.com/burrowers/garble). +Wails includes support for obfuscating your application using [garble](https://github.com/burrowers/garble). To produce an obfuscated build, you can use the `-obfuscate` flag with the `wails build` command: ```bash wails build -obfuscate ``` + To customise the obfuscation settings, you can use the `-garbleargs` flag: ```bash @@ -19,13 +20,15 @@ These settings may be persisted in your [project config](/guides/reference/proje In a standard build, all bound methods are available in the frontend under the `window.go` variable. When these methods are called, the corresponding backend method is called using -the fully qualified function name. When using an obfuscated build, methods are bound using -an ID instead of a name. The bindings generated in the `wailsjs` directory use these IDs to +the fully qualified function name. When using an obfuscated build, methods are bound using +an ID instead of a name. The bindings generated in the `wailsjs` directory use these IDs to call the backend functions. :::note -To ensure that your application will work in obfuscated mode, you must use the generated -bindings under the `wailsjs` directory in your application. + +To ensure that your application will work in obfuscated mode, you must use the generated +bindings under the `wailsjs` directory in your application. + ::: ## Example @@ -33,11 +36,11 @@ bindings under the `wailsjs` directory in your application. Importing the "Greet" method from the bindings like this: ```js -import { Greet } from '../../wailsjs/go/main/App'; +import { Greet } from "../../wailsjs/go/main/App"; // snip -Greet('World'); +Greet("World"); ``` -will ensure that the method will work correctly in obfuscated mode, as the bindings will -be regenerated with IDs and the call mechanism updated. \ No newline at end of file +will ensure that the method will work correctly in obfuscated mode, as the bindings will +be regenerated with IDs and the call mechanism updated. diff --git a/website/docs/guides/overscroll.mdx b/website/docs/guides/overscroll.mdx index afe93de41..7715390bb 100644 --- a/website/docs/guides/overscroll.mdx +++ b/website/docs/guides/overscroll.mdx @@ -5,7 +5,7 @@ get when you scroll beyond a page's content boundaries. This is common in mobile ```css html { - height: 100%; - overflow: hidden; + height: 100%; + overflow: hidden; } ``` diff --git a/website/docs/guides/templates.mdx b/website/docs/guides/templates.mdx index 923b10d6b..1ab354844 100644 --- a/website/docs/guides/templates.mdx +++ b/website/docs/guides/templates.mdx @@ -79,12 +79,14 @@ Renaming package-lock.json -> package-lock.tmpl.json... - Once the project has compiled, run it: `.\build\bin\my-vue3-project.exe` - You should have a fully functioning Vue3 application: +```mdx-code-block
+``` ## Publishing Templates diff --git a/website/docs/guides/troubleshooting.mdx b/website/docs/guides/troubleshooting.mdx index 6dc9f53ba..524d1a311 100644 --- a/website/docs/guides/troubleshooting.mdx +++ b/website/docs/guides/troubleshooting.mdx @@ -39,6 +39,7 @@ Reference: https://github.com/wailsapp/wails/issues/1504#issuecomment-1174317433 If your built application looks like this in finder: +```mdx-code-block

+``` it's likely that your application's `info.plist` is invalid. Update the file in `build/.app/Contents/info.plist` and check if the data is valid, EG check the binary name is correct. To persist the changes, copy the file back to @@ -132,10 +134,10 @@ Source: https://github.com/wailsapp/wails/discussions/1512 ## I get `too many open files` errors on my Mac when I run `wails dev` -By default, macOS will only allow you to open a maximum of 256 files. This can affect the `wails dev` command. +By default, macOS will only allow you to open a maximum of 256 files. This can affect the `wails dev` command. This limit can be increased by running: `ulimit -n 1024` in the terminal. -FSNotify is [looking to move to Apple's fsevents](https://github.com/fsnotify/fsnotify/issues/11) for Mac. +FSNotify is [looking to move to Apple's fsevents](https://github.com/fsnotify/fsnotify/issues/11) for Mac. If this isn't completed soon, we will create our own implementation, tracked [here](https://github.com/wailsapp/wails/issues/1733). ## My Mac app gives me weird compilation errors @@ -153,7 +155,7 @@ In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/Sy #define NS_FORMAT_ARGUMENT(A) __attribute__ ((format_arg(A))) ``` -This is *normally* due to a mismatch with the OS version you are running and the version of the XCode Command Line Tools +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 \ No newline at end of file +Source: https://github.com/wailsapp/wails/issues/1806 diff --git a/website/docs/guides/windows-installer.mdx b/website/docs/guides/windows-installer.mdx index cb31d0527..533734886 100644 --- a/website/docs/guides/windows-installer.mdx +++ b/website/docs/guides/windows-installer.mdx @@ -1,5 +1,6 @@ # NSIS installer +```mdx-code-block


+``` Wails supports generating Windows installers using the [NSIS installer](https://nsis.sourceforge.io/). diff --git a/website/docs/howdoesitwork.mdx b/website/docs/howdoesitwork.mdx index 87ce7b767..b292dcc35 100644 --- a/website/docs/howdoesitwork.mdx +++ b/website/docs/howdoesitwork.mdx @@ -10,9 +10,11 @@ window. The frontend is a webkit window that will display the frontend assets. A version of the runtime library. Finally, it is possible to bind Go methods to the frontend, and these will appear as Javascript methods that can be called, just as if they were local Javascript methods. +```mdx-code-block
+``` ## The Main Application @@ -266,7 +268,9 @@ it will be returned to your frontend as a Javascript class. Note: If you wish to `json` struct tags for your fields! :::info Note + Anonymous nested structs are not supported at this time. + ::: It is possible to send structs back to Go. Any Javascript map/class passed as an argument that diff --git a/website/docs/introduction.mdx b/website/docs/introduction.mdx index 546e0d148..5e463f876 100644 --- a/website/docs/introduction.mdx +++ b/website/docs/introduction.mdx @@ -13,25 +13,26 @@ and power of Go, combined with a rich, modern frontend. - Native Menus, Dialogs, Theming and Translucency - Windows, macOS and linux support -- Built in templates for Svelte, React, Preact, Vue, Lit and Vanilla JS +- Built in templates for Svelte, React, Preact, Vue, Lit and Vanilla JS - Easily call Go methods from Javascript - Automatic Go struct to Typescript model generation - No CGO or external DLLs required on Windows - Live development mode using the power of [Vite](https://vitejs.dev/) - Powerful CLI to easily Create, Build and Package applications -- A rich [runtime library](/docs/next/reference/runtime/intro) +- A rich [runtime library](/docs/next/reference/runtime/intro) - Applications built with Wails are Apple & Microsoft Store compliant - This is [varly](https://varly.app) - a desktop application for MacOS & Windows written using Wails. Not only does it look great, it uses native menus and translucency - everything you'd expect from a modern native app. +```mdx-code-block

+``` ### Quick Start Templates diff --git a/website/docs/reference/cli.mdx b/website/docs/reference/cli.mdx index 70fa61d31..0e0687c53 100644 --- a/website/docs/reference/cli.mdx +++ b/website/docs/reference/cli.mdx @@ -53,7 +53,7 @@ If you are unsure about a template, inspect `package.json` and `wails.json` for `wails build` is used for compiling your project to a production-ready binary. | Flag | Description | Default | -| :------------------- |:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| :-------------------------------------------------------------------------------------------------------------------------------------------- | +| :------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------- | | -platform | Build for the given (comma delimited) [platforms](../reference/cli.mdx#platforms) eg. `windows/arm64`. Note, if you do not give the architecture, `runtime.GOARCH` is used. | platform = `GOOS` environment variable if given else `runtime.GOOS`.
arch = `GOARCH` envrionment variable if given else `runtime.GOARCH`. | | -clean | Cleans the `build/bin` directory | | | -compiler "compiler" | Use a different go compiler to build, eg go1.15beta1 | go | diff --git a/website/docs/reference/menus.mdx b/website/docs/reference/menus.mdx index 608b392bb..1c2d3f5b7 100644 --- a/website/docs/reference/menus.mdx +++ b/website/docs/reference/menus.mdx @@ -107,57 +107,23 @@ Example: Keys are any single character on a keyboard with the exception of `+`, which is defined as `plus`. Some keys cannot be represented as characters so there are a set of named characters that may be used: -- `backspace` -- `tab` -- `return` -- `enter` -- `escape` -- `left` -- `right` -- `up` -- `down` -- `space` -- `delete` -- `home` -- `end` -- `page up` -- `page down` -- `f1` -- `f2` -- `f3` -- `f4` -- `f5` -- `f6` -- `f7` -- `f8` -- `f9` -- `f10` -- `f11` -- `f12` -- `f13` -- `f14` -- `f15` -- `f16` -- `f17` -- `f18` -- `f19` -- `f20` -- `f21` -- `f22` -- `f23` -- `f24` -- `f25` -- `f26` -- `f27` -- `f28` -- `f29` -- `f30` -- `f31` -- `f32` -- `f33` -- `f34` -- `f35` -- `numlock` +| | | | | +| :---------: | :---: | :---: | :-------: | +| `backspace` | `f1` | `f16` | `f31` | +| `tab` | `f2` | `f17` | `f32` | +| `return` | `f3` | `f18` | `f33` | +| `enter` | `f4` | `f19` | `f34` | +| `escape` | `f5` | `f20` | `f35` | +| `left` | `f6` | `f21` | `numlock` | +| `right` | `f7` | `f22` | | +| `up` | `f8` | `f23` | | +| `down` | `f9` | `f24` | | +| `space` | `f10` | `f25` | | +| `delete` | `f11` | `f36` | | +| `home` | `f12` | `f37` | | +| `end` | `f13` | `f38` | | +| `page up` | `f14` | `f39` | | +| `page down` | `f15` | `f30` | | Wails also supports parsing accelerators using the same syntax as Electron. This is useful for storing accelerators in config files. diff --git a/website/docs/reference/options.mdx b/website/docs/reference/options.mdx index 5371ed964..039f6a92c 100644 --- a/website/docs/reference/options.mdx +++ b/website/docs/reference/options.mdx @@ -97,12 +97,14 @@ func main() { The text shown in the window's title bar. +Name: Title
Type: `string` ### Width The initial width of the window. +Name: Width
Type: `int`
Default: 1024. @@ -110,6 +112,7 @@ Default: 1024. The initial height of the window. +Name: Height
Type: `int`
Default: 768 @@ -117,12 +120,14 @@ Default: 768 By default, the main window is resizable. Setting this to `true` will keep it a fixed size. +Name: DisableResize
Type: `bool` ### Fullscreen Setting this to `true` will make the window fullscreen at startup. +Name: Fullscreen
Type: `bool` ### Frameless @@ -130,6 +135,7 @@ Type: `bool` When set to `true`, the window will have no borders or title bar. Also see [Frameless Windows](../guides/frameless.mdx). +Name: Frameless
Type: `bool` ### MinWidth @@ -137,6 +143,7 @@ Type: `bool` This sets the minimum width for the window. If the value given in `Width` is less than this value, the window will be set to `MinWidth` by default. +Name: MinWidth
Type: `int` ### MinHeight @@ -144,6 +151,7 @@ Type: `int` This sets the minimum height for the window. If the value given in `Height` is less than this value, the window will be set to `MinHeight` by default. +Name: MinHeight
Type: `int` ### MaxWidth @@ -151,6 +159,7 @@ Type: `int` This sets the maximum width for the window. If the value given in `Width` is more than this value, the window will be set to `MaxWidth` by default. +Name: MaxWidth
Type: `int` ### MaxHeight @@ -158,6 +167,7 @@ Type: `int` This sets the maximum height for the window. If the value given in `Height` is more than this value, the window will be set to `MaxHeight` by default. +Name: MaxHeight
Type: `int` ### StartHidden @@ -165,13 +175,16 @@ Type: `int` When set to `true`, the application will be hidden until [WindowShow](../reference/runtime/window.mdx#windowshow) is called. +Name: StartHidden
Type: `bool` + ### HideWindowOnClose By default, closing the window will close the application. Setting this to `true` means closing the window will hide the window instead. +Name: HideWindowOnClose
Type: `bool` ### BackgroundColour @@ -179,6 +192,7 @@ Type: `bool` This value is the default background colour of the window. Example: options.NewRGBA(255,0,0,128) - Red at 50% transparency +Name: BackgroundColour
Type: `*options.RGBA`
Default: white @@ -186,12 +200,14 @@ Default: white Indicates that the window should stay above other windows when losing focus. +Name: AlwaysOnTop
Type: `bool` ### Assets The frontend assets to be used by the application. Requires an `index.html` file. +Name: Assets
Type: `embed.FS` ### AssetsHandler @@ -222,6 +238,7 @@ supported by the introduction of WebKit2GTK 2.36.0+ support. 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. +Name: AssetsHandler
Type: `http.Handler` ### Menu @@ -229,15 +246,19 @@ Type: `http.Handler` The menu to be used by the application. More details about Menus in the [Menu Reference](../reference/runtime/menu.mdx). :::note + On Mac, if no menu is specified, a default menu will be created. + ::: +Name: Menu
Type: `*menu.Menu` ### Logger The logger to be used by the application. More details about logging in the [Log Reference](../reference/runtime/log.mdx). +Name: Logger
Type: `logger.Logger`
Default: Logs to Stdout @@ -245,6 +266,7 @@ Default: Logs to Stdout The default log level. More details about logging in the [Log Reference](../reference/runtime/log.mdx). +Name: LogLevel
Type: `logger.LogLevel`
Default: `Info` in dev mode, `Error` in production mode @@ -252,6 +274,7 @@ Default: `Info` in dev mode, `Error` in production mode The default log level for production builds. More details about logging in the [Log Reference](../reference/runtime/log.mdx). +Name: LogLevelProduction
Type: `logger.LogLevel`
Default: `Error` @@ -260,6 +283,7 @@ Default: `Error` This callback is called after the frontend has been created, but before `index.html` has been loaded. It is given the application context. +Name: OnStartup
Type: `func(ctx context.Context)` ### OnDomReady @@ -267,6 +291,7 @@ Type: `func(ctx context.Context)` This callback is called after the frontend has loaded `index.html` and its resources. It is given the application context. +Name: OnDomReady
Type: `func(ctx context.Context)` ### OnShutdown @@ -274,6 +299,7 @@ Type: `func(ctx context.Context)` This callback is called after the frontend has been destroyed, just before the application terminates. It is given the application context. +Name: OnShutdown
Type: `func(ctx context.Context)` ### OnBeforeClose @@ -286,21 +312,20 @@ Example: ```go title=windowsapp.go func (b *App) beforeClose(ctx context.Context) (prevent bool) { - dialog, err := runtime.MessageDialog(ctx, runtime.MessageDialogOptions{ - Title: "Quit?", - Message: "Are you sure you want to quit?", - - Type: ` runtime`.QuestionDialog, + dialog, err := runtime.MessageDialog(ctx, runtime.MessageDialogOptions{ + Type: runtime.QuestionDialog, + Title: "Quit?", + Message: "Are you sure you want to quit?", + }) - }) - - if err != nil { - return false - } - return dialog != "Yes" + if err != nil { + return false + } + return dialog != "Yes" } ``` +Name: OnBeforeClose
Type: `func(ctx context.Context) bool` ### WindowStartState @@ -313,82 +338,78 @@ Defines how the window should present itself at startup. | Maximised | ✅ | ✅ | ✅ | | Minimised | ✅ | ❌ | ✅ | +Name: WindowStartState
Type: `options.WindowStartState` ### CSSDragProperty Indicates the CSS property to use to identify which elements can be used to drag the window. Default: `--wails-draggable`. +Name: CSSDragProperty
Type: `string` ### CSSDragValue Indicates what value the `CSSDragProperty` style should have to drag the window. Default: `drag`. +Name: CSSDragValue
Type: `string` ### Bind A slice of struct instances defining methods that need to be bound to the frontend. +Name: Bind
Type: `[]interface{}` ### Windows This defines [Windows specific options](#windows-specific-options). +Name: Windows
Type: `*windows.Options` -### Mac - -This defines [Mac specific options](#mac-specific-options). - -Type: `*mac.Options` - -### Linux - -This defines [Linux specific options](#linux-specific-options). - -Type: `*linux.Options` - -## Windows Specific Options - -### WebviewIsTransparent +#### WebviewIsTransparent Setting this to `true` will make the webview background transparent when an alpha value of `0` is used. This means that if you use `rgba(0,0,0,0)` for `background-color` in your CSS, the host window will show through. Often combined with [WindowIsTranslucent](#WindowIsTranslucent) to make frosty-looking applications. +Name: WebviewIsTransparent
Type: `bool` -### WindowIsTranslucent +#### WindowIsTranslucent Setting this to `true` will make the window background translucent. Often combined with [WebviewIsTransparent](#WebviewIsTransparent) to make frosty-looking applications. +Name: WindowIsTranslucent
Type: `bool` -### DisableWindowIcon +#### DisableWindowIcon Setting this to `true` will remove the icon in the top left corner of the title bar. +Name: DisableWindowIcon
Type: `bool` -### DisableFramelessWindowDecorations +#### DisableFramelessWindowDecorations Setting this to `true` will remove the window decorations in [Frameless](#Frameless) mode. This means there will be no 'Aero Shadow' and no 'Rounded Corners' shown for the window. Please note that 'Rounded Corners' are only supported on Windows 11. +Name: DisableFramelessWindowDecorations
Type: `bool` -### WebviewUserDataPath +#### WebviewUserDataPath This defines the path where the WebView2 stores the user data. If empty `%APPDATA%\[BinaryName.exe]` will be used. +Name: WebviewUserDataPath
Type: `string` -### WebviewBrowserPath +#### WebviewBrowserPath This defines the path to a directory with WebView2 executable files and libraries. If empty, webview2 installed in the system will be used. @@ -398,9 +419,10 @@ Important information about distribution of fixed version runtime: - [Known issues for fixed version](https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#known-issues-for-fixed-version) - [The path of fixed version of the WebView2 Runtime should not contain \Edge\Application\.](https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.1245.22#createcorewebview2environmentwithoptions) +Name: WebviewBrowserPath
Type: `string` -### Theme +#### Theme Minimum Windows Version: Windows 10 2004/20H1 @@ -412,20 +434,24 @@ This defines the theme that the application should use: | Dark | The application will use a dark theme exclusively | | Light | The application will use a light theme exclusively | +Name: Theme
Type: `windows.Theme` -### CustomTheme +#### CustomTheme :::note + Minimum Windows Version: Windows 10/11 2009/21H2 Build 22000 + ::: Allows you to specify custom colours for TitleBar, TitleText and Border for both light and dark mode, as well as when the window is active or inactive. +Name: CustomTheme
Type: `windows.CustomTheme` -#### CustomTheme Type +##### CustomTheme type The CustomTheme struct uses `int32` to specify the colour values. These are in the standard(!) Windows format of: `0x00BBGGAA`. A helper function is provided to do RGB conversions into this format: `windows.RGB(r,g,b uint8)`. @@ -470,71 +496,52 @@ Example: }, ``` -### Messages +#### Messages A struct of strings used by the webview2 installer if a valid webview2 runtime is not found. +Name: Messages
Type: `*windows.Messages` Customise this for any language you choose to support. -### ResizeDebounceMS +#### ResizeDebounceMS ResizeDebounceMS is the amount of time to debounce redraws of webview2 when resizing the window. The default value (0) will perform redraws as fast as it can. +Name: ResizeDebounceMS
Type: `uint16` -### OnSuspend +#### OnSuspend If set, this function will be called when windows initiates a switch to low power mode (suspend/hibernate) +Name: OnSuspend
Type: `func()` -### OnResume +#### OnResume If set, this function will be called when windows resumes from low power mode (suspend/hibernate) +Name: OnResume
Type: `func()` -## Mac Specific Options +### Mac -### TitleBar +This defines [Mac specific options](#mac-specific-options). + +Name: Mac
+Type: `*mac.Options` + +#### TitleBar The TitleBar struct provides the ability to configure the look and feel of the title bar. +Name: TitleBar
Type: [`*mac.TitleBar`](#titlebar-struct) - -### Appearance - -Appearance is used to set the style of your app in accordance with Apple's [NSAppearance](https://developer.apple.com/documentation/appkit/nsappearancename?language=objc) names. - -Type: [`AppearanceType`](#appearance-type) - -### WebviewIsTransparent - -Setting this to `true` will make the webview background transparent when an alpha value of `0` is used. -This means that if you use `rgba(0,0,0,0)` for `background-color` in your CSS, the host window will show through. -Often combined with [WindowIsTranslucent](#WindowIsTranslucent) to make frosty-looking applications. - -Type: `bool` - -### WindowIsTranslucent - -Setting this to `true` will make the window background translucent. Often combined -with [WebviewIsTransparent](#WebviewIsTransparent) to make frosty-looking applications. - -Type: `bool` - -### About - -This configuration lets you set the title, message and icon for the "About" menu item in the app menu created by the "AppMenu" role. - -Type: [`About`](#about-struct) - - -#### Titlebar struct +##### Titlebar struct The titlebar of the application can be customised by using the TitleBar options: @@ -560,8 +567,8 @@ type TitleBar struct { Preconfigured titlebar settings are available: -| Setting | Example | -| --------------------------- | --------------------------------------------- | +| Setting | Example | +| --------------------------- | ---------------------------------------------- | | `mac.TitleBarDefault()` | ![](/img/reference/titlebar-default.webp) | | `mac.TitleBarHidden()` | ![](/img/reference/titlebar-hidden.webp) | | `mac.TitleBarHiddenInset()` | ![](/img/reference/titlebar-hidden-inset.webp) | @@ -576,7 +583,14 @@ Mac: &mac.Options{ Click [here](https://github.com/lukakerr/NSWindowStyles) for some inspiration on customising the titlebar. -#### Appearance type +#### Appearance + +Appearance is used to set the style of your app in accordance with Apple's [NSAppearance](https://developer.apple.com/documentation/appkit/nsappearancename?language=objc) names. + +Name: Appearance
+Type: [`mac.AppearanceType`](#appearance-type) + +##### Appearance type You can specify the application's [appearance](https://developer.apple.com/documentation/appkit/nsappearance?language=objc). @@ -599,9 +613,34 @@ Mac: &mac.Options{ } ``` -#### About struct +#### WebviewIsTransparent + +Setting this to `true` will make the webview background transparent when an alpha value of `0` is used. +This means that if you use `rgba(0,0,0,0)` for `background-color` in your CSS, the host window will show through. +Often combined with [WindowIsTranslucent](#WindowIsTranslucent) to make frosty-looking applications. + +Name: WebviewIsTransparent
+Type: `bool` + +#### WindowIsTranslucent + +Setting this to `true` will make the window background translucent. Often combined +with [WebviewIsTransparent](#WebviewIsTransparent) to make frosty-looking applications. + +Name: WindowIsTranslucent
+Type: `bool` + +#### About + +This configuration lets you set the title, message and icon for the "About" menu item in the app menu created by the "AppMenu" role. + +Name: About
+Type: [`*mac.AboutInfo`](#about-struct) + +##### About struct ```go + type AboutInfo struct { Title string Message string @@ -631,6 +670,7 @@ func main() { The "About" menu item will appear in the app menu: +```mdx-code-block

+``` When clicked, that will open an about message box: +```mdx-code-block

+``` -## Linux Specific Options +### Linux -### Icon +This defines [Linux specific options](#linux-specific-options). + +Name: Linux
+Type: `*linux.Options` + +#### Icon Sets up the icon representing the window. This icon is used when the window is minimized (also known as iconified). +Name: Icon
Type: `[]byte` Some window managers or desktop environments may also place it in the window frame, or display it in other contexts. diff --git a/website/docs/reference/project-config.mdx b/website/docs/reference/project-config.mdx index 7a243da9e..9111e59af 100644 --- a/website/docs/reference/project-config.mdx +++ b/website/docs/reference/project-config.mdx @@ -8,16 +8,16 @@ The project config resides in the `wails.json` file in the project directory. Th ```json { - "name": "[The project name]", + "name": "[The project name]", "assetdir": "[Relative path to the directory containing the compiled assets, this is normally inferred and could be left empty]", "reloaddirs": "[Additional directories to trigger reloads (comma separated), this is only used for some advanced asset configurations]", "frontend:install": "[The command to install node dependencies, run in the frontend directory - often `npm install`]", "frontend:build": "[The command to build the assets, run in the frontend directory - often `npm run build`]", - "frontend:dev": "[This command has been replaced by frontend:dev:build. If frontend:dev:build is not specified will falls back to this command. If this command is also not specified will falls back to frontend:build]", + "frontend:dev": "[This command has been replaced by frontend:dev:build. If frontend:dev:build is not specified will falls back to this command. \nIf this command is also not specified will falls back to frontend:build]", "frontend:dev:build": "[This command is the dev equivalent of frontend:build. If not specified falls back to frontend:dev]", "frontend:dev:install": "[This command is the dev equivalent of frontend:install. If not specified falls back to frontend:install]", "frontend:dev:watcher": "[This command is run in a separate process on `wails dev`. Useful for 3rd party watchers or starting 3d party dev servers]", - "frontend:dev:serverUrl": "[URL to a 3rd party dev server to be used to serve assets, EG Vite. If this is set to 'auto' then the devServerUrl will be inferred from the Vite output]", + "frontend:dev:serverUrl": "[URL to a 3rd party dev server to be used to serve assets, EG Vite. \nIf this is set to 'auto' then the devServerUrl will be inferred from the Vite output]", "wailsjsdir": "[Relative path to the directory that the auto-generated JS modules will be created]", "version": "[Project config version]", "outputfilename": "[The name of the binary]", diff --git a/website/docs/reference/runtime/browser.mdx b/website/docs/reference/runtime/browser.mdx index 263c5897c..6f72be0ce 100644 --- a/website/docs/reference/runtime/browser.mdx +++ b/website/docs/reference/runtime/browser.mdx @@ -12,4 +12,3 @@ Opens the given URL in the system browser. Go: `BrowserOpenURL(ctx context.Context, url string)`
JS: `BrowserOpenURL(url string)` - diff --git a/website/docs/reference/runtime/dialog.mdx b/website/docs/reference/runtime/dialog.mdx index 5f679b1b2..2f487ee36 100644 --- a/website/docs/reference/runtime/dialog.mdx +++ b/website/docs/reference/runtime/dialog.mdx @@ -7,7 +7,9 @@ sidebar_position: 5 This part of the runtime provides access to native dialogs, such as File Selectors and Message boxes. :::info Javascript + Dialog is currently unsupported in the JS runtime. + ::: ### OpenDirectoryDialog @@ -151,14 +153,16 @@ selection, err := runtime.MessageDialog(b.ctx, runtime.MessageDialogOptions{ the first button is shown as default: +```mdx-code-block

+``` And if we specify `DefaultButton` to be "two": @@ -173,14 +177,16 @@ selection, err := runtime.MessageDialog(b.ctx, runtime.MessageDialogOptions{ the second button is shown as default. When `return` is pressed, the value "two" is returned. +```mdx-code-block

+``` If we now specify `CancelButton` to be "three": @@ -196,9 +202,10 @@ selection, err := runtime.MessageDialog(b.ctx, runtime.MessageDialogOptions{ the button with "three" is shown at the bottom of the dialog. When `escape` is pressed, the value "three" is returned: +```mdx-code-block
@@ -206,6 +213,7 @@ the button with "three" is shown at the bottom of the dialog. When `escape` is p


+``` #### DialogType @@ -232,9 +240,10 @@ type FileFilter struct { Windows allows you to use multiple file filters in dialog boxes. Each FileFilter will show up as a separate entry in the dialog: +```mdx-code-block
@@ -242,15 +251,17 @@ dialog:


+``` #### Linux Linux allows you to use multiple file filters in dialog boxes. Each FileFilter will show up as a separate entry in the dialog: +```mdx-code-block
@@ -258,6 +269,7 @@ dialog:


+``` #### Mac diff --git a/website/docs/reference/runtime/events.mdx b/website/docs/reference/runtime/events.mdx index 6fc64cf47..8bfd346a5 100644 --- a/website/docs/reference/runtime/events.mdx +++ b/website/docs/reference/runtime/events.mdx @@ -42,4 +42,3 @@ This method emits the given event. Optional data may be passed with the event. T Go: `EventsEmit(ctx context.Context, eventName string, optionalData ...interface{})`
JS: `EventsEmit(ctx context, optionalData function(optionalData?: any))` - diff --git a/website/docs/reference/runtime/intro.mdx b/website/docs/reference/runtime/intro.mdx index 4310bab57..1f69f662f 100644 --- a/website/docs/reference/runtime/intro.mdx +++ b/website/docs/reference/runtime/intro.mdx @@ -41,9 +41,11 @@ JS: `Hide()` Hides the application. :::info Note + On Mac, this will hide the application in the same way as the `Hide` menu item in standard Mac applications. This is different to hiding the window, but the application still being in the foreground. For Windows and Linux, this is currently the same as `WindowHide`. + ::: ### Show @@ -51,8 +53,10 @@ For Windows and Linux, this is currently the same as `WindowHide`. Shows the application. :::info Note + On Mac, this will bring the application back into the foreground. For Windows and Linux, this is currently the same as `WindowShow`. + ::: Go: `Show(ctx context.Context)`
@@ -75,6 +79,7 @@ JS: `Environment(): Promise` #### EnvironmentInfo Go: + ```go type EnvironmentInfo struct { BuildType string @@ -82,11 +87,13 @@ type EnvironmentInfo struct { Arch string } ``` + JS: + ```ts interface EnvironmentInfo { - buildType: string; - platform: string; - arch: string; + buildType: string; + platform: string; + arch: string; } ``` diff --git a/website/docs/reference/runtime/menu.mdx b/website/docs/reference/runtime/menu.mdx index 6a7e06cf9..da4b74b69 100644 --- a/website/docs/reference/runtime/menu.mdx +++ b/website/docs/reference/runtime/menu.mdx @@ -7,7 +7,9 @@ sidebar_position: 6 These methods are related to the application menu. :::info Javascript + Menu is currently unsupported in the JS runtime. + ::: ### MenuSetApplicationMenu diff --git a/website/docs/reference/runtime/window.mdx b/website/docs/reference/runtime/window.mdx index 3ddceea4c..bac1f3fbe 100644 --- a/website/docs/reference/runtime/window.mdx +++ b/website/docs/reference/runtime/window.mdx @@ -31,7 +31,7 @@ JS: `WindowUnfullscreen()` Returns true if the window is full screen. -Go: `WindowIsFullscreen(ctx context.Context) bool` +Go: `WindowIsFullscreen(ctx context.Context) bool`
JS: `WindowIsFullscreen() bool` ### WindowCenter @@ -100,7 +100,7 @@ JS: `WindowHide()` Returns true if the window not minimised, maximised or fullscreen. -Go: `WindowIsNormal(ctx context.Context) bool` +Go: `WindowIsNormal(ctx context.Context) bool`
JS: `WindowIsNormal() bool` ### WindowSetSize @@ -176,7 +176,7 @@ JS: `WindowUnmaximise()` Returns true if the window is maximised. -Go: `WindowIsMaximised(ctx context.Context) bool` +Go: `WindowIsMaximised(ctx context.Context) bool`
JS: `WindowIsMaximised() bool` ### WindowToggleMaximise @@ -204,7 +204,7 @@ JS: `WindowUnminimise()` Returns true if the window is minimised. -Go: `WindowIsMinimised(ctx context.Context) bool` +Go: `WindowIsMinimised(ctx context.Context) bool`
JS: `WindowIsMinimised() bool` ### WindowSetBackgroundColour @@ -215,8 +215,10 @@ This colour will show through for all transparent pixels. Valid values for R, G, B and A are 0-255. :::info Windows + On Windows, only alpha values of 0 or 255 are supported. Any value that is not 0 will be considered 255. + ::: Go: `WindowSetBackgroundColour(ctx context.Context, R, G, B, A uint8)`
diff --git a/website/docs/tutorials/dogsapi.mdx b/website/docs/tutorials/dogsapi.mdx index 4a5f9c88a..011ebe266 100644 --- a/website/docs/tutorials/dogsapi.mdx +++ b/website/docs/tutorials/dogsapi.mdx @@ -4,6 +4,7 @@ sidebar_position: 20 # Dogs API +```mdx-code-block

+``` :::note + This tutorial has been kindly provided by [@tatadan](https://twitter.com/tatadan) and forms part of their [Wails Examples Repository](https://github.com/tataDan/wails-v2-examples). + ::: -In this tutorial we are going to develop an application that retrieves photos of dogs from the web +In this tutorial we are going to develop an application that retrieves photos of dogs from the web and then displays them. ### Create the project -Let's create the application. From a terminal enter: -```wails init -n dogs-api -t svelte``` +Let's create the application. From a terminal enter: +`wails init -n dogs-api -t svelte` Note: We could optionally add `-ide vscode` or `-ide goland` to the end of this command if you wanted to add IDE support. @@ -151,6 +155,7 @@ import ( Add the following lines to `frontend/src/App.svelte`: + ```html - - -crwdns34882:0{0}crwdne34882:0 - - diff --git a/website/i18n/ach/docusaurus-theme-classic/footer.json b/website/i18n/ach/docusaurus-theme-classic/footer.json deleted file mode 100644 index db53e6198..000000000 --- a/website/i18n/ach/docusaurus-theme-classic/footer.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "link.title.Docs": { - "message": "crwdns35356:0crwdne35356:0", - "description": "The title of the footer links column with title=Docs in the footer" - }, - "link.title.Community": { - "message": "crwdns35358:0crwdne35358:0", - "description": "The title of the footer links column with title=Community in the footer" - }, - "link.title.More": { - "message": "crwdns35360:0crwdne35360:0", - "description": "The title of the footer links column with title=More in the footer" - }, - "link.item.label.Introduction": { - "message": "crwdns35362:0crwdne35362:0", - "description": "The label of footer link with label=Introduction linking to /docs/introduction" - }, - "link.item.label.Getting Started": { - "message": "crwdns35364:0crwdne35364:0", - "description": "The label of footer link with label=Getting Started linking to /docs/gettingstarted/installation" - }, - "link.item.label.Changelog": { - "message": "crwdns35366:0crwdne35366:0", - "description": "The label of footer link with label=Changelog linking to /changelog" - }, - "link.item.label.Github": { - "message": "crwdns35368:0crwdne35368:0", - "description": "The label of footer link with label=Github linking to https://github.com/wailsapp/wails" - }, - "link.item.label.Twitter": { - "message": "crwdns35370:0crwdne35370:0", - "description": "The label of footer link with label=Twitter linking to https://twitter.com/wailsapp" - }, - "link.item.label.Slack": { - "message": "crwdns35372:0crwdne35372:0", - "description": "The label of footer link with label=Slack linking to https://gophers.slack.com/messages/CJ4P9F7MZ/" - }, - "link.item.label.Slack invite": { - "message": "crwdns35374:0crwdne35374:0", - "description": "The label of footer link with label=Slack invite linking to https://invite.slack.golangbridge.org/" - }, - "link.item.label.Blog": { - "message": "crwdns35376:0crwdne35376:0", - "description": "The label of footer link with label=Blog linking to /blog" - }, - "copyright": { - "message": "crwdns35378:0crwdne35378:0", - "description": "The footer copyright" - }, - "link.item.label.Awesome": { - "message": "crwdns35380:0crwdne35380:0", - "description": "The label of footer link with label=Awesome linking to https://github.com/wailsapp/awesome-wails" - } -} diff --git a/website/i18n/ach/docusaurus-theme-classic/navbar.json b/website/i18n/ach/docusaurus-theme-classic/navbar.json deleted file mode 100644 index 8a34833f7..000000000 --- a/website/i18n/ach/docusaurus-theme-classic/navbar.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "item.label.Sponsor": { - "message": "crwdns35382:0crwdne35382:0", - "description": "Navbar item with label Sponsor" - }, - "item.label.Docs": { - "message": "crwdns35384:0crwdne35384:0", - "description": "Navbar item with label Docs" - }, - "item.label.Blog": { - "message": "crwdns35386:0crwdne35386:0", - "description": "Navbar item with label Blog" - }, - "item.label.GitHub": { - "message": "crwdns35388:0crwdne35388:0", - "description": "Navbar item with label GitHub" - }, - "item.label.About": { - "message": "crwdns35390:0crwdne35390:0", - "description": "Navbar item with label About" - }, - "item.label.FAQ": { - "message": "crwdns35392:0crwdne35392:0", - "description": "Navbar item with label FAQ" - }, - "item.label.Changelog": { - "message": "crwdns35394:0crwdne35394:0", - "description": "Navbar item with label Changelog" - }, - "item.label.Community Guide": { - "message": "crwdns35396:0crwdne35396:0", - "description": "Navbar item with label Community Guide" - }, - "item.label.Credits": { - "message": "crwdns35398:0crwdne35398:0", - "description": "Navbar item with label Credits" - } -} diff --git a/website/i18n/en/docusaurus-plugin-content-docs/version-v2.0.0-beta.43.json b/website/i18n/en/docusaurus-plugin-content-docs/version-v2.0.0-beta.43.json deleted file mode 100644 index 375e7f9ef..000000000 --- a/website/i18n/en/docusaurus-plugin-content-docs/version-v2.0.0-beta.43.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "version.label": { - "message": "v2.0.0-beta.43", - "description": "The label for version v2.0.0-beta.43" - }, - "sidebar.tutorialSidebar.category.Getting Started": { - "message": "Getting Started", - "description": "The label for category Getting Started in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Reference": { - "message": "Reference", - "description": "The label for category Reference in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Runtime": { - "message": "Runtime", - "description": "The label for category Runtime in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Community": { - "message": "Community", - "description": "The label for category Community in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Showcase": { - "message": "Showcase", - "description": "The label for category Showcase in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Guides": { - "message": "Guides", - "description": "The label for category Guides in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Tutorials": { - "message": "Tutorials", - "description": "The label for category Tutorials in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Contributing": { - "message": "Contributing", - "description": "The label for category Contributing in sidebar tutorialSidebar" - } -} diff --git a/website/i18n/ach/docusaurus-plugin-content-docs/current.json b/website/i18n/en/docusaurus-plugin-content-docs/version-v2.0.0-rc.1.json similarity index 68% rename from website/i18n/ach/docusaurus-plugin-content-docs/current.json rename to website/i18n/en/docusaurus-plugin-content-docs/version-v2.0.0-rc.1.json index bcb11482d..49cf4687e 100644 --- a/website/i18n/ach/docusaurus-plugin-content-docs/current.json +++ b/website/i18n/en/docusaurus-plugin-content-docs/version-v2.0.0-rc.1.json @@ -1,38 +1,38 @@ { "version.label": { - "message": "crwdns35306:0crwdne35306:0", - "description": "The label for version current" + "message": "v2.0.0-rc.1", + "description": "The label for version v2.0.0-rc.1" }, "sidebar.docs.category.Getting Started": { - "message": "crwdns36034:0crwdne36034:0", + "message": "Getting Started", "description": "The label for category Getting Started in sidebar docs" }, "sidebar.docs.category.Reference": { - "message": "crwdns36036:0crwdne36036:0", + "message": "Reference", "description": "The label for category Reference in sidebar docs" }, "sidebar.docs.category.Runtime": { - "message": "crwdns36038:0crwdne36038:0", + "message": "Runtime", "description": "The label for category Runtime in sidebar docs" }, "sidebar.docs.category.Community": { - "message": "crwdns36040:0crwdne36040:0", + "message": "Community", "description": "The label for category Community in sidebar docs" }, "sidebar.docs.category.Showcase": { - "message": "crwdns36042:0crwdne36042:0", + "message": "Showcase", "description": "The label for category Showcase in sidebar docs" }, "sidebar.docs.category.Guides": { - "message": "crwdns36044:0crwdne36044:0", + "message": "Guides", "description": "The label for category Guides in sidebar docs" }, "sidebar.docs.category.Tutorials": { - "message": "crwdns36046:0crwdne36046:0", + "message": "Tutorials", "description": "The label for category Tutorials in sidebar docs" }, "sidebar.docs.link.Contributing": { - "message": "crwdns36360:0crwdne36360:0", + "message": "Contributing", "description": "The label for link Contributing in sidebar docs, linking to /community-guide#ways-of-contributing" } } diff --git a/website/i18n/en/docusaurus-theme-classic/navbar.json b/website/i18n/en/docusaurus-theme-classic/navbar.json index 9288275cd..2fa37c664 100644 --- a/website/i18n/en/docusaurus-theme-classic/navbar.json +++ b/website/i18n/en/docusaurus-theme-classic/navbar.json @@ -34,5 +34,9 @@ "item.label.Credits": { "message": "Credits", "description": "Navbar item with label Credits" + }, + "item.label.Code of Conduct": { + "message": "Code of Conduct", + "description": "Navbar item with label Code of Conduct" } } diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-v2.0.0-beta.43.json b/website/i18n/ja/docusaurus-plugin-content-docs/version-v2.0.0-beta.43.json deleted file mode 100644 index 375e7f9ef..000000000 --- a/website/i18n/ja/docusaurus-plugin-content-docs/version-v2.0.0-beta.43.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "version.label": { - "message": "v2.0.0-beta.43", - "description": "The label for version v2.0.0-beta.43" - }, - "sidebar.tutorialSidebar.category.Getting Started": { - "message": "Getting Started", - "description": "The label for category Getting Started in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Reference": { - "message": "Reference", - "description": "The label for category Reference in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Runtime": { - "message": "Runtime", - "description": "The label for category Runtime in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Community": { - "message": "Community", - "description": "The label for category Community in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Showcase": { - "message": "Showcase", - "description": "The label for category Showcase in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Guides": { - "message": "Guides", - "description": "The label for category Guides in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Tutorials": { - "message": "Tutorials", - "description": "The label for category Tutorials in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Contributing": { - "message": "Contributing", - "description": "The label for category Contributing in sidebar tutorialSidebar" - } -} diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-v2.0.0-rc.1.json b/website/i18n/ja/docusaurus-plugin-content-docs/version-v2.0.0-rc.1.json new file mode 100644 index 000000000..49cf4687e --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-v2.0.0-rc.1.json @@ -0,0 +1,38 @@ +{ + "version.label": { + "message": "v2.0.0-rc.1", + "description": "The label for version v2.0.0-rc.1" + }, + "sidebar.docs.category.Getting Started": { + "message": "Getting Started", + "description": "The label for category Getting Started in sidebar docs" + }, + "sidebar.docs.category.Reference": { + "message": "Reference", + "description": "The label for category Reference in sidebar docs" + }, + "sidebar.docs.category.Runtime": { + "message": "Runtime", + "description": "The label for category Runtime in sidebar docs" + }, + "sidebar.docs.category.Community": { + "message": "Community", + "description": "The label for category Community in sidebar docs" + }, + "sidebar.docs.category.Showcase": { + "message": "Showcase", + "description": "The label for category Showcase in sidebar docs" + }, + "sidebar.docs.category.Guides": { + "message": "Guides", + "description": "The label for category Guides in sidebar docs" + }, + "sidebar.docs.category.Tutorials": { + "message": "Tutorials", + "description": "The label for category Tutorials in sidebar docs" + }, + "sidebar.docs.link.Contributing": { + "message": "Contributing", + "description": "The label for link Contributing in sidebar docs, linking to /community-guide#ways-of-contributing" + } +} diff --git a/website/i18n/ko/docusaurus-plugin-content-docs/version-v2.0.0-beta.38.json b/website/i18n/ko/docusaurus-plugin-content-docs/version-v2.0.0-beta.38.json deleted file mode 100644 index c195ee101..000000000 --- a/website/i18n/ko/docusaurus-plugin-content-docs/version-v2.0.0-beta.38.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "version.label": { - "message": "v2.0.0-beta.38", - "description": "The label for version v2.0.0-beta.38" - }, - "sidebar.tutorialSidebar.category.Getting Started": { - "message": "Getting Started", - "description": "The label for category Getting Started in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Reference": { - "message": "Reference", - "description": "The label for category Reference in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Runtime": { - "message": "Runtime", - "description": "The label for category Runtime in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Community": { - "message": "Community", - "description": "The label for category Community in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Showcase": { - "message": "Showcase", - "description": "The label for category Showcase in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Guides": { - "message": "Guides", - "description": "The label for category Guides in sidebar tutorialSidebar" - } -} diff --git a/website/i18n/ko/docusaurus-plugin-content-docs/version-v2.0.0-beta.39.json b/website/i18n/ko/docusaurus-plugin-content-docs/version-v2.0.0-beta.39.json deleted file mode 100644 index 50826a275..000000000 --- a/website/i18n/ko/docusaurus-plugin-content-docs/version-v2.0.0-beta.39.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "version.label": { - "message": "v2.0.0-beta.39", - "description": "The label for version v2.0.0-beta.39" - }, - "sidebar.tutorialSidebar.category.Getting Started": { - "message": "Getting Started", - "description": "The label for category Getting Started in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Reference": { - "message": "Reference", - "description": "The label for category Reference in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Runtime": { - "message": "Runtime", - "description": "The label for category Runtime in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Community": { - "message": "Community", - "description": "The label for category Community in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Showcase": { - "message": "Showcase", - "description": "The label for category Showcase in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Guides": { - "message": "Guides", - "description": "The label for category Guides in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Tutorials": { - "message": "Tutorials", - "description": "The label for category Tutorials in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Contributing": { - "message": "Contributing", - "description": "The label for category Contributing in sidebar tutorialSidebar" - } -} diff --git a/website/i18n/ko/docusaurus-plugin-content-docs/version-v2.0.0-beta.43.json b/website/i18n/ko/docusaurus-plugin-content-docs/version-v2.0.0-beta.43.json deleted file mode 100644 index 71885c03f..000000000 --- a/website/i18n/ko/docusaurus-plugin-content-docs/version-v2.0.0-beta.43.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "version.label": { - "message": "v2.0.0-beta.43", - "description": "The label for version v2.0.0-beta.43" - }, - "sidebar.tutorialSidebar.category.Getting Started": { - "message": "시작하기", - "description": "The label for category Getting Started in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Reference": { - "message": "참조", - "description": "The label for category Reference in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Runtime": { - "message": "런타임", - "description": "The label for category Runtime in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Community": { - "message": "커뮤니티", - "description": "The label for category Community in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Showcase": { - "message": "쇼케이스", - "description": "The label for category Showcase in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Guides": { - "message": "가이드", - "description": "The label for category Guides in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Tutorials": { - "message": "튜토리얼", - "description": "The label for category Tutorials in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Contributing": { - "message": "기여", - "description": "The label for category Contributing in sidebar tutorialSidebar" - } -} diff --git a/website/i18n/ko/docusaurus-plugin-content-docs/version-v2.0.0-rc.1.json b/website/i18n/ko/docusaurus-plugin-content-docs/version-v2.0.0-rc.1.json new file mode 100644 index 000000000..49cf4687e --- /dev/null +++ b/website/i18n/ko/docusaurus-plugin-content-docs/version-v2.0.0-rc.1.json @@ -0,0 +1,38 @@ +{ + "version.label": { + "message": "v2.0.0-rc.1", + "description": "The label for version v2.0.0-rc.1" + }, + "sidebar.docs.category.Getting Started": { + "message": "Getting Started", + "description": "The label for category Getting Started in sidebar docs" + }, + "sidebar.docs.category.Reference": { + "message": "Reference", + "description": "The label for category Reference in sidebar docs" + }, + "sidebar.docs.category.Runtime": { + "message": "Runtime", + "description": "The label for category Runtime in sidebar docs" + }, + "sidebar.docs.category.Community": { + "message": "Community", + "description": "The label for category Community in sidebar docs" + }, + "sidebar.docs.category.Showcase": { + "message": "Showcase", + "description": "The label for category Showcase in sidebar docs" + }, + "sidebar.docs.category.Guides": { + "message": "Guides", + "description": "The label for category Guides in sidebar docs" + }, + "sidebar.docs.category.Tutorials": { + "message": "Tutorials", + "description": "The label for category Tutorials in sidebar docs" + }, + "sidebar.docs.link.Contributing": { + "message": "Contributing", + "description": "The label for link Contributing in sidebar docs, linking to /community-guide#ways-of-contributing" + } +} diff --git a/website/i18n/ru/docusaurus-plugin-content-docs/version-v2.0.0-beta.43.json b/website/i18n/ru/docusaurus-plugin-content-docs/version-v2.0.0-beta.43.json deleted file mode 100644 index 375e7f9ef..000000000 --- a/website/i18n/ru/docusaurus-plugin-content-docs/version-v2.0.0-beta.43.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "version.label": { - "message": "v2.0.0-beta.43", - "description": "The label for version v2.0.0-beta.43" - }, - "sidebar.tutorialSidebar.category.Getting Started": { - "message": "Getting Started", - "description": "The label for category Getting Started in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Reference": { - "message": "Reference", - "description": "The label for category Reference in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Runtime": { - "message": "Runtime", - "description": "The label for category Runtime in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Community": { - "message": "Community", - "description": "The label for category Community in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Showcase": { - "message": "Showcase", - "description": "The label for category Showcase in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Guides": { - "message": "Guides", - "description": "The label for category Guides in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Tutorials": { - "message": "Tutorials", - "description": "The label for category Tutorials in sidebar tutorialSidebar" - }, - "sidebar.tutorialSidebar.category.Contributing": { - "message": "Contributing", - "description": "The label for category Contributing in sidebar tutorialSidebar" - } -} diff --git a/website/i18n/ru/docusaurus-plugin-content-docs/version-v2.0.0-rc.1.json b/website/i18n/ru/docusaurus-plugin-content-docs/version-v2.0.0-rc.1.json new file mode 100644 index 000000000..49cf4687e --- /dev/null +++ b/website/i18n/ru/docusaurus-plugin-content-docs/version-v2.0.0-rc.1.json @@ -0,0 +1,38 @@ +{ + "version.label": { + "message": "v2.0.0-rc.1", + "description": "The label for version v2.0.0-rc.1" + }, + "sidebar.docs.category.Getting Started": { + "message": "Getting Started", + "description": "The label for category Getting Started in sidebar docs" + }, + "sidebar.docs.category.Reference": { + "message": "Reference", + "description": "The label for category Reference in sidebar docs" + }, + "sidebar.docs.category.Runtime": { + "message": "Runtime", + "description": "The label for category Runtime in sidebar docs" + }, + "sidebar.docs.category.Community": { + "message": "Community", + "description": "The label for category Community in sidebar docs" + }, + "sidebar.docs.category.Showcase": { + "message": "Showcase", + "description": "The label for category Showcase in sidebar docs" + }, + "sidebar.docs.category.Guides": { + "message": "Guides", + "description": "The label for category Guides in sidebar docs" + }, + "sidebar.docs.category.Tutorials": { + "message": "Tutorials", + "description": "The label for category Tutorials in sidebar docs" + }, + "sidebar.docs.link.Contributing": { + "message": "Contributing", + "description": "The label for link Contributing in sidebar docs, linking to /community-guide#ways-of-contributing" + } +} diff --git a/website/i18n/zh-Hans/code.json b/website/i18n/zh-Hans/code.json index cc56b491b..ce08c5b09 100644 --- a/website/i18n/zh-Hans/code.json +++ b/website/i18n/zh-Hans/code.json @@ -242,7 +242,7 @@ "description": "The label used by the button on the collapsible TOC component" }, "theme.navbar.mobileLanguageDropdown.label": { - "message": "选择语言", + "message": "语言", "description": "The label for the mobile language switcher dropdown" }, "theme.SearchBar.seeAll": { diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-blog/2021-09-27-v2-beta1-release-notes.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-blog/2021-09-27-v2-beta1-release-notes.mdx index 5c95df3ec..dc86462b9 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-blog/2021-09-27-v2-beta1-release-notes.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-blog/2021-09-27-v2-beta1-release-notes.mdx @@ -8,6 +8,7 @@ tags: - v2 --- +```mdx-code-block
-
+``` -两年多前,在悉尼的火车上,当我第一次在 Reddit 宣布 Wails 时,我没想到它会引起太多关注。 几天后,一位多产的科技视频博主发布了一个教程视频,并给予了正面评价,从那时起,人们对该项目的兴趣猛增。 +两年多前,在悉尼的火车上,当我第一次在 Reddit 上宣布 Wails 时,我没想到它会引起太多关注。 几天后,一位多产的科技视频博主发布了一个教程视频,并给予了正面评价,从那时起,人们对该项目的兴趣猛增。 很明显,人们对将 Web 前端添加到他们的 Go 项目感到兴奋,几乎立即将项目推动到超出我创建这个项目的设想。 当时,Wails 使用 [webview](https://github.com/webview/webview) 项目来处理前端, Windows 的唯一选择是 IE11 渲染器。 许多错误报告都因为受到它的限制:糟糕的 JavaScript/CSS 支持并且没有开发工具来调试它。 这是一段令人沮丧的开发经历,但我们也没有采取什么措施去纠正它。 @@ -28,10 +29,11 @@ tags: ### 没有 CGO 依赖 -不,我不是在开玩笑:*没有 CGO 依赖*🤯! Windows 的问题在于,与 MacOS 和 Linux 不同,它没有默认编译器。 此外,CGO 需要一个 mingw 编译器,并且有大量不同的安装选项。 删除 CGO 的要求大大简化了设置,并使调试变得非常容易。 虽然我已经付出了相当多的努力来完成这项工作,但大部分功劳应该归功于[John Chadwick](https://github.com/jchv),他不仅启动了几个项目使这成为可能, 而且还对接受这些项目并以此为基础的人持开放态度。 还要归功于[Tad Vizbaras](https://github.com/tadvi),他的[winc](https://github.com/tadvi/winc)项目让我走上了这条道路。 +不,我不是在开玩笑:_没有 CGO 依赖_🤯! Windows 的问题在于,与 MacOS 和 Linux 不同,它没有默认编译器。 此外,CGO 需要一个 mingw 编译器,并且有大量不同的安装选项。 删除 CGO 的要求大大简化了设置,并使调试变得非常容易。 虽然我已经付出了相当多的努力来完成这项工作,但大部分功劳应该归功于[John Chadwick](https://github.com/jchv),他不仅启动了几个项目使这成为可能, 而且还对接受这些项目并以此为基础的人持开放态度。 还要感谢[Tad Vizbaras](https://github.com/tadvi),他的[winc](https://github.com/tadvi/winc)项目让我走上了这条道路。 ### WebView2 Chromium 渲染引擎 +```mdx-code-block
-
+``` 最终,Windows 开发人员为他们的应用程序获得了一流的渲染引擎! 扭曲前端代码以在 Windows 上工作的日子已经一去不复返了。 最重要的是,您将获得一流的开发者工具体验! 但是,WebView2 组件确实需要将其放置`WebView2Loader.dll`在二进制文件旁边。 这使得分发比我们 gophers 习惯的更痛苦。 所有使用 WebView2 的解决方案和库(我知道的)都具有这种依赖性。 -然而,我真的很高兴地宣布,Wails 应用程序*没有这样的要求*! 感谢[John Chadwick](https://github.com/jchv)的魔法,我们能够将这个 dll 打包在二进制文件中,并让 Windows 加载它,就像它存在于磁盘上一样。 +然而,我真的很高兴地宣布,Wails 应用程序_没有这样的要求_! 感谢[John Chadwick](https://github.com/jchv)的魔法,我们能够将这个 dll 打包在二进制文件中,并让 Windows 加载它,就像它存在于磁盘上一样。 Gophers 欢呼吧! 单个二进制文件的构想依然存在! ### 新功能 +```mdx-code-block
-
+``` 有很多对原生菜单支持的请求。 Wails 终于帮您搞定了。 应用程序菜单现已可用,并且包括对大多数原生菜单功能的支持。 这包括标准菜单项、复选框、单选组、子菜单和分隔符。 @@ -68,6 +71,7 @@ Gophers 欢呼吧! 单个二进制文件的构想依然存在! 现在可以选择随项目生成 IDE 配置。 这意味着如果您在受支持的 IDE 中打开您的项目,它已经被配置为构建和调试您的应用程序。 目前支持 VSCode,但我们希望尽快支持其他 IDE,例如 Goland。 +```mdx-code-block
- -
+
+``` ### 无需打包资源 @@ -92,6 +96,7 @@ v1 的一个巨大痛点是需要将整个应用程序压缩为单个 JS 和 CSS ### 全新的开发体验 +```mdx-code-block
-
+``` 现在不需要打包资源,它启用了全新的开发体验。 新`wails dev`命令将构建并运行您的应用程序,但它不使用`embed.FS`中的资源,而是直接从磁盘加载它们。 @@ -117,6 +122,7 @@ v1 的一个巨大痛点是需要将整个应用程序压缩为单个 JS 和 CSS ### 远程模板 +```mdx-code-block
-
+``` 让应用程序快速启动并运行一直是 Wails 项目的一个关键目标。 当我们推出时,我们试图涵盖当时的很多现代框架:react、vue 和 angular。 前端开发的世界非常固执己见,发展迅速,很难保持领先地位! 这也意味着,我们没有为最新和最伟大的技术栈提供酷炫的现代模板。 这也意味着,我们没有为最新和最伟大的技术栈提供酷炫的现代模板。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-blog/2021-11-08-v2-beta2-release-notes.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-blog/2021-11-08-v2-beta2-release-notes.mdx index 21061e0b4..98bcde022 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-blog/2021-11-08-v2-beta2-release-notes.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-blog/2021-11-08-v2-beta2-release-notes.mdx @@ -8,6 +8,7 @@ tags: - v2 --- +```mdx-code-block
-
+``` 今天是 Mac 版 Wails v2 的第一个测试版! 花了很长时间才走到这一步,我希望今天的版本会给你一些相当有用的东西。 为了达到这一点,经历了许多曲折,我希望在您的帮助下,消除问题并为最终的 v2 版本完善 Mac 端口。 @@ -24,8 +25,9 @@ tags: 那么 Mac 版 Wails v2 与 v1 有哪些新变化? 提示:它与 Windows Beta 非常相似 😉 -### 新特性 +### 新功能 +```mdx-code-block
-
+``` -有很多对原生菜单支持的需求。 Wails 终于帮您搞定了。 应用程序菜单现已可用,并且包括对大多数本原生菜单功能的支持。 这包括标准菜单项、复选框、单选组、子菜单和分隔符。 +有很多对原生菜单支持的请求。 Wails 终于帮您搞定了。 应用程序菜单现已可用,并且包括对大多数原生菜单功能的支持。 这包括标准菜单项、复选框、单选组、子菜单和分隔符。 -在 v1 中有大量的需求,要求能够更好地控制窗口本身。 我很高兴地宣布,有专门用于此的新运行时 API。 它功能丰富,支持多显示器配置。 还有一个改进的对话框 API:现在,您可以拥有具有丰富配置的现代原生对话框,以满足您所有的对话框需求。 +在 v1 中有大量的请求,要求能够更好地控制窗口本身。 我很高兴地宣布,有专门用于此的新运行时 API。 它功能丰富,支持多显示器配置。 还有一个改进的对话框 API:现在,您可以拥有具有丰富配置的现代原生对话框,以满足您的所有对话框需求。 ### Mac 特定选项 @@ -78,6 +80,7 @@ v1 的一个巨大痛点是需要将整个应用程序压缩为单个 JS 和 CSS ### 远程模板 +```mdx-code-block
-
+``` 让应用程序快速启动并运行一直是 Wails 项目的一个关键目标。 当我们推出时,我们试图涵盖当时的很多现代框架:react、vue 和 angular。 前端开发的世界非常固执己见,发展迅速,很难保持领先地位! 这也意味着,我们没有为最新和最伟大的技术栈提供酷炫的现代模板。 这也意味着,我们没有为最新和最伟大的技术栈提供酷炫的现代模板。 @@ -96,6 +99,7 @@ v1 的一个巨大痛点是需要将整个应用程序压缩为单个 JS 和 CSS 感谢[Mat Ryer](https://github.com/matryer/)的惊人支持,Wails 项目现在支持 M1 原生构建: +```mdx-code-block
-
+``` 您也可以指定`darwin/amd64`为目标: +```mdx-code-block
-
+``` 哦,我差点忘了....你也可以做`darwin/universal`....😉 +```mdx-code-block
-
+``` ### 交叉编译到 Windows 因为 Windows 的 Wails v2 是纯 Go,所以你可以在没有 docker 的情况下针对 Windows 构建。 +```mdx-code-block
-
+``` ### WKWebView 渲染器 @@ -150,7 +157,7 @@ V1 依赖于 WebView(现已弃用)组件。 V2 使用最新的 WKWebKit 组 ### 结语 -正如我在 Windows 发行说明中所说,Wails v2 代表了该项目的新起点。 此版本的目的是获得有关新方式的反馈,并在完整版本发布之前解决所有错误。 非常欢迎您的意见! 请将任何反馈发送到[v2 测试版](https://github.com/wailsapp/wails/discussions/828)讨论板。 +正如我在 Windows 发行说明中所说,Wails v2 代表了该项目的新起点。 此版本的目的是获得有关新方式的反馈,并在完整版本发布之前解决所有错误。 非常欢迎您的意见! 请直接反馈到 [v2 测试版](https://github.com/wailsapp/wails/discussions/828)讨论板。 最后,我还要特别感谢包括[JetBrains](https://www.jetbrains.com?from=Wails)在内的所有项目[赞助商](/credits#sponsors),他们的幕后支持以多种方式推动了该项目。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-blog/2022-02-22-v2-beta3-release-notes.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-blog/2022-02-22-v2-beta3-release-notes.mdx index b7fa4f173..7cd186157 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-blog/2022-02-22-v2-beta3-release-notes.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-blog/2022-02-22-v2-beta3-release-notes.mdx @@ -8,6 +8,7 @@ tags: - v2 --- +```mdx-code-block
-
+``` 我很高兴终于宣布,Wails v2 现在处于 Linux 测试版中! 有点讽刺的是,v2 的第一次实验是在 Linux 上进行的,但它最终成为了最后一个版本。 话虽如此,我们今天拥有的 v2 与最初的实验非常不同。 因此,事不宜迟,让我们回顾一下新功能: ### 新功能 +```mdx-code-block
-
+``` -有很多对原生菜单支持的需求。 Wails 终于帮您搞定了。 应用程序菜单现已可用,并且包括对大多数本原生菜单功能的支持。 这包括标准菜单项、复选框、单选组、子菜单和分隔符。 +有很多对原生菜单支持的请求。 Wails 终于帮您搞定了。 应用程序菜单现已可用,并且包括对大多数原生菜单功能的支持。 这包括标准菜单项、复选框、单选组、子菜单和分隔符。 -在 v1 中有大量的需求,要求能够更好地控制窗口本身。 我很高兴地宣布,有专门用于此的新运行时 API。 它功能丰富,支持多显示器配置。 还有一个改进的对话框 API:现在,您可以拥有具有丰富配置的现代原生对话框,以满足您所有的对话框需求。 +在 v1 中有大量的请求,要求能够更好地控制窗口本身。 我很高兴地宣布,有专门用于此的新运行时 API。 它功能丰富,支持多显示器配置。 还有一个改进的对话框 API:现在,您可以拥有具有丰富配置的现代原生对话框,以满足您的所有对话框需求。 ### 无需打包资源 @@ -65,6 +67,7 @@ v1 的一个巨大痛点是需要将整个应用程序压缩为单个 JS 和 CSS ### 远程模板 +```mdx-code-block
-
+``` 让应用程序快速启动并运行一直是 Wails 项目的一个关键目标。 当我们推出时,我们试图涵盖当时的很多现代框架:react、vue 和 angular。 前端开发的世界非常固执己见,发展迅速,很难保持领先地位! 这也意味着,我们没有为最新和最伟大的技术栈提供酷炫的现代模板。 这也意味着,我们没有为最新和最伟大的技术栈提供酷炫的现代模板。 @@ -81,21 +84,22 @@ v1 的一个巨大痛点是需要将整个应用程序压缩为单个 JS 和 CSS ### 交叉编译到 Windows -因为适用于 Windows 的 Wails v2 是纯 Go,所以您可以在没有 docker 的情况下针对 Windows 构建。 +因为 Windows 的 Wails v2 是纯 Go,所以你可以在没有 docker 的情况下针对 Windows 构建。 +```mdx-code-block
-
+``` ### 结语 -正如我在 Windows 发行说明中所说,Wails v2 代表了该项目的新起点。 此版本的目的是获得有关新方式的反馈,并在完整版本发布之前解决所有错误。 非常欢迎您的意见! 请将任何反馈发送到[v2 测试版](https://github.com/wailsapp/wails/discussions/828)讨论板。 +正如我在 Windows 发行说明中所说,Wails v2 代表了该项目的新起点。 此版本的目的是获得有关新方式的反馈,并在完整版本发布之前解决所有错误。 非常欢迎您的意见! 请直接反馈到 [v2 测试版](https://github.com/wailsapp/wails/discussions/828)讨论板。 Linux**很难**支持。 我们预计测试版会有一些小毛病。 请通过提交详细的错误报告来帮助我们帮助您! diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-blog/authors.yml b/website/i18n/zh-Hans/docusaurus-plugin-content-blog/authors.yml index 25bd8097b..9415d5c27 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-blog/authors.yml +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-blog/authors.yml @@ -4,7 +4,7 @@ leaanthony: url: https://github.com/leaanthony image_url: https://github.com/leaanthony.png misitebao: - name: 米司特包 + name: Misite Bao title: 架构师 url: https://github.com/misitebao image_url: https://github.com/misitebao.png diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/links.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/links.mdx index 90c365a3d..b62a6f2ee 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/links.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/links.mdx @@ -4,13 +4,13 @@ sidebar_position: 2 # 链接 -此页面用于列出社区相关的链接。 请提交 PR(点击页面底部的`编辑此页`)增加链接。 +此页面用于列出社区相关的链接。 请提交 PR(点击页面底部的 `编辑此页`)增加链接。 -## 了不起的 Wails +## Awesome Wails -Wails 相关的[优秀列表](https://github.com/wailsapp/awesome-wails)。 +Wails 相关的 [优秀列表](https://github.com/wailsapp/awesome-wails)。 -## 支持的通道 +## 支持的频道 - [Gophers Slack Channel](https://gophers.slack.com/messages/CJ4P9F7MZ/) - [Gophers Slack Channel Invite](https://invite.slack.golangbridge.org/) diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/emailit.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/emailit.mdx index 4a1ebe835..04150ba28 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/emailit.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/emailit.mdx @@ -1,8 +1,10 @@ # EmailIt +```mdx-code-block


+``` [EmailIt](https://github.com/raguay/EmailIt/) is a Wails 2 program that is a markdown based email sender only with nine notepads, scripts to manipulate the text, and templates. It also has a builtin [Node-Red](https://nodered.org/) server, scripts terminal, and the [ScriptBar](https://github.com/raguay/ScriptBarApp) program for displaying results from Node-Red or a script on your system. Documentation is very scarce, but the programs works. It’s built using Wails2 and Svelte, and the download is a universal macOS application. diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/encrypteasy.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/encrypteasy.mdx index 9b2e5f8ac..7504950ea 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/encrypteasy.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/encrypteasy.mdx @@ -1,10 +1,12 @@ # EncryptEasy +```mdx-code-block


+``` -**[cryptEasy](https://www.encrypteasy.app) 是一个管理您和您所有的联系人密钥的简单易用的 PGP 加密工具。 加密应该是简单的。 使用Wails开发。** +**[EncryptEasy](https://www.encrypteasy.app) is a simple and easy to use PGP encryption tool, managing all your and your contacts keys. Encryption should be simple. Developed with Wails.** Encrypting messages using PGP is the industry standard. Everyone has a private and a public key. Your private key, well, needs to be kept private so only you can read messages. Your public key is distributed to anyone who wants to send you secret, encrypted messages. Managing keys, encrypting messages and decrypting messages should be a smooth experience. EncryptEasy is all about making it easy. diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/filehound.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/filehound.mdx index 78cbfca86..134365aaf 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/filehound.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/filehound.mdx @@ -1,9 +1,11 @@ # FileHound Export Utility +```mdx-code-block


+``` [FileHound Export Utility](https://www.filehound.co.uk/) FileHound is a cloud document management platform made for secure file retention, business process automation and SmartCapture capabilities. diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/minecraftupdater.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/minecraftupdater.mdx index 11247339d..2f6c7c72b 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/minecraftupdater.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/minecraftupdater.mdx @@ -1,10 +1,14 @@ # Minecraft Updater +```mdx-code-block


+``` [Minecraft Updater](https://github.com/Gurkengewuerz/MinecraftModUpdater) is a utility tool to update and synchronize Minecraft mods for your userbase. It’s built using Wails2 and React with [antd](https://ant.design/) as frontend framework. diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/modalfilemanager.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/modalfilemanager.mdx index a7ae8c492..f8e2bcd66 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/modalfilemanager.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/modalfilemanager.mdx @@ -1,11 +1,13 @@ # Modal File Manager +```mdx-code-block


+``` [Modal File Manager](https://github.com/raguay/ModalFileManager) is a dual pane file manager using web technologies. My original design was based on NW.js and can be found [here](https://github.com/raguay/ModalFileManager-NWjs). This version uses the same Svelte based frontend code (but it has be greatly modified since the departure from NW.js), but the backend is a [Wails 2](https://wails.io/) implementation. By using this implementation, I no longer use command line `rm`, `cp`, etc. commands. It is fully coded using Go and runs much faster than the previous versions. diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/mollywallet.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/mollywallet.mdx index 534b097ca..5d846d06d 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/mollywallet.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/mollywallet.mdx @@ -1,8 +1,10 @@ # Molley Wallet +```mdx-code-block


+``` [Molly Wallet](https://github.com/grvlle/constellation_wallet/) the official $DAG wallet of the Constellation Network. It'll let users interact with the Hypergraph Network in various ways, not limited to producing $DAG transactions. diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/october.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/october.mdx index 889d2dd9e..66d634dc5 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/october.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/october.mdx @@ -1,9 +1,11 @@ # October +```mdx-code-block


+``` [October](https://october.utf9k.net) is a small Wails application that makes it really easy to extract highlights from [Kobo eReaders](https://en.wikipedia.org/wiki/Kobo_eReader) and then forward them to [Readwise](https://readwise.io). diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/optimus.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/optimus.mdx index c3eb79507..4f87479d6 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/optimus.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/optimus.mdx @@ -1,8 +1,10 @@ # Optimus +```mdx-code-block


+``` [Optimus](https://github.com/splode/optimus) is a desktop image optimization application. It supports conversion and compression between WebP, JPEG, and PNG image formats. diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/portfall.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/portfall.mdx index 4cc2c63c9..03e740f4c 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/portfall.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/portfall.mdx @@ -1,8 +1,10 @@ # Portfall +```mdx-code-block


+``` [Portfall](https://github.com/rekon-oss/portfall) - A desktop k8s port-forwarding portal for easy access to all your cluster UIs diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/restic-browser.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/restic-browser.mdx index 1505ce07a..3646384ec 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/restic-browser.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/restic-browser.mdx @@ -1,10 +1,12 @@ # Restic Browser +```mdx-code-block


+``` [Restic-Browser](https://github.com/emuell/restic-browser) - A simple, cross-platform [restic](https://github.com/restic/restic) backup GUI for browsing and restoring restic repositories. diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/riftshare.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/riftshare.mdx index 5223e88cf..6224bbf89 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/riftshare.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/riftshare.mdx @@ -1,13 +1,15 @@ # RiftShare +```mdx-code-block


+``` Easy, Secure, and Free file sharing for everyone. Learn more at [Riftshare.app](https://riftshare.app) -## Features +## 功能 - Easy secure file sharing between computers both in the local network and through the internet - Supports sending files or directories securely through the [magic wormhole protocol](https://magic-wormhole.readthedocs.io/en/latest/) diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/scriptbar.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/scriptbar.mdx index aaa556f92..2ccb2acb4 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/scriptbar.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/scriptbar.mdx @@ -1,8 +1,10 @@ # ScriptBar +```mdx-code-block


+``` [ScriptBar](https://GitHub.com/raguay/ScriptBarApp) is a program to show the output of the embedded [Node-Red](https://nodered.org) server in the [EmailIt](https://GitHub.com/raguay/EmailIt) application. It also displays the output of scripts on your system. ScriptBar doesn't put them in the menubar, but has them all in a convient window for easy viewing. You can have multiple tabs to have many different things show. You can also keep the links to your most visited web sites. diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/surge.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/surge.mdx index 2d895dc29..c3b3fb4c0 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/surge.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/surge.mdx @@ -1,8 +1,10 @@ # Surge +```mdx-code-block


+``` [Surge](https://getsurge.io/) is a p2p filesharing app designed to utilize blockchain technologies to enable 100% anonymous file transfers. Surge is end-to-end encrypted, decentralized and open source. diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/wally.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/wally.mdx index 2a2498f40..7408aa585 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/wally.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/wally.mdx @@ -1,8 +1,10 @@ # Wally +```mdx-code-block


+``` [Wally](https://ergodox-ez.com/pages/wally) is the official firmware flasher for [Ergodox](https://ergodox-ez.com/) keyboards. It looks great and is a fantastic example of what you can achieve with Wails: the ability to combine the power of Go and the rich graphical tools of the web development world. diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/wombat.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/wombat.mdx index 54cedacea..f100c55e2 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/wombat.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/wombat.mdx @@ -1,8 +1,10 @@ # Wombat +```mdx-code-block


+``` [Wombat](https://github.com/rogchap/wombat) is a cross platform gRPC client. diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/ytd.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/ytd.mdx index 178ff0529..5db428f72 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/ytd.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/showcase/ytd.mdx @@ -1,8 +1,10 @@ # Ytd +```mdx-code-block


+``` [Ytd](https://github.com/marcio199226/ytd/tree/v2-wails) is an app for downloading tracks from youtube, creating offline playlists and share them with your friends, your friends will be able to playback your playlists or download them for offline listening, has an built-in player. diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/templates.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/templates.mdx index 8b98f7115..08126dcea 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/templates.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/community/templates.mdx @@ -4,22 +4,24 @@ sidebar_position: 1 # 模板 -此页面用作社区支持的模板列表。 请提交一个包含您的模板的 PR(点击页面底部的`编辑此页`)。 要构建您自己的模板,请参考[模板](../guides/templates)指南。 +此页面用作社区支持的模板列表。 请提交一个包含您的模板的 PR(点击页面底部的 `编辑此页`)。 要构建您自己的模板,请参考 [模板](../guides/templates) 指南。 要使用这些模板,请运行 `wails init -n "您的项目名" -t [下面的链接[@版本]]` -如果不带版本后缀,默认使用的是主分支代码模板,如果带有版本后缀,则使用该版本对应标签的代码模板。 If there is a version suffix, the code template corresponding to the tag of this version is used. +如果不带版本后缀,默认使用的是主分支代码模板。 如果带有版本后缀,则使用该版本对应标签的代码模板。 -示例:`wails init -n "Your Project Name" -t https://github.com/misitebao/wails-template-vue@v2.0.0-beta.3` +示例:`wails init -n "Your Project Name" -t https://github.com/misitebao/wails-template-vue` :::warning 注意 + **Wails 项目不维护也不对第 3 方模板负责** 如果您不确定某个模板,请检查 `package.json`和`wails.json` 中安装的模块和运行的脚本。 ::: + ## Vue - [wails-template-vue](https://github.com/misitebao/wails-template-vue) - 基于 Vite、Vue 和 Vue-Router 的 Wails 模板(同时支持 JavaScript 和 TypeScript) @@ -45,8 +47,8 @@ sidebar_position: 1 ## Elm -- [wails-elm-template](https://github.com/benjamin-thomas/wails-elm-template) - Develop your GUI app with functional programming and a **snappy** hot-reload setup :tada: :rocket: +- [wails-elm-template](https://github.com/benjamin-thomas/wails-elm-template) - 使用函数式编程和 **快速** 的热重载设置开发您的 GUI 应用程序 :tada: :rocket: ## Pure JavaScript (Vanilla) -- [wails-pure-js-template](https://github.com/KiddoV/wails-pure-js-template) - A template with nothing but just basic JavaScript, HTML, and CSS \ No newline at end of file +- [wails-pure-js-template](https://github.com/KiddoV/wails-pure-js-template) - 一个只有基本 JavaScript、HTML 和 CSS 的模板 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/building.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/building.mdx index 38bf5d47d..c4fe879bc 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/building.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/building.mdx @@ -4,10 +4,11 @@ sidebar_position: 6 # 编译您的项目 -从项目目录,运行`wails build`。 这将编译您的项目并将构建的可用于生产的二进制文件保存在 `build/bin` 目录中。 +从项目目录,运行 `wails build`。 这将编译您的项目并将构建的可用于生产的二进制文件保存在 `build/bin` 目录中。 如果您运行二进制文件,您应该会看到默认应用程序: +```mdx-code-block
-
+``` -有关编译选项的更多详细信息,请参阅[构建命令](../reference/cli#构建)。 +有关编译选项的更多详细信息,请参阅 [构建命令](../reference/cli#构建)。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/development.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/development.mdx index a9e165543..f64a342bd 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/development.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/development.mdx @@ -4,13 +4,13 @@ sidebar_position: 5 # 开发您的应用程序 -您可以通过运行`wails dev`从项目目录在开发模式下运行您的应用程序。 这将执行以下操作: +您可以通过从项目目录运行 `wails dev` 在开发模式下运行您的应用程序。 这将执行以下操作: - 构建您的应用程序并运行它 -- 监听 Go 文件中的修改并在更改时重新构建/重新运行 -- Using the power of [vite](https://vitejs.dev/), will watch for modifications in your Go files and rebuild/re-run on change -- 设置将通过浏览器为您的应用程序提供服务的[网络服务器](http://localhost:34115)。 这允许您使用您喜欢的浏览器扩展。 您甚至可以从控制台调用 Go 代码。 +- 将您的 Go 代码绑定到前端,以便可以从 Javascript 调用它 +- 使用 [vite](https://vitejs.dev/) 的强大功能,将监视您的 Go 文件中的修改并在更改时重新构建/重新运行 +- 启动一个 [网络服务器](http://localhost:34115) 通过浏览器为您的应用程序提供服务。 这使您可以使用自己喜欢的浏览器扩展。你甚至可以从控制台调用你的 Go 代码。 您甚至可以从控制台调用 Go 代码。 -首先,在项目目录中运行`wails dev`。 可以在[此处](../reference/cli#开发)找到有关这方面的更多信息。 +首先,在项目目录中运行 `wails dev`。 可以在 [此处](../reference/cli#开发) 找到有关这方面的更多信息。 即将提供:教程 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/firstproject.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/firstproject.mdx index e43d5f7d1..3c22691b7 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/firstproject.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/firstproject.mdx @@ -6,12 +6,11 @@ sidebar_position: 2 ## 项目生成 -现在 CLI 已安装,您可以使用`wails init`命令生成一个新项目。 +现在 CLI 已安装,您可以使用 `wails init` 命令生成一个新项目。 选择您最喜欢的框架: - - +```mdx-code-block import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; @@ -19,80 +18,81 @@ import TabItem from "@theme/TabItem"; defaultValue="Svelte" values={[ {label: "Svelte", value: "Svelte"}, - {label: "React", value: "React"}, - {label: "Vue", value: "Vue"}, - {label: "Preact", value: "Preact"}, - {label: "Lit", value: "Lit"}, - {label: "Vanilla", value: "Vanilla"}, - ]} + {label: "React", value: "React"}, + {label: "Vue", value: "Vue"}, + {label: "Preact", value: "Preact"}, + {label: "Lit", value: "Lit"}, + {label: "Vanilla", value: "Vanilla"}, + ]} > - Generate a Svelte project using Javascript with:

+ 使用 Javascript 生成一个 Svelte 项目:

wails init -n myproject -t svelte -If you would rather use Typescript:
+ +如果您更愿意使用 Typescript:
wails init -n myproject -t svelte-ts
- Generate a React project using Javascript with:

+ 使用 Javascript 生成一个 React 项目:

wails init -n myproject -t react -If you would rather use Typescript:
+ +如果您更愿意使用 Typescript:
wails init -n myproject -t react-ts
- Generate a Vue project using Javascript with:

+ 使用 Javascript 生成一个 Vue 项目:

wails init -n myproject -t vue -If you would rather use Typescript:
+如果您更愿意使用 Typescript:
wails init -n myproject -t vue-ts
- Generate a Preact project using Javascript with:

+ 使用 Javascript 生成一个 Preact 项目:

wails init -n myproject -t preact -If you would rather use Typescript:
+如果您更愿意使用 Typescript:
wails init -n myproject -t preact-ts
- Generate a Lit project using Javascript with:

+ 使用 Javascript 生成一个 Lit 项目:

wails init -n myproject -t lit -If you would rather use Typescript:
+如果您更愿意使用 Typescript:
wails init -n myproject -t lit-ts
- Generate a Vanilla project using Javascript with:

+ 使用 Javascript 生成一个 Vanilla 项目:

wails init -n myproject -t vanilla -If you would rather use Typescript:
+如果您更愿意使用 Typescript:
wails init -n myproject -t vanilla-ts
- - +```
-Wails 项目具有以下布局: +还有提供不同功能和框架的 [社区模板](../community/templates.mdx)。 -要查看其他可用选项,您可以运行 `wails init -help`。 更多详细信息可以在 [初始化命令](../reference/cli#初始化)中找到。 +要查看其他可用选项,您可以运行 `wails init -help`。 更多详细信息可以在 [初始化命令](../reference/cli#初始化) 中找到。 ## 项目布局 @@ -100,8 +100,6 @@ Wails 项目有以下布局: ``` . -. -. ├── build/ │ ├── appicon.png │ ├── darwin/ @@ -118,15 +116,15 @@ Wails 项目有以下布局: - `/main.go` - 主应用 - `/frontend/` - 前端项目文件 - `/build/` - 项目构建目录 -- `/wails.json` - 项目配置 -- `/go.mod` - Go mod 文件 -- `/go.sum` - Go mod 校验文件 -- `/build/windows/` - Windows 特定的项目文件 -- `/go.mod` - Go module file -- `/go.sum` - Go module checksum file +- `/wails.json` - 应用程序图标 +- `/go.mod` - Mac 特定的项目文件 +- `/go.sum` - Windows 特定的项目文件 +- `/build/windows/` - 项目配置 +- `/go.mod` - Go module 文件 +- `/go.sum` - Go module 校验文件 -`frontend`目录没有特定于 Wails 的内容,可以是您选择的任何前端项目。 +`frontend` 目录没有特定于 Wails 的内容,可以是您选择的任何前端项目。 -`build`目录在构建过程中使用。 这些文件可以修改以自定义您的构建。 如果文件从构建目录中删除,将重新生成默认版本。 +`build` 目录在构建过程中使用。 这些文件可以修改以自定义您的构建。 如果从 build 目录中删除文件,将重新生成默认版本。 -`go.mod`中的默认模块名称是“changeme”。 您应该将其更改为更合适的内容。 +`go.mod` 中的默认模块名称是“changeme”。 您应该将其更改为更合适的内容。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/installation.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/installation.mdx index 6ae1825aa..31702ad32 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/installation.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/gettingstarted/installation.mdx @@ -20,25 +20,24 @@ Wails 有许多安装前需要的常见依赖项: ### Go -从[Go 下载页面](https://golang.org/dl/)下载 Go。 +从 [Go 下载页面](https://golang.org/dl/) 下载 Go。 -确保您遵守官方的[Go 安装说明](https://golang.org/doc/install#install)。 您还需要确保您的 `PATH` 环境变量包含您的 `~/go/bin` 目录路径。 重启终端并执行以下命令检查: +确保您遵守官方的 [Go 安装说明](https://golang.org/doc/install#install)。 您还需要确保您的 `PATH` 环境变量包含您的 `~/go/bin` 目录路径。 重启终端并执行以下命令检查: - 检查 Go 是否安装正确: `go version` - 检查 "~/go/bin" 是否在您的 PATH 变量中: `echo $PATH | grep go/bin` ### NPM -从[Node 下载页面](https://nodejs.org/en/download/)下载 NPM。 最好使用最新版本,因为这是我们通常会测试的版本。 +从 [Node 下载页面](https://nodejs.org/en/download/) 下载 NPM。 最好使用最新版本,因为这是我们通常会测试的版本。 运行 `npm --version` 进行验证。 -## 平台指定依赖关系 +## 平台特定依赖关系 -您还需要安装指定平台的依赖项: - - +您还需要安装平台特定的依赖项: +```mdx-code-block import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; @@ -46,51 +45,21 @@ import TabItem from "@theme/TabItem"; defaultValue="Windows" values={[ { label: "Windows", value: "Windows" }, - { label: "MacOS", value: "MacOS" }, - { label: "Linux", value: "Linux" }, - ]} + { label: "MacOS", value: "MacOS" }, + { label: "Linux", value: "Linux" }, + ]} > - Wails 需要安装 xcode 命令行工具。 This can be - done by running:
- xcode-select --install + Wails 要求安装 xcode 命令行工具。 这可以通过运行 xcode-select --install 来完成。
- Wails requires that the WebView2{" "} - runtime is installed. Some Windows installations will already have this installed. You can check using - the{" "} - wails doctor command (see below). Some Windows installations will already have this installed. You can check using - the{" "} - wails doctor command (see below). Some Windows installations will already have this - installed. You can check using the wails doctor command (see - below). + Wails 要求安装 WebView2 运行时。 一些 Windows 安装已经安装了这个。 您可以使用 wails doctor 命令进行检查。 - Linux required the standard gcc build tools - plus libgtk3 and libwebkit. - Rather than list a ton of commands for different distros, Wails can try to determine - what the installation commands are for your specific distribution. Run wails doctor after - installation - to be shown how to install the dependencies. - If your distro/package manager is not supported, please consult the {" "} - Add Linux Distro guide. - Rather than list a ton of commands for different distros, Wails can try to determine - what the installation commands are for your specific distribution. Run wails doctor after - installation - to be shown how to install the dependencies. - If your distro/package manager is not supported, please consult the {" "} - Add Linux Distro guide. Rather than list a ton of - commands for different distros, Wails can try to determine what the - installation commands are for your specific distribution. Run{" "} - wails doctor after installation to be shown how to install the - dependencies. If your distro/package manager is not supported, please - consult the{" "} - Add Linux Distro guide. + Linux 需要标准 gcc 构建工具以及 libgtk3libwebkit。 与其为不同的发行版列出大量命令,Wails 可以尝试确定针对您的特定发行版的安装命令。 安装后运行 wails doctor 以显示如何安装依赖项。 如果您的发行版/包管理器不受支持,请参阅 添加Linux发行版指南 - - +``` ## 可选依赖 @@ -104,6 +73,6 @@ import TabItem from "@theme/TabItem"; 运行 `wails doctor` 将检查您是否安装了正确的依赖项。 如果没有,它会就缺少的内容提供建议以帮助纠正问题。 -## The `wails` command appears to be missing? +## `wails` 命令好像不见了? -If your system is reporting that the `wails` command is missing, make sure you have followed the Go installation guide correctly. Normally, it means that the `go/bin` directory in your User's home directory is not in the `PATH` environment variable. You will also normally need to close and reopen any open command prompts so that changes to the environment made by the installer are reflected at the command prompt. +如果您的系统报告缺少 `wails` 命令,请确保您已正确遵循 Go 安装指南。 通常,这意味着您的用户 home 目录中的 `go/bin` 目录不在 `PATH` 环境变量中。 通常情况下还需要关闭并重新打开任何已打开的命令提示符,以便安装程序对环境所做的更改反映在命令提示符中。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/application-development.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/application-development.mdx index 76e93b17a..d8d340cdf 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/application-development.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/application-development.mdx @@ -4,7 +4,7 @@ ## 应用程序设置 -默认模板使用 `main.go` 配置和运行应用程序, 同时`app.go`用于定义应用程序逻辑. +默认模板使用 `main.go` 配置和运行应用程序, 同时`app.go` 用于定义应用程序逻辑. `app.go`文件将定义一个结构体,该结构体有 2 个方法作为主应用程序的回调: @@ -25,11 +25,11 @@ func (a *App) shutdown(ctx context.Context) { } ``` -- `startup`方法会在 Wails 分配它需要的资源后立即调用,这是创建资源、设置事件侦听器以及应用程序在启动时需要的任何其他内容的好地方。 它提供了一个`context.Context`, 通常保存在结构字段中。 调用[运行时](../reference/runtime/intro)需要此`context.Context`。 如果此方法返回错误,则应用程序将终止。 在开发模式下,错误会输出到控制台。 +- 一旦 Wails 分配了它需要的资源,就会调用 startup 方法,它是创建资源、设置事件侦听器以及应用程序在启动时需要的任何其他东西的好地方。 它提供了一个 `context.Context`, 通常保存在一个结构体字段中。 调用 [运行时](../reference/runtime/intro) 需要此`context.Context`。 如果此方法返回错误,则应用程序将终止。 在开发模式下,错误会输出到控制台。 -- The shutdown method will be called by Wails right at the end of the shutdown process. This is a good place to deallocate memory and perform any shutdown tasks. This is a good place to deallocate memory and perform any shutdown tasks. +- Shutdown 方法将在关闭过程结束时由 Wails 调用。 这是释放内存和执行关闭任务的好地方。 -`main.go`文件通常由对`wails.Run()`的单个调用组成,它接受应用程序配置。 模板使用的模式是,在调用`wails.Run()`之前, 我们创建并保存一个在`app.go`中定义的结构体的实例在名`app`的变量中。 这个配置是我们添加回调的地方: +`main.go` 文件通常由对`wails.Run()`的单个调用组成,它接受应用程序配置。 模板使用的模式是,在调用 `wails.Run()` 之前, 我们创建并保存一个在 `app.go` 中定义的结构体的实例在名为 `app` 的变量中。 这个配置是我们添加回调的地方: ```go {3,9,10} title="main.go" func main() { @@ -50,11 +50,11 @@ func main() { ``` -可以在[此处](../howdoesitwork#应用程序生命周期回调)找到有关应用程序生命周期回调的更多信息。 +可以在 [此处](../howdoesitwork#应用程序生命周期回调) 找到有关应用程序生命周期回调的更多信息。 ## 绑定方法 -您可能希望从前端调用 Go 方法。 这通常是通过向`app.go`中已经定义的结构体中添加公共方法来实现的: +您可能希望从前端调用 Go 方法。 这通常是通过向 `app.go` 中已经定义的结构体中添加公共方法来实现的: ```go {16-18} title="app.go" type App struct { @@ -73,11 +73,11 @@ func (a *App) shutdown(ctx context.Context) { } func (a *App) Greet(name string) string { - return fmt.Printf("Hello %s!", name) + return fmt.Sprintf("Hello %s!", name) } ``` -在主应用程序中,`Bind`字段告诉我们 Wails 想要绑定什么: +在主应用程序中,`Bind` 字段是我们告诉 Wails 想要绑定什么: ```go {11-13} title="main.go" func main() { @@ -101,11 +101,11 @@ func main() { ``` -这将绑定`App`结构中的所有公共方法(它永远不会绑定 startup 和 shutdown 方法)。 +这将绑定 `App` 结构中的所有公共方法(它永远不会绑定 startup 和 shutdown 方法)。 -### Dealing with context when binding multiple structs +### 绑定多个结构体时处理 context -可以在[此处](../howdoesitwork#方法绑定)找到有关绑定的更多信息。 +如果您想为多个结构绑定方法,但希望每个结构都保留对 context 的引用,以便您可以使用运行时函数,一个好的方式是将上下文从 `OnStartup` 方法传递给您的结构实例: ```go func main() { @@ -133,7 +133,7 @@ func main() { } ``` -More information on Binding can be found [here](../howdoesitwork.mdx#method-binding). +可以在 [此处](../howdoesitwork.mdx#method-binding) 找到有关绑定的更多信息。 ## 应用程序菜单 @@ -162,33 +162,33 @@ func main() { ``` -## 资源 +## 资产 -Wails v2 处理资源的方式的伟大之处在于它没有! 您唯一需要给 Wails 的是一个 `embed.FS`, 如何做到这一点完全取决于您。 How you get to that is entirely up to you. 您可以像 vanilla 模板一样使用 vanilla html/css/js 文件。 您可能有一些复杂的构建系统,但这并不影响。 +Wails v2 处理资源的方式的伟大之处在于它不需要处理! 您唯一需要给 Wails 的是一个 `embed.FS`。 你如何做到这一点完全取决于你。 您可以像 vanilla 模板一样使用 vanilla html/css/js 文件。 您可能有一些复杂的构建系统,但这并不影响。 -当运行`wails build`时,它会检查项目根目录的`wails.json`文件。 文件中有 2 个字段会被读取: +运行 `wails build` 时,它会检查项目根目录的 `wails.json` 文件。 文件中有 2 个字段会被读取: - "frontend:install" - "frontend:build" -第一个,如果有给定,将在`frontend`目录中执行以安装 node 模块。 第二个,如果有给定,将在`frontend`目录中执行以构建前端项目。 +第一个,如果有给定,将在 `frontend` 目录中执行以安装 node 模块。 第二个,如果有给定,将在 `frontend` 目录中执行以构建前端项目。 -如果没有给出这两个字段,那么 Wails 不会对前端做任何操作。 它仅仅被用作`embed.FS`。 +如果没有给出这两个字段,那么 Wails 不会对前端做任何操作。 它仅仅被用作 `embed.FS`。 -### AssetsHandler +### 资产处理程序 -A Wails v2 app can optionally define a `http.Handler` in the `options.App`, which allows hooking into the AssetServer to create files on the fly or process POST/PUT requests. GET requests are always first handled by the `assets` FS. If the FS doesn't find the requested file the request will be forwarded to the `http.Handler` for serving. Any requests other than GET will be directly processed by the `AssetsHandler` if specified. It's also possible to only use the `AssetsHandler` by specifiy `nil` as the `Assets` option. GET requests are always first handled by the `assets` FS. If the FS doesn't find the requested file the request will be forwarded to the `http.Handler` for serving. Any requests other than GET will be directly processed by the `AssetsHandler` if specified. It's also possible to only use the `AssetsHandler` by specifiy `nil` as the `Assets` option. +Wails v2 应用程序可以选择在 `options.App` 中定义一个 `http.Handler`,它允许连接到 AssetServer 以动态创建文件或处理 POST/PUT 请求。 GET 请求总是首先由 `assets` FS 处理。 如果 FS 没有找到请求的文件,请求将被转发到 `http.Handler` 服务。 如果指定,除了 GET 以外的任何请求都将由 `AssetsHandler` 直接处理。 也可以仅通过将 `nil` 指定为 `Assets` 选项来使用 `AssetsHandler`。 ## 内置开发服务器 -运行`wails dev`将启动内置的开发服务器,它将在您的项目目录中启动一个文件监听器。 默认情况下,如果有任何文件更改,wails 会检查它是否是应用程序文件(默认:.go,可使用`-e`标志配置)。 如果是,那么它将重新构建您的应用程序并重新启动它。 如果更改的文件在`assetdir`目录中,它会在很短的时间后重新加载。 +运行 `wails dev` 将启动内置的开发服务器,它将在您的项目目录中启动一个文件监听器。 默认情况下,如果有任何文件更改,wails 会检查它是否是应用程序文件(默认:.go,可使用 `-e` 标志配置)。 如果是,那么它将重新构建您的应用程序并重新启动它。 如果更改的文件在 assetdir 目录中,它会在很短的时间后重新加载。 -开发服务器使用一种称为“防抖”的技术,这意味着它不会立即重新加载,因为可能会在短时间内更改多个文件。 当触发发生时,它会在发出重新加载之前等待一定的时间。 如果发生另一个触发,它会再次重置为等待时间。 默认情况下,此值为 100ms。 如果此值不适用于您的项目,则可以使用`-debounce`标志进行配置。 如果使用,此值将保存到您的项目配置中并成为默认值。 +开发服务器使用一种称为“防抖”的技术,这意味着它不会立即重新加载,因为可能会在短时间内更改多个文件。 当触发发生时,它会在发出重新加载之前等待一定的时间。 如果发生另一个触发,它会再次重置为等待时间。 默认情况下,此值为 100ms。 如果此值不适用于您的项目,则可以使用 `-debounce` 标志进行配置。 如果使用,此值将保存到您的项目配置中并成为默认值。 ## 外部开发服务器 -一些框架带有自己的实时重新加载服务器,但是它们将无法利用 Wails Go 绑定。 在这种情况下,最好运行一个监听脚本,将项目重新构建到构建目录中,Wails 将监视该目录。 有关示例,请参阅使用[rollup](https://rollupjs.org/guide/en/)的默认 svelte 模板。 对于[create-react-app](https://create-react-app.dev/),可以使用[此脚本](https://gist.github.com/int128/e0cdec598c5b3db728ff35758abdbafd)来实现类似的结果。 +一些框架带有自己的实时重新加载服务器,但是它们将无法利用 Wails Go 绑定。 在这种情况下,最好运行一个监听脚本,将项目重新构建到构建目录中,Wails 将监视该目录。 有关示例,请参阅使用 [rollup](https://rollupjs.org/guide/en/) 的默认 svelte 模板。 对于 [create-react-app](https://create-react-app.dev/),可以使用 [此脚本](https://gist.github.com/int128/e0cdec598c5b3db728ff35758abdbafd) 来实现类似的结果。 ## Go 模块 -默认的 Wails 模板会生成一个包含模块名称“changeme”的`go.mod`文件。 您应该在项目生成后将其更改为更合适的内容。 +默认的 Wails 模板会生成一个包含模块名称“changeme”的 `go.mod` 文件。 您应该在项目生成后将其更改为更合适的内容。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/bleeding-edge.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/bleeding-edge.mdx index 8fad99fde..088c00175 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/bleeding-edge.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/bleeding-edge.mdx @@ -2,7 +2,7 @@ ## 概述 -Wails 一直在开发中,新版本会定期“标记”。 这通常发生在`master`分支上所有较新的代码都经过测试并确认有效时。 如果您需要尚未发布的错误修复或功能,可以通过以下步骤使用最新的“前沿风险”版本: +Wails 一直在开发中,新版本会定期“标记”。 这通常发生在 `master` 分支上所有较新的代码都经过测试并确认有效时。 如果您需要尚未发布的错误修复或功能,可以通过以下步骤使用最新的“前沿风险”版本: - `git clone https://github.com/wailsapp/wails` - `cd wails/v2/cmd/wails` @@ -10,21 +10,21 @@ Wails 一直在开发中,新版本会定期“标记”。 这通常发生在` 注意:您将项目克隆到的目录现在将被称为“clonedir”。 -Wails CLI 现在将是最新版本。 +现在,Wails CLI 将是最新版本。 -### Updating your project +### 更新您的项目 -To update projects to use the latest version of the Wails library, update the project's `go.mod` and ensure the following line is at the bottom of the file: +要更新项目以使用最新版本的 Wails 库,请更新项目 `go.mod` 并确保以下行位于文件底部: `replace github.com/wailsapp/wails/v2 => ` 示例: -在 Windows 上: `replace github.com/wailsapp/wails/v2 => C:\Users\leaan\Documents\wails-v2-beta\wails\v2` +在 Windows 上:`replace github.com/wailsapp/wails/v2 => C:\Users\leaan\Documents\wails-v2-beta\wails\v2` -在'nix 上: `replace github.com/wailsapp/wails/v2 => /home/me/projects/wails/v2` +在'nix 上:`replace github.com/wailsapp/wails/v2 => /home/me/projects/wails/v2` -To revert to a stable version, run: +要恢复到稳定版本,请运行: `go install github.com/wailsapp/wails/v2/cmd/wails@latest` @@ -38,11 +38,11 @@ To revert to a stable version, run: - `cd v2/cmd/wails` - `go install` -Make sure you [update your project](#updating-your-project) as described above. +确保如上所述 [更新您的项目](#updating-your-project)。 -## Testing a PR +## 测试 PR -If you want to test a PR, follow the instructions above, but ensure you fetch the PR and switch the branch before installing. Please replace `[IDofThePR]` with the ID of the PR shown on github.com: If you want to test a PR, follow the instructions above, but ensure you fetch the PR and switch the branch before installing. Please replace `[IDofThePR]` with the ID of the PR shown on github.com: Please replace `[IDofThePR]` with the ID of the PR shown on github.com: +如果您想测试 PR,请按照上面的说明进行操作,但请确保在安装前获取 PR 并切换分支。 请替换 `[IDofThePR]` 为 github.com 上显示的 PR 的 ID: - `git clone https://github.com/wailsapp/wails` - `cd wails` @@ -52,4 +52,4 @@ If you want to test a PR, follow the instructions above, but ensure you fetch th - `cd v2/cmd/wails` - `go install` -Make sure you [update your project](#updating-your-project) as described above. +确保如上所述 [ 更新您的项目](#updating-your-project)。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/dynamic-assets.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/dynamic-assets.mdx index fedb2c0c9..7233ffaa9 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/dynamic-assets.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/dynamic-assets.mdx @@ -1,12 +1,12 @@ -# 动态资源 +# 动态资产 -If you want to load or generate assets for your frontend dynamically, you can achieve that using the [AssetsHandler](../reference/options#assetshandler) option. The AssetsHandler 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 bundled assets because the file is not found. The AssetsHandler 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 bundled assets because the file is not found. The AssetsHandler 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 bundled assets because the file is not found. +如果你想为你的前端动态加载或生成资产,你可以使用 [AssetsHandler](../reference/options#assetshandler) 选项来实现。 AssetsHandler 是一个通用的 `http.Handler`,对于资产服务器上的任何非 GET 请求以及由于找不到文件而无法从捆绑资产提供服务的 GET 请求,都会调用它。 -By installing a custom AssetsHandler, you can serve your own assets using a custom asset server. +通过安装自定义 AssetsHandler,您可以使用自定义资产服务器提供您自己的资产。 -## Example +## 示例 -In our example project, we will create a simple assets handler which will load files off disk: +在我们的示例项目中,我们将创建一个简单的资产处理程序,它将从磁盘加载文件: ```go title=main.go {16-35,49} package main @@ -69,7 +69,7 @@ func main() { } ``` -When we run the application in dev mode using `wails dev`, we will see the following output: +当我们在开发模式使用 `wails dev` 运行应用程序时,我们将看到以下输出: ``` DEB | [ExternalAssetHandler] Loading 'http://localhost:3001/favicon.ico' @@ -77,54 +77,58 @@ DEB | [ExternalAssetHandler] Loading 'http://localhost:3001/favicon.ico' failed, Requesting file: favicon.ico ``` -As you can see, the assets handler is called when the default assets server is unable to serve the `favicon.ico` file. +如您所见,当默认资产服务器无法提供 `favicon.ico` 文件时,将调用资产处理程序。 -If you right click the main application and select "inspect" to bring up the devtools, you can test this feature out by typing the following into the console: +如果您右键单击主应用程序并选择“检查”以调出开发工具,您可以通过在控制台中输入以下内容来测试此功能: ``` let response = await fetch('does-not-exist.txt'); ``` -This will generate an error in the devtools. This will generate an error in the devtools. This will generate an error in the devtools. We can see that the error is what we expect, returned by our custom assets handler: +这将在 devtools 中产生错误。 我们可以看到错误是我们所期望的,由我们的自定义资产处理程序返回: +```mdx-code-block

+``` -However, if we request `go.mod`, we will see the following output: +但是,如果我们请求 `go.mod`,我们将看到以下输出: +```mdx-code-block

- -This technique can be used to load images directly into the page. This technique can be used to load images directly into the page. If we updated our default vanilla template and replaced the logo image: This technique can be used to load images directly into the page. This technique can be used to load images directly into the page. If we updated our default vanilla template and replaced the logo image: This technique can be used to load images directly into the page. If we updated our default vanilla template and replaced the logo image: - -```html - ``` -with: +此技术可用于将图像直接加载到页面中。 如果我们更新了默认的 vanilla 模板并替换了 logo 图像: ```html - + ``` -Then we would see the following: +和: +```html + +``` + +然后我们会看到以下内容: + +```mdx-code-block

+``` :::warning -Exposing your filesystem in this way is a security risk. It is recommended that you properly manage access -to your filesystem. -::: It is recommended that you properly manage access -to your filesystem. -::: It is recommended that you properly manage access -to your filesystem. + + +以这种方式暴露您的文件系统是一种安全风险。 建议您正确管理对文件系统的访问。 + ::: diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/frameless.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/frameless.mdx index 24385fb25..cda133e4a 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/frameless.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/frameless.mdx @@ -1,9 +1,8 @@ # 无边框应用 -Wails supports application that have no frames. 这可以通过使用[应用程序参数选项](../reference/options#应用程序参数选项)中的[无边框](../reference/options#无边框)字段来实现。 - -Wails offers a simple solution for dragging the window: Any HTML element that has the CSS style `--wails-draggable:drag` will act as a "drag handle". This property applies to all child elements. If you need to indicate that a nested element should not drag, then use the attribute '--wails-draggable:no-drag' on that element. +Wails 支持无边框应用程序。 这可以通过使用 [应用程序参数选项](../reference/options#应用程序参数选项) 中的 [无边框](../reference/options#无边框) 字段来实现。 +Wails 为拖动窗口提供了一个简单的解决方案:任何具有 `--wails-draggable:drag` CSS 样式的 HTML 元素都将充当“拖动句柄”。 此属性适用于所有子元素。 如果您需要指示嵌套元素不应拖动,则在该元素上使用“--wails-draggable:no-drag”属性。 ```html @@ -24,7 +23,7 @@ Wails offers a simple solution for dragging the window: Any HTML element that ha ``` -For some projects, using a CSS variable may not be possible due to dynamic styling. In this case, you can use the `CSSDragProperty` and `CSSDragValue` application options to define a property and value that will be used to indicate draggable regions: +对于一些项目,由于动态样式,可能无法使用 CSS 变量。 在这种情况下,您可以使用 `CSSDragProperty` 和 `CSSDragValue` 应用程序选项来定义将用于指示可拖动区域的属性和值: ```go title=main.go package main @@ -66,19 +65,21 @@ func main() { ```html title=index.html - - - + + + alwaysontop - - -
- - + + +
+ + - ``` :::info 全屏 -如果您允许应用程序全屏显示,则此拖动功能将被禁用。 + + +如果您允许您的应用程序全屏显示,则此拖动功能将被禁用。 + ::: diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/frontend.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/frontend.mdx index 789e834b8..7c4246863 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/frontend.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/frontend.mdx @@ -2,7 +2,7 @@ ## 脚本注入 -当 Wails 为您的`index.html`提供服务时,默认情况下,它会将 2 个脚本注入``标签以加载`/wails/ipc.js`和`/wails/runtime.js`。 这些文件分别安装绑定和运行时。 +当 Wails 为您的 `index.html` 提供服务时,默认情况下,它会将 2 个脚本注入 `` 标签以加载 `/wails/ipc.js` 和 `/wails/runtime.js`。 这些文件分别安装绑定和运行时。 下面的代码显示了这些默认注入的位置: @@ -30,7 +30,7 @@ ### 覆盖默认脚本注入 -为了给开发人员提供更大的灵活性,有一个`meta`标签可用于自定义此行为: +为了给开发人员提供更大的灵活性,有一个 meta 标签可用于自定义此行为: ```html diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/ides.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/ides.mdx index 0ae681f0f..faf959b1c 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/ides.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/ides.mdx @@ -2,20 +2,22 @@ Wails 旨在提供出色的开发体验。 为此,我们现在支持生成 IDE 特定配置以提供更顺畅的项目设置。 -目前,我们支持[Visual Studio Code](https://code.visualstudio.com/),但我们希望尽快支持其他 IDE,例如 Goland。 +目前,我们支持 [Visual Studio Code](https://code.visualstudio.com/),但我们希望尽快支持其他 IDE,例如 Goland。 ## Visual Studio Code +```mdx-code-block

+``` -使用`-ide vscode`标志生成项目时,IDE 文件将与其他项目文件一起创建。 这些文件放置在`.vscode`目录中,并为调试应用程序提供正确的配置。 +使用 `-ide vscode` 标志生成项目时,IDE 文件将与其他项目文件一起创建。 这些文件放置在 `.vscode` 目录中,并为调试应用程序提供正确的配置。 -生成的 2 个文件是`tasks.json`和`launch.json`. 以下是为默认 vanilla 项目生成的文件: 生成的 2 个文件是`tasks.json`和`launch.json`. 以下是为默认 vanilla 项目生成的文件: Below are the files generated for the default vanilla project: 生成的 2 个文件是`tasks.json`和`launch.json`. 以下是为默认 vanilla 项目生成的文件: Below are the files generated for the default vanilla project: 生成的 2 个文件是`tasks.json`和`launch.json`. 以下是为默认 vanilla 项目生成的文件: Below are the files generated for the default vanilla project: 生成的 2 个文件是`tasks.json`和`launch.json`. 以下是为默认 vanilla 项目生成的文件: Below are the files generated for the default vanilla project: +生成的 2 个文件是 `tasks.json` 和 `launch.json`。 以下是为默认 vanilla 项目生成的文件: ```json title="tasks.json" { @@ -28,7 +30,15 @@ Wails 旨在提供出色的开发体验。 为此,我们现在支持生成 IDE "cwd": "${workspaceFolder}" }, "command": "go", - "args": ["build", "-tags", "dev", "-gcflags", "all=-N -l", "-o", "build/bin/myproject.exe"] + "args": [ + "build", + "-tags", + "dev", + "-gcflags", + "all=-N -l", + "-o", + "build/bin/myproject.exe" + ] } ] } @@ -46,8 +56,7 @@ Wails 旨在提供出色的开发体验。 为此,我们现在支持生成 IDE "program": "${workspaceFolder}/build/bin/myproject.exe", "preLaunchTask": "build", "cwd": "${workspaceFolder}", - "env": {}, - "args": ["-assetdir", "frontend/src"] + "env": {} } ] } @@ -55,7 +64,7 @@ Wails 旨在提供出色的开发体验。 为此,我们现在支持生成 IDE ### 配置安装和构建步骤 -`tasks.json`文件对于默认项目很简单,因为不需要`npm install`或`npm run build`的步骤。 对于具有前端构建步骤的项目,例如 svelte 模板,我们需要编辑`tasks.json`以添加安装和构建步骤: +`tasks.json` 文件对于默认项目很简单,因为不需要 `npm install` 或 `npm run build` 的步骤。 对于具有前端构建步骤的项目,例如 svelte 模板,我们需要编辑 `tasks.json` 以添加安装和构建步骤: ```json title="tasks.json" { @@ -96,15 +105,24 @@ Wails 旨在提供出色的开发体验。 为此,我们现在支持生成 IDE "cwd": "${workspaceFolder}" }, "command": "go", - "args": ["build", "-tags", "dev", "-gcflags", "all=-N -l", "-o", "build/bin/vscode.exe"], + "args": [ + "build", + "-tags", + "dev", + "-gcflags", + "all=-N -l", + "-o", + "build/bin/vscode.exe" + ], "dependsOn": ["npm install", "npm run build"] } ] } ``` -:::info 功能改善 +:::info 功能增强 -在未来,我们希望生成一个自动包含安装和构建步骤的`tasks.json`。 + +将来,我们希望生成一个 `tasks.json` 自动包含安装和构建步骤的文件。 ::: diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/linux-distro-support.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/linux-distro-support.mdx index 2ee209e03..60a23bef5 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/linux-distro-support.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/linux-distro-support.mdx @@ -14,9 +14,9 @@ Wails 提供 Linux 支持,但为所有可用发行版提供安装说明是一 ## 添加包名 -在某些情况下,您的发行版使用受支持的包管理器之一,但包名称不同。 例如,您可能使用 Ubuntu 衍生产品,但 gtk 的包名称可能不同。 Wails 尝试通过遍历包名称列表来找到正确的包。 包列表存储在`v2/internal/system/packagemanager` 目录中的包管理器特定文件中。 在我们的示例中,将是`v2/internal/system/packagemanager/apt.go`。 +在某些情况下,您的发行版使用受支持的包管理器之一,但包名称不同。 例如,您可能使用 Ubuntu 衍生产品,但 gtk 的包名称可能不同。 Wails 尝试通过遍历包名称列表来找到正确的包。 包列表存储在 `v2/internal/system/packagemanager` 目录中的包管理器特定文件中。 在我们的示例中,是 `v2/internal/system/packagemanager/apt.go`。 -在此文件中,包列表由以下`Packages()`方法定义: +在此文件中,包列表由以下 `Packages()` 方法定义: ```go func (a *Apt) Packages() packagemap { @@ -43,7 +43,7 @@ func (a *Apt) Packages() packagemap { } ``` -假设在我们的 linux 发行版中,libgtk-3 以 lib-gtk3-dev 的名称打包。 我们可以通过添加以下行来添加对此的支持: +假设在我们的 linux 发行版中,`libgtk-3` 以 `lib-gtk3-dev` 的名称打包。 我们可以通过添加以下行来添加对此的支持: ```go {5} func (a *Apt) Packages() packagemap { @@ -75,8 +75,8 @@ func (a *Apt) Packages() packagemap { 要添加新的包管理器,请执行以下步骤: -- 在`v2/internal/system/packagemanager`中创建一个名为`.go`的新文件,其中``是包管理器的名称。 -- 定义一个符合`pm.go`中定义的包管理器接口的结构体。 +- 在 `v2/internal/system/packagemanager` 中创建一个名为 `.go` 的新文件,其中 `` 是包管理器的名称。 +- 定义一个符合 `pm.go` 中定义的包管理器接口的结构体。 ```go type PackageManager interface { @@ -89,7 +89,7 @@ type PackageManager interface { ``` - `Name()` 应该返回包管理器的名称 -- `Packages()` 应该返回一个`packagemap`,它为依赖项提供候选文件名 +- `Packages()` 应该返回一个 `packagemap`,它为依赖项提供候选文件名 - `PackageInstalled()` 如果安装了指定的包,应该返回`true` - `PackageAvailable()` 如果指定的软件包未安装但可以安装,则应返回`true` - `InstallCommand()` 应该返回确切的命令来安装指定的包名 @@ -97,5 +97,8 @@ type PackageManager interface { 查看其他包管理器代码以了解其工作原理。 :::info 记住 + + 如果您添加了对新包管理器的支持,请不要忘记更新此页面! + ::: diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/linux.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/linux.mdx index 073e207b2..dfcdc5fb2 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/linux.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/linux.mdx @@ -1,10 +1,10 @@ # Linux -This page has miscellaneous guides related to developing Wails applications for Linux. +此页面包含与开发适用于 Linux 的 Wails 应用程序相关的其他指南。 -## Video tag doesn't fire "ended" event +## video 标签不能触发 "ended" 事件 -When using a video tag, the "ended" event is not fired when the video is finished playing. This is a bug in WebkitGTK, however you can use the following workaround to fix it: This is a bug in WebkitGTK, however you can use the following workaround to fix it: +使用视频标签时,视频播放完毕后不会触发“结束”事件。 这是 WebkitGTK 中的一个错误,但是您可以使用以下解决方法来修复它: ```js videoTag.addEventListener("timeupdate", (event) => { @@ -15,4 +15,4 @@ videoTag.addEventListener("timeupdate", (event) => { }); ``` -Source: [Lyimmi](https://github.com/Lyimmi) on the [discussions board](https://github.com/wailsapp/wails/issues/1729#issuecomment-1212291275) +资料来源:[讨论板](https://github.com/wailsapp/wails/issues/1729#issuecomment-1212291275) 上的 [Lyimmi](https://github.com/Lyimmi) diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/manual-builds.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/manual-builds.mdx index 3472cb91a..83de0fdfd 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/manual-builds.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/manual-builds.mdx @@ -4,11 +4,11 @@ Wails CLI 为项目做了很多繁重的工作,但有时需要手动构建项 ## 构建过程 -当使用`wails build`或`wails dev`时,Wails CLI 会执行一个通用的构建过程: +当使用 `wails build` 或 `wails dev` 时,Wails CLI 会执行一个通用的构建过程: - 安装前端依赖 - 构建前端项目 - - 生成构建资源 + - 生成构建资产 - 编译应用程序 - [可选]压缩应用程序 @@ -16,80 +16,80 @@ Wails CLI 为项目做了很多繁重的工作,但有时需要手动构建项 #### 命令行步骤 -- 如果给出了`-s`标志,则跳过此步骤 -- 检查`wails.json`中是否有安装命令`frontend:install` +- 如果给出了 `-s` 标志,则跳过此步骤 +- 检查 `wails.json` 中是否有安装命令 `frontend:install` - 如果没有,则跳过此步骤 -- 如果有,则检查前端目录中是否存在`package.json`。 如果不存在,则跳过这一步 -- 从`package.json`文件内容生成 MD5 -- 它检查`package.json.md5`是否存在,如果存在,则将其内容(MD5 sum)与生成的内容进行比较,以查看内容是否已更改。 如果相同,则跳过此步骤 -- 如果`package.json.md5`不存在,则使用生成的 MD5 sum 创建它 -- 如果现在需要构建,或者`node_modules`不存在,或者给出了`-f`标志,则在前端目录中执行安装命令 +- 如果有,则检查前端目录中是否存在 `package.json`。 如果不存在,则跳过这一步 +- 从 `package.json` 文件内容生成 MD5 +- 检查 `package.json.md5` 是否存在,如果存在,则将其内容(MD5 sum)与生成的内容进行比较,以查看内容是否已更改。 如果相同,则跳过此步骤 +- 如果 `package.json.md5` 不存在,则使用生成的 MD5 并创建它 +- 如果现在需要构建,或者 `node_modules` 不存在,或者给出了`-f` 标志,则在前端目录中执行安装命令 #### 手动步骤 -这一步可以从命令行或带有`npm install`的前端脚本完成. +这一步可以从命令行或带有 `npm install` 的前端脚本完成. ### 构建前端项目 #### Wails 命令行 -- 如果给出了`-s`标志,则跳过此步骤 -- 检查`wails.json`中是否有构建命令`frontend:build` +- 如果给出了 `-s` 标志,则跳过此步骤 +- 检查 `wails.json` 中是否有构建命令 `frontend:build` - 如果没有,则跳过此步骤 - 如果有,就在 frontend 目录下执行它 #### 手动步骤 -这一步可以从命令行或带有前端构建脚本`npm run build`的脚本或任何前端构建脚本完成。 +这一步可以从命令行或带有前端构建脚本 `npm run build` 的脚本或任何前端构建脚本完成。 -### 生成资源 +### 生成资产 #### Wails 命令行 -- 如果设置了`-nopackage`标志,则跳过此阶段 -- 如果`build/appicon.png`文件不存在,则创建一个默认文件 -- 对于 Windows,请参阅[Windows](#windows) -- 如果`build/windows/icon.ico`不存在,它将从`build/appicon.png`图像创建它。 +- 如果设置了`-nopackage` 标志,则跳过此阶段 +- 如果 `build/appicon.png` 文件不存在,则创建一个默认文件 +- 对于 Windows,请参阅 [ Windows](#windows) +- 如果 `build/windows/icon.ico` 不存在,它将从 `build/appicon.png` 图像创建它。 ##### Windows -- 如果`build/windows/icon.ico`不存在,它将从`build/appicon.png`创建 256、128、64、48、32 和 16 大小的图标。 这是使用[winicon](https://github.com/leaanthony/winicon)完成的。 -- 如果`build/windows/.manifest`文件不存在,它会从默认版本创建它。 +- 如果 `build/windows/icon.ico` 不存在,它将从 `build/appicon.png` 创建 256、128、64、48、32 和 16 大小的图标。 这是使用 [winicon](https://github.com/leaanthony/winicon) 完成的。 +- 如果 `build/windows/.manifest` 文件不存在,它会从默认版本创建它。 - 将应用程序编译为生产版本(如上所述)。 -- 使用[winres](https://github.com/tc-hib/winres)将 icon 和 manifest 打包到一个`.syso`文件。 +- 使用 [winres](https://github.com/tc-hib/winres) 将 icon 和 manifest 打包到一个 `.syso` 文件。 #### 手动步骤 - 使用[winicon](https://github.com/leaanthony/winicon)命令行工具或者其他工具创建`icon.ico` -- 为您的应用程序创建或者更新`.manifest`文件 -- 使用[winres 命令行](https://github.com/tc-hib/go-winres)生成一个`.syso`文件 +- 为您的应用程序创建或者更新 `.manifest` 文件 +- 使用 [winres 命令行](https://github.com/tc-hib/go-winres) 生成一个 `.syso` 文件 ### 编译应用程序 #### Wails 命令行 -- 如果提供了`-clean`标志,则删除并重新创建`build`目录 -- 对于`wails dev`,使用以下默认 Go 标志:`-tags dev -gcflags "all=-N -l"` -- 对于`wails build`,使用以下默认 Go 标志:`-tags desktop,production -ldflags "-w -s"` - - 在 Windows 上, `-ldflags "-w -h -H windowsgui"` -- 使用`-tags`传递给命令行的其他`tags`被添加到默认值中 -- 使用`-ldflags`传递给命令行的其他`ldflags`将添加到默认值中 -- 传递`-o`标志 -- 指定的`-compiler`将用于 Go 编译器 +- 如果提供了 `-clean` 标志,则删除并重新创建 `build` 目录 +- 对于 `wails dev`,使用以下默认 Go 标志:`-tags dev -gcflags "all=-N -l"` +- 对于 `wails build`,使用以下默认 Go 标志:`-tags desktop,production -ldflags "-w -s"` + - 在 Windows 上,是 `-ldflags "-w -h -H windowsgui"` +- 传递给 CLI 的附加标签使用 `-tags` 添​​加到默认值中 +- 传递给 CLI 的附加 `ldflags-ldflags` 添加到默认值 +- 传递 `-o` 标志 +- 将使用指定的 Go 编译器 `-compiler` 进行编译 #### 手动步骤 -- 开发环境构建,最简单的命令是: `go build -tags dev -gcflags "all=-N -l"` -- 生产环境构建,最简单的命令是:`go build -tags desktop,production -ldflags "-w -s -H windowsgui"` -- 确保在与`.syso`文件相同的目录中进行编译 +- 对于 dev 构建,最少的命令是:`go build -tags dev -gcflags "all=-N -l"` +- 对于生产构建,最少的命令是:`go build -tags desktop,production -ldflags "-w -s -H windowsgui"` +- 确保在与 `.syso` 文件相同的目录中进行编译 ### 压缩应用程序 #### Wails 命令行 -- 如果已给出`-upx`标志,则`upx`程序将运行以使用默认设置压缩应用程序 -- 如果也传递了`-upxflags`标志,则使用这些标志而不是默认 +- 如果 `-upx` 已给出标志,将运行 `upx` 程序以使用默认设置压缩应用程序 +- 如果也传递了 `-upxflags` 标志,则使用这些标志而不是默认 #### 手动步骤 -- 手动运行`upx [flags]`以压缩应用程序。 +- 手动运行 `upx [flags]` 以压缩应用程序。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/migrating.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/migrating.mdx index f7c00120d..d7707847f 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/migrating.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/migrating.mdx @@ -6,7 +6,7 @@ Wails v2 与 v1 相比有重大变化。 本文档旨在重点介绍迁移现有 ### 创建应用程序 -在 v1 中,使用`wails.CreateApp`来创建主应用程序,使用`app.Bind`来添加绑定,然后使用`app.Run()`运行应用程序。 +在 v1 中,使用 `wails.CreateApp` 来创建主应用程序,使用 `app.Bind` 来添加绑定,然后使用 `app.Run()` 运行应用程序。 示例: @@ -23,7 +23,7 @@ Wails v2 与 v1 相比有重大变化。 本文档旨在重点介绍迁移现有 app.Run() ``` -在 v2 中,只有一个方法`wails.Run()`接受[应用程序参数选项](../reference/options#应用程序参数选项)。 +在 v2 中,只有一个 `wails.Run()` 方法接受 [应用程序参数选项](../reference/options#应用程序参数选项)。 ```go title="v2" err := wails.Run(&options.App{ @@ -39,7 +39,7 @@ Wails v2 与 v1 相比有重大变化。 本文档旨在重点介绍迁移现有 ### 绑定 -在 v1 中,可以绑定任意函数和结构。 在 v2 中,这已被简化为仅绑定结构。 以前传递给 v1`Bind()`中的方法的结构实例现在在[应用程序参数选项](../reference/options#应用程序参数选项)`Bind`字段中指定: +在 v1 中,可以绑定任意函数和结构。 在 v2 中,这已被简化为仅绑定结构体。 以前 v1 传递给 `Bind()` 中的方法的结构实例现在在 [应用程序参数选项 ](../reference/options#应用程序参数选项)`Bind` 字段中指定: ```go title="v1" app := wails.CreateApp(/* options */) @@ -55,19 +55,19 @@ Wails v2 与 v1 相比有重大变化。 本文档旨在重点介绍迁移现有 }) ``` -在 v1 中,绑定方法在`window.backend`中。 这已更改为`window.go`。 +在 v1 中,绑定方法可用于前端的 `window.backend`。 这已更改为 `window.go`。 ### 应用程序生命周期 -In v1, there were 2 special methods in a bound struct: `WailsInit()` and `WailsShutdown()`. In v1, there were 2 special methods in a bound struct: `WailsInit()` and `WailsShutdown()`. These have been replaced with 3 lifecycle hooks as part of the [application options](../reference/options.mdx#application-options): In v1, there were 2 special methods in a bound struct: `WailsInit()` and `WailsShutdown()`. These have been replaced with 3 lifecycle hooks as part of the [application options](../reference/options.mdx#application-options): In v1, there were 2 special methods in a bound struct: `WailsInit()` and `WailsShutdown()`. These have been replaced with 3 lifecycle hooks as part of the [application options](../reference/options.mdx#application-options): +在 v1 中,绑定结构中有 2 个特殊方法:`WailsInit()` 和 `WailsShutdown()`。 作为应用程序选项的一部分,这些已被 3 个生命周期钩子替换: - [应用启动回调](../reference/options.mdx#onstartup) - [应用退出回调](../reference/options.mdx#onshutdown) - [前端 Dom 加载完成回调](../reference/options.mdx#ondomready) -注意:[前端 Dom 加载完成回调](../reference/options#前端-dom-加载完成回调)替换了 v1 中的 `wails:ready` 系统事件。 +注意:[ 前端 Dom 加载完成回调](../reference/options#前端-dom-加载完成回调)替换了 v1 中的 `wails:ready` 系统事件。 -这些方法可以是标准函数,但通常的做法是将它们作为结构的一部分: +这些方法可以是标准函数,但通常的做法是让它们成为结构的一部分: ```go title="v2" basic := NewBasicApp() @@ -85,27 +85,13 @@ func (b *Basic) startup(ctx context.Context) { b.ctx = ctx } ... -type Basic struct { - ctx context.Context -} -func (b *Basic) startup(ctx context.Context) { - b.ctx = ctx -} -... -type Basic struct { - ctx context.Context -} -func (b *Basic) startup(ctx context.Context) { - b.ctx = ctx -} -... ``` ### 运行时 -v2 中的运行时比 v1 丰富得多,支持菜单、窗口操作和更好的对话框。 方法的签名略有变化 - 请参阅[运行时](../reference/runtime/intro)。 +v2 中的运行时比 v1 丰富得多,支持菜单、窗口操作和更好的对话框。 方法的签名略有变化 - 请参阅 [运行时](../reference/runtime/intro)。 -在 v1 中,[运行时](../reference/runtime/intro)可通过传递给`WailsInit()`. 在 v2 中,运行时已移出到它自己的包。 In v2, the runtime has been moved out to its own package. 运行时中的每个方法都采用`context.Context`传递给了[应用启动回调](../reference/options#应用启动回调)方法。 +在 v1 中,[运行时](../reference/runtime/intro) 可通过传递给 `WailsInit()`。 在 v2 中,运行时已移出到它自己的包。 运行时中的每个方法都采用 `context.Context` 传递给了 [应用启动回调](../reference/options#应用启动回调)方法。 ```go title="Runtime Example" package main @@ -126,7 +112,7 @@ func (a *App) startup(ctx context.Context) { ``` -### 资源 +### 资产 在 v2 最大的变化是资源的处理方式。 @@ -137,9 +123,9 @@ func (a *App) startup(ctx context.Context) { 这意味着生成单个 JS 和 CSS 文件的责任在于开发人员。 这本质上需要使用繁琐的打包程序,例如 webpack。 -在 v2 中,Wails 不对您的前端资源做任何预设,就像网络服务器一样。 您的所有应用程序资源都作为`embed.FS`. +在 v2 中,Wails 不对您的前端资源做任何预设,就像网络服务器一样。 您的所有应用程序资源都作为 `embed.FS`。 -这意味着不需要打包您的资源、将图像编码为 Base64 或尝试使用奇葩的打包工具配置来使用自定义字体。 +**这意味着不需要捆绑您的资产、将图像编码为 Base64 或尝试使用捆绑器配置的黑暗艺术来使用自定义字体**。 在启动时,Wails 将扫描给定的`embed.FS`的`index.html`并将其位置用作所有其他应用程序资源的根路径 - 就像网络服务器一样。 @@ -147,8 +133,6 @@ func (a *App) startup(ctx context.Context) { ```shell . -. -. ├── build/ ├── frontend/ │ └── dist/ @@ -160,7 +144,7 @@ func (a *App) startup(ctx context.Context) { └── wails.json ``` -应用程序可以通过简单地创建一个`embed.FS`来使用这些资源: +应用程序可以通过简单地创建一个 `embed.FS` 来使用这些资源: ```go title="Assets Example" //go:embed all:frontend/dist @@ -174,7 +158,7 @@ func main() { } ``` -当然,如果您愿意,也可以使用打包工具。 唯一的要求是在 Wails 中使用`embed.FS`,将最终的程序资源目录传递给[应用程序参数选项](../reference/options#应用程序参数选项)的`Assets`键。 +当然,如果您愿意,也可以使用打包工具。 唯一的要求是在 Wails 中使用 `embed.FS` 将最终的程序资源目录传递给 [应用程序参数选项](../reference/options#应用程序参数选项) 的 `Assets` 键。 ### 项目配置 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/mouse-buttons.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/mouse-buttons.mdx index dcb5b582d..13e54ec46 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/mouse-buttons.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/mouse-buttons.mdx @@ -1,9 +1,9 @@ # 鼠标按钮 -The Wails runtime intercepts mouse clicks to determine whether a frameless window needs resizing or a window needs to be moved. It has been asked how to detect when a mouse click has occurred, because `window.onclick` doesn't report the mouse buttons correctly. The following code shows how to detect mouse clicks: It has been asked how to detect when a mouse click has occurred, because `window.onclick` doesn't report the mouse buttons correctly. The following code shows how to detect mouse clicks: It has been asked how to detect when a mouse click has occurred, because `window.onclick` doesn't report the mouse buttons correctly. The following code shows how to detect mouse clicks: +Wails 运行时拦截鼠标单击以确定无框窗口是否需要调整大小或需要移动窗口。 有人询问如何检测鼠标点击何时发生,因为 `window.onclick` 没有正确报告鼠标按钮。 下面的代码展示了如何检测鼠标点击: ```javascript -window.addEventListener('mousedown', handleMouseButtonDown); +window.addEventListener("mousedown", handleMouseButtonDown); function handleMouseButtonDown(event) { if (event.button === 0) { @@ -22,4 +22,4 @@ function handleMouseButtonDown(event) { } ``` -Reference: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button +参考:https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/obfuscated.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/obfuscated.mdx new file mode 100644 index 000000000..39ca036ef --- /dev/null +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/obfuscated.mdx @@ -0,0 +1,42 @@ +# 混淆构建 + +Wails 支持使用 [garble](https://github.com/burrowers/garble) 来混淆您的应用程序。 + +要生成混淆构建,您可以将 `-obfuscate` 标志与 `wails build` 命令一起使用: + +```bash +wails build -obfuscate +``` + +要自定义混淆设置,您可以使用以下 `-garbleargs` 标志: + +```bash +wails build -obfuscate -garbleargs "-literals -tiny -seed=myrandomseed" +``` + +这些设置可能会保留在您的 [项目配置](/guides/reference/project-config) 中。 + +## 工作原理 + +在标准构建中,所有绑定的方法都在前端的 `window.go` 变量下可用。 调用这些方法时,会使用完全限定的函数名调用相应的后端方法。 使用混淆构建时,使用 ID 而不是绑定方法的名称。 目录中生成的绑定 `wailsjs` 使用这些 ID 调用后端函数。 + +:::note + + +为确保您的应用程序在混淆模式下工作,您必须使用 `wailsjs` 应用程序目录下生成的绑定。 + +::: + + +## 示例 + +Importing the "Greet" method from the bindings like this: + +```js +import { Greet } from "../../wailsjs/go/main/App"; + +// snip +Greet("World"); +``` + +将确保该方法在混淆模式下正常工作,因为绑定将使用 ID 重新生成并更新调用机制。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/overscroll.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/overscroll.mdx index 4262f1f84..64673dafd 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/overscroll.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/overscroll.mdx @@ -4,7 +4,7 @@ ```css html { - height: 100%; - overflow: hidden; + height: 100%; + overflow: hidden; } ``` diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/routing.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/routing.mdx index 910290a98..b1b4c6690 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/routing.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/routing.mdx @@ -4,7 +4,7 @@ ## Vue -在 Vue 中推荐的路由方法是[Hash 模式](https://next.router.vuejs.org/guide/essentials/history-mode.html#hash-mode): +在 Vue 中推荐的路由方法是 [Hash 模式](https://next.router.vuejs.org/guide/essentials/history-mode.html#hash-mode): ```js import { createRouter, createWebHashHistory } from "vue-router"; @@ -12,16 +12,14 @@ import { createRouter, createWebHashHistory } from "vue-router"; const router = createRouter({ history: createWebHashHistory(), routes: [ - // .... - ], -}); + //... ], }); ``` ## Angular -在 Angular 中推荐的路由方法是[HashLocationStrategy](https://codecraft.tv/courses/angular/routing/routing-strategies/#_hashlocationstrategy): +在 Angular 中推荐的路由方法是 [HashLocationStrategy](https://codecraft.tv/courses/angular/routing/routing-strategies/#_hashlocationstrategy): ```ts RouterModule.forRoot(routes, { useHash: true }); @@ -29,7 +27,7 @@ RouterModule.forRoot(routes, { useHash: true }); ## React -The recommended approach for routing in React is [HashRouter](https://reactrouter.com/docs/en/v6/routers/hash-router): +React 中推荐的路由方法是 [HashRouter](https://reactrouter.com/docs/en/v6/routers/hash-router): ```jsx import { HashRouter } from "react-router-dom"; diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/signing.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/signing.mdx index a1f4ca990..b1241c1e8 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/signing.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/signing.mdx @@ -1,14 +1,14 @@ # 代码签名 -This is a guide on how you can sign your binaries generated with Wails on MacOS and Windows. The guide will target CI environments, more specifically GitHub Actions. The guide will target CI environments, more specifically GitHub Actions. The guide will target CI environments, more specifically GitHub Actions. +这是有关如何在 MacOS 和 Windows 上对使用 Wails 生成的二进制文件进行签名的指南。 该指南将针对 CI 环境,更具体地说是 GitHub Actions。 ## Windows -First off you need a code signing certificate. First off you need a code signing certificate. If you do not already have one, Microsoft's info page lists some providers [here](https://docs.microsoft.com/en-us/windows-hardware/drivers/dashboard/get-a-code-signing-certificate). First off you need a code signing certificate. If you do not already have one, Microsoft's info page lists some providers [here](https://docs.microsoft.com/en-us/windows-hardware/drivers/dashboard/get-a-code-signing-certificate). Please note that an EV certificate is not required unless you need to write kernel-level software such as device drivers. For signing your Wails app, a standard code signing certificate will do just fine. For signing your Wails app, a standard code signing certificate will do just fine. First off you need a code signing certificate. If you do not already have one, Microsoft's info page lists some providers [here](https://docs.microsoft.com/en-us/windows-hardware/drivers/dashboard/get-a-code-signing-certificate). Please note that an EV certificate is not required unless you need to write kernel-level software such as device drivers. For signing your Wails app, a standard code signing certificate will do just fine. For signing your Wails app, a standard code signing certificate will do just fine. +首先,您需要一个代码签名证书。 如果您还没有,Microsoft 的信息页面会 [在此处](https://docs.microsoft.com/en-us/windows-hardware/drivers/dashboard/get-a-code-signing-certificate) 列出一些提供商。 请注意,除非您需要编写内核级软件,例如设备驱动程序,否则不需要 EV 证书。 为了签署你的 Wails 应用程序,一个标准的代码签名证书就可以了。 -It may be a good idea to check with your certificate provider how to sign your binaries on your local machine before targeting automated build systems, just so you know if there are any special requirements. For instance, [here](https://www.ssl.com/how-to/using-your-code-signing-certificate/) is SSL.com's code signing guide for Windows. If you know how to sign locally, it will be easier to troubleshoot any potential issues in a CI environment. For instance, SSL.com code signing certificates require the `/tr` flag for [SignTool.exe](https://docs.microsoft.com/en-us/windows/win32/seccrypto/signtool) while other providers may only need the `/t` flag for providing the timestamping server. Popular GitHub Actions for signing Windows binaries like [this one](https://github.com/Dana-Prajea/code-sign-action) does not support the `/tr` flag on SignTool.exe. Therefore this guide will focus on signing our app manually with PowerShell commands, but you can use actions like the [code-sign-action](https://github.com/Dana-Prajea/code-sign-action) Action if you prefer. +在针对自动构建系统之前,与您的证书提供商核实如何在您的本地计算机上签署您的二进制文件可能是一个好主意,这样您就知道是否有任何特殊要求。 例如,[这里](https://www.ssl.com/how-to/using-your-code-signing-certificate/) 是 SSL.com 的 Windows 代码签名指南。 如果您知道如何在本地签名,则可以更轻松地解决 CI 环境中的任何潜在问题。 例如,SSL.com 代码签名证书需要 [SignTool.exe](https://docs.microsoft.com/en-us/windows/win32/seccrypto/signtool) 的 `/tr` 标志, 而其他提供商可能只需要 `/tr` 标志来提供时间戳服务器。 用于签署 [此类](https://github.com/Dana-Prajea/code-sign-action) Windows 二进制文件的流行 GitHub Actions 不支持 SignTool.exe 上的 `/tr` 标志。 因此,本指南将重点介绍使用 PowerShell 命令手动签署我们的应用程序,但如果您愿意,可以使用类似 [代码签名操作](https://github.com/Dana-Prajea/code-sign-action) 的操作。 -First off, let's make sure we are able to build our Wails app in our GitHub CI. Here is a small workflow template: Here is a small workflow template: Here is a small workflow template: +首先,让我们确保我们能够在我们的 GitHub CI 中构建我们的 Wails 应用程序。 这是一个小型工作流模板: ```yaml name: "example" @@ -16,16 +16,11 @@ on: workflow_dispatch: # This Action only starts when you go to Actions and manually run the workflow. -name: "example" -on: - workflow_dispatch: - # This Action only starts when you go to Actions and manually run the workflow. - jobs: package: strategy: matrix: - platform: [ windows-latest, macos-latest ] + platform: [windows-latest, macos-latest] go-version: [1.18] runs-on: ${{ matrix.platform }} steps: @@ -39,69 +34,6 @@ jobs: with: node-version: 14 # You may need to manually build you frontend manually here, unless you have configured frontend build and install commands in wails.json. - name: "example" -on: - workflow_dispatch: - # This Action only starts when you go to Actions and manually run the workflow. - -jobs: - package: - strategy: - matrix: - platform: [ windows-latest, macos-latest ] - go-version: [1.18] - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v2 - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - name: setup node - uses: actions/setup-node@v2 - with: - node-version: 14 - # You may need to manually build you frontend here, unless you have configured frontend build and install commands in wails.json. - - name: Get Wails - run: go install github.com/wailsapp/wails/v2/cmd/wails@latest - - name: Build Wails app - run: | - wails build - - name: upload artifacts macOS - if: matrix.platform == 'macos-latest' - uses: actions/upload-artifact@v2 - with: - name: wails-binaries-macos - path: build/bin/* - - name: upload artifacts windows - if: matrix.platform == 'windows-latest' - uses: actions/upload-artifact@v2 - with: - name: wails-binaries-windows - path: build/bin/* - name: "example" -on: - workflow_dispatch: - # This Action only starts when you go to Actions and manually run the workflow. - -jobs: - package: - strategy: - matrix: - platform: [ windows-latest, macos-latest ] - go-version: [1.18] - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v2 - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - name: setup node - uses: actions/setup-node@v2 - with: - node-version: 14 - # You may need to manually build you frontend here, unless you have configured frontend build and install commands in wails.json. - name: Get Wails run: go install github.com/wailsapp/wails/v2/cmd/wails@latest - name: Build Wails app @@ -121,24 +53,24 @@ jobs: path: build/bin/* ``` -Next we need to give the GitHub workflow access to our signing certificate. This is done by encoding your .pfx or .p12 certificate into a base64 string. To do this in PowerShell, you can use the following command assuming your certificate is called 'my-cert.p12': This is done by encoding your .pfx or .p12 certificate into a base64 string. To do this in PowerShell, you can use the following command assuming your certificate is called 'my-cert.p12': This is done by encoding your .pfx or .p12 certificate into a base64 string. To do this in PowerShell, you can use the following command assuming your certificate is called 'my-cert.p12': +接下来,我们需要让 GitHub 工作流访问我们的签名证书。 这是通过将您的 .pfx 或 .p12 证书编码为 base64 字符串来完成的。 要在 PowerShell 中执行此操作,您可以使用以下命令,假设您的证书名为“my-cert.p12”: ```PowerShell certutil -encode .\my-cert.p12 my-cert-base64.txt ``` -You should now have your .txt file with the base64 encoded certificate. It should start with _-----BEGIN CERTIFICATE-----_ and end with _-----END CERTIFICATE-----_. Now you need to make two action secrets on GitHub. Navigate to _Settings -> Secrets -> Actions_ and create the two following secrets: +您现在应该拥有带有 base64 编码证书的 .txt 文件。 它应该以 _-----BEGIN CERTIFICATE-----_ 开头并以 _-----END CERTIFICATE-----_ 结尾。 现在你需要在 GitHub 上创建两个 action secret。 导航到 _Settings -> Secrets -> Actions_ 并创建以下两个 secrets: -- **WIN_SIGNING_CERT** with the contents of your base64 encoded certificate text. -- **WIN_SIGNING_CERT_PASSWORD** with the contents of your certificate password. +- **WIN_SIGNING_CERT** 您的 base64 编码证书文本的内容。 +- **WIN_SIGNING_CERT_PASSWORD** 您的证书密码的内容。 -Now we're ready to implement the signing in our workflow using one of the two methods: +现在我们准备好使用以下两种方法之一在我们的工作流程中实现签名: -### Method 1: signing with commands +### 方法一:使用命令签名 -This method uses PowerShell commands to sign our app, and leaves you control over the entire signing process. +此方法使用 PowerShell 命令对我们的应用程序进行签名,并让您控制整个签名过程。 -After the `"Build Wails app"` step, we can add the following step to our workflow: +在该 `"Build Wails app"` 步骤之后,我们可以将以下步骤添加到我们的工作流程中: ```yaml - name: Sign Windows binaries @@ -153,13 +85,13 @@ After the `"Build Wails app"` step, we can add the following step to our workflo ``` -This script creates a new directory for your certificate file, creates the certificate file from our base64 secret, converts it to a .pfx file, and finally signs the binary. The following variables needs to be replaced in the last line: The following variables needs to be replaced in the last line: The following variables needs to be replaced in the last line: +此脚本为您的证书文件创建一个新目录,从我们的 base64 密钥创建证书文件,将其转换为 .pfx 文件,最后对二进制文件进行签名。 最后一行需要替换以下变量: -- **signing algorithm**: usually sha256. -- **timestamping server**: URL to the timestamping server to use with your certificate. -- **path to binary**: path to the binary you want to sign. +- **签名算法**:通常是 sha256。 +- **时间戳服务器**:与您的证书一起使用的时间戳服务器的 URL。 +- **二进制路径**:要签名的二进制文件的路径。 -Given that our Wails config has `outputfilename` set to "app.exe" and that we have a certificate from SSL.com, this would be our workflow: +鉴于我们的 Wails 配置将 `outputfilename` 设置为“app.exe”并且我们拥有来自 SSL.com 的证书,这将是我们的工作流程: ```yaml name: "example" @@ -185,7 +117,204 @@ jobs: with: node-version: 14 # You may need to manually build you frontend here, unless you have configured frontend build and install commands in wails.json. - name: "example combined" + - name: Get Wails + run: go install github.com/wailsapp/wails/v2/cmd/wails@latest + - name: Build Wails app + run: | + wails build + - name: Sign Windows binaries + if: matrix.platform == 'windows-latest' + run: | + echo "Creating certificate file" + New-Item -ItemType directory -Path certificate + Set-Content -Path certificate\certificate.txt -Value '${{ secrets.WIN_SIGNING_CERT }}' + certutil -decode certificate\certificate.txt certificate\certificate.pfx + echo "Signing our binaries" + & 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe' sign /fd sha256 /tr http://ts.ssl.com /f certificate\certificate.pfx /p '${{ secrets.WIN_SIGNING_CERT_PASSWORD }}' .\build\bin\app.exe + + - name: upload artifacts macOS + if: matrix.platform == 'macos-latest' + uses: actions/upload-artifact@v2 + with: + name: wails-binaries-macos + path: build/bin/* + - name: upload artifacts windows + if: matrix.platform == 'windows-latest' + uses: actions/upload-artifact@v2 + with: + name: wails-binaries-windows + path: build/bin/* +``` + +### 方法二:Action自动签名 + +可以使用像 [这样](https://github.com/marketplace/actions/code-sign-a-file-with-pfx-certificate) 的 Windows 代码签名操作,但请注意,它需要证书的 SHA1 哈希和证书名称。 查看如何在 Action 的 [市场](https://github.com/marketplace/actions/code-sign-a-file-with-pfx-certificate) 上配置它的示例。 + +--- + +## MacOS + +首先,您需要 Apple 提供的代码签名证书。 如果您没有,简单的谷歌搜索将帮助您获得一个。 获得证书后,您需要将其导出并将其编码为 base64。 本 [教程](https://localazy.com/blog/how-to-automatically-sign-macos-apps-using-github-actions) 向您展示了如何以简单的方式做到这一点。 导出 .p12 证书文件后,您可以使用以下命令将其编码为 base64,如教程中所示: + +```bash +base64 Certificates.p12 | pbcopy +``` + +现在您已准备好创建一些 GitHub 项目 secrets,就像在 Windows 中一样: + +- **APPLE_DEVELOPER_CERTIFICATE_P12_BASE64** 您新复制的 base64 证书的内容。 +- **APPLE_DEVELOPER_CERTIFICATE_PASSWORD** 与您的证书密码的内容。 +- **APPLE_PASSWORD** 包含您可以在 [此处](https://appleid.apple.com/account/manage) 生成的 Apple-ID 帐户的应用程序特定密码的内容。 + +让我们确保我们能够在我们的 GitHub Action 工作流程中构建我们的 Wails 应用程序。 这是一个小模板: + +```yaml +name: "example" +on: + workflow_dispatch: + # This Action only starts when you go to Actions and manually run the workflow. + +jobs: + package: + strategy: + matrix: + platform: [windows-latest, macos-latest] + go-version: [1.18] + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v2 + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + - name: setup node + uses: actions/setup-node@v2 + with: + node-version: 14 + # You may need to manually build you frontend here, unless you have configured frontend build and install commands in wails.json. + - name: Get Wails + run: go install github.com/wailsapp/wails/v2/cmd/wails@latest + - name: Build Wails app + run: | + wails build + - name: upload artifacts macOS + if: matrix.platform == 'macos-latest' + uses: actions/upload-artifact@v2 + with: + name: wails-binaries-macos + path: build/bin/* + - name: upload artifacts windows + if: matrix.platform == 'windows-latest' + uses: actions/upload-artifact@v2 + with: + name: wails-binaries-windows + path: build/bin/* +``` + +对于 macOS 上的代码签名,[gon](https://github.com/mitchellh/gon) 是一个非常方便的工具,用于代码签名和与 Apple 服务器通信,也是用 Go 编写的,将在本指南中使用。 + +在 `Build Wails 应用` 步骤之后,将以下内容添加到工作流中: + +```yaml +- name: MacOS download gon for code signing and app notarization + if: matrix.platform == 'macos-latest' + run: | + brew install mitchellh/gon/gon +``` + +Now we need to configure some gon config files in our `build/darwin` directory: + +1. gon-sign.json: + +```json +{ + "source": ["./build/bin/app.app"], + "bundle_id": "app.myapp", + "apple_id": { + "username": "my-appleid@email.com", + "password": "@env:APPLE_PASSWORD" + }, + "sign": { + "application_identity": "Developer ID Application: My Name" + } +} +``` + +其中 `source` 是您的 Wails 二进制文件,`bundle_id` 是您的捆绑包 ID,`apple_id` 包含您之前创建的 Apple ID 用户名和 App-Specific 密码,`sign.application_identity` 是您的身份,您可以通过运行以下命令找到它: + +```bash +security find-identity -v -p codesigning +``` + +2. entitlements.plist: + +```plist + + + + + com.apple.security.app-sandbox + + com.apple.security.network.client + + com.apple.security.network.server + + com.apple.security.files.user-selected.read-write + + com.apple.security.files.downloads.read-write + + + +``` + +在此文件中,您可以配置应用所需的权利,例如 如果您的应用使用相机,相机权限。 在 [此处](https://developer.apple.com/documentation/bundleresources/entitlements) 阅读有关权利的更多信息。 + +确保您已使用您在 `gon-sign.json` 中输入的相同包 ID 更新了 `Info.plist` 文件。 这是一个示例 `Info.plist` 文件: + +```plist + + + CFBundlePackageTypeAPPL + CFBundleNameMyApp + CFBundleExecutableapp + CFBundleIdentifierapp.myapp + CFBundleVersion0.1.0 + CFBundleGetInfoStringMy app is cool and nice and chill and + CFBundleShortVersionString0.1.0 + CFBundleIconFileiconfile + LSMinimumSystemVersion10.13.0 + NSHighResolutionCapabletrue + LSApplicationCategoryTypepublic.app-category.utilities + NSHumanReadableCopyright© Me + +``` + +现在我们准备好在构建 Wails 应用程序后在我们的工作流程中添加签名步骤: + +```yaml +- name: Import Code-Signing Certificates for macOS + if: matrix.platform == 'macos-latest' + uses: Apple-Actions/import-codesign-certs@v1 + with: + # The certificates in a PKCS12 file encoded as a base64 string + p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }} + # The password used to import the PKCS12 file. + p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }} +- name: Sign our macOS binary + if: matrix.platform == 'macos-latest' + run: | + echo "Signing Package" + gon -log-level=info ./build/darwin/gon-sign.json +``` + +请注意,与 Apple 签署二进制文件可能需要几分钟到几小时。 + +## 组合工作流文件: + +这是我们结合了 Windows + macOS 的 GitHub 工作流文件: + +```yaml +name: "example combined" on: workflow_dispatch: # This Action only starts when you go to Actions and manually run the workflow. @@ -194,7 +323,7 @@ jobs: package: strategy: matrix: - platform: [ windows-latest, macos-latest ] + platform: [windows-latest, macos-latest] go-version: [1.18] runs-on: ${{ matrix.platform }} steps: @@ -253,323 +382,6 @@ jobs: path: build/bin/* ``` -### Method 2: automatically signing with Action +# 尾注 -It is possible to use a Windows code signing Action like [this](https://github.com/marketplace/actions/code-sign-a-file-with-pfx-certificate) one, but note it requires a SHA1 hash for the certificate and a certificate name. View an example of how to configure it on the Action's [marketplace](https://github.com/marketplace/actions/code-sign-a-file-with-pfx-certificate). View an example of how to configure it on the Action's [marketplace](https://github.com/marketplace/actions/code-sign-a-file-with-pfx-certificate). View an example of how to configure it on the Action's [marketplace](https://github.com/marketplace/actions/code-sign-a-file-with-pfx-certificate). - ---- - -## MacOS - -First off you need your code signing certificate from Apple. If you do not have one, a simple Google search will help you acquire one. Once you have your certificate, you need to export it and encode it to base64. [This tutorial](https://localazy.com/blog/how-to-automatically-sign-macos-apps-using-github-actions) shows you how to do that in an easy manner. Once you have exported your .p12 certificate file, you can encode it to base64 as seen in the tutorial with the following command: If you do not have one, a simple Google search will help you acquire one. Once you have your certificate, you need to export it and encode it to base64. [This tutorial](https://localazy.com/blog/how-to-automatically-sign-macos-apps-using-github-actions) shows you how to do that in an easy manner. Once you have exported your .p12 certificate file, you can encode it to base64 as seen in the tutorial with the following command: If you do not have one, a simple Google search will help you acquire one. Once you have your certificate, you need to export it and encode it to base64. [This tutorial](https://localazy.com/blog/how-to-automatically-sign-macos-apps-using-github-actions) shows you how to do that in an easy manner. Once you have exported your .p12 certificate file, you can encode it to base64 as seen in the tutorial with the following command: - -```bash -base64 Certificates.p12 | pbcopy -``` - -Now you're ready to create some GitHub project secrets, just as with Windows: - -- **APPLE_DEVELOPER_CERTIFICATE_P12_BASE64** with the contents of your newly copied base64 certificate. -- **APPLE_DEVELOPER_CERTIFICATE_PASSWORD** with the contents of your certificate password. -- **APPLE_PASSWORD** with the contents of an App-Specific password to your Apple-ID account which you can generate [here](https://appleid.apple.com/account/manage). - -Let's make sure we are able to build our Wails app in our GitHub Action workflow. Here is a small template: Here is a small template: Here is a small template: - -```yaml -name: "example" -on: - workflow_dispatch: - # This Action only starts when you go to Actions and manually run the workflow. - -jobs: - package: - strategy: - matrix: - platform: [windows-latest, macos-latest] - go-version: [1.18] - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v2 - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - name: setup node - uses: actions/setup-node@v2 - with: - node-version: 14 - # You may need to manually build you frontend here, unless you have configured frontend build and install commands in wails.json. - name: "example" -on: - workflow_dispatch: - # This Action only starts when you go to Actions and manually run the workflow. - -jobs: - package: - strategy: - matrix: - platform: [ windows-latest, macos-latest ] - go-version: [1.18] - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v2 - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - name: setup node - uses: actions/setup-node@v2 - with: - node-version: 14 - # You may need to manually build you frontend here, unless you have configured frontend build and install commands in wails.json. - - name: Get Wails - run: go install github.com/wailsapp/wails/v2/cmd/wails@latest - - name: Build Wails app - run: | - wails build - - name: upload artifacts macOS - if: matrix.platform == 'macos-latest' - uses: actions/upload-artifact@v2 - with: - name: wails-binaries-macos - path: build/bin/* - - name: upload artifacts windows - if: matrix.platform == 'windows-latest' - uses: actions/upload-artifact@v2 - with: - name: wails-binaries-windows - path: build/bin/* -``` - -For code signing on macOS, [gon](https://github.com/mitchellh/gon) is a very handy tool for code signing and communicating with Apple servers, also written in Go, and will be used in this guide. - -After the `Build Wails app` step, add the following to the workflow: - -```yaml -- name: MacOS download gon for code signing and app notarization - if: matrix.platform == 'macos-latest' - run: | - brew install mitchellh/gon/gon -``` - -Now we need to configure some gon config files in our `build/darwin` directory: - -1. gon-sign.json: - -```json -{ - "source" : ["./build/bin/app.app"], - "bundle_id" : "app.myapp", - "apple_id": { - "username": "my-appleid@email.com", - "password": "@env:APPLE_PASSWORD" - }, - "sign" :{ - "application_identity" : "Developer ID Application: My Name" - } - } -``` - -Where `source` is your Wails binary, `bundle_id` is your bundle ID, `apple_id` contains your Apple ID username and App-Specific password which you created earlier, and `sign.application_identity` is your identity which you can find by running the following command: - -```bash -security find-identity -v -p codesigning -``` - -2. entitlements.plist: - -```plist -name: "example combined" -on: - workflow_dispatch: - # This Action only starts when you go to Actions and manually run the workflow. - -jobs: - package: - strategy: - matrix: - platform: [ windows-latest, macos-latest ] - go-version: [1.18] - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v2 - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - name: setup node - uses: actions/setup-node@v2 - with: - node-version: 14 - # You may need to manually build you frontend here, unless you have configured frontend build and install commands in wails.json. - - name: Get Wails - run: go install github.com/wailsapp/wails/v2/cmd/wails@latest - - name: Build Wails app - run: | - wails build - - name: MacOS download gon for code signing and app notarization - if: matrix.platform == 'macos-latest' - run: | - brew install mitchellh/gon/gon - - name: Import Code-Signing Certificates for macOS - if: matrix.platform == 'macos-latest' - uses: Apple-Actions/import-codesign-certs@v1 - with: - # The certificates in a PKCS12 file encoded as a base64 string - p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }} - # The password used to import the PKCS12 file. - - name: Import Code-Signing Certificates for macOS - if: matrix.platform == 'macos-latest' - uses: Apple-Actions/import-codesign-certs@v1 - with: - # The certificates in a PKCS12 file encoded as a base64 string - p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }} - # The password used to import the PKCS12 file. - p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }} -- name: Sign our macOS binary - if: matrix.platform == 'macos-latest' - run: | - echo "Signing Package" - gon -log-level=info ./build/darwin/gon-sign.json - p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }} -- name: Sign our macOS binary - if: matrix.platform == 'macos-latest' - run: | - echo "Signing Package" - gon -log-level=info ./build/darwin/gon-sign.json - p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }} -- name: Sign our macOS binary - if: matrix.platform == 'macos-latest' - run: | - echo "Signing Package" - gon -log-level=info ./build/darwin/gon-sign.json -``` - -In this file you configure the entitlements you need for you app, e.g. camera permissions if your app uses the camera. Read more about entitlements [here](https://developer.apple.com/documentation/bundleresources/entitlements). Read more about entitlements [here](https://developer.apple.com/documentation/bundleresources/entitlements). Read more about entitlements [here](https://developer.apple.com/documentation/bundleresources/entitlements). - -Make sure you have updated your `Info.plist` file with the same bundle ID as you entered in `gon-sign.json`. Here's an example `Info.plist` file: Here's an example `Info.plist` file: Here's an example `Info.plist` file: - -```plist - - - CFBundlePackageTypeAPPL - CFBundleNameMyApp - CFBundleExecutableapp - CFBundleIdentifierapp.myapp - CFBundleVersion0.1.0 - CFBundleGetInfoStringMy app is cool and nice and chill and - CFBundleShortVersionString0.1.0 - CFBundleIconFileiconfile - LSMinimumSystemVersion10.13.0 - NSHighResolutionCapabletrue - LSApplicationCategoryTypepublic.app-category.utilities - NSHumanReadableCopyright© Me - -``` - -Now we're ready to add the signing step in our workflow after building the Wails app: - -```yaml -- name: Import Code-Signing Certificates for macOS - if: matrix.platform == 'macos-latest' - uses: Apple-Actions/import-codesign-certs@v1 - with: - # The certificates in a PKCS12 file encoded as a base64 string - p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }} - # The password used to import the PKCS12 file. - p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }} -- name: Sign our macOS binary - if: matrix.platform == 'macos-latest' - run: | - echo "Signing Package" - gon -log-level=info ./build/darwin/gon-sign.json - p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }} -- name: Sign our macOS binary - if: matrix.platform == 'macos-latest' - run: | - echo "Signing Package" - gon -log-level=info ./build/darwin/gon-sign.json - p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }} -- name: Sign our macOS binary - if: matrix.platform == 'macos-latest' - run: | - echo "Signing Package" - gon -log-level=info ./build/darwin/gon-sign.json -``` - -Please note that signing binaries with Apple could take anywhere from minutes to hours. - -## Combined workflow file: - -Here is our GitHub workflow file with Windows + macOS combined: - -```yaml -name: "example combined" -on: - workflow_dispatch: - # This Action only starts when you go to Actions and manually run the workflow. - -jobs: - package: - strategy: - matrix: - platform: [windows-latest, macos-latest] - go-version: [1.18] - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v2 - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - name: setup node - uses: actions/setup-node@v2 - with: - node-version: 14 - # You may need to manually build you frontend here, unless you have configured frontend build and install commands in wails.json. - - name: Get Wails - run: go install github.com/wailsapp/wails/v2/cmd/wails@latest - - name: Build Wails app - run: | - wails build - - name: MacOS download gon for code signing and app notarization - if: matrix.platform == 'macos-latest' - run: | - brew install mitchellh/gon/gon - - name: Import Code-Signing Certificates for macOS - if: matrix.platform == 'macos-latest' - uses: Apple-Actions/import-codesign-certs@v1 - with: - # The certificates in a PKCS12 file encoded as a base64 string - p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }} - # The password used to import the PKCS12 file. - - name: Import Code-Signing Certificates for macOS - if: matrix.platform == 'macos-latest' - uses: Apple-Actions/import-codesign-certs@v1 - with: - # The certificates in a PKCS12 file encoded as a base64 string - p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }} - # The password used to import the PKCS12 file. - p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }} -- name: Sign our macOS binary - if: matrix.platform == 'macos-latest' - run: | - echo "Signing Package" - gon -log-level=info ./build/darwin/gon-sign.json - p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }} -- name: Sign our macOS binary - if: matrix.platform == 'macos-latest' - run: | - echo "Signing Package" - gon -log-level=info ./build/darwin/gon-sign.json - p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }} -- name: Sign our macOS binary - if: matrix.platform == 'macos-latest' - run: | - echo "Signing Package" - gon -log-level=info ./build/darwin/gon-sign.json -``` - -# End notes - -This guide inspired by the RiftShare project and its workflow, which is highly recommended to check out [here](https://github.com/achhabra2/riftshare/blob/main/.github/workflows/build.yaml). +本指南受 RiftShare 项目及其工作流程的启发,强烈建议在 [此处](https://github.com/achhabra2/riftshare/blob/main/.github/workflows/build.yaml) 查看。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/templates.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/templates.mdx index 5dba260b8..7f701203d 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/templates.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/templates.mdx @@ -2,12 +2,12 @@ Wails 从预先创建的模板生成项目。 在 v1 中,这是一组难以维护的项目,这些项目可能会过时。 在 v2 中,为了增强社区的能力,为模板添加了一些新功能: -- 能够从[远程模板](../reference/cli#远程模板)生成项目 +- 能够从 [远程模板](../reference/cli#远程模板) 生成项目 - 帮助创建自己的模板的工具 ## 创建模板 -要创建模板,您可以使用`wails generate template`命令。 要生成默认模板,请运行: +要创建模板,您可以使用 `wails generate template` 命令。 要生成默认模板,请运行: `wails generate template -name mytemplate` @@ -15,8 +15,6 @@ Wails 从预先创建的模板生成项目。 在 v1 中,这是一组难以维 ```shell title=mytemplate/ . -. -. |-- NEXTSTEPS.md |-- README.md |-- app.tmpl.go @@ -52,7 +50,7 @@ Wails 从预先创建的模板生成项目。 在 v1 中,这是一组难以维 | template.json | 模板元数据 | | wails.tmpl.json | `wails.json` 模板文件 | -此时,建议按照`NEXTSTEPS.md`中的步骤操作。 +此时,建议按照 `NEXTSTEPS.md` 中的步骤操作。 ## 从现有项目创建模板 @@ -71,32 +69,29 @@ Updating package.json data... Renaming package.json -> package.tmpl.json... Updating package-lock.json data... Renaming package-lock.json -> package-lock.tmpl.json... -Migrating existing project files to frontend directory... -Updating package.json data... -Renaming package.json -> package.tmpl.json... -Updating package-lock.json data... -Renaming package-lock.json -> package-lock.tmpl.json... ``` -- 现在可以按照`NEXTSTEPS.md`中指定的方式定制模板。 +- 现在可以按照 `NEXTSTEPS.md` 中指定的方式定制模板。 - 一旦文件准备完毕,就可以通过运行命令来测试它:`wails init -n my-vue3-project -t .\wails-vue3-template\` - 要测试新项目,请运行:`cd my-vue3-project` then `wails build` - 项目编译完成后,运行它:`.\build\bin\my-vue3-project.exe` - 您应该有了一个功能齐全的 Vue3 应用程序: +```mdx-code-block
+``` ## 发布模板 发布模板只是将文件推送到 GitHub。 鼓励以下最佳实践: - 从前端目录中删除任何不需要的文件和目录(例如:.git) -- 确保`template.json`完整,尤其是`helpurl` +- 确保 `template.json` 完整,尤其是 `helpurl` - 将文件推送到 GitHub -- 在[社区模板](../community/templates)页面上创建 PR -- 在[模板公告](https://github.com/wailsapp/wails/discussions/825)讨论板上发布模板 +- 在 [社区模板](../community/templates) 页面上创建 PR +- 在 [模板公告](https://github.com/wailsapp/wails/discussions/825) 讨论板上发布模板 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/troubleshooting.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/troubleshooting.mdx index 7cc6d3eba..aaf13ab63 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/troubleshooting.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/troubleshooting.mdx @@ -1,25 +1,25 @@ -# Troubleshooting +# 故障排除 -An assortment of troubleshooting tips. +各种故障排除技巧。 -## The `wails` command appears to be missing? +## `wails` 命令好像不见了? -If your system is reporting that the `wails` command is missing, make sure you have followed the Go installation guide correctly. Normally, it means that the `go/bin` directory in your User's home directory is not in the `PATH` environment variable. You will also normally need to close and reopen any open command prompts so that changes to the environment made by the installer are reflected at the command prompt. +如果您的系统报告缺少 `wails` 命令,请确保您已正确遵循 Go 安装指南。 通常,这意味着您的用户 home 目录中的 `go/bin` 目录不在 `PATH` 环境变量中。 通常情况下还需要关闭并重新打开任何已打开的命令提示符,以便安装程序对环境所做的更改反映在命令提示符中。 -## My application is displaying a white/blank screen +## 我的应用程序正在显示白屏/空白屏幕 -检查您的应用程序是否在正确目录中包含资源。 Check that your application includes the assets from the correct directory. In your `main.go` file, you will have something similar to the following code: +检查您的应用程序是否包含正确目录中的资产。 在您的 `main.go` 文件中,您将拥有类似于以下代码的内容: ```go //go:embed all:frontend/dist var assets embed.FS ``` -Check that `frontend/dist` contains your application assets. +检查它是否 `frontend/dist` 包含您的应用程序资产。 ### Mac -If this happens on Mac, try adding the following to your `Info.plist`: +如果在 Mac 上发生这种情况,请尝试将以下内容添加到您的 `Info.plist`: ```xml NSAppTransportSecurity @@ -29,21 +29,27 @@ If this happens on Mac, try adding the following to your `Info.plist`: ``` -Reference: https://github.com/wailsapp/wails/issues/1504#issuecomment-1174317433 +参考:https://github.com/wailsapp/wails/issues/1504#issuecomment-1174317433 -## Mac application not valid +## Mac 应用程序无效 -If your built application looks like this in finder: +如果您构建的应用程序在 finder 中如下所示: +```mdx-code-block

- +

+``` -It's likely that your application's `info.plist` is invalid. Update the file in `build/.app/Contents/info.plist` and check if the data is valid, EG check the binary name is correct. To persist the changes, copy the file back to the `build/darwin` directory. +您的申请很可能 `info.plist` 是无效的。 更新 `build/.app/Contents/info.plist`文件 并检查数据是否有效,比如:检查二进制名称是否正确。 要保留更改,请将文件复制回 `build/darwin` 目录。 -## Cannot call backend method from frontend with variadic arguments +## 无法使用可变参数 -If you have a backend method defined with variadic parameters, eg: +如果您有使用可变参数定义的后端方法,例如: ```go func (a *App) TestFunc(msg string, args ...interface{}) error { @@ -51,7 +57,7 @@ func (a *App) TestFunc(msg string, args ...interface{}) error { } ``` -calling this method from the frontend like this will fail: +像这样从前端调用此方法将失败: ```js var msg = "Hello: "; @@ -65,7 +71,7 @@ window.go.main.App.TestFunc(msg, ...args) }); ``` -Workaround: +解决方法: ```js var msg = "Hello "; @@ -80,32 +86,32 @@ window.go.main.App.TestFunc(msg, args) }); ``` -Credit: https://github.com/wailsapp/wails/issues/1186 +致谢:https://github.com/wailsapp/wails/issues/1186 -## I'm having getting proxy errors when trying to install Wails +## 我正在尝试安装Wails时获取代理错误 -If you are getting errors like this: +如果您遇到这样的错误: ``` "https://proxy.golang.org/github.com/wailsapp/wails/cmd/wails/@v/list": dial tcp 172.217.163.49:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ``` -it's probably because the official Go Proxy is being blocked (Users in China have reported this). The solution is to set up the proxy manually, eg: 解决方案是手动设置代理,例如: +这可能是因为官方 Go Proxy 被阻止(中国用户报告了这一点)。 解决方案是手动设置代理,例如: ``` go env -w GO111MODULE=on go env -w GOPROXY=https://goproxy.cn,direct ``` -Source: https://github.com/wailsapp/wails/issues/1233 +来源:https://github.com/wailsapp/wails/issues/1233 -## The generated Typescript doesn't have the correct types +## 没有生成正确的 Typescript 类型 -Sometimes the generated Typescript doesn't have the correct types. Sometimes the generated Typescript doesn't have the correct types. To mitigate this, it is possible to specify what types should be generated using the `ts_type` struct tag. For more details, please read [this](https://github.com/tkrajina/typescriptify-golang-structs#custom-types). For more details, please read [this](https://github.com/tkrajina/typescriptify-golang-structs#custom-types). +有时生成的 Typescript 没有正确的类型。 `ts_type` 为了缓解这种情况,可以使用 struct 标签指定应该生成哪些类型。 有关详细信息,请阅读 [此](https://github.com/tkrajina/typescriptify-golang-structs#custom-types) 内容。 -## When I navigate away from `index.html`, I am unable to call methods on the frontend +## 当我离开 `index.html`时,我无法在前端调用方法 -If you navigate away from `index.html` to a new html file, the context will be lost. If you navigate away from `index.html` to a new html file, the context will be lost. This can be fixed by adding the following imports to the `` section of any new page you navigate to: +如果您导航 `index.html` 到一个新的 html 文件,上下文将会丢失。 这可以通过将以下导入添加到 `` 您导航到的任何新页面的部分来解决: ```html @@ -114,17 +120,17 @@ If you navigate away from `index.html` to a new html file, the context will be l ``` -Source: https://github.com/wailsapp/wails/discussions/1512 +来源:https://github.com/wailsapp/wails/discussions/1512 -## I get `too many open files` errors on my Mac when I run `wails dev` +## 运行 `wails dev` 出现 `too many open files` 错误 -By default, macOS will only allow you to open a maximum of 256 files. This can affect the `wails dev` command. This limit can be increased by running: `ulimit -n 1024` in the terminal. This can affect the `wails dev` command. This limit can be increased by running: `ulimit -n 1024` in the terminal. +默认情况下,macOS 最多只能打开 256 个文件。 这会影响 `wails dev` 命令 可以通过在终端中运行:`ulimit -n 1024` 来增加此限制。 -FSNotify is [looking to move to Apple's fsevents](https://github.com/fsnotify/fsnotify/issues/11) for Mac. If this isn't completed soon, we will create our own implementation, tracked [here](https://github.com/wailsapp/wails/issues/1733). If this isn't completed soon, we will create our own implementation, tracked [here](https://github.com/wailsapp/wails/issues/1733). +FSNotify 正在 [寻求转移到苹果](https://github.com/fsnotify/fsnotify/issues/11)。 如果这不能很快完成,我们将创建自己的实现,在 [此处](https://github.com/wailsapp/wails/issues/1733) 跟踪。 -## My Mac app gives me weird compilation errors +## 我的 Mac 应用程序给了我奇怪的编译错误 -A few users have reported seeing compilation errors such as the following: +一些用户报告看到编译错误,如下所示: ```shell # github.com/wailsapp/wails/v2/internal/frontend/desktop/darwin @@ -137,6 +143,6 @@ In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/Sy #define NS_FORMAT_ARGUMENT(A) __attribute__ ((format_arg(A))) ``` -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. +这 _通常_ 是由于您正在运行的操作系统版本和安装的 XCode 命令行工具的版本不匹配。 如果您看到这样的错误,请尝试将您的 XCode 命令行工具升级到最新版本。 -Source: https://github.com/wailsapp/wails/issues/1806 \ No newline at end of file +来源:https://github.com/wailsapp/wails/issues/1806 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/vscode.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/vscode.mdx index 9911a286c..ea2d1b99d 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/vscode.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/vscode.mdx @@ -1,15 +1,15 @@ # Visual Studio Code -This page is for miscellaneous tips and tricks when using Visual Studio Code with Wails. +此页面提供在使用带有 Wails 的 Visual Studio Code 时的各种提示和技巧。 -## Vetur Configuration +## Vetur 配置 -Many thanks to [@Lyimmi](https://github.com/Lyimmi) for this tip. Many thanks to [@Lyimmi](https://github.com/Lyimmi) for this tip. Originally posted [here](https://github.com/wailsapp/wails/issues/1791#issuecomment-1228158349). +非常感谢 [@Lyimmi](https://github.com/Lyimmi) 的这个提示。 最初张贴 [在这里](https://github.com/wailsapp/wails/issues/1791#issuecomment-1228158349)。 -Vetur is a popular plugin for Visual Studio Code that provides syntax highlighting and code completion for Vue projects. Vetur is a popular plugin for Visual Studio Code that provides syntax highlighting and code completion for Vue projects. When loading a Wails project in VSCode, Vetur will throw an error as it is expecting to find the frontend project in the root directory. To fix this, you can do the following: To fix this, you can do the following: +Vetur 是一个流行的 Visual Studio Code 插件,它为 Vue 项目提供语法高亮和代码完成。 在 VSCode 中加载 Wails 项目时,Vetur 会抛出错误,因为它期望在根目录中找到前端项目。 要解决此问题,您可以执行以下操作: -Create a file named `vetur.config.js` in the project's root. +在项目根目录创建一个以 `vetur.config.js` 命名的文件。 ```javascript // vetur.config.js @@ -53,46 +53,10 @@ module.exports = { ] } ] -} - settings: { - "vetur.useWorkspaceDependencies": true, - "vetur.experimental.templateInterpolationService": true - }, - // **optional** default: `[{ root: './' }]` - // support monorepos - projects: [ - { - // **required** - // Where is your project? - // It is relative to `vetur.config.js`. - // root: './packages/repo1', - root: './frontend', - // **optional** default: `'package.json'` - // Where is `package.json` in the project? - // We use it to determine the version of vue. - // It is relative to root property. - package: './package.json', - // **optional** - // Where is TypeScript config file in the project? - // It is relative to root property. - tsconfig: './tsconfig.json', - // **optional** default: `'./.vscode/vetur/snippets'` - // Where is vetur custom snippets folders? - snippetFolder: './.vscode/vetur/snippets', - // **optional** default: `[]` - // Register globally Vue component glob. - // If you set it, you can get completion by that components. - // It is relative to root property. - // Notice: It won't actually do it. You need to use `require.context` or `Vue.component` - globalComponents: [ - './src/components/**/*.vue' - ] - } - ] } ``` -Next, configure `frontend/tsconfig.json`: +接下来,配置 `frontend/tsconfig.json`: ```javascript { @@ -115,4 +79,4 @@ Next, configure `frontend/tsconfig.json`: ] } ``` -This should enable you to now use Vetur as expected. +这应该使您现在可以按预期使用 Vetur。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/windows-installer.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/windows-installer.mdx index 5eb5b7d1f..02c73c16c 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/windows-installer.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/windows-installer.mdx @@ -1,20 +1,22 @@ # NSIS 安装程序 +```mdx-code-block

+ />

+``` -Wails 支持使用[NSIS 安装程序](https://nsis.sourceforge.io/)生成 Windows 安装程序。 +Wails 支持使用 [NSIS 安装程序](https://nsis.sourceforge.io/) 生成 Windows 安装程序。 ## 安装 NSIS ### Windows -安装程序可在[NSIS 下载页面](https://nsis.sourceforge.io/Download)上找到。 +安装程序可在 [NSIS 下载页面](https://nsis.sourceforge.io/Download) 上找到。 如果您使用 chocolatey 包管理器,请运行以下脚本: @@ -22,11 +24,11 @@ Wails 支持使用[NSIS 安装程序](https://nsis.sourceforge.io/)生成 Window choco install nsis ``` -如果手动安装 NSIS,则需要将 NSIS 安装目录中包含`makensis.exe`的*Bin*目录添加到 PATH 中。 [这是](https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/) 一个关于如何在 Windows 上添加到 PATH 的好教程。 +如果手动安装 NSIS,则需要将 NSIS 安装目录中包含 `makensis.exe` 的 *Bin* 目录添加到 PATH 中。 [这是](https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/) 一个关于如何在 Windows 上添加到 PATH 的好教程。 ### Linux -应该可以通过您的发行版的软件包管理器获得`nsis`包。 +应该可以通过您的发行版的软件包管理器获得 `nsis` 包。 ### MacOS @@ -34,10 +36,10 @@ NSIS 可通 homebrew 安装:`brew install nsis`。 ## 生成安装程序 -创建新项目时,Wails 从`installer/info.json`中读取配置数据并使用项目的`wails.json`的 Info 部分,在`build/windows/installer`中生成 NSIS 配置文件: 创建新项目时,Wails 从`installer/info.json`中读取配置数据并使用项目的`wails.json`的 Info 部分,在`build/windows/installer`中生成 NSIS 配置文件: The config data is read from `installer/info.json` and that is configured to use the project's `wails.json` Info section: 创建新项目时,Wails 从`installer/info.json`中读取配置数据并使用项目的`wails.json`的 Info 部分,在`build/windows/installer`中生成 NSIS 配置文件: The config data is read from `installer/info.json` and that is configured to use the project's `wails.json` Info section: +创建新项目时,Wails 会在 `build/windows/installer` 中生成 NSIS 配置文件。 从 `installer/info.json` 读取配置数据,并配置为使用项目的 `wails.json` 信息部分: ```json - // ... +// ... "Info": { "companyName": "My Company Name", "productName": "Wails Vite", @@ -47,10 +49,10 @@ NSIS 可通 homebrew 安装:`brew install nsis`。 }, ``` -要为您的应用程序生成安装程序,请使用`wails build`的`-nsis`标志: +要为您的应用程序生成安装程序,请使用 `wails build` 的 `-nsis` 标志: ``` wails build -nsis ``` -现在可用安装程序将生成在`build/bin`目录中。 +现在可用安装程序将生成在 `build/bin` 目录中。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/windows.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/windows.mdx index 93f89b44c..0fc857c81 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/windows.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/windows.mdx @@ -1,17 +1,17 @@ -# Windows 系统 +# Windows 此页面包含了在 Windows 上开发 Wails 应用程序相关的其他指南。 ## 处理 WebView2 运行时依赖 -为 Windows 构建 Wails 应用程序时对 Microsoft [WebView2 运行时](https://developer.microsoft.com/en-us/microsoft-edge/webview2/)有要求。 默认情况下,Windows 11 会安装它,但有些机器不会。 Wails 提供了一种简单的方法来处理这种依赖关系。 +为 Windows 构建 Wails 应用程序时对 Microsoft [WebView2 运行时](https://developer.microsoft.com/en-us/microsoft-edge/webview2/) 有要求。 默认情况下,Windows 11 会安装它,但有些机器不会。 Wails 提供了一种简单的方法来处理这种依赖关系。 -通过在构建时使用`-webview2`标志,您可以决定在未检测到合适的运行时的时候(包括安装的运行时是否太旧)应用程序将执行的操作。 四个选项是: +通过在构建时使用 `-webview2` 标志, 您可以决定在未检测到合适的运行时的时候(包括安装的运行时是否太旧)应用程序将执行的操作。 四个选项是: 1. Download(下载) 2. Embed(内嵌) 3. Browser(浏览器) -4. Error(错误) +4. Error(报错) ### Download(下载) @@ -25,15 +25,15 @@ 此选项将提示用户没有找到合适的运行时时,提供打开浏览器到 WebView2 官方页面,可以下载和安装引导程序。 然后应用程序将会退出,安装的操作留给用户。 -### Error(错误) +### Error(报错) 如果未找到合适的运行时间,则会向用户显示错误并且不采取进一步措施。 -## Fixed version runtime +## 固定版本运行时 -Another way of dealing with webview2 dependency is shipping it yourself. Another way of dealing with webview2 dependency is shipping it yourself. You can download [fixed version runtime](https://developer.microsoft.com/ru-ru/microsoft-edge/webview2/#download-section) and bundle or download it with your application. Another way of dealing with webview2 dependency is shipping it yourself. You can download [fixed version runtime](https://developer.microsoft.com/microsoft-edge/webview2/#download-section) and bundle or download it with your application. +处理 webview2 依赖的另一种方法是自己发送。 您可以下载 [固定版本的运行时](https://developer.microsoft.com/microsoft-edge/webview2/#download-section) 并将其捆绑或与您的应用程序一起下载。 -Also, you should specify path to fixed version of webview2 runtime in the `windows.Options` structure when launching wails. +此外,您应该在启动 wails 时在结构体 `windows.Options` 中指定 webview2 运行时的固定版本的路径。 ```go wails.Run(&options.App{ @@ -43,11 +43,11 @@ Also, you should specify path to fixed version of webview2 runtime in the `windo }) ``` -Note: When `WebviewBrowserPath` is specified, `error` strategy will be forced in case of minimal required version mismatch or invalid path to a runtime. +注意:当 `WebviewBrowserPath` 指定时,`error` 策略将在最小要求版本不匹配或运行时路径无效的情况下被强制执行。 -## Spawning other programs +## 创建其他程序 -When spawning other programs, such as scripts, you will see the window appear on the screen. To hide the window, you can use the following code: +当生成其他程序(例如脚本)时,您将看到屏幕上出现该窗口。 要隐藏窗口,可以使用以下代码: ```go cmd := exec.Command("your_script.exe") @@ -58,4 +58,4 @@ cmd.SysProcAttr = &syscall.SysProcAttr{ cmd.Start() ``` -Solution provided by [sithembiso](https://github.com/sithembiso) on the [discussions board](https://github.com/wailsapp/wails/discussions/1734#discussioncomment-3386172). +[sithembiso](https://github.com/sithembiso) 在 [讨论板](https://github.com/wailsapp/wails/discussions/1734#discussioncomment-3386172) 上提供的解决方案。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/howdoesitwork.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/howdoesitwork.mdx index ebd640bef..1874960e6 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/howdoesitwork.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/howdoesitwork.mdx @@ -6,15 +6,17 @@ sidebar_position: 20 Wails 应用程序是一个带有一个 webkit 前端的标准的 Go 应用程序。 应用程序的 Go 部分由应用程序代码和一个运行时库组成, 该库提供了许多有用的操作,例如控制应用程序窗口。 前端是一个 webkit 窗口,将显示前端资源。 前端还可以使用运行时库的 Javascript 版本。 最后,可以将 Go 方法绑定到前端,这些将显示为可以调用的 Javascript 方法,就像它们是原生 Javascript 方法一样。 +```mdx-code-block
+``` ## 主应用程序 ### 概述 -主应用程序由对`wails.Run()`的调用组成。 它接受描述应用程序窗口大小、窗口标题、要使用的资源等应用程序配置。 基本应用程序可能如下所示: +主应用程序由对 `wails.Run()` 的调用组成。 它接受描述应用程序窗口大小、窗口标题、要使用的资源等应用程序配置。 基本应用程序可能如下所示: ```go title="main.go" package main @@ -71,46 +73,48 @@ func (b *App) Greet(name string) string { 此示例设置了以下选项: - `Title` - 应该出现在窗口标题栏中的文本 -- `Width&Height`- 窗口的尺寸 -- `Assets` - 应用程序的前端资源 +- `Width` & `Height` - 窗口的尺寸 +- `Assets` - 应用程序的前端资产 - `OnStartup` - 创建窗口并即将开始加载前端资源时的回调 - `OnShutdown` - 应用程序即将退出时的回调 - `Bind` - 我们希望向前端暴露的一部分结构体实例 -完整的应用程序参数选项列表可以在[参数选项](./reference/options)中找到。 +完整的应用程序参数选项列表可以在 [参数选项](./reference/options) 中找到。 #### 资产 -`Assets` 选项是必须的,因为您不能拥有没有前端资源的 Wails 应用程序。 这些资源可以是您希望在 Web 应用程序中找到的任何文件 - html、js、css、svg、png 等。 **不需要生成资源包** - 纯文件即可。 当应用程序启动时,它将尝试从您的资源中加载`index.html`,并且那时起前端基本上将作为浏览器工作。 值得注意的是`embed.FS`对文件所在的位置没有要求。 嵌入路径很可能使用了相对于您的主应用程序代码的嵌套目录,例如 `frontend/dist`: +`Assets` 选项是必须的,因为您不能拥有没有前端资产的 Wails 应用程序。 这些资产可以是您希望在 Web 应用程序中找到的任何文件 - html、js、css、svg、png 等。 **不需要生成资源包** - 普通文件即可。 当应用程序启动时,它将尝试从您的资产中加载 `index.html`,并且那时起前端基本上将作为浏览器工作。 值得注意的是 `embed.FS` 对文件所在的位置没有要求。 嵌入路径很可能使用了相对于您的主应用程序代码的嵌套目录,例如 `frontend/dist`: ```go title="main.go" //go:embed all:frontend/dist var assets embed.FS ``` -启动时,Wails 将遍历嵌入的文件,寻找包含的`index.html`。 所有其他资源将相对于该目录加载。 +启动时,Wails 将遍历嵌入的文件,寻找包含的 `index.html`。 所有其他资源将相对于该目录加载。 -由于可用于生产的二进制文件使用包含在`embed.FS`中的文件,因此应用程序不需要附带任何外部文件。 +由于可用于生产的二进制文件使用包含在 `embed.FS` 中的文件,因此应用程序不需要附带任何外部文件。 -当使用`wails dev`命令在“开发”模式下,资源从磁盘加载,任何更改都会导致“实时重新加载”。 资产的位置将从 `embed.FS` 推断。 +在开发模式下使用 `wails dev` 命令,资产从磁盘加载,任何更改都会导致“实时重新加载”。 资产的位置将从 `embed.FS` 推断。 -更多细节可以在[应用程序开发指南](./guides/application-development)中找到。 +更多细节可以在 [应用程序开发指南](./guides/application-development) 中找到。 #### 应用程序生命周期回调 -在即将加载前端`index.html`之前,对 [应用启动回调](./reference/options#应用启动回调) 中提供的函数进行调用。 一个标准的 Go 上下文被传递给这个方法。 调用运行时需要此上下文,因此标准方式是保存此时对它的引用。 在应用程序关闭之前,再次使用上下文以同样的方式调用 [应用退出回调](./reference/options#应用退出回调)。 当前端完成加载`index.html`中所有资源时,还有一个 [前端 Dom 加载完成回调](./reference/options#前端-dom-加载完成回调) ,相当于 Javascript 中的`body onload`事件。 还可以通过设置 [关闭应用程序之前回调](./reference/options#关闭应用程序之前回调) 选项来控制窗口关闭(或应用程序退出)事件。 +在即将加载前端 `index.html` 之前,会对 [应用启动回调](./reference/options#应用启动回调) 中提供的函数进行调用。 一个标准的 Go context 被传递给这个方法。 调用运行时需要此 context ,因此标准模式是在此方法中保存对它的引用。 在应用程序关闭之前,以同样的方式调用 [应用退出回调](./reference/options#应用退出回调),并再次使用上下文 当前端加载完 `index.html` 中所有资源时,还有一个 [前端 Dom 加载完成回调](./reference/options#前端-dom-加载完成回调) ,相当于 Javascript 中的 [`body onload`](https://www.w3schools.com/jsref/event_onload.asp) 事件。 还可以通过设置 [关闭应用程序之前回调](./reference/options#关闭应用程序之前回调) 选项来控制窗口关闭(或应用程序退出)事件。 #### 方法绑定 -`Bind`选项是 Wails 应用程序中最重要的参数选项之一。 它指定向前端暴露哪些结构方法。 想到传统的 web 应用程序中的 "Controllers" 。 当应用程序启动时,它会检查 `Bind` 中列出的结构实例, 确定哪些方法是公开的(以大写字母开头),并将生成前端可以调用的那些方法的 Javascript 版本。 +`Bind` 选项是 Wails 应用程序中最重要的参数选项之一。 它指定向前端暴露哪些结构体方法。 想想传统 web 应用程序中的 "Controllers" 之类的结构 。 当应用程序启动时,它会检查 `Bind` 字段中列出的结构体实例, 确定哪些方法是公开的(以大写字母开头),并生成前端可以调用的这些方法的 Javascript 版本。 :::info 注意 -Wails 要求您传入结构的 _实例_ 才能正确绑定它 + +Wails 要求您传入结构体的 _实例_ 以使其正确绑定 ::: -在此示例中,我们创建一个新`App`实例,然后将此实例添加到`wails.Run`中的`Bind`选项: + +在此示例中,我们创建一个新的 `App` 实例,然后将此实例添加到 `wails.Run` 中的 `Bind` 选项: ```go {16,24} title="main.go" package main @@ -154,105 +158,89 @@ func (a *App) Greet(name string) string { } ``` -您可以绑定任意数量的结构体。 只需确保创建它的一个实例并将其传递给 `Bind`: +您可以绑定任意数量的结构体。 只需确保创建它的实例并将其传递给 `Bind`: ```go {8-10} //... - //... - ... err := wails.Run(&options.App{ Title: "Basic Demo", Width: 1024, Height: 768, Assets: &assets, - OnStartup: app.startup, - OnShutdown: app.shutdown, Bind: []interface{}{ app, &mystruct1{}, &mystruct2{}, }, }) -... ``` -When you run `wails dev` (or `wails generate module`), a frontend module will be generated containing the following: +当您运行 `wails dev`(或 `wails generate module`)时,将生成一个前端模块,其中包含以下内容: -- 调用绑定的 Go 方法 -- 调用运行时方法 -- Typescript definitions for all Go structs used as inputs or outputs by the bound methods +- 所有绑定方法的 Javascript 绑定 +- 所有绑定方法的 Typescript 声明 +- 绑定方法用作输入或输出的所有 Go 结构的 Typescript 声明 -This makes it incredibly simple to call Go code from the frontend, using the same strongly typed datastructures. +这使得使用相同的强类型数据结构从前端调用 Go 代码变得异常简单。 ## 前端 ### 概述 -前端是由 webkit 渲染的文件集合。 这就像浏览器和网络服务器合二为一。 您可以使用的框架或库[^1]几乎没有限制。 前端和 Go 代码之间的主要交互点是: +前端是由 webkit 渲染的文件集合。 这就合二为一的浏览器和网络服务器。 您可以使用的框架或库[^1]几乎没有限制。 前端和 Go 代码之间的主要交互点是: - 调用绑定的 Go 方法 - 调用运行时方法 ### 调用绑定的 Go 方法 -在`wails dev`模式下运行应用程序时,会生成一个 javascript 模块,该模块用 JSDoc 注释包装这些方法。 这确实有助于开发,尤其是因为大多数 IDE 将处理 JSDoc 以提供代码完成和类型提示。 该模块名为`go` 并在`wailsjsdir`标志指定的目录中生成。 The generated files mirror the package names in your application. 在上面的例子中,我们绑定 `app`,它有一个公开方法 `Greet`。 在上面的例子中,我们绑定 `app`,它有一个公开方法 `Greet`。 This will lead to the generation of the following files: +当您使用 `wails dev` 运行应用程序时,它将自动在名为 `wailsjs/go` 的目录中为您的结构体生成 Javascript 绑定(您也可以通过运行 `wails generate module` 来执行此操作)。 生成的文件反映了应用程序中的包名称。 在上面的例子中,我们绑定了有公开方法 `Greet` 的 `app`。 这将导致生成以下文件: ```bash -window.go.main.App.Greet("Bill").then((result) => { - console.log("The greeting is: " + result); - }) +wailsjs + └─go + └─main + ├─App.d.ts + └─App.js ``` -Here we can see that there is a `main` package that contains the Javascript bindings for the bound `App` struct, as well as the Typescript declaration file for those methods. To call `Greet` from our frontend, we simply import the method and call it like a regular Javascript function: 要从我们的前端调用 `Greet`,我们只需导入该方法并像普通的 Javascript 函数一样调用它: +在这里我们可以看到有一个 `main` 包,其中包含绑定 `App` 结构体的 Javascript 绑定,以及这些方法的 Typescript 声明文件。 要从我们的前端调用 `Greet`,我们只需导入该方法并像普通的 Javascript 函数一样调用它: ```javascript // ... -// ... -// ... - // ... - import {Greet} from '../wailsjs/go/main/App' +import { Greet } from "../wailsjs/go/main/App"; - function doGreeting(name) { - Greet(name).then((result) => { - // Do something with result - }) - } +function doGreeting(name) { + Greet(name).then((result) => { + // Do something with result + }); +} ``` -The Typescript declaration file gives you the correct types for the bound methods: +Typescript 声明文件为您提供了绑定方法的正确类型: ```ts -const go = { - main: { - App: { - /** - * Greet - * @param {Person} arg1 - Go Type: string - * @returns {Promise} - Go Type: string - */ - Greet: (arg1) => { - return window.go.main.App.Greet(arg1); - }, - }, - }, -}; -export default go; +export function Greet(arg1: string): Promise; ``` -这些方法返回一个 Promise。 成功的调用将导致 Go 调用的第一个返回值被传递给 `resolve` 处理程序。 一个不成功的调用是将一个 Go 方法的第二个错误类型返回值通过`reject`传递回调用者。 这通过 `reject` 处理程序传回。 This is passed back via the `reject` handler. 在上面的例子中,Greet 只返回一个字符串,所以 `Javascript` 调用永远不会`reject` - 除非将无效数据传递给它。 +生成的方法返回一个 Promise 成功的调用将导致 Go 调用的第一个返回值被传递给 `resolve` 处理程序。 不成功的调用是当 Go 方法的第二个返回值具有错误类型时,将错误实例传递回调用者。 这通过 `reject` 处理程序传回的。 在上面的示例中,`Greet` 只返回一个 `string`,因此 Javascript 调用永远不会 reject - 除非将无效数据传递给它。 -所有数据类型都在 Go 和 Javascript 之间正确转换。 包括结构体。 如果您从 Go 调用返回一个结构体,它将作为 `Javascript` Map 返回到您的前端。 注意:如果您想使用结构体,您必须为您的结构体字段定义`json` 标签! +所有数据类型都在 Go 和 Javascript 之间正确转换。 包括结构体。 如果您从 Go 调用返回一个结构体,它将作为 Javascript 类返回到您的前端。 注意:如果您想使用结构体,您 **必须** 为您的结构体字段定义 `json` 标签! :::info 注意 + + 目前不支持嵌套匿名结构体。 + ::: -也可以将结构体发送回 Go。 任何作为期望结构的参数传递的 Javascript Map 都将转换为该结构类型。 为了使这个过程更容易,在 `开发`模式下,会生成一个 TypeScript 模块,定义绑定方法中使用的所有结构类型。 使用此模块,可以构建原生 Javascript 对象并将其发送到 Go 代码。 -还额外支持在其签名中使用结构的 Go 方法。 所有由绑定方法指定的 Go 结构体(作为参数或返回类型)都将自动生成 Typescript 版本作为 Go 代码包装器模块的一部分。 使用这些,可以在 Go 和 Javascript 之间共享相同的数据模型。 +也可以将结构体发送回 Go。 作为期望的结构体的参数传递的任何 Javascript map/class 都将转换为该结构体类型。 为了使这个过程更容易,在 `开发` 模式下,会生成一个 TypeScript 模块,声明绑定方法中使用的所有结构体类型。 使用此模块,可以构建原生 Javascript 对象并将其发送到 Go 代码。 -此外`bindings.js`,还有一个名为`models.ts`的文件. 这包含我们 Go 结构体的 TypeScript 形式: +还支持在其签名中使用结构的 Go 方法。 绑定方法(作为参数或返回类型)指定的所有 Go 结构体都将作为 Go 代码包装器模块的一部分自动生成 Typescript 版本。 使用这些,可以在 Go 和 Javascript 之间共享相同的数据模型。 + +示例:我们更新 `Greet` 方法以接受一个 `Person` 而不是字符串: ```go title="main.go" type Person struct { @@ -271,156 +259,96 @@ func (a *App) Greet(p Person) string { } ``` -只要您将 TypeScript 作为前端构建配置的一部分,您就可以通过以下方式使用这些模型: +`wailsjs/go/main/App.js` 文件仍将包含以下代码: ```js title="App.js" -export class Address { - street: string; - postcode: string; - - static createFrom(source: any = {}) { - return new Address(source); - } - - constructor(source: any = {}) { - if ("string" === typeof source) source = JSON.parse(source); - this.street = source["street"]; - this.postcode = source["postcode"]; - } +export function Greet(arg1) { + return window["go"]["main"]["App"]["Greet"](arg1); } -export class Person { - name: string; - age: number; - address?: Address; +``` - static createFrom(source: any = {}) { - return new Person(source); - } +但是 `wailsjs/go/main/App.d.ts` 文件将使用以下代码进行更新: - constructor(source: any = {}) { - if ("string" === typeof source) source = JSON.parse(source); - this.name = source["name"]; - this.age = source["age"]; - this.address = this.convertValues(source["address"], Address); - } +```ts title="App.d.ts" +import { main } from "../models"; - convertValues(a: any, classs: any, asMap: boolean = false): any { - if (!a) { - return a; +export function Greet(arg1: main.Person): Promise; +``` + +正如我们所见,“main”命名空间是从一个新的“models.ts”文件中导入的。 该文件包含我们绑定方法使用的所有结构体定义。 在此示例中,这是一个 `Person` 结构。 如果我们查看 `models.ts`,我们可以看到模型是如何定义的: + +```ts title="models.ts" +export namespace main { + export class Address { + street: string; + postcode: string; + + static createFrom(source: any = {}) { + return new Address(source); } - if (a.slice) { - return (a as any[]).map((elem) => this.convertValues(elem, classs)); - } else if ("object" === typeof a) { - if (asMap) { - for (const key of Object.keys(a)) { - a[key] = new classs(a[key]); - } + + constructor(source: any = {}) { + if ("string" === typeof source) source = JSON.parse(source); + this.street = source["street"]; + this.postcode = source["postcode"]; + } + } + export class Person { + name: string; + age: number; + address?: Address; + + static createFrom(source: any = {}) { + return new Person(source); + } + + constructor(source: any = {}) { + if ("string" === typeof source) source = JSON.parse(source); + this.name = source["name"]; + this.age = source["age"]; + this.address = this.convertValues(source["address"], Address); + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { return a; } - return new classs(a); + if (a.slice) { + return (a as any[]).map((elem) => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; } - return a; } } ``` -JSDoc 和 TypeScript 生成模型的组合构成了一个强大的开发环境。 +只要您将 TypeScript 作为前端构建配置的一部分,您就可以通过以下方式使用这些模型: -```ts title="App.d.ts" -import go from "./wailsjs/go/bindings"; -import { Person } from "./wailsjs/go/models"; +```js title="mycode.js" +import { Greet } from "../wailsjs/go/main/App"; +import { main } from "../wailsjs/go/models"; -let name = ""; - -function greet(name) { - let p = new Person(); - p.name = name; - p.age = 42; - go.main.App.Greet(p).then((result) => { +function generate() { + let person = new main.Person(); + person.name = "Peter"; + person.age = 27; + Greet(person).then((result) => { console.log(result); }); } ``` -As we can see, the "main" namespace is imported from a new "models.ts" file. This file contains all the struct definitions used by our bound methods. In this example, this is a `Person` struct. If we look at `models.ts`, we can see how the models are defined: 该文件包含我们绑定方法使用的所有结构定义。 在这个示例中,这是一个 `Person` 结构体。 如果我们查看 `models.ts`,我们可以看到模型是如何定义的: +生成的绑定和 TypeScript 模型的结合构成了一个强大的开发环境。 -```ts title="models.ts" -export namespace main { - - export class Address { - street: string; - postcode: string; - - static createFrom(source: any = {}) { - return new Address(source); - } - - constructor(source: any = {}) { - if ('string' === typeof source) source = JSON.parse(source); - this.street = source["street"]; - this.postcode = source["postcode"]; - } - } - export class Person { - name: string; - age: number; - address?: Address; - - static createFrom(source: any = {}) { - return new Person(source); - } - - constructor(source: any = {}) { - if ('string' === typeof source) source = JSON.parse(source); - this.name = source["name"]; - this.age = source["age"]; - this.address = this.convertValues(source["address"], Address); - } - - convertValues(a: any, classs: any, asMap: boolean = false): any { - if (!a) { - return a; - } - if (a.slice) { - return (a as any[]).map(elem => this.convertValues(elem, classs)); - } else if ("object" === typeof a) { - if (asMap) { - for (const key of Object.keys(a)) { - a[key] = new classs(a[key]); - } - return a; - } - return new classs(a); - } - return a; - } - } -} -``` - -可以在[运行时参考](./reference/runtime/intro)中找到有关 JS 运行时的更多详细信息。 - -```js title="mycode.js" -const go = { - main: { - App: { - /** - * Greet - * @param {Person} arg1 - Go Type: main.Person - * @returns {Promise} - Go Type: string - */ - Greet: (arg1) => { - return window.go.main.App.Greet(arg1); - }, - }, - }, -}; -export default go; -``` - -The combination of generated bindings and TypeScript models makes for a powerful development environment. - -关于绑定的更多信息可以在[应用程序开发指南](./guides/application-development)的[绑定方法](./guides/application-development#绑定方法)一节中找到。 +有关绑定的更多信息,请参见 [应用开发指南](guides/application-development.mdx) 的 [绑定方法](guides/application-development.mdx#绑定方法) 部分。 ### 调用运行时方法 @@ -430,6 +358,6 @@ Javascript 运行时位于`window.runtime`并包含许多方法来执行各种 window.runtime.EventsEmit("my-event", 1); ``` -More details about the JS runtime can be found in the [Runtime Reference](reference/runtime/intro). +更多关于 JS 运行时的细节可以在 [运行时参考](reference/runtime/intro) 中找到。 [^1]: 有一小部分库使用了 WebView 中不支持的功能。 对于这种情况,通常有替代方案和解决方法。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/introduction.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/introduction.mdx index 68bdd5ed6..bfc83897d 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/introduction.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/introduction.mdx @@ -16,19 +16,20 @@ Wails 是一个可让您使用 Go 和 Web 技术编写桌面应用的项目。 - 从 Javascript 轻松调用 Go 方法 - 自动将Go结构体转换为TypeScript模块 - Windows 上不需要 CGO 或外部 DLL -- 使用 [Vite ](https://vite.net/) 的实时开发模式 +- 使用 [Vite ](https://vitejs.dev/) 的实时开发模式 - 可以轻松创建、构建和打包应用的强大命令行工具 -- 丰富的 [运行时库](/docs/next/reference/runtime) -- Applications built with Wails are Apple & Microsoft Store compliant - +- 丰富的 [运行时库](/docs/next/reference/runtime/intro) +- 使用 Wails 构建的应用程序兼容 Apple & Microsoft 商店 这是 [varly](https://varly.app) - 一个使用 Wails 编写的 MacOS 和 Windows 桌面应用。 它不仅看起来很强,它使用原生菜单和半透明 - 你希望从现代原生应用中得到的一切 +```mdx-code-block

+``` ### 快速启动模板 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/cli.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/cli.mdx index 7ff1f0ddc..ef2e5027d 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/cli.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/cli.mdx @@ -19,60 +19,62 @@ Wails CLI 有许多用于管理项目的命令。 所有命令都以此方式运 | -g | 初始化 git 存储库 | | | -l | 可用项目模板列表 | | | -q | 禁止输出到控制台 | | -| -t "模板名称" | 要使用的项目模板。 这可能是默认模板的名称或在 github 上托管的远程模板的 URL 。 | vanilla | +| -t "模板名称" | 要使用的项目模板。 这可能是默认模板的名称或托管在 github 上的远程模板的 URL 。 | vanilla | | -ide | 生成 IDE 项目文件 | | -| -f | 强制构建应用 | 否 | +| -f | 强制构建应用 | false | 示例: `wails init -n test -d mytestproject -g -ide vscode -q` 这将在 "mytestproject" 目录生成一个名为 "test" 的项目,初始化 git,生成 vscode 项目文件并静默执行。 -可以在[此处](../guides/ides)找到有关在 Wails 中使用 IDE 的更多信息。 +可以在 [此处](../guides/ides) 找到有关在 Wails 中使用 IDE 的更多信息。 ### 远程模板 -支持远程模板(托管在 GitHub 上)并且可以使用模板项目的 URL 进行安装。 +支持远程模板(托管在 GitHub )并且可以使用模板项目的 URL 进行安装。 示例: `wails init -n test -t https://github.com/leaanthony/testtemplate[@v1.0.0]` -可以在[此处](../community/templates)找到社区维护的模板列表 +可以在 [此处](../community/templates.mdx) 找到社区维护的模板列表 :::warning 注意 + **Wails 项目不维护也不对第 3 方模板负责** -如果您不信任某个模板,请检查 `package.json` 和 `wails.json` 中安装的模块和运行的脚本。 +如果您不确定某个模板,请检查 `package.json` 和 `wails.json` 中安装的模块和运行的脚本。 ::: + ## 构建 -`wails build`用于将您的项目编译为生产可用的二进制文件。 +`wails build` 用于将您的项目编译为生产可用的二进制文件。 -| 标志 | 描述 | 默认 | -|:-------------------- |:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |:--------------------------- | -| -platform | 为指定的[平台](../reference/cli#平台)(逗号分割)构建,例如:`windows/arm64`。 `windows/arm64`. `windows/arm64`. 注意,如果没有指定架构,则使用`runtime.GOARCH`。 `windows/arm64`. 注意,如果没有指定架构,则使用`runtime.GOARCH`。 | runtime.GOOS/runtime.GOARCH | -| -clean | 清理`build/bin`目录 | | -| -compiler "编译器" | 使用不同的 go 编译器来构建,例如 go1.15beta1 | go | -| -ldflags "标志" | 传递给编译器的额外 ldflags | | -| -nopackage | 不打包应用程序 | | -| -o filename | 输出文件名 | | -| -s | 跳过前端构建 | 否 | -| -f | 强制构建应用 | 否 | -| -tags "额外标签" | 传递给编译器构建标签(引号和空格分隔) | | -| -upx | 使用“upx”压缩最终二进制文件 | | -| -upxflags | 传递给 upx 的标志 | | -| -v int | 详细级别 (0 - silent, 1 - default, 2 - verbose) | 1 | -| -webview2 | WebView2 安装程序策略:download,embed,browser,error. | download | -| -u | 更新项目的 `go.mod` 以使用与 CLI 相同版本的 Wails | | -| -debug | 在应用程序中保留调试信息 在应用程序中保留调试信息 Allows the use of the devtools in the application window | 否 | -| -trimpath | Remove all file system paths from the resulting executable. | 否 | -| -race | Build with Go's race detector | 否 | -| -platform "platform" | Keep the console window for Windows builds | 否 | +| 标志 | 描述 | 默认 | +|:--------------- |:-------------------------------------------------------------------------------------------- |:--------------------------------------------------------------------------------------------------------- | +| -platform | 为指定的 [平台](../reference/cli#平台)(逗号分割)构建,例如: `windows/arm64`。 注意,如果不给出架构,则使用 `runtime.GOARCH`。 | 如果给定环境变量 platform = `GOOS` 否则等于 `runtime.GOOS`。
如果给定环境变量 arch = `GOARCH` 否则等于 `runtime.GOARCH`. | +| -clean | 清理 `build/bin` 目录 | | +| -compiler "编译器" | 使用不同的 go 编译器来构建,例如 go1.15beta1 | go | +| -ldflags "标志" | 传递给编译器的额外 ldflags | | +| -nopackage | 不打包应用程序 | | +| -o 文件名 | 输出文件名 | | +| -s | 跳过前端构建 | false | +| -f | 强制构建应用 | false | +| -tags "额外标签" | 构建标签以传递给 Go 编译器。 必须引用。 空格或逗号(但不能同时使用)分隔 | | +| -upx | 使用 “upx” 压缩最终二进制文件 | | +| -upxflags | 传递给 upx 的标志 | | +| -v int | 详细级别 (0 - silent, 1 - default, 2 - verbose) | 1 | +| -webview2 | WebView2 安装策略:download,embed,browser,error. | download | +| -u | 更新项目的 `go.mod` 以使用与 CLI 相同版本的 Wails | | +| -debug | 在应用程序中保留调试信息。 允许在应用程序窗口中使用 devtools | false | +| -trimpath | 从生成的可执行文件中删除所有文件系统路径。 | false | +| -race | 使用 Go 的竞态检测器构建 | false | +| -windowsconsole | 保留Windows构建控制台窗口 | false | -有关`webview2`标志的详细描述,请参阅[Windows 系统](../guides/windows)指南。 +有关 `webview2` 标志的详细描述,请参阅 [Windows 系统](../guides/windows) 指南。 -如果您更喜欢使用标准 Go 工具进行构建,请参阅[手动构建](../guides/manual-builds)指南。 +如果您更喜欢使用标准 Go 工具进行构建,请参阅 [手动构建](../guides/manual-builds) 指南。 示例: @@ -80,16 +82,20 @@ Wails CLI 有许多用于管理项目的命令。 所有命令都以此方式运 :::info 苹果芯片上的 UPX -在苹果芯片上使用 UPX 相关的[问题](https://github.com/upx/upx/issues/446)。 + +在苹果芯片上使用 UPX 相关的 [问题](https://github.com/upx/upx/issues/446)。 ::: + :::info Windows 上的 UPX -一些防病毒软件供应商误将`upx`压缩的二进制文件标记为病毒,请查看相关[问题](https://github.com/upx/upx/issues/437)。 + +一些防病毒软件供应商误将 `upx` 压缩的二进制文件标记为病毒,请查看相关 [问题](https://github.com/upx/upx/issues/437)。 ::: + ### 平台 支持的平台有: @@ -118,10 +124,6 @@ Wails CLI v2.0.0-beta Scanning system - Please wait (this may take a long time)...Done. -Wails CLI v2.0.0-beta - -Scanning system - Please wait (this may take a long time)...Done. - System ------ OS: Windows 10 Pro @@ -136,33 +138,6 @@ Dependency Package Name Status Version WebView2 N/A Installed 93.0.961.52 npm N/A Installed 6.14.15 *upx N/A Installed upx 3.96 -*docker N/A Installed 20.10.6 - -* - Optional Dependency - -Diagnosis ---------- -Your system is ready for Wails development! - -Wails CLI v2.0.0-beta - -Scanning system - Please wait (this may take a long time)...Done. - -System ------- -OS: Windows 10 Pro -Version: 2009 (Build: 19043) -ID: 21H1 -Go Version: go1.18 -Platform: windows -Architecture: amd64 - -Dependency Package Name Status Version ----------- ------------ ------ ------- -WebView2 N/A Installed 93.0.961.52 -npm N/A Installed 6.14.15 -*upx N/A Installed upx 3.96 -*docker N/A Installed 20.10.6 * - Optional Dependency @@ -176,37 +151,37 @@ Your system is ready for Wails development! `wails dev` 用于以 "实时开发" 模式运行您的应用。 这意味着: -- 应用程序的`go.mod`将被更新为与 Wails CLI 版本相同的版本 +- 应用程序的 `go.mod` 将被更新为与 Wails CLI 相同的版本 - 应用程序被编译并自动运行 - 一个观察者被启动,如果它检测到您的 go 文件的变化,它将触发您的开发应用程序的重新构建 -- 启动一个网络服务器`http://localhost:34115`,通过 http 为您的应用程序(不仅仅是前端)提供服务。 这允许您使用您喜欢的浏览器开发扩展 +- 启动一个网络服务器 `http://localhost:34115`,通过 http 为您的应用程序(不仅仅是前端)提供服务。 这允许您使用您喜欢的浏览器开发扩展 - 所有应用程序资源都从磁盘加载。 如果它们被更改,应用程序将自动重新加载(而不是重新构建)。 所有连接的浏览器也将重新加载 - 生成的 JS 模块提供以下内容: - 带有自动生成的 JSDoc 的 Go 方法的 Javascript 包装器,提供代码提示 - 您的 Go 结构体的 TypeScript 版本,可以构造并传递给您的 Go 方法 -- 生成第二个 JS 模块,为运行时提供包装器 + TS 声明 +- 生成的第二个 JS 模块,为运行时提供包装器 + TS 声明 -| 标志 | 描述 | 默认 | -|:------------------------------ |:-------------------------------------------------------------------------------------------------------------------------------- |:------------------------ | -| -assetdir "./path/to/assets" | 编译资源的路径 | `wails.json`中的值 | -| -browser | 在启动时打开浏览器到`http://localhost:34115` | | -| -compiler "编译器" | 使用不同的 go 编译器来构建,例如 go1.15beta1 | go | -| -e | 触发重新构建的扩展(逗号分隔) | go | -| -reloaddirs | 触发重新加载的附加目录(逗号分隔) | `wails.json`中的值 | -| -ldflags "标志" | 传递给编译器的额外 ldflags | | -| -tags "额外标签" | 传递给编译器构建标签(引号和空格分隔) | | -| -loglevel "日志级别" | 要使用的日志级别 - Trace, Debug, Info, Warning, Error | Debug | -| -noreload | 资源更改时禁用自动重新加载 | | -| -nogen | 详细级别 (0 - silent, 1 - standard, 2 - verbose) | | -| -v | 生成生成的 Wails JS 模块的目录 | 1 | -| -wailsjsdir | 检测到资源更改后等待重新加载的时间 | `wails.json`中的值 | -| -debounce | 将 wails 开发服务器绑定到的地址 | "http://localhost:34115" | -| -frontenddevserverurl "url 地址" | 使用第三方开发服务器提供资源,比如 Vite | "localhost:34115" | -| -frontenddevserverurl "url" | 以 shell 样式传递给应用程序的参数 | "" | -| -appargs "args" | 目标平台/架构 | | -| -save | 将指定的 `assetdir`、 `reloaddirs`、 `wailsjsdir`、 `debounce` 、 `devserver` 和 `frontenddevserverurl` 标志的值保存到 `wails.json` 以成为后续调用的默认值。 | | -| -race | Build with Go's race detector | 否 | -| -s | 跳过前端构建 | 否 | +| 标志 | 描述 | 默认 | +|:---------------------------- |:-------------------------------------------------------------------------------------------------------------------------------- |:----------------- | +| -assetdir "./path/to/assets" | 从给定目录提供资产,而不是使用提供的资产 FS | `wails.json` 中的值 | +| -browser | 在启动时打开浏览器到 `http://localhost:34115` | | +| -compiler "编译器" | 使用不同的 go 编译器来构建,例如 go1.15beta1 | go | +| -e | 触发重新构建的扩展(逗号分隔) | go | +| -reloaddirs | 触发重新加载的附加目录(逗号分隔) | `wails.json` 中的值 | +| -ldflags "标志" | 传递给编译器的额外 ldflags | | +| -tags "额外标签" | 传递给编译器的构建标签(引号和空格分隔) | | +| -loglevel "日志级别" | 要使用的日志级别 - Trace, Debug, Info, Warning, Error | Debug(调试) | +| -noreload | 资产更改时禁用自动重新加载 | | +| -nogen | 禁用生成模块 | | +| -v | 详细级别 (0 - silent, 1 - standard, 2 - verbose) | 1 | +| -wailsjsdir | 生成生成的Wails JS模块的目录 | `wails.json` 中的值 | +| -debounce | 检测到资产更改后等待重新加载的时间 | 100 (毫秒) | +| -devserver "host:port" | 将 wails 开发服务器绑定到的地址 | "localhost:34115" | +| -frontenddevserverurl "url" | 使用 3rd 方开发服务器 url 提供资产,例如:Vite | "" | +| -appargs "参数" | 以 shell 样式传递给应用程序的参数 | | +| -save | 将指定的 `assetdir`、 `reloaddirs`、 `wailsjsdir`、 `debounce` 、 `devserver` 和 `frontenddevserverurl` 标志的值保存到 `wails.json` 以成为后续调用的默认值。 | | +| -race | 使用 Go 的竞态检测器构建 | false | +| -s | 跳过前端构建 | false | 示例: @@ -214,33 +189,33 @@ Your system is ready for Wails development! 此命令将执行以下操作: -- 构建应用程序并运行它(更多细节在[这里](../guides/manual-builds)) -- 在`./frontend/src`中生成 Wails JS 模块 -- 监听`./frontend/dist`中文件的更新并在更改时重新加载 +- 构建应用程序并运行它(更多细节在 [这里](../guides/manual-builds)) +- 在 `./frontend/src` 中生成 Wails JS 模块 +- 监听 `./frontend/dist` 中文件的更新并在更改时重新加载 - 打开浏览器并连接到应用程序 -[此处](../guides/application-development)提供了有关将此功能与现有框架脚本一起使用的更多信息。 +有更多关于在现有框架脚本中使用此功能的 [信息](../guides/application-development.mdx#live-reloading)。 ## 生成 ### 模板 -Wails 使用模板来生成项目。 `wails generate template`命令有助于构建模板,以使它可以用于生成项目。 +Wails 使用模板来生成项目。 `wails generate template` 命令有助于构建模板,以使它可以用于生成项目。 | 标志 | 描述 | |:-------------- |:--------------- | | -name | 模板名称(必填) | | -frontend "路径" | 要在模板中使用的前端项目的路径 | -有关创建模板的更多详细信息,请参阅[模板指南](../guides/templates)。 +有关创建模板的更多详细信息,请参阅 [模板指南](../guides/templates)。 -### module +### 模块 -`wails update` 将更新 Wails CLI 的版本。 +`wails generate module` 命令允许您为应用程序手动生成 `wailsjs` 目录。 ## 更新 -`wails version` 仅输出当前的 CLI 版本。 +`wails update` 将更新 Wails CLI 的版本。 | 标志 | 描述 | |:------------- |:----------- | @@ -249,4 +224,4 @@ Wails 使用模板来生成项目。 `wails generate template`命令有助于构 ## 版本 -`wails version` will simply output the current CLI version. +`wails version` 仅输出当前的 CLI 版本。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/menus.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/menus.mdx index f486cb1e3..0d1e6c446 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/menus.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/menus.mdx @@ -4,9 +4,9 @@ sidebar_position: 4 # 应用菜单 -It is possible to add an application menu to Wails projects. 可以通过定义 [菜单](#菜单) 结构并设置 [`Menu`](../reference/options#菜单) 选项或者通过调用运行时方法 [设置应用程序菜单](../reference/runtime/menu#设置应用程序菜单) 来将应用程序菜单添加到 Wails 项目。 可以通过定义 [菜单](#菜单) 结构并设置 [`Menu`](../reference/options#菜单) 选项或者通过调用运行时方法 [设置应用程序菜单](../reference/runtime/menu#设置应用程序菜单) 来将应用程序菜单添加到 Wails 项目。 +可以将应用程序菜单添加到 Wails 项目。 可以通过定义一个 [菜单](#菜单) 结构体并设置 [`Menu`](../reference/options#菜单) 选项或者通过调用运行时方法 [设置应用程序菜单](../reference/runtime/menu#设置应用程序菜单) 来将应用程序菜单添加到 Wails 项目。 -也可以通过更新菜单结构并调用[更新应用程序菜单](../reference/runtime/menu#更新应用程序菜单)来动态更新菜单 。 +如何创建菜单的示例: ```go AppMenu := menu.NewMenu() @@ -31,25 +31,15 @@ It is possible to add an application menu to Wails projects. 可以通过定义 }, ) // ... -```` - -It is also possible to dynamically update the menu, by updating the menu struct and calling -[MenuUpdateApplicationMenu](../reference/runtime/menu.mdx#menuupdateapplicationmenu). - -The example above uses helper methods, however it's possible to build the menu structs manually. - -type Menu struct { - Items []*MenuItem -} ``` -示例: +也可以通过更新菜单结构体并调用 [更新应用程序菜单](../reference/runtime/menu#更新应用程序菜单) 来动态更新菜单 。 -上面的示例使用快捷方法,但是可以手动构建菜单结构。 +上面的示例使用辅助方法,但是可以手动构建菜单结构。 -## Menu +## 菜单 -A Menu is a collection of MenuItems: +Menu 是 MenuItem 的集合: ```go title="Package: github.com/wailsapp/wails/v2/pkg/menu" type Menu struct { @@ -57,19 +47,19 @@ type Menu struct { } ``` -示例: +对于应用程序菜单,每个 MenuItem 代表一个菜单,例如“编辑”。 -上面的示例使用快捷方法,但是可以手动构建菜单结构。 +提供了一个简单的辅助方法来构建菜单: ```go title="Package: github.com/wailsapp/wails/v2/pkg/menu" func NewMenuFromItems(first *MenuItem, rest ...*MenuItem) *Menu ``` -这使得代码的布局更像是菜单的布局,而无需在创建菜单项后手动添加它们。 或者,您可以只创建菜单项并手动将它们添加到菜单中。 +这使得代码的布局更像菜单的布局,而无需在创建菜单项后手动添加它们。 或者,您可以只创建菜单项并将它们手动添加到菜单中。 -## 菜单 +## 菜单项 -对于应用程序菜单,每个菜单项代表一个菜单,例如“编辑”。 +MenuItem 表示菜单中的一个项目。 ```go title="Package: github.com/wailsapp/wails/v2/pkg/menu" // MenuItem represents a menu item contained in a menu @@ -86,23 +76,23 @@ type MenuItem struct { } ``` -| 字段 | Type | 注解 | -| ----------- | ------------------------------------ | --------------------------- | -| Label | string | 菜单文字 | -| Accelerator | [\*keys.Accelerator](#accelerator) | 此菜单项的键绑定 | -| Type | [Type](#type) | 菜单项的类型 | -| Disabled | bool | 禁用菜单项 | -| Hidden | bool | 隐藏此菜单项 | -| Checked | bool | 向菜单项设置选中 (复选框和单选类型) | -| SubMenu | [\*Menu](#menu) | 设置子菜单 | -| Click | [Callback](#callback) | 单击菜单时的回调函数 | -| Role | string | 定义此菜单项的[角色](#角色)。 暂时只支持 Mac | +| 字段 | 类型 | 注解 | +| ----------- | ------------------------------------ | ---------------------------- | +| Label | string | 菜单文字 | +| Accelerator | [\*keys.Accelerator](#accelerator) | 此菜单项的键绑定 | +| 类型 | [类型](#type) | 菜单项的类型 | +| Disabled | bool | 禁用菜单项 | +| Hidden | bool | 隐藏此菜单项 | +| Checked | bool | 添加检查项目 (复选框和单选类型) | +| SubMenu | [\*Menu](#menu) | 设置子菜单 | +| Click | [Callback](#callback) | 单击菜单时的回调函数 | +| Role | string | 定义此菜单项的 [角色](#角色)。 暂时只支持 Mac | -### Accelerator +### 快捷键 -加速器(有时称为键盘快捷键)定义了按键和菜单项之间的绑定。 Wails 将加速器定义为一个组合或键 + [修饰符](#修饰符)。 它们在`"github.com/wailsapp/wails/v2/pkg/menu/keys"`包中可用。 +加速器(有时称为键盘快捷键)定义了按键和菜单项之间的绑定。 Wails 将加速器定义为一个组合或键 + [修饰符](#修饰符)。 它们在 `"github.com/wailsapp/wails/v2/pkg/menu/keys"` 包中提供。 -Example: +示例: ```go title="Package: github.com/wailsapp/wails/v2/pkg/menu/keys" // Defines cmd+o on Mac and ctrl-o on Window/Linux @@ -111,61 +101,27 @@ Example: 键是键盘上除了`+`的任何字符,它被定义为`加号`。 有些键不能表示为字符,因此可以使用一组命名字符: -- `backspace` -- `tab` -- `return` -- `enter` -- `escape` -- `left` -- `right` -- `up` -- `down` -- `space` -- `delete` -- `home` -- `end` -- `page up` -- `page down` -- `f1` -- `f2` -- `f3` -- `f4` -- `f5` -- `f6` -- `f7` -- `f8` -- `f9` -- `f10` -- `f11` -- `f12` -- `f13` -- `f14` -- `f15` -- `f16` -- `f17` -- `f18` -- `f19` -- `f20` -- `f21` -- `f22` -- `f23` -- `f24` -- `f25` -- `f26` -- `f27` -- `f28` -- `f29` -- `f30` -- `f31` -- `f32` -- `f33` -- `f34` -- `f35` -- `numlock` +| | | | | +|:-----------:|:-----:|:---------:|:---------:| +| `backspace` | `f1` | `f16` | `f31` | +| `tab` | `f2` | `f17` | `f32` | +| `return` | `f3` | `f18` | `f33` | +| `enter` | `f4` | `f19` | `f34` | +| `escape` | `f5` | `f20` | `f35` | +| `left` | `f6` | `f21` | `numlock` | +| `right` | `f7` | `f22` | | +| `up` | `f8` | `f23` | | +| `down` | `f9` | `f24` | | +| `space` | `f10` | `f25` | | +| `delete` | `f11` | `f36` | | +| `home` | `f12` | `f37` | | +| `end` | `f13` | `f38` | | +| `page up` | `f14` | `page up` | | +| `page down` | `f15` | `f30` | | -Wails 还支持使用与 Electron 相同的语法来解析加速器。 这对于在配置文件中存储加速器很有用。 +Wails 还支持使用与 Electron 相同的语法来解析加速器。 这对于将加速器存储在配置文件中很有用。 -Example: +示例: ```go title="Package: github.com/wailsapp/wails/v2/pkg/menu/keys" // Defines cmd+o on Mac and ctrl-o on Window/Linux @@ -174,7 +130,7 @@ Example: #### 修饰符 -The following modifiers are keys that may be used in combination with the accelerator key: +以下修饰符是可以与加速键结合使用的键: ```go title="Package: github.com/wailsapp/wails/v2/pkg/menu/keys" const ( @@ -189,7 +145,7 @@ const ( ) ``` -A number of helper methods are available to create Accelerators using modifiers: +许多辅助方法可用于使用修饰符创建加速器: ```go title="Package: github.com/wailsapp/wails/v2/pkg/menu/keys" func CmdOrCtrl(key string) *Accelerator @@ -198,16 +154,16 @@ func Shift(key string) *Accelerator func Control(key string) *Accelerator ``` -示例: +可以使用 `keys.Combo(key string, modifier1 Modifier, modifier2 Modifier, rest ...Modifier)` 用以下方式组合修饰符 : ```go title="Package: github.com/wailsapp/wails/v2/pkg/menu/keys" // Defines "Ctrl+Option+A" on Mac and "Ctrl+Alt+A" on Window/Linux myShortcut := keys.Combo("a", ControlKey, OptionOrAltKey) ``` -### Type +### 类型 -以下修饰符是可以与加速键组合使用的键: +每个菜单项必须有一个类型,有 5 种类型可用: ```go title="Package: github.com/wailsapp/wails/v2/pkg/menu" const ( @@ -219,37 +175,31 @@ const ( ) ``` -许多快捷方法可用于使用修饰符创建加速器: - -```go title="Package: github.com/wailsapp/wails/v2/pkg/menu" -myMenu := menu.NewMenuFromItems( - menu.SubMenu("File", menu.NewMenuFromItems( - menu.Text("&Open", keys.CmdOrCtrl("o"), openFile), - menu.Separator(), - menu.Text("Quit", keys.CmdOrCtrl("q"), func(_ *menu.CallbackData) { - runtime.Quit() - }), - )), - ) - - runtime.MenuSetApplicationMenu(myMenu) -``` - -修饰符可以结合`keys.Combo(key string, modifier1 Modifier, modifier2 Modifier, rest ...Modifier)`使用: +为方便起见,提供了帮助方法来快速创建菜单项: ```go title="Package: github.com/wailsapp/wails/v2/pkg/menu" func Text(label string, accelerator *keys.Accelerator, click Callback) *MenuItem func Separator() *MenuItem func Radio(label string, selected bool, accelerator *keys.Accelerator, click Callback) *MenuItem func Checkbox(label string, checked bool, accelerator *keys.Accelerator, click Callback) *MenuItem -func SubMenu(label string, menu *Menu) *MenuItem +func SubMenu(label string, menu *Menu) *Menu ``` -关于单选菜单组的说明:单选菜单组定义为菜单中相邻的多个单选菜单项。 这意味着您不需要将项目分组在一起,因为它是自动的。 然而,这也意味着您不能有两个相邻的单选菜单组-它们之间必须有一个非单选菜单项。 +您还可以使用“添加”助手直接在菜单上创建菜单项: -### Callback +```go title="Package: github.com/wailsapp/wails/v2/pkg/menu" +func (m *Menu) AddText(label string, accelerator *keys.Accelerator, click Callback) *MenuItem +func (m *Menu) AddSeparator() *MenuItem +func (m *Menu) AddRadio(label string, selected bool, accelerator *keys.Accelerator, click Callback) *MenuItem +func (m *Menu) AddCheckbox(label string, checked bool, accelerator *keys.Accelerator, click Callback) *MenuItem +func (m *Menu) AddSubMenu(label string, menu *Menu) *MenuI +``` -为方便起见,提供了快捷方法来快速创建菜单项: +关于单选组的说明:单选组被定义为在菜单中彼此相邻的多个单选菜单项。 这意味着您不需要将项目组合在一起,因为它是自动的。 但是,这也意味着您不能有 2 个彼此相邻的无线电组 - 它们之间必须有一个非无线电项目。 + +### 回调 + +每个菜单项都可能有一个回调,在单击该项时执行: ```go title="Package: github.com/wailsapp/wails/v2/pkg/menu" type Callback func(*CallbackData) @@ -259,19 +209,21 @@ type CallbackData struct { } ``` -给函数一个`CallbackData`结构体,它指示哪个菜单项触发了回调。 这在使用可能共享回调的单选菜单组时很有用。 +该函数被赋予一个 `CallbackData` 结构,该结构指示哪个菜单项触发了回调。 这在使用可能共享回调的单选菜单组时很有用。这在使用可能共享回调的单选组时很有用。 -### Role +### 角色 + +:::info 角色 -每个菜单项都可能有一个回调,在单击该项时会执行该回调: 目前仅 Mac 支持角色。 ::: + 一个菜单项可能有一个角色,它本质上是一个预定义的菜单项。 我们目前支持以下角色: -| Role | 描述 | -| ------------ | -------------------------------------- | -| AppMenuRole | 标准的 Mac 应用程序菜单。 可以使用`menu.AppMenu()`创建 | -| EditMenuRole | 标准的 Mac 编辑菜单。 可以使用`menu.EditMenu()`创建 | +| 角色 | 描述 | +| ------------ | ---------------------------------------- | +| AppMenuRole | 标准的 Mac 应用程序菜单。 可以使用 `menu.AppMenu()` 创建 | +| EditMenuRole | 标准的 Mac 编辑菜单。 可以使用 `menu.EditMenu()` 创建 | diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/options.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/options.mdx index 5235e6fa0..9222980ca 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/options.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/options.mdx @@ -6,7 +6,7 @@ sidebar_position: 3 ## 应用程序参数选项 -该`Options.App`结构包含应用程序配置。 它被传递给`wails.Run()`方法: +该 `Options.App` 结构包含应用程序配置。 它被传递给 `wails.Run()` 方法: ```go title="Example" import "github.com/wailsapp/wails/v2/pkg/options" @@ -96,98 +96,99 @@ func main() { 窗口标题栏中显示的文本。 -类型:string +名称:Title
类型:`string` ### 宽度 窗口的初始宽度。 -名称:Width +名称:Width
类型:`int`
默认值:1024. ### 高度 窗口的初始高度。 -类型:`windows.Theme` +名称:Height
类型:`int`
默认值:768 ### 禁用调整窗口尺寸 默认情况下,主窗口可调整大小。 将此设置为 `true` 将使其保持固定大小。 -类型:int +名称:DisableResize
类型:`bool` -### Fullscreen +### 全屏 将此设置为 `true` 将在启动时使窗口全屏。 -类型:int +名称:Fullscreen
类型:`bool` ### 无边框 -设置为`true`时,窗口将没有边框或标题栏。 另请参阅[无边框窗口](../guides/frameless)。 +设置为`true`时,窗口将没有边框或标题栏。 另请参阅 [无边框窗口](../guides/frameless)。 -类型:int +名称:Frameless
类型:`bool` ### 最小宽度 -这将设置窗口的最小宽度。 如果给出的值`Width`小于这个值,窗口将被设置为`MinWidth`默认值。 +这将设置窗口的最小宽度。 如果给出的值 `Width` 小于这个值,窗口将被设置为 `MinWidth` 默认值。 -类型:bool +名称:MinWidth
类型:`int` ### 最小高度 -这将设置窗口的最小高度。 如果给出的值`Height`小于这个值,窗口将被设置为`MinHeight`默认值。 +这将设置窗口的最小高度。 如果给出的值 `Height` 小于这个值,窗口将被设置为 `MinHeight` 默认值。 -类型:bool +名称:MinHeight
类型:`int` ### 最大宽度 -这将设置窗口的最大宽度。 如果给出的值`Width`大于这个值,窗口将被设置为`MaxWidth`默认值。 +这将设置窗口的最大宽度。 如果给出的值 `Width` 大于这个值,窗口将被设置为 `MaxWidth` 默认值。 -类型:bool +名称:MaxWidth
类型:`int` ### 最大高度 -这将设置窗口的最大高度。 如果给出的值`Height`大于这个值,窗口将被设置为`MaxHeight`默认值。 +这将设置窗口的最大高度。 如果给出的值 `Height` 大于这个值,窗口将被设置为 `MaxHeight` 默认值。 -类型:bool +名称:MaxHeight
类型:`int` ### 启动时隐藏窗口 -设置为`true`时,应用程序将被隐藏,直到调用[显示窗口](../reference/runtime/window#显示窗口)。 +设置为 `true` 时,应用程序将被隐藏,直到调用 [显示窗口](../reference/runtime/window#显示窗口)。 + +名称:StartHidden
类型:`bool` -类型:int ### 关闭时隐藏窗口 -默认情况下,关闭窗口将关闭应用程序。 将此设置为`true`意味着关闭窗口将隐藏窗口。 +默认情况下,关闭窗口将关闭应用程序。 将此设置为 `true` 意味着关闭窗口将隐藏窗口。 -窗口在失去焦点时应保持在其他窗口之上。 +隐藏窗口。 -类型:int +名称:HideWindowOnClose
类型:`bool` -### RGBA +### 背景颜色 -This value is the default background colour of the window. Default: white 类型:int (0xRRGGBBAA) 示例:0xFF000088 - 透明度为 50% 的红色 +此值是窗口的默认背景颜色。 示例:options.NewRGBA(255,0,0,128) - 红色,透明度为 50% -Type: `*options.RGBA`
Default: white +名称:BackgroundColour
类型:`*options.RGBA`
默认值:white ### 窗口固定在最顶层 窗口在失去焦点时应保持在其他窗口之上。 -类型:int +名称:AlwaysOnTop
类型:`bool` -### 资源 +### 资产 -应用程序要使用的前端资源。 需要一个`index.html`文件。 +应用程序要使用的前端资源。 需要一个 `index.html` 文件。 -名称:StartHidden +名称:Assets
类型:`embed.FS` -### 菜单 +### 资产处理程序 -注意:在 Mac 上,如果未指定菜单,则将创建默认菜单。 +资产处理程序是一个通用的 `http.Handler` ,对于资产服务器上的任何非 GET 请求和 `assets` 由于找不到文件而无法从 GET 请求提供服务的 GET 请求都将被调用。 | 值 | Win | Mac | Lin | | ----------------------- | --- | --- | --- | @@ -204,68 +205,72 @@ Type: `*options.RGBA`
Default: white | Response Body | ✅ | ✅ | ✅ | | Response Body Streaming | ❌ | ❌ | ✅ | -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. In the future some features will be supported by the introduction of WebKit2GTK 2.36.0+ support. +注意:Linux 当前非常有限,因为目标是 WebKit2GTK 版本 < 2.36.0。 将来,一些特性将通过引入 WebKit2GTK 2.36.0+ 支持来支持。 -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. 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. Vite serves the index.html on every path, that does not contain a file extension. +注意:当与前端 DevServer 结合使用时,可能会有一些限制,例如。 Vite 在不包含文件扩展名的每个路径上提供 index.html。 -类型:[AppearanceType](#外观类型) +名称:AssetsHandler
类型:`http.Handler` + +### 菜单 + +应用程序要使用的菜单。 [菜单参考](../reference/runtime/menu) 中有关菜单的更多详细信息。 + +:::note + + +在 Mac 上,如果未指定菜单,将创建一个默认菜单。 + +::: + + +名称:Menu
类型:`*menu.Menu` ### 日志 -应用程序要使用的菜单。 [菜单参考](../reference/runtime/menu)中有关菜单的更多详细信息。 +应用程序要使用的记录器。 有关日志记录的更多详细信息,请参阅 [日志参考](../reference/runtime/log)。 -:::note -On Mac, if no menu is specified, a default menu will be created. -::: - -This value is the default background colour of the window. Default: white Default: white +名称:Logger
类型:`logger.Logger`
默认值:Logs to Stdout ### 日志级别 -应用程序要使用的记录器。 有关日志记录的更多详细信息,请参阅[日志参考](../reference/runtime/log)。 +默认日志级别。 有关日志记录的更多详细信息,请参阅 [日志参考](../reference/runtime/log)。 -类型:bool +名称:LogLevel
类型:`logger.LogLevel`
默认值:开发模式为 `Info`, 生产模式为 `Error` + +### 生产日志级别 + +生产构建的默认日志级别。 有关日志记录的更多详细信息,请参阅 [日志参考](../reference/runtime/log)。 + +名称:LogLevelProduction
类型:`logger.LogLevel`
默认值:`Error` ### 应用启动回调 -默认日志级别。 有关日志记录的更多详细信息,请参阅[日志参考](../reference/runtime/log)。 +此回调在前端创建之后调用,但在 `index.html` 加载之前调用。 它提供了应用程序上下文。 -名称:Assets +名称:OnStartup
类型:`func(ctx context.Context)` ### 前端 Dom 加载完成回调 -The default log level for production builds. 有关日志记录的更多详细信息,请参阅[日志参考](../reference/runtime/log)。 有关日志记录的更多详细信息,请参阅[日志参考](../reference/runtime/log)。 +在前端加载完毕 `index.html` 及其资源后调用此回调。 它提供了应用程序上下文。 -类型:logger.Logger +名称:OnDomReady
类型:`func(ctx context.Context)` ### 应用退出回调 -此回调在前端创建之后调用,但在`index.html`加载之前调用。 它提供了应用程序上下文。 - -类型:\*menu.Menu - -### 关闭应用程序之前回调 - -在前端加载完毕`index.html`及其资源后调用此回调。 它提供了应用程序上下文。 - -类型:\*menu.Menu - -### 窗口启动状态 - 在前端被销毁之后,应用程序终止之前,调用此回调。 它提供了应用程序上下文。 -类型:\*menu.Menu +名称:OnShutdown
类型:`func(ctx context.Context)` -### 绑定 +### 关闭应用前 -如果设置了此回调,它将在通过单击窗口关闭按钮或调用`runtime.Quit`即将退出应用程序时被调用. 返回 `true` 将导致应用程序继续,`false` 将继续正常关闭。 Returning true will cause the application to continue, false will continue shutdown as normal. 这有助于与用户确认他们希望退出程序。 这有助于与用户确认他们希望退出程序。 +如果设置了此回调,它将在通过单击窗口关闭按钮或调用`runtime.Quit`即将退出应用程序时被调用. 返回 `true` 将导致应用程序继续,`false` 将继续正常关闭。 返回 true 将导致应用程序继续,false 将继续正常关闭。 这有助于与用户确认他们希望退出程序。 -名称:Mac +示例: ```go title=windowsapp.go func (b *App) beforeClose(ctx context.Context) (prevent bool) { dialog, err := runtime.MessageDialog(ctx, runtime.MessageDialogOptions{ - 类型: runtime.QuestionDialog, + Type: runtime.QuestionDialog, Title: "Quit?", Message: "Are you sure you want to quit?", }) @@ -274,129 +279,122 @@ func (b *App) beforeClose(ctx context.Context) (prevent bool) { return false } return dialog != "Yes" +} ``` -类型:func(ctx context.Context) +名称:OnBeforeClose
类型:`func(ctx context.Context) bool` -### WindowStartState +### 窗口启动状态 -名称:Linux +定义窗口在启动时应如何呈现。 -| 值 | Win | Mac | Lin | -| ---------- | --- | --- | --- | -| Fullscreen | ✅ | ✅ | ✅ | -| Maximised | ✅ | ✅ | ✅ | -| Minimised | ✅ | ❌ | ✅ | +| 值 | Win | Mac | Lin | +| --------- | --- | --- | --- | +| 全屏 | ✅ | ✅ | ✅ | +| Maximised | ✅ | ✅ | ✅ | +| Minimised | ✅ | ❌ | ✅ | -默认值:在开发模式下是`Info`,在生产模式下是`Error`。 +名称:WindowStartState
类型:`options.WindowStartState` ### CSSDragProperty -Indicates the CSS property to use to identify which elements can be used to drag the window. Default: `--wails-draggable`. +指示用于标识哪些元素可用于拖动窗口的 CSS 属性。 默认值:`--wails-draggable` -类型:string +名称:CSSDragProperty
类型:`string` ### CSSDragValue -Indicates what value the `CSSDragProperty` style should have to drag the window. Default: `drag`. +指示 `CSSDragProperty` 样式应该具有什么值才能拖动窗口。 默认值:`drag` -类型:string +名称:CSSDragValue
类型:`string` -### Bind +### 绑定 -名称:WebviewIsTransparent +定义需要绑定到前端的方法的结构实例切片。 -名称:OnStartup +名称:Bind
类型:`[]interface{}` ### Windows -名称:WindowIsTranslucent +这定义了 [Windows 特定的选项](#windows-特定选项)。 -名称:LogLevel +名称:Windows
类型:`*windows.Options` -### Mac +#### Webview 透明 -名称:DisableWindowIcon +当使用 `alpha` 值 `0` 时,将此设置为 true 将使 webview 背景透明。 这意味着如果您在 CSS 中使用 `rgba(0,0,0,0)` 作为 `background-color`,则主机窗口将显示出来。 通常与 [窗口半透明](#窗口半透明) 结合使用以制作看起来冷冰冰的应用程序。 -类型:func(ctx context.Context) +名称:WebviewIsTransparent
类型:`bool` -### Linux +#### 窗口半透明 -名称:DisableFramelessWindowDecorations +将此设置为 `true` 将使窗口半透明。 通常与[Webview 透明](#webview-透明) 结合使用以制作冰霜效果的应用程序。 -名称:OnShutdown +名称:WindowIsTranslucent
类型:`bool` -## Windows 特定选项 +#### 禁用窗口图标 -### 禁用窗口图标 +将此设置为 `true` 将删除标题栏左上角的图标。 -设置为 `true` 时将使 WebView 背景透明。 这意味着如果你使用`rgba(0,0,0,0)`,主窗口将显示。 通常与[窗口半透明](#窗口半透明)结合使用以制作冰霜效果的应用程序。 +名称:DisableWindowIcon
类型:`bool` -类型:int +#### 禁用无边框窗口装饰 -### 禁用无边框窗口装饰 +将此设置为 `true` 将移除 [无边框](#无边框) 模式下的窗口装饰。 这意味着将不会有`Aero 阴影` 和 `圆角`显示在窗口上。 请注意,'圆角' 只在 Windows 11 上支持。 -将此设置为 `true` 将使窗口半透明。 通常与[网页透明](#网页透明) 结合使用以制作冰霜效果的应用程序。 +名称:DisableFramelessWindowDecorations
类型:`bool` -类型:int +#### Webview 用户数据路径 -### Webview 用户数据路径 +这定义了 WebView2 存储用户数据的路径。 如果为空将使用 `%APPDATA%\[BinaryName.exe]`。 + +名称:WebviewUserDataPath
类型:`string` + +#### Webview 浏览器路径 + +这定义了带有 WebView2 可执行文件和库的目录的路径 如果为空,则使用系统中安装的 webview2 + +有关固定版本运行时分发的重要信息: + +- [如何获取和提取运行时](https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#details-about-the-fixed-version-runtime-distribution-mode) +- [固定版本的已知问题](https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#known-issues-for-fixed-version) +- [WebView2 Runtime 固定版本的路径不应包含 \Edge\Application](https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.1245.22#createcorewebview2environmentwithoptions) + +名称:WebviewBrowserPath
类型:`string` + +#### 主题 + +最低 Windows 版本:Windows 10 2004/20H1 这定义了应用程序应该使用的主题: -类型:int +| 值 | 描述 | +| ------------- | -------------------------------------------- | +| SystemDefault | _默认_。 主题将基于系统默认值。 如果用户更改了他们的主题,应用程序将更新以使用新设置 | +| Dark | 该应用程序将只使用深色主题 | +| Light | 该应用程序将专门使用浅色主题 | -### 主题 +名称:Theme
类型:`windows.Theme` -将此设置为`true`将移除[无边框](#无边框)模式下的窗口装饰。 这意味着将不会有`Aero 阴影` 和 `圆角`显示在窗口上。 请注意,`圆角`只在 Windows 11 上支持。 +#### 自定义主题 -类型:int +:::note -### 自定义主题 -这定义了 WebView2 存储用户数据的路径。 如果为空将使用`%APPDATA%\[BinaryName.exe]`。 +最低 Windows 版本:Windows 10/11 2009/21H2 Build 22000 -类型:string +::: -### 消息 -This defines the path to a directory with WebView2 executable files and libraries. If empty, webview2 installed in the system will be used. If empty, webview2 installed in the system will be used. +允许您为浅色和深色模式以及窗口处于活动或非活动状态的 TitleBar、TitleText 和 Border 指定自定义颜色。 -Important information about distribution of fixed version runtime: +名称:CustomTheme
类型:`windows.CustomTheme` -- [How to get and extract runtime](https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#details-about-the-fixed-version-runtime-distribution-mode) -- [Known issues for fixed version](https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#known-issues-for-fixed-version) -- [The path of fixed version of the WebView2 Runtime should not contain \Edge\Application\.](https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.1245.22#createcorewebview2environmentwithoptions) +##### 自定义主题类型 -类型:string +CustomTheme 结构体使用 `int32` 指定颜色值。 它们采用标准(!)Windows 格式:`0x00BBGGAA`。 These are in the standard(!) Windows format of: `0x00BBGGAA`. 提供了一个辅助函数来将 RGB 转换为这种格式:`windows.RGB(r,g,b uint8)`。 -### 标题栏 - -TitleBar 结构提供了配置标题栏外观的能力。 - -名称:Appearance - -| 值 | 描述 | -| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| SystemDefault | _默认_. 主题将基于系统默认值。 The theme will be based on the system default. The theme will be based on the system default. 如果用户更改了他们的主题,应用程序将更新以使用新设置 The theme will be based on the system default. 如果用户更改了他们的主题,应用程序将更新以使用新设置 The theme will be based on the system default. 如果用户更改了他们的主题,应用程序将更新以使用新设置 | -| Dark | 该应用程序将只使用深色主题 | -| Light | 从样式掩码中移除 [NSWindowStyleMaskTitled](https://developer.apple.com/documentation/appkit/nswindowstylemask/nswindowstylemasktitled/)。 | - -类型:[\*mac.TitleBar](#标题栏结构) - -### 外观 - -类型:\*mac.Options - -类型:bool - -Appearance 用于根据 Apple 的 [NSAppearance](https://developer.apple.com/documentation/appkit/nsappearancename?language=objc) 名称设置应用程序的样式。 - -#### 外观 - -CustomTheme 结构使用 `int32` 指定颜色值. 这些是非标准 Windows 格式: `0x00BBGGAA`。 These are in the standard(!) Windows format of: `0x00BBGGAA`. These are in the standard(!) Windows format of: `0x00BBGGAA`. 提供了一个辅助函数来将 RGB 转换为这种格式:`windows.RGB(r,g,b uint8)`。 - -名称:WindowIsTranslucent +注意:任何未提供的值都将默认为黑色。 ```go type ThemeSettings struct { @@ -415,7 +413,7 @@ type ThemeSettings struct { } ``` -名称:Mac +示例: ```go CustomTheme: &windows.ThemeSettings{ @@ -436,69 +434,47 @@ type ThemeSettings struct { }, ``` -### 网页透明 +#### 消息 一个如果找不到有效的 webview2 运行时,webview2 安装程序所使用的字符串结构。 -名称:About +名称:Messages
类型:`*windows.Messages` 您可以选择支持的任意语言定制此选项。 -### 窗口半透明 +#### 重置尺寸防抖间隔 -ResizeDebounceMS is the amount of time to debounce redraws of webview2 when resizing the window. The default value (0) will perform redraws as fast as it can. The default value (0) will perform redraws as fast as it can. +ResizeDebounceMS 是调整窗口大小时去抖动 webview2 重绘的时间量。 默认值 (0) 将尽可能快地执行重绘。 -Type: \*mac.Options +名称:ResizeDebounceMS
类型:`uint16` -### 关于 +#### 待机回调 -您可以指定应用程序的[外观](https://developer.apple.com/documentation/appkit/nsappearance?language=objc)。 +如果设置,当 Windows 启动切换到低功耗模式(挂起/休眠)时,将调用此函数 -类型:bool +名称:OnSuspend
类型:`func()` -### OnResume +#### 恢复回调 -“关于”菜单项将出现在应用程序菜单中: +如果设置,当 Windows 从低功耗模式(挂起/休眠)恢复时将调用此函数 -类型:bool +名称:OnResume
类型:`func()` -## Mac 特定选项 +### Mac -### TitleBar +这定义了 [Mac 特定的选项](#mac-特定选项)。 -The TitleBar struct provides the ability to configure the look and feel of the title bar. +名称:Mac
类型:`*mac.Options` -类型:bool +#### 标题栏 +TitleBar 结构提供了配置标题栏外观的能力。 -### Appearance +名称:TitleBar
类型:[`*mac.TitleBar`](#标题栏结构) -Appearance is used to set the style of your app in accordance with Apple's [NSAppearance](https://developer.apple.com/documentation/appkit/nsappearancename?language=objc) names. +##### 标题栏结构 -类型:string - -### 禁用窗口图标 - -设置为 `true` 时将使 WebView 背景透明。 这意味着如果你使用`rgba(0,0,0,0)`,主窗口将显示。 通常与[窗口半透明](#窗口半透明)结合使用以制作冰霜效果的应用程序。 - -类型:int - -### 禁用无边框窗口装饰 - -将此设置为 `true` 将使窗口半透明。 通常与[网页透明](#网页透明) 结合使用以制作冰霜效果的应用程序。 - -类型:int - -### About - -This configuration lets you set the title, message and icon for the "About" menu item in the app menu created by the "AppMenu" role. - -名称:CustomTheme - - -#### 标题栏结构 - -预设的标题栏设置可用: +可以使用 TitleBar 选项自定义应用程序的标题栏: ```go type TitleBar struct { @@ -511,24 +487,24 @@ type TitleBar struct { } ``` -| 设置 | 描述 | -| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| TitlebarAppearsTransparent | 使标题栏透明。 This has the effect of hiding the titlebar and the content fill the window. This has the effect of hiding the titlebar and the content fill the window. [Apple Docs](https://developer.apple.com/documentation/appkit/nswindow/1419167-titlebarappearstransparent?language=objc) | -| HideTitle | 隐藏窗口的标题。 [Apple Docs](https://developer.apple.com/documentation/appkit/nswindowtitlevisibility?language=objc) | -| HideTitleBar | Removes [NSWindowStyleMaskTitled](https://developer.apple.com/documentation/appkit/nswindowstylemask/nswindowstylemasktitled/) from the style mask | -| FullSizeContent | 使 webview 填满整个窗口。 [Apple Docs](https://developer.apple.com/documentation/appkit/nswindowstylemask/nswindowstylemaskfullsizecontentview) | -| UseToolbar | 向窗口添加默认工具栏。 [Apple Docs](https://developer.apple.com/documentation/appkit/nstoolbar?language=objc) | -| HideToolbarSeparator | 删除工具栏下方的线条。 [Apple Docs](https://developer.apple.com/documentation/appkit/nstoolbar/1516954-showsbaselineseparator?language=objc) | +| 设置 | 描述 | +| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | +| TitlebarAppearsTransparent | 使标题栏透明。 这具有隐藏标题栏和内容填充窗口的效果。 [苹果文档](https://developer.apple.com/documentation/appkit/nswindow/1419167-titlebarappearstransparent?language=objc) | +| HideTitle | 隐藏窗口的标题。 [苹果文档](https://developer.apple.com/documentation/appkit/nswindowtitlevisibility?language=objc) | +| HideTitleBar | Removes [NSWindowStyleMaskTitled](https://developer.apple.com/documentation/appkit/nswindowstylemask/nswindowstylemasktitled/) from the style mask | +| FullSizeContent | 使 webview 填满整个窗口。 [苹果文档](https://developer.apple.com/documentation/appkit/nswindowstylemask/nswindowstylemaskfullsizecontentview) | +| UseToolbar | 向窗口添加默认工具栏。 [苹果文档](https://developer.apple.com/documentation/appkit/nstoolbar?language=objc) | +| HideToolbarSeparator | 删除工具栏下方的线条。 [苹果文档](https://developer.apple.com/documentation/appkit/nstoolbar/1516954-showsbaselineseparator?language=objc) | -Preconfigured titlebar settings are available: +预配置的标题栏设置可用: -| 值 | 描述 | +| 设置 | 示例 | | --------------------------- | ---------------------------------------------- | | `mac.TitleBarDefault()` | ![](/img/reference/titlebar-default.webp) | | `mac.TitleBarHidden()` | ![](/img/reference/titlebar-hidden.webp) | | `mac.TitleBarHiddenInset()` | ![](/img/reference/titlebar-hidden-inset.webp) | -名称:Mac +示例: ```go Mac: &mac.Options{ @@ -536,11 +512,17 @@ Mac: &mac.Options{ } ``` -Click [here](https://github.com/lukakerr/NSWindowStyles) for some inspiration on customising the titlebar. +单击 [此处](https://github.com/lukakerr/NSWindowStyles) 获取有关自定义标题栏的一些灵感。 -#### 外观类型 +#### 外观 -You can specify the application's [appearance](https://developer.apple.com/documentation/appkit/nsappearance?language=objc). +Appearance 用于根据 Apple 的 [NSAppearance](https://developer.apple.com/documentation/appkit/nsappearancename?language=objc) 名称设置您的应用程序的样式。 + +名称:Appearance
类型:[`mac.AppearanceType`](#appearance-type) + +##### 外观类型 + +您可以指定应用程序的 [外观](https://developer.apple.com/documentation/appkit/nsappearance?language=objc)。 | 值 | 描述 | | ----------------------------------------------------- | --------------- | @@ -553,7 +535,7 @@ You can specify the application's [appearance](https://developer.apple.com/docum | NSAppearanceNameAccessibilityHighContrastVibrantLight | 轻盈灵动外观的高对比度版本 | | NSAppearanceNameAccessibilityHighContrastVibrantDark | 深色活力外观的高对比度版本 | -名称:Mac +示例: ```go Mac: &mac.Options{ @@ -561,9 +543,28 @@ Mac: &mac.Options{ } ``` -#### 关于结构 +#### Webview 透明 + +当使用 `alpha` 值 `0` 时,将此设置为 true 将使 webview 背景透明。 这意味着如果您在 CSS 中使用 `rgba(0,0,0,0)` 作为 `background-color`,则主机窗口将显示出来。 通常与 [窗口半透明](#窗口半透明) 结合使用以制作看起来冷冰冰的应用程序。 + +名称:WebviewIsTransparent
类型:`bool` + +#### 窗口半透明 + +将此设置为 `true` 将使窗口半透明。 通常与[Webview 透明](#webview-透明) 结合使用以制作冰霜效果的应用程序。 + +名称:WindowIsTranslucent
类型:`bool` + +#### 关于 + +此配置允许您在“AppMenu”角色创建的应用程序菜单中设置“关于”菜单项的标题、消息和图标。 + +名称:About
类型:[`*mac.AboutInfo`](#about-struct) + +##### 关于结构 ```go + type AboutInfo struct { Title string Message string @@ -606,19 +607,21 @@ func main() { }) ``` -The "About" menu item will appear in the app menu: +“关于”菜单项将出现在应用程序菜单中: +```mdx-code-block
-
+``` -When clicked, that will open an about message box: +单击后,将打开一个关于消息框: +```mdx-code-block
-
+``` -## Linux 特定选项 +### Linux -### Icon +这定义了 [Linux 特定的选项](#linux-特定选项)。 + +名称:Linux
类型:`*linux.Options` + +#### 图标 设置代表窗口的图标。 当窗口最小化(也称为图标化)时使用此图标。 -名称:Appearance +名称:Icon
类型:`[]byte` 一些窗口管理器或桌面环境也可能将其放置在窗口框架中,或在其他上下文中显示。 在其他情况下,根本不使用该图标,因此您的预计情况可能会有所不同。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/project-config.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/project-config.mdx index a491fb3d5..c7f38d680 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/project-config.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/project-config.mdx @@ -4,60 +4,50 @@ sidebar_position: 5 # 项目配置 -项目配置在项目目录中的`wails.json`文件中。 配置的结构是: +项目配置在项目目录中的 `wails.json` 文件中。 配置的结构是: ```json { - "name": "[项目名称]", - "assetdir": "[资源目录的相对路径]", - "reloaddirs": "[触发重新加载的附加目录(逗号分隔),这仅用于一些重要资源配置]", - "frontend:install": "[安装 node 依赖的命令,在 frontend 目录下运行 - 通常是 `npm install`]", - "frontend:build": "[构建资源的命令,在 frontend 目录下运行 - 通常是 `npm run build`]", - "frontend:dev": "[此命令已被 frontend:dev:build 替代。 If frontend:dev:build is not specified will falls back to this command. If frontend:dev:build is not specified will falls back to this command. 如果没有指定 frontend:dev:build 将回退到该命令,如果此命令也没有指定将回退到 frontend:build]", - "frontend:dev:build": "[此命令等效于开发模式中的 frontend:build,如果没有指定则回退到 frontend:dev]", - "frontend:dev:install": "[此命令等效于开发模式中的 frontend:install,如果没有指定则只有 frontend:install]", - "frontend:dev:watcher": "[此命令在 `wails dev` 上的单独进程中运行。 If not specified falls back to frontend:dev]", + "name": "[The project name]", + "assetdir": "[Relative path to the directory containing the compiled assets, this is normally inferred and could be left empty]", + "reloaddirs": "[Additional directories to trigger reloads (comma separated), this is only used for some advanced asset configurations]", + "frontend:install": "[The command to install node dependencies, run in the frontend directory - often `npm install`]", + "frontend:build": "[The command to build the assets, run in the frontend directory - often `npm run build`]", + "frontend:dev": "[This command has been replaced by frontend:dev:build. If frontend:dev:build is not specified will falls back to this command. \nIf this command is also not specified will falls back to frontend:build]", + "frontend:dev:build": "[This command is the dev equivalent of frontend:build. If not specified falls back to frontend:dev]", "frontend:dev:install": "[This command is the dev equivalent of frontend:install. If not specified falls back to frontend:install]", "frontend:dev:watcher": "[This command is run in a separate process on `wails dev`. Useful for 3rd party watchers or starting 3d party dev servers]", - "frontend:dev:serverUrl": "[URL to a 3rd party dev server to be used to serve assets, EG Vite. 对第 3 方观察者有用]", - "frontend:dev:serverUrl": "[使用第三方开发服务器提供资源,比如 Vite", - "wailsjsdir": "[自动生成的JS模块将被创建的目录的相对路径]", - "version": "[项目配置版本]", - "outputfilename": "[二进制文件的名称]", - "debounceMS": 100, // 在检测到资源更改时,开发服务器等待重新加载的时间 - "devServer": "[将 wails 开发服务器绑定到的地址。 默认:localhost:34115]", - "appargs": "[在dev模式下以shell样式传递给应用程序的参数]", - "runNonNativeBuildHooks": false, // 定义构建钩子是否应该运行,尽管它们是为主机操作系统以外的操作系统定义的。 + "frontend:dev:serverUrl": "[URL to a 3rd party dev server to be used to serve assets, EG Vite. \nIf this is set to 'auto' then the devServerUrl will be inferred from the Vite output]", + "wailsjsdir": "[Relative path to the directory that the auto-generated JS modules will be created]", + "version": "[Project config version]", + "outputfilename": "[The name of the binary]", + "debounceMS": 100, // The default time the dev server waits to reload when it detects a change in assets + "devServer": "[Address to bind the wails dev sever to. Default: localhost:34115]", + "appargs": "[Arguments passed to the application in shell style when in dev mode]", + "runNonNativeBuildHooks": false, // Defines if build hooks should be run though they are defined for an OS other than the host OS. "preBuildHooks": { "GOOS/GOARCH": "[The command that will be executed before a build of the specified GOOS/GOARCH: ${platform} is replaced with the "GOOS/GOARCH". The "GOOS/GOARCH" hook is executed before the "GOOS/*" and "*/*" hook.]", "GOOS/*": "[The command that will be executed before a build of the specified GOOS: ${platform} is replaced with the "GOOS/GOARCH". The "GOOS/*" hook is executed before the "*/*" hook.]", "*/*": "[The command that will be executed before every build: ${platform} is replaced with the "GOOS/GOARCH".]" + }, "postBuildHooks": { - "GOOS/GOARCH": "[在构建指定的 GOOS/GOARCH 后将执行的命令:${platform} 替换为'GOOS/GOARCH',${bin} 替换为编译后的二进制文件的路径。 The "GOOS/GOARCH" hook is executed before the "GOOS/*" and "*/*" hook.]", - "GOOS/*": "[The command that will be executed before a build of the specified GOOS: ${platform} is replaced with the "GOOS/GOARCH". The "GOOS/GOARCH" hook is executed before the "GOOS/*" and "*/*" hook.]", - "GOOS/*": "[The command that will be executed before a build of the specified GOOS: ${platform} is replaced with the "GOOS/GOARCH". The "GOOS/GOARCH" hook is executed before the "GOOS/*" and "*/*" hook.]", - "GOOS/*": "[The command that will be executed before a build of the specified GOOS: ${platform} is replaced with the "GOOS/GOARCH". The "GOOS/*" hook is executed before the "*/*" hook.]", - "*/*": "[The command that will be executed before every build: ${platform} is replaced with the "GOOS/GOARCH".]" - "postBuildHooks": { - "GOOS/GOARCH": "[在构建指定的 GOOS/GOARCH 后将执行的命令:${platform} 替换为'GOOS/GOARCH',${bin} 替换为编译后的二进制文件的路径。 - ]", - "GOOS/*": "[在构建指定的 GOOS 后将执行的命令:${platform} 替换为'GOOS/GOARCH',${bin} 替换为编译后的二进制文件的路径。 'GOOS/GOARCH'钩子在'GOOS/*'和'*/*'钩子之前执行。 ]", - "GOOS/*": "[在构建指定的 GOOS 后将执行的命令:${platform} 替换为'GOOS/GOARCH',${bin} 替换为编译后的二进制文件的路径。 'GOOS/*'钩子在'*/*'钩子之前执行。 ]", - "*/*": "[每次构建后将执行的命令:${platform} 替换为'GOOS/GOARCH',${bin} 替换为编译后的二进制文件的路径。 - ]" - }, - "info": { - // 用于填充 manifests 和 version 信息的数据。 - "companyName": "[公司名称。 默认: [项目名]]", - "productName": "[产品名称。 默认: [项目名]]", - "productVersion": "[产品的版本。 默认: '1.0.0']", - "copyright": "[产品的版权。 默认: 'Copyright.........']", - "comments": "[该应用程序的简短注释。 默认: 'Built using Wails (https://wails.app)']" - }, - "nsisType": "['multiple': 每个架构一个安装程序。 'single': 适用于所有正在构建的架构的单一通用安装程序。 默认: 'multiple']" + "GOOS/GOARCH": "[The command that will be executed after a build of the specified GOOS/GOARCH: ${platform} is replaced with the "GOOS/GOARCH" and ${bin} with the path to the compiled binary. The "GOOS/GOARCH" hook is executed before the "GOOS/*" and "*/*" hook.]", + "GOOS/*": "[The command that will be executed after a build of the specified GOOS: ${platform} is replaced with the "GOOS/GOARCH" and ${bin} with the path to the compiled binary. The "GOOS/*" hook is executed before the "*/*" hook.]", + "*/*": "[The command that will be executed after every build: ${platform} is replaced with the "GOOS/GOARCH" and ${bin} with the path to the compiled binary.]" + }, + "info": { // Data used to populate manifests and version info. + "companyName": "[The company name. Default: [The project name]]", + "productName": "[The product name. Default: [The project name]]", + "productVersion": "[The version of the product. Default: '1.0.0']", + "copyright": "[The copyright of the product. Default: 'Copyright.........']", + "comments": "[A short comment of the app. Default: 'Built using Wails (https://wails.app)']" + }, + "nsisType": "['multiple': One installer per architecture. 'single': Single universal installer for all architectures being built. Default: 'multiple']", + "obfuscated": "[Whether the app should be obfuscated. Default: false]", + "garbleargs": "[The arguments to pass to the garble command when using the obfuscated flag]" } ``` -该文件将在运行`wails build`或`wails dev`时,由 Wails CLI 读取。 +该文件将在运行 `wails build` 或 `wails dev` 时,由 Wails CLI 读取。 -`wails build/dev`命令中的`assetdir`、`reloaddirs`、`wailsjsdir`、`debounceMS`、`devserver`和`frontenddevserverurl`标志将覆盖项目配置并作为后续运行的默认值。 +`wails build/dev` 命令中的 `assetdir`、`reloaddirs`、`wailsjsdir`、`debounceMS`、`devserver`和`frontenddevserverurl`标志将覆盖项目配置并作为后续运行的默认值。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/browser.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/browser.mdx index 7a3679fe9..26b81b958 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/browser.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/browser.mdx @@ -11,4 +11,3 @@ sidebar_position: 7 使用系统默认浏览器打开给定的 URL。 Go: `BrowserOpenURL(ctx context.Context, url string)`
JS: `BrowserOpenURL(url string)` - diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/dialog.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/dialog.mdx index efffe260b..e99d6d50d 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/dialog.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/dialog.mdx @@ -7,12 +7,16 @@ sidebar_position: 5 运行时的这一部分提供对原生对话框的调用,例如文件选择器和消息框。 :::info Javascript + + JS 运行时当前不支持对话框。 + ::: + ### 打开选择目录对话框 -打开一个对话框,提示用户选择目录。 可以使用 [打开选择文件对话框参数选项](#打开选择文件对话框参数选项)进行自定义。 +打开一个对话框,提示用户选择目录。 可以使用 [ 打开选择文件对话框参数选项](#打开选择文件对话框参数选项) 进行自定义。 Go: `OpenDirectoryDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error)` @@ -20,23 +24,23 @@ Go: `OpenDirectoryDialog(ctx context.Context, dialogOptions OpenDialogOptions) ( ### 打开选择文件对话框 -打开一个对话框,提示用户选择文件。 可以使用 [打开选择文件对话框参数选项](#打开选择文件对话框参数选项)进行自定义。 +打开一个对话框,提示用户选择文件。 可以使用 [ 打开选择文件对话框参数选项](#打开选择文件对话框参数选项) 进行自定义。 Go: `OpenFileDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error)` 返回值: 所选文件(如果用户取消则为空白)或错误 -### 打开选择多个文件对话框 +### 打开选择多文件对话框 -打开一个对话框,提示用户选择多个文件。 可以使用 [打开选择文件对话框参数选项](#打开选择文件对话框参数选项)进行自定义。 +打开一个对话框,提示用户选择多个文件。 可以使用 [ 打开选择文件对话框参数选项](#打开选择文件对话框参数选项) 进行自定义。 Go: `OpenMultipleFilesDialog(ctx context.Context, dialogOptions OpenDialogOptions) ([]string, error)` -返回值: 选定的文件(如果用户取消则为零)或错误 +返回值: 选定的文件(如果用户取消则为 nil)或错误 ### 保存文件对话框 -打开一个对话框,提示用户选择文件名以进行保存。 可以使用[保存文件对话框参数选项](#保存文件对话框参数选项)自定义。 +打开一个对话框,提示用户选择文件名以进行保存。 可以使用 [保存文件对话框参数选项](#保存文件对话框参数选项) 自定义。 Go: `SaveFileDialog(ctx context.Context, dialogOptions SaveDialogOptions) (string, error)` @@ -44,7 +48,7 @@ Go: `SaveFileDialog(ctx context.Context, dialogOptions SaveDialogOptions) (strin ### 消息对话框 -使用消息对话框显示消息。 可以使用[消息对话框参数选项](#消息对话框参数选项)进行自定义。 +使用消息对话框显示消息。 可以使用 [消息对话框参数选项](#消息对话框参数选项) 进行自定义。 Go: `MessageDialog(ctx context.Context, dialogOptions MessageDialogOptions) (string, error)` @@ -115,14 +119,14 @@ type MessageDialogOptions struct { } ``` -| 字段 | 描述 | Win | Mac | Lin | -| ------------- | ----------------------------------- | --- | --- | --- | -| Type | 消息对话框的类型,例如问题、信息... | ✅ | ✅ | ✅ | -| Title | 对话框的标题 | ✅ | ✅ | ✅ | -| Message | 向用户显示的消息 | ✅ | ✅ | ✅ | -| Buttons | 按钮标题列表 | | ✅ | | -| DefaultButton | 带有此文本的按钮应被视为默认按钮。 Bound to `return` | | ✅ | | -| CancelButton | 带有此文本的按钮应被视为取消。 Bound to `escape` | | ✅ | | +| 字段 | 描述 | Win | Mac | Lin | +| ------------- | ------------------------------ | --- | --- | --- | +| 类型 | 消息对话框的类型,例如问题、信息... | ✅ | ✅ | ✅ | +| Title | 对话框的标题 | ✅ | ✅ | ✅ | +| Message | 向用户显示的消息 | ✅ | ✅ | ✅ | +| Buttons | 按钮标题列表 | | ✅ | | +| DefaultButton | 带有此文本的按钮应被视为默认按钮。 绑定到 `return` | | ✅ | | +| CancelButton | 带有此文本的按钮应被视为取消。 绑定到 `escape` | | ✅ | | #### Windows @@ -134,7 +138,7 @@ Linux 有标准的对话框类型,其中的按钮是不可定制的。 返回 #### Mac -Mac 上的消息对话框最多可以指定 4 个按钮。 如果没有`DefaultButton`或`CancelButton`给出,第一个按钮被认为是默认的并绑定到`return`键。 +Mac 上的消息对话框最多可以指定 4 个按钮。 如果没有 `DefaultButton` 或 `CancelButton` 给出,第一个按钮被认为是默认的并绑定到 `return` 键。 对于以下代码: @@ -148,17 +152,18 @@ selection, err := runtime.MessageDialog(b.ctx, runtime.MessageDialogOptions{ 第一个按钮显示为默认值: +```mdx-code-block
-
+``` -如果我们指定`DefaultButton`为“two”: +如果我们指定 `DefaultButton` 为“two”: ```go selection, err := runtime.MessageDialog(b.ctx, runtime.MessageDialogOptions{ @@ -171,15 +176,16 @@ selection, err := runtime.MessageDialog(b.ctx, runtime.MessageDialogOptions{ 第二个按钮显示为默认值。 当 `return` 被按下时,则返回数值“two”。 +```mdx-code-block
-
+``` 如果我们现在指定`CancelButton`为“three”: @@ -193,19 +199,20 @@ selection, err := runtime.MessageDialog(b.ctx, runtime.MessageDialogOptions{ }) ``` -带有“three”的按钮显示在对话框的底部。 当`escape`被按下时,则返回值“three”: +带有“three”的按钮显示在对话框的底部。 当 `escape` 被按下时,则返回值“three”: +```mdx-code-block
-


+``` #### 对话框类型 @@ -231,33 +238,35 @@ type FileFilter struct { Windows 允许您在对话框中使用多个文件过滤器。 每个 FileFilter 将在对话框中显示为一个单独的条目: +```mdx-code-block
-


+``` #### Linux Linux 允许您在对话框中使用多个文件过滤器。 每个 FileFilter 将在对话框中显示为一个单独的条目: +```mdx-code-block
-


+``` #### Mac @@ -280,4 +289,4 @@ Mac 对话框只有一组模式来过滤文件的概念。 如果提供了多个 }) ``` -这将导致使用`*.png,*.jpg,*.mov,*.mp4`作为过滤器打开文件对话框。 +这将导致使用 `*.png,*.jpg,*.mov,*.mp4` 作为过滤器打开文件对话框。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/events.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/events.mdx index 8d21f7bee..478eef71b 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/events.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/events.mdx @@ -8,13 +8,13 @@ Wails 运行时提供了一个统一的事件系统,其中事件可以由 Go ### 添加事件侦听器 -此方法为给定的事件名称设置一个侦听器。 当一个`eventName`类型的事件被[触发指定事件](#触发指定事件)时,回调被触发。 与触发事件一起发送的任何其他数据都将传递给回调。 +此方法为给定的事件名称设置一个侦听器。 当 [触发指定事件](#触发指定事件) 名为 `eventName` 类型的事件时,将触发回调。 与触发事件一起发送的任何其他数据都将传递给回调。 Go: `EventsOn(ctx context.Context, eventName string, callback func(optionalData ...interface{}))`
JS: `EventsOn(eventName string, callback function(optionalData?: any))` ### 移除事件侦听器 -This method unregisters the listener for the given event name, optionally multiple listeneres can be unregistered via `additionalEventNames`. +此方法取消注册给定事件名称的侦听器,可选地,可以通过 `additionalEventNames` 取消注册多个侦听器。 Go: `EventsOff(ctx context.Context, eventName string, additionalEventNames ...string)`
JS: `EventsOff(eventName string, ...additionalEventNames)` @@ -26,13 +26,12 @@ Go: `EventsOnce(ctx context.Context, eventName string, callback func(optionalDat ### 添加指定对多触发次数的事件侦听器 -此方法为给定的事件名称设置一个侦听器,但最多只能触发`counter`次。 +此方法为给定的事件名称设置一个侦听器,但最多只能触发 `counter` 次。 Go: `EventsOnMultiple(ctx context.Context, eventName string, callback func(optionalData ...interface{}), counter int)`
JS: `EventsOnMultiple(eventName string, callback function(optionalData?: any), counter int)` ### 触发指定事件 -此方法触发指定的事件。 可选数据可以与事件一起传递。 这将触发任何事件侦听器。 +此方法触发指定的事件。 可选数据可以与事件一起传递。 这将触发任意事件侦听器。 Go: `EventsEmit(ctx context.Context, eventName string, optionalData ...interface{})`
JS: `EventsEmit(ctx context, optionalData function(optionalData?: any))` - diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/intro.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/intro.mdx index 24f60593f..444b4195b 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/intro.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/intro.mdx @@ -2,28 +2,30 @@ sidebar_position: 1 --- -# 介绍 +# 简介 运行时是一个为应用程序提供实用方法的库。 有 Go 和 Javascript 运行时,目的是在可能的情况下尝试使它们保持一致。 -It has utility methods for: +它具有以下实用方法: -- [Window](window.mdx) -- [Menu](menu.mdx) -- [Dialog](dialog.mdx) -- [Events](events.mdx) -- [Browser](browser.mdx) -- [Log](log.mdx) +- [窗口](window.mdx) +- [菜单](menu.mdx) +- [对话框](dialog.mdx) +- [事件](events.mdx) +- [浏览器](browser.mdx) +- [日志](log.mdx) -Go 运行时可通过导入`github.com/wailsapp/wails/v2/pkg/runtime`。 此包中的所有方法都将 context 作为第一个参数。 此 context 应该从 [应用启动回调](../options.mdx#onstartup) 或 [前端 Dom 加载完成回调](../options.mdx#ondomready) 钩子获得。 +Go 运行时可通过导入 `github.com/wailsapp/wails/v2/pkg/runtime` 获取。 此包中的所有方法都将 context 作为第一个参数。 此 context 应该从 [应用启动回调](../options.mdx#onstartup) 或 [前端 Dom 加载完成回调](../options.mdx#ondomready) 回调方法中获取。 :::info 注意 -虽然上下文将提供给[应用启动回调](../../reference/options#应用启动回调)方法,但不能保证运行时将在此方法中工作,因为窗口正在不同的线程中初始化。 如果您希望在启动时调用运行时方法,请使用[前端 Dom 加载完成回调](../../reference/options#前端-dom-加载完成回调)方法。 + +虽然上下文将提供给 [应用启动回调](../../reference/options#应用启动回调) 方法,但不能保证运行时将在此方法中工作,因为窗口正在不同的线程中初始化。 如果您希望在启动时调用运行时方法,请使用 [前端 Dom 加载完成回调](../../reference/options#前端-dom-加载完成回调) 方法。 ::: -Javascript 库可通过`window.runtime`提供给前端。 使用 `开发` 模式时会生成一个运行时包,该包为运行时提供 Typescript 声明。 这应该位于您的前端目录中的`wailsjs`目录中。 + +Javascript 库可通过 `window.runtime` 提供给前端。 使用 `开发` 模式时会生成一个运行时包,该包为运行时提供 Typescript 声明。 这应该位于您的前端目录的`wailsjs`目录中。 ### 隐藏 @@ -31,31 +33,44 @@ Go: `Hide(ctx context.Context)`
JS: `Hide()` 隐藏应用程序。 -:::info Note On Mac, this will hide the application in the same way as the `Hide` menu item in standard Mac applications. This is different to hiding the window, but the application still being in the foreground. For Windows and Linux, this is currently the same as `WindowHide`. ::: This is different to hiding the window, but the application still being in the foreground. For Windows and Linux, this is currently the same as `WindowHide`. ::: +:::info 注意 -### 环境 -Shows the application. +` Hide` 在 Mac 上,这将以与标准 Mac 应用程序中的菜单项相同的方式隐藏应用程序。 这与隐藏窗口不同,但应用程序仍处于前台。 对于 Windows 和 Linux,这与 `WindowHide` 相同。 + +::: + + +### 显示 + +显示应用程序。 + +:::info 注意 + + +在 Mac 上,这会将应用程序带回前台。 对于 Windows 和 Linux,这目前与 `WindowShow` 相同。 + +::: -:::info Note On Mac, this will bring the application back into the foreground. For Windows and Linux, this is currently the same as `WindowShow`. ::: :::info Note On Mac, this will bring the application back into the foreground. For Windows and Linux, this is currently the same as `WindowShow`. ::: For Windows and Linux, this is currently the same as `WindowShow`. ::: ::: Go: `Show(ctx context.Context)`
JS: `Show()` -### Quit +### 退出 -Quits the application. +退出应用程序。 Go: `Quit(ctx context.Context)`
JS: `Quit()` -### Environment +### 环境 -Returns details of the current environment. +返回当前环境的详细信息。 Go: `Environment(ctx context.Context) EnvironmentInfo`
JS: `Environment(): Promise` #### 环境信息 Go: + ```go type EnvironmentInfo struct { BuildType string @@ -63,11 +78,13 @@ type EnvironmentInfo struct { Arch string } ``` + JS: + ```ts interface EnvironmentInfo { - buildType: string; - platform: string; - arch: string; + buildType: string; + platform: string; + arch: string; } ``` diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/log.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/log.mdx index 2b717aa52..d88b29e5e 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/log.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/log.mdx @@ -6,22 +6,22 @@ sidebar_position: 3 Wails 运行时提供了一种可以从 Go 或 Javascript 调用的日志记录机制。 像大多数记录器一样,有许多日志级别: -- Trace -- Debug -- Info -- Warning -- Error -- Fatal +- Trace(追踪) +- Debug(调试) +- Info(信息) +- Warning(警告) +- Error(错误) +- Fatal(致命) 记录器将输出当前或更高日志级别的任何日志消息。 示例:`Debug`日志级别将输出除`Trace`消息之外的所有消息。 -### 打印日志 +### Print 日志 将给定的消息记录为原始消息。 Go: `LogPrint(ctx context.Context, message string)`
JS: `LogPrint(message: string)` -### 格式化打印日志 +### 格式化 Print 日志 将给定的消息记录为原始消息。 @@ -29,25 +29,25 @@ Go: `LogPrintf(ctx context.Context, format string, args ...interface{})`
### Trace 日志 -在`Trace`日志级别记录给定的消息。 +在 `Trace` 日志级别记录给定的消息。 Go: `LogTrace(ctx context.Context, message string)`
JS: `LogTrace(message: string)` ### 格式化 Trace 日志 -在`Trace`日志级别记录给定的消息。 +在 `Trace` 日志级别记录给定的消息。 Go: `LogTracef(ctx context.Context, format string, args ...interface{})`
### Debug 日志 -在`Debug`日志级别记录给定的消息。 +在 `Debug` 日志级别记录给定的消息。 Go: `LogDebug(ctx context.Context, message string)`
JS: `LogDebug(message: string)` ### 格式化 Debug 日志 -在`Debug`日志级别记录给定的消息。 +在 `Debug` 日志级别记录给定的消息。 Go: `LogDebugf(ctx context.Context, format string, args ...interface{})`
@@ -65,37 +65,37 @@ Go: `LogInfof(ctx context.Context, format string, args ...interface{})`
### Warning 日志 -在`Warning`日志级别记录给定的消息。 +在 `Warning` 日志级别记录给定的消息。 Go: `LogWarning(ctx context.Context, message string)`
JS: `LogWarning(message: string)` ### 格式化 Warning 日志 -在`Warning`日志级别记录给定的消息。 +在 `Warning` 日志级别记录给定的消息。 Go: `LogWarningf(ctx context.Context, format string, args ...interface{})`
### Error 日志 -在`Error`日志级别记录给定的消息。 +在 `Error` 日志级别记录给定的消息。 Go: `LogError(ctx context.Context, message string)`
JS: `LogError(message: string)` ### 格式化 Error 日志 -在`Error`日志级别记录给定的消息。 +在 `Error` 日志级别记录给定的消息。 Go: `LogErrorf(ctx context.Context, format string, args ...interface{})`
### Fatal 日志 -在`Fatal`日志级别记录给定的消息。 +在 `Fatal` 日志级别记录给定的消息。 Go: `LogFatal(ctx context.Context, message string)`
JS: `LogFatal(message: string)` ### 格式化 Fatal 日志 -在`Fatal`日志级别记录给定的消息。 +在 `Fatal` 日志级别记录给定的消息。 Go: `LogFatalf(ctx context.Context, format string, args ...interface{})`
@@ -103,19 +103,19 @@ Go: `LogFatalf(ctx context.Context, format string, args ...interface{})`
设置日志级别。 在 Javascript 中,该数字与以下日志级别有关: -| 值 | 日志等级 | -| - | ------- | -| 1 | Trace | -| 2 | Debug | -| 3 | Info | -| 4 | Warning | -| 5 | Error | +| 值 | 日志等级 | +| - | ----------- | +| 1 | Trace(追踪) | +| 2 | Debug(调试) | +| 3 | Info(信息) | +| 4 | Warning(警告) | +| 5 | Error(报错) | Go: `LogSetLogLevel(ctx context.Context, level logger.LogLevel)`
JS: `LogSetLogLevel(level: number)` ## 使用自定义日志 -可以通过使用应用程序参数选项 [日志](../../reference/options#日志) 提供自定义记录器来使用它。 唯一的要求是记录器实现了在`github.com/wailsapp/wails/v2/pkg/logger`里`logger.Logger`定义的接口: +可以通过使用应用程序参数选项 [日志](../../reference/options#日志) 提供自定义记录器来使用它。 唯一的要求是记录器实现在 `github.com/wailsapp/wails/v2/pkg/logger` 里 `logger.Logger` 定义的接口: ```go title="logger.go" type Logger interface { diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/menu.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/menu.mdx index 4ce2b368e..63f8793cd 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/menu.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/menu.mdx @@ -7,18 +7,21 @@ sidebar_position: 6 这些方法与应用程序菜单相关。 :::info Javascript - Menu is currently unsupported in the JS runtime. -::: ::: -::: ::: + + +JS 运行时当前不支持菜单。 + +::: + ### 设置应用程序菜单 -Sets the application menu to the given [menu](../menus.mdx). +将应用程序菜单设置为给定的 [菜单](../menus.mdx)。 Go: `MenuSetApplicationMenu(ctx context.Context, menu *menu.Menu)` ### 更新应用程序菜单 -将应用程序菜单设置为给定的[应用菜单](../../reference/menus)。 +获取传递给 `MenuSetApplicationMenu` 的菜单的任意更改更新应用程序菜单。 Go: `MenuUpdateApplicationMenu(ctx context.Context)` diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/window.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/window.mdx index e26776d0c..78952445b 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/window.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/runtime/window.mdx @@ -20,25 +20,31 @@ Go: `WindowFullscreen(ctx context.Context)`
JS: `WindowFullscreen()` ### 窗口取消全屏 -在全屏之前恢复先前的窗口尺寸和位置。 +恢复全屏之前的先前窗口尺寸和位置。 Go: `WindowUnfullscreen(ctx context.Context)`
JS: `WindowUnfullscreen()` +### 窗口是否全屏 + +如果窗口是全屏的,则返回 true。 + +Go: `WindowIsFullscreen(ctx context.Context) bool`
JS: `WindowIsFullscreen() bool` + ### 窗口居中 使窗口在当前窗口所在的监视器上居中。 Go: `WindowCenter(ctx context.Context)`
JS: `WindowCenter()` -### 窗口居中 +### 窗口重新加载 -使窗口在当前窗口所在的监视器上居中。 +执行“重新加载”(重新加载当前页面)。 Go: `WindowReload(ctx context.Context)`
JS: `WindowReload()` -### 窗口重新加载 +### 重新加载应用程序前端。 -执行“重新加载”(重新加载 index.html) +重新加载应用程序前端。 Go: `WindowReloadApp(ctx context.Context)`
JS: `WindowReloadApp()` @@ -48,153 +54,149 @@ Go: `WindowReloadApp(ctx context.Context)`
JS: `WindowReloadApp()` Go: `WindowSetSystemDefaultTheme(ctx context.Context)`
JS: `WindowSetSystemDefaultTheme()` -### 窗口设置深色主题 +将窗口主题设置为系统默认值(暗/亮)。 -JS 方法签名: `WindowSetLightTheme()` - -JS 方法签名: `WindowSetLightTheme()` +### 窗口设置浅色主题 仅限 Windows。 +Go: `WindowSetLightTheme(ctx context.Context)`
JS: `WindowSetLightTheme()` + +将窗口主题设置为浅色。 + +### 窗口设置深色主题 + +仅限 Windows。 + +Go: `WindowSetDarkTheme(ctx context.Context)`
JS: `WindowSetDarkTheme()` + +将窗口主题设置为深色。 + ### 显示窗口 -JS 方法签名: `WindowSetLightTheme()` +显示窗口,如果它当前是隐藏的。 -JS 方法签名: `WindowSetLightTheme()` - -仅限 Windows。 +Go: `WindowShow(ctx context.Context)`
JS: `WindowShow()` ### 隐藏窗口 -JS 方法签名: `WindowSetLightTheme()` - -隐藏窗口(如果当前可见)。 - -如果窗口当前处于隐藏状态,则显示该窗口。 - -### 设置窗口尺寸 - -隐藏窗口(如果当前可见)。 +如果当前可见,则隐藏窗口。 Go: `WindowHide(ctx context.Context)`
JS: `WindowHide()` -### 获取窗口尺寸 +### 窗口是否为正常 + +如果窗口未最小化、最大化或全屏,则返回 true。 + +Go: `WindowIsNormal(ctx context.Context) bool`
JS: `WindowIsNormal() bool` + +### 设置窗口尺寸 设置窗口的宽度和高度。 Go: `WindowSetSize(ctx context.Context, width int, height int)`
JS: `WindowSetSize(size: Size)` -### 设置窗口最大尺寸 +### 获取窗口尺寸 -Returns true if the window not minimised, maximised or fullscreen. +获取窗口的宽度和高度。 Go: `WindowGetSize(ctx context.Context) (width int, height int)`
JS: `WindowGetSize() : Size` ### 设置窗口最小尺寸 -获取窗口的宽度和高度。 +设置窗口最小尺寸。 如果窗口当前小于给定尺寸,将调整窗口大小。 + +设置大小 `0,0` 将禁用此约束。 Go: `WindowSetMinSize(ctx context.Context, width int, height int)`
JS: `WindowSetMinSize(size: Size)` ### 设置窗口最大尺寸 -Gets the width and height of the window. +设置窗口最大尺寸。 如果窗口当前大于给定尺寸,将调整窗口大小。 + +设置大小 `0,0` 将禁用此约束。 + +Go: `WindowSetMaxSize(ctx context.Context, width int, height int)`
JS: `WindowSetMaxSize(size: Size)` + +### 设置窗口置顶 + +设置窗口置顶或取消置顶。 Go: `WindowSetAlwaysOnTop(ctx context.Context, b bool)`
JS: `WindowSetAlwaysOnTop(b: Boolen)` ### 设置窗口位置 -设置最小窗口大小。 如果窗口当前小于给定尺寸,将调整窗口大小。 - -Setting a size of `0,0` will disable this constraint. - -获取相对于窗口当前所在显示器的窗口位置。 - -### 获取窗口位置 - -设置最大窗口大小。 如果窗口当前大于给定尺寸,将调整窗口大小。 - -Setting a size of `0,0` will disable this constraint. +设置相对于窗口当前所在监视器的窗口位置。 Go: `WindowSetPosition(ctx context.Context, x int, y int)`
JS: `WindowSetPosition(position: Position)` -### 窗口最大化 +### 获取窗口位置 -获取相对于窗口当前所在显示器的窗口位置。 +获取相对于窗口当前所在监视器的窗口位置。 Go: `WindowGetPosition(ctx context.Context) (x int, y int)`
JS: `WindowGetPosition() : Position` -### 窗口取消最大化 +### 窗口最大化 最大化窗口以填满屏幕。 Go: `WindowMaximise(ctx context.Context)`
JS: `WindowMaximise()` -### 窗口最大化切换 +### 窗口取消最大化 将窗口恢复到最大化之前的尺寸和位置。 Go: `WindowUnmaximise(ctx context.Context)`
JS: `WindowUnmaximise()` -### 窗口最小化 +### 窗口是否最大化 -在最大化和最大化之间切换。 +如果窗口最大化,则返回 true。 + +Go: `WindowIsMaximised(ctx context.Context) bool`
JS: `WindowIsMaximised() bool` + +### 窗口最大化切换 + +在最大化和未最大化之间切换。 Go: `WindowToggleMaximise(ctx context.Context)`
JS: `WindowToggleMaximise()` -### 窗口取消最小化 +### 窗口最小化。 最小化窗口。 Go: `WindowMinimise(ctx context.Context)`
JS: `WindowMinimise()` -### 尺寸 - -Returns true if the window is maximised. - -Go: `WindowUnminimise(ctx context.Context)`
JS: `WindowUnminimise()` - -### 窗口设置 RGBA +### 窗口取消最小化 将窗口恢复到最小化之前的尺寸和位置。 -Go: `WindowToggleMaximise(ctx context.Context)`
JS: `WindowToggleMaximise()` - -### 位置 - -窗口 - -Go: `WindowSetBackgroundColour(ctx context.Context, R, G, B, A uint8)`
JS: `WindowSetBackgroundColour(R, G, B, A)` - -### 尺寸 - -Restores the window to the dimensions and position prior to minimising. - Go: `WindowUnminimise(ctx context.Context)`
JS: `WindowUnminimise()` -### WindowIsMinimised +### 窗口是否最小化 -Returns true if the window is minimised. +如果窗口最小化,则返回 true。 -Go: `WindowIsMinimised(ctx context.Context) bool` JS: `WindowIsMinimised() bool` +Go: `WindowIsMinimised(ctx context.Context) bool`
JS: `WindowIsMinimised() bool` -### WindowSetBackgroundColour +### 窗口设置背景色 -将窗口的背景颜色设置为给定的 RGBA 颜色定义。 此颜色将显示所有透明像素。 +将窗口的背景颜色设置为给定的 RGBA 颜色定义。 这种颜色将显示所有透明像素。 -Valid values for R, G, B and A are 0-255. +R、G、B 和 A 的有效值为 0-255。 :::info Windows -On Windows, only alpha values of 0 or 255 are supported. -任何不为 0 的值都将被视为 255。 -任何不为 0 的值都将被视为 255。 + + +在 Windows 上,仅支持 0 或 255 的 alpha 值。 任何非 0 的值都将被视为 255。 + ::: + Go: `WindowSetBackgroundColour(ctx context.Context, R, G, B, A uint8)`
JS: `WindowSetBackgroundColour(R, G, B, A)` ## Typescript 对象定义 -### Position +### Position(位置) ```ts interface Position { @@ -203,7 +205,7 @@ interface Position { } ``` -### Size +### Size(尺寸) ```ts interface Size { diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/dogsapi.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/dogsapi.mdx index f4845fdbe..38f5f7233 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/dogsapi.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/tutorials/dogsapi.mdx @@ -2,8 +2,9 @@ sidebar_position: 20 --- -# Dogs API +# 狗狗 API +```mdx-code-block
-
+``` -:::note This tutorial has been kindly provided by [@tatadan](https://twitter.com/tatadan) and forms part of their [Wails Examples Repository](https://github.com/tataDan/wails-v2-examples). ::: +:::note -In this tutorial we are going to develop an application that retrieves photos of dogs from the web and then displays them. -### Create the project +本教程由 [@tatadan](https://twitter.com/tatadan) 友情提供,是他们的 [Wails Examples Repository](https://github.com/tataDan/wails-v2-examples) 的一部分。 -Let's create the application. From a terminal enter: `wails init -n dogs-api -t svelte` +::: -Note: We could optionally add `-ide vscode` or `-ide goland` to the end of this command if you wanted to add IDE support. -Now let's `cd dogs-api` and start editing the project files. +在本教程中,我们将开发一个应用程序,从网络上检索狗的照片,然后显示它们。 -### Remove unused code +### 创建项目 -We will start by removing some elements that we know we will not use: +让我们创建应用程序。 从终端输入:` wails init -n dogs-api -t svelte` -- Open `app.go` and remove the following lines: +注意:如果您想添加 IDE 支持,我们可以选择在此命令的末尾添加 `-ide vscode` 或 `-ide goland`。 + +现在让我们 `cd dogs-api` 开始编辑项目文件。 + +### 删除未使用的代码 + +我们将从删除一些我们知道不会使用的元素开始: + +- 打开 `app.go` 并删除以下行: ```go // Greet returns a greeting for the given name @@ -39,14 +46,14 @@ func (a *App) Greet(name string) string { } ``` -- Open `frontend/src/App.svelte` and delete all lines. -- Delete the `frontend/src/assets/images/logo-universal.png` file +- 打开 `frontend/src/App.svelte` 并删除所有行。 +- 删除 `frontend/src/assets/images/logo-universal.png` 文件 -### Creating our application +### 创建应用程序 -Now let's add our new Go code. +现在让我们添加新的 Go 代码。 -Add the following struct declarations to `app.go` before the function definitions: +在函数定义之前添加以下结构声明到 `app.go`: ```go type RandomImage struct { @@ -65,7 +72,7 @@ type ImagesByBreed struct { } ``` -Add the following functions to `app.go` (perhaps after the existing function definitions): +将以下函数添加到 `app.go`(可能在现有函数定义之后): ```go func (a *App) GetRandomImageUrl() string { @@ -130,7 +137,7 @@ func (a *App) GetImageUrlsByBreed(breed string) []string { } ``` -Modify the `import` section of `app.go` to look like this: +将 `app.go` 的 `import` 部分修改为如下所示: ```go import ( @@ -144,8 +151,9 @@ import ( ) ``` -Add the following lines to `frontend/src/App.svelte`: +将以下行添加到 `frontend/src/App.svelte`: + ```html