mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
docs: sync translations (#2893)
Co-authored-by: leaanthony <leaanthony@users.noreply.github.com>
This commit is contained in:
co-authored by
leaanthony
parent
30d17a760d
commit
a59f8b2cf3
@@ -60,6 +60,10 @@ Si vous n'êtes pas sûr d'un modèle, inspectez `package.json` et `wails.json`
|
||||
- [wails-elm-template](https://github.com/benjamin-thomas/wails-elm-template) - Développez votre application GUI avec de la programmation fonctionnelle et une configuration de développement en direct :tada: :rocket:
|
||||
- [wails-template-elm-tailwind](https://github.com/rnice01/wails-template-elm-tailwind) - Combine les puissances :muscle: d'Elm + Tailwind CSS + Wails ! Rechargement automatique pris en charge.
|
||||
|
||||
## HTMX
|
||||
|
||||
- [wails-htmx-templ-chi-tailwind](https://github.com/PylotLight/wails-hmtx-templ-template) - Use a unique combination of pure htmx for interactivity plus templ for creating components and forms
|
||||
|
||||
## Pure JavaScript (Vanilla)
|
||||
|
||||
- [wails-pure-js-template](https://github.com/KiddoV/wails-pure-js-template) - Un modèle avec rien que du JavaScript, du HTML et du CSS de base
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
# Crossplatform build with Github Actions
|
||||
|
||||
To build a Wails project for all the available platforms, you need to create an application build for each operating system. One effective method to achieve this is by utilizing GitHub Actions.
|
||||
|
||||
An action that facilitates building a Wails app is available at:
|
||||
https://github.com/dAppServer/wails-build-action
|
||||
|
||||
In case the existing action doesn't fulfill your requirements, you can select only the necessary steps from the source:
|
||||
https://github.com/dAppServer/wails-build-action/blob/main/action.yml
|
||||
|
||||
Below is a comprehensive example that demonstrates building an app upon the creation of a new Git tag and subsequently uploading it to the Actions artifacts:
|
||||
|
||||
```yaml
|
||||
name: Wails build
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
# Match any new tag
|
||||
- '*'
|
||||
|
||||
env:
|
||||
# Necessary for most environments as build failure can occur due to OOM issues
|
||||
NODE_OPTIONS: "--max-old-space-size=4096"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
# Failure in one platform build won't impact the others
|
||||
fail-fast: false
|
||||
matrix:
|
||||
build:
|
||||
- name: 'App'
|
||||
platform: 'linux/amd64'
|
||||
os: 'ubuntu-latest'
|
||||
- name: 'App'
|
||||
platform: 'windows/amd64'
|
||||
os: 'windows-latest'
|
||||
- name: 'App'
|
||||
platform: 'darwin/universal'
|
||||
os: 'macos-latest'
|
||||
|
||||
runs-on: ${{ matrix.build.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Build wails
|
||||
uses: dAppServer/wails-build-action@v2.2
|
||||
id: build
|
||||
with:
|
||||
build-name: ${{ matrix.build.name }}
|
||||
build-platform: ${{ matrix.build.platform }}
|
||||
package: false
|
||||
go-version: '1.20'
|
||||
```
|
||||
|
||||
This example offers opportunities for various enhancements, including:
|
||||
|
||||
- Caching dependencies
|
||||
- Code signing
|
||||
- Uploading to platforms like S3, Supbase, etc.
|
||||
- Injecting secrets as environment variables
|
||||
- Utilizing environment variables as build variables (such as version variable extracted from the current Git tag)
|
||||
@@ -0,0 +1,199 @@
|
||||
# File Association
|
||||
|
||||
File association feature allows you to associate specific file types with your app so that when users open those files,
|
||||
your app is launched to handle them. This can be particularly useful for text editors, image viewers, or any application
|
||||
that works with specific file formats. In this guide, we'll walk through the steps to implement file association in Wails app.
|
||||
|
||||
## Set Up File Association:
|
||||
|
||||
To set up file association, you need to modify your application's wails.json file.
|
||||
In "info" section add a "fileAssociations" section specifying the file types your app should be associated with.
|
||||
|
||||
For example:
|
||||
|
||||
```json
|
||||
{
|
||||
"info": {
|
||||
"fileAssociations": [
|
||||
{
|
||||
"ext": "wails",
|
||||
"name": "Wails",
|
||||
"description": "Wails Application File",
|
||||
"iconName": "wailsFileIcon",
|
||||
"role": "Editor"
|
||||
},
|
||||
{
|
||||
"ext": "jpg",
|
||||
"name": "JPEG",
|
||||
"description": "Image File",
|
||||
"iconName": "jpegFileIcon",
|
||||
"role": "Editor"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Property | Description |
|
||||
| :---------- | :------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| ext | The extension (minus the leading period). e.g. png |
|
||||
| name | The name. e.g. PNG File |
|
||||
| iconName | The icon name without extension. Icons should be located in build folder. Proper icons will be generated from .png file for both macOS and Windows |
|
||||
| description | Windows-only. The description. It is displayed on the `Type` column on Windows Explorer. |
|
||||
| role | macOS-only. The app’s role with respect to the type. Corresponds to CFBundleTypeRole. |
|
||||
|
||||
## Platform Specifics:
|
||||
|
||||
### macOS
|
||||
|
||||
When you open file (or files) with your app, the system will launch your app and call the `OnFileOpen` function in your Wails app. Example:
|
||||
|
||||
```go title="main.go"
|
||||
func main() {
|
||||
// Create application with options
|
||||
err := wails.Run(&options.App{
|
||||
Title: "wails-open-file",
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
AssetServer: &assetserver.Options{
|
||||
Assets: assets,
|
||||
},
|
||||
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
|
||||
Mac: &mac.Options{
|
||||
OnFileOpen: func(filePaths []string) { println(filestring) },
|
||||
},
|
||||
Bind: []interface{}{
|
||||
app,
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
println("Error:", err.Error())
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Windows
|
||||
|
||||
On Windows file association is supported only with NSIS installer. During installation, the installer will create a
|
||||
registry entry for your file associations. When you open file with your app, new instance of app is launched and file path is passed
|
||||
as argument to your app. To handle this you should parse command line arguments in your app. Example:
|
||||
|
||||
```go title="main.go"
|
||||
func main() {
|
||||
argsWithoutProg := os.Args[1:]
|
||||
|
||||
if len(argsWithoutProg) != 0 {
|
||||
println("launchArgs", argsWithoutProg)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Linux
|
||||
|
||||
Currently, Wails doesn't support bundling for Linux. So, you need to create file associations manually.
|
||||
For example if you distribute your app as a .deb package, you can create file associations by adding required files in you bundle.
|
||||
You can use [nfpm](https://nfpm.goreleaser.com/) to create .deb package for your app.
|
||||
|
||||
1. Create a .desktop file for your app and specify file associations there. Example:
|
||||
|
||||
```ini
|
||||
[Desktop Entry]
|
||||
Categories=Office
|
||||
Exec=/usr/bin/wails-open-file %u
|
||||
Icon=wails-open-file.png
|
||||
Name=wails-open-file
|
||||
Terminal=false
|
||||
Type=Application
|
||||
MimeType=application/x-wails;application/x-test
|
||||
```
|
||||
|
||||
2. Create mime types file. Example:
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
|
||||
<mime-type type="application/x-wails">
|
||||
<comment>Wails Application File</comment>
|
||||
<glob pattern="*.wails"/>
|
||||
</mime-type>
|
||||
</mime-info>
|
||||
```
|
||||
|
||||
3. Create icons for your file types. SVG icons are recommended.
|
||||
4. Prepare postInstall/postRemove scripts for your package. Example:
|
||||
|
||||
```sh
|
||||
# reload mime types to register file associations
|
||||
update-mime-database /usr/share/mime
|
||||
# reload desktop database to load app in list of available
|
||||
update-desktop-database /usr/share/applications
|
||||
# update icons
|
||||
update-icon-caches /usr/share/icons/*
|
||||
```
|
||||
|
||||
5. Configure nfpm to use your scripts and files. Example:
|
||||
|
||||
```yaml
|
||||
name: "wails-open-file"
|
||||
arch: "arm64"
|
||||
platform: "linux"
|
||||
version: "1.0.0"
|
||||
section: "default"
|
||||
priority: "extra"
|
||||
maintainer: "FooBarCorp <FooBarCorp@gmail.com>"
|
||||
description: "Sample Package"
|
||||
vendor: "FooBarCorp"
|
||||
homepage: "http://example.com"
|
||||
license: "MIT"
|
||||
contents:
|
||||
- src: ../bin/wails-open-file
|
||||
dst: /usr/bin/wails-open-file
|
||||
- src: ./main.desktop
|
||||
dst: /usr/share/applications/wails-open-file.desktop
|
||||
- src: ./application-wails-mime.xml
|
||||
dst: /usr/share/mime/packages/application-x-wails.xml
|
||||
- src: ./application-test-mime.xml
|
||||
dst: /usr/share/mime/packages/application-x-test.xml
|
||||
- src: ../appicon.svg
|
||||
dst: /usr/share/icons/hicolor/scalable/apps/wails-open-file.svg
|
||||
- src: ../wailsFileIcon.svg
|
||||
dst: /usr/share/icons/hicolor/scalable/mimetypes/application-x-wails.svg
|
||||
- src: ../testFileIcon.svg
|
||||
dst: /usr/share/icons/hicolor/scalable/mimetypes/application-x-test.svg
|
||||
# copy icons to Yaru theme as well. For some reason Ubuntu didn't pick up fileicons from hicolor theme
|
||||
- src: ../appicon.svg
|
||||
dst: /usr/share/icons/Yaru/scalable/apps/wails-open-file.svg
|
||||
- src: ../wailsFileIcon.svg
|
||||
dst: /usr/share/icons/Yaru/scalable/mimetypes/application-x-wails.svg
|
||||
- src: ../testFileIcon.svg
|
||||
dst: /usr/share/icons/Yaru/scalable/mimetypes/application-x-test.svg
|
||||
scripts:
|
||||
postinstall: ./postInstall.sh
|
||||
postremove: ./postRemove.sh
|
||||
```
|
||||
|
||||
6. Build your .deb package using nfpm:
|
||||
|
||||
```sh
|
||||
nfpm pkg --packager deb --target .
|
||||
```
|
||||
|
||||
7. Now when your package is installed, your app will be associated with specified file types. When you open file with your app,
|
||||
new instance of app is launched and file path is passed as argument to your app.
|
||||
To handle this you should parse command line arguments in your app. Example:
|
||||
|
||||
```go title="main.go"
|
||||
func main() {
|
||||
argsWithoutProg := os.Args[1:]
|
||||
|
||||
if len(argsWithoutProg) != 0 {
|
||||
println("launchArgs", argsWithoutProg)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Limitations:
|
||||
|
||||
On Windows and Linux when associated file is opened, new instance of your app is launched.
|
||||
Currently, Wails doesn't support opening files in already running app. There is plugin for single instance support for v3 in development.
|
||||
@@ -159,6 +159,28 @@ If `/Applications/Xcode.app/Contents/Developer` is displayed, run `sudo xcode-se
|
||||
|
||||
Sources: https://github.com/wailsapp/wails/issues/1806 and https://github.com/wailsapp/wails/issues/1140#issuecomment-1290446496
|
||||
|
||||
## My application won't compile on Mac
|
||||
|
||||
If you are getting errors like this:
|
||||
|
||||
```shell
|
||||
l1@m2 GoEasyDesigner % go build -tags dev -gcflags "all=-N -l"
|
||||
/Users/l1/sdk/go1.20.5/pkg/tool/darwin_arm64/link: running clang failed: exit status 1
|
||||
Undefined symbols for architecture arm64:
|
||||
"_OBJC_CLASS_$_UTType", referenced from:
|
||||
objc-class-ref in 000016.o
|
||||
ld: symbol(s) not found for architecture arm64
|
||||
clang: error: linker command failed with exit code 1 (use -v to see invocation)
|
||||
```
|
||||
Ensure you have the latest SDK installed. If so and you're still experiencing this issue, try the following:
|
||||
|
||||
```shell
|
||||
export CGO_LDFLAGS="-framework UniformTypeIdentifiers" && go build -tags dev -gcflags "all=-N -l"
|
||||
```
|
||||
|
||||
Sources: https://github.com/wailsapp/wails/pull/2925#issuecomment-1726828562
|
||||
|
||||
|
||||
--
|
||||
|
||||
## Cannot start service: Host version "x.x.x does not match binary version "x.x.x"
|
||||
@@ -185,4 +207,162 @@ This is due to the default background of the webview being white. If you want to
|
||||
WebviewIsTransparent: true,
|
||||
},
|
||||
})
|
||||
```
|
||||
```
|
||||
|
||||
## I get a "Microsoft Edge can't read or write to its data directory" error when running my program as admin on Windows
|
||||
|
||||
You set your program to require admin permissions and it worked great! Unfortunately, some users are seeing a "Microsoft Edge can't read or write to its data directory" error when running it.
|
||||
|
||||
When a Windows machine has two local accounts:
|
||||
|
||||
- Alice, an admin
|
||||
- Bob, a regular user
|
||||
|
||||
Bob sees a UAC prompt when running your program. Bob enters Alice's admin credentials into this prompt. The app launches with admin permissions under Alice's account.
|
||||
|
||||
Wails instructs WebView2 to store user data at the specified `WebviewUserDataPath`. It defaults to `%APPDATA%\[BinaryName.exe]`.
|
||||
|
||||
Because the application is running under Alice's account, `%APPDATA%\[BinaryName.exe]` resolves to `C:\Users\Alice\AppData\Roaming\[BinaryName.exe]`.
|
||||
|
||||
WebView2 [creates some child processes under Bob's logged-in account instead of Alice's admin account](https://github.com/MicrosoftEdge/WebView2Feedback/issues/932#issue-807464179). Since Bob cannot access `C:\Users\Alice\AppData\Roaming\[BinaryName.exe]`, the "Microsoft Edge can't read or write to its data directory" error is shown.
|
||||
|
||||
Possible solution #1:
|
||||
|
||||
Refactor your application to work without constant admin permissions. If you just need to perform a small set of admin tasks (such as running an updater), you can run your application with the minimum permissions and then use the `runas` command to run these tasks with admin permissions as needed:
|
||||
|
||||
```go
|
||||
//go:build windows
|
||||
|
||||
package sample
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/windows"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// Calling RunAs("C:\path\to\my\updater.exe") shows Bob a UAC prompt. Bob enters Alice's admin credentials. The updater launches with admin permissions under Alice's account.
|
||||
func RunAs(path string) error {
|
||||
verbPtr, _ := syscall.UTF16PtrFromString("runas")
|
||||
exePtr, _ := syscall.UTF16PtrFromString(path)
|
||||
cwdPtr, _ := syscall.UTF16PtrFromString("")
|
||||
argPtr, _ := syscall.UTF16PtrFromString("")
|
||||
|
||||
var showCmd int32 = 1 //SW_NORMAL
|
||||
|
||||
err := windows.ShellExecute(0, verbPtr, exePtr, argPtr, cwdPtr, showCmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
```
|
||||
|
||||
Possible solution #2:
|
||||
|
||||
Run your application with extended permissions. If you absolutely must run with constant admin permissions, WebView2 will function correctly if you use a data directory accessible by both users and you also launch your app with the `SeBackupPrivilege`, `SeDebugPrivilege`, and `SeRestorePrivilege` permissions. Here's an example:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/fourcorelabs/wintoken"
|
||||
"github.com/hectane/go-acl"
|
||||
"github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/windows"
|
||||
)
|
||||
|
||||
//go:embed all:frontend/dist
|
||||
var assets embed.FS
|
||||
|
||||
const (
|
||||
fixedTokenKey = "SAMPLE_RANDOM_KEY"
|
||||
fixedTokenVal = "with-fixed-token"
|
||||
webviewDir = "C:\\ProgramData\\Sample"
|
||||
)
|
||||
|
||||
func runWithFixedToken() {
|
||||
println("Re-launching self")
|
||||
token, err := wintoken.OpenProcessToken(0, wintoken.TokenPrimary) //pass 0 for own process
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer token.Close()
|
||||
|
||||
token.EnableTokenPrivileges([]string{
|
||||
"SeBackupPrivilege",
|
||||
"SeDebugPrivilege",
|
||||
"SeRestorePrivilege",
|
||||
})
|
||||
|
||||
cmd := exec.Command(os.Args[0])
|
||||
cmd.Args = os.Args
|
||||
cmd.Env = os.Environ()
|
||||
cmd.Env = append(cmd.Env, fmt.Sprintf("%v=%v", fixedTokenKey, fixedTokenVal))
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Token: syscall.Token(token.Token())}
|
||||
if err := cmd.Run(); err != nil {
|
||||
println("Error after launching self:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
println("Clean self launch :)")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func main() {
|
||||
if runtime.GOOS == "windows" && os.Getenv(fixedTokenKey) != fixedTokenVal {
|
||||
runWithFixedToken()
|
||||
}
|
||||
|
||||
println("Setting data dir to", webviewDir)
|
||||
if err := os.MkdirAll(webviewDir, os.ModePerm); err != nil {
|
||||
println("Failed creating dir:", err)
|
||||
}
|
||||
if err := acl.Chmod(webviewDir, 0777); err != nil {
|
||||
println("Failed setting ACL on dir:", err)
|
||||
}
|
||||
|
||||
app := NewApp()
|
||||
|
||||
err := wails.Run(&options.App{
|
||||
Title: "sample-data-dir",
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
AssetServer: &assetserver.Options{
|
||||
Assets: assets,
|
||||
},
|
||||
Bind: []interface{}{
|
||||
app,
|
||||
},
|
||||
Windows: &windows.Options{
|
||||
WebviewUserDataPath: webviewDir,
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
println("Error:", err.Error())
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you use a data directory accessible by both users but not the extended privileges, you will receive a WebView2 `80010108 The object invoked has disconnected from its clients` error.
|
||||
|
||||
Possible future solution #3: [run WebView2 using an in-memory mode if implemented](https://github.com/MicrosoftEdge/WebView2Feedback/issues/3637#issuecomment-1728300982).
|
||||
|
||||
## WebView2 installation succeeded, but the wails doctor command shows that it is not installed
|
||||
|
||||
If you have installed WebView2, but the `wails doctor` command shows that it is not installed, it is likely that the WebView2 runtime installed was for a different architecture. You can download the correct runtime from [here](https://developer.microsoft.com/en-us/microsoft-edge/webview2/).
|
||||
|
||||
Source: https://github.com/wailsapp/wails/issues/2917
|
||||
|
||||
## WebVie2wProcess failed with kind
|
||||
|
||||
If your Windows app generates this kind of error, you can check out what the error means [here](https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2processfailedkind?view=webview2-winrt-1.0.2045.28).
|
||||
|
||||
|
||||
@@ -49,35 +49,35 @@ Si vous n'êtes pas sûr d'un modèle, inspectez les fichiers `package.json` et
|
||||
|
||||
`wails build` est utilisé pour compiler votre projet vers un binaire prêt à la production.
|
||||
|
||||
| Option | Description | Par défaut |
|
||||
|:-------------------- |:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| -clean | Nettoie le répertoire `build/bin` | |
|
||||
| -compiler "compiler" | Utiliser un autre compilateur pour compiler, par exemple go1.15beta1 | go |
|
||||
| -debug | Conserve les informations de débogage dans l'application et affiche la console de débogage. Permet l'utilisation des outils de développement dans la fenêtre de l'application | |
|
||||
| -devtools | Permet l'utilisation des devtools dans la fenêtre d'application en production (quand -debug n'est pas utilisé) | |
|
||||
| -dryrun | Affiche la commande build sans l'exécuter | |
|
||||
| -f | Forcer la compilation de l'application | |
|
||||
| -garbleargs | Arguments à passer à garble | `-literals -tiny -seed=random` |
|
||||
| -ldflags "flags" | Options supplémentaires à passer au compilateur | |
|
||||
| -m | Permet d'ignorer mod tidy avant la compilation | |
|
||||
| -nopackage | Ne pas empaqueter l'application | |
|
||||
| -nocolour | Désactive la couleur des logs dans le terminal | |
|
||||
| -nosyncgomod | Ne pas synchroniser go.mod avec la version Wails | |
|
||||
| -nsis | Génère l'installateur NSIS pour Windows | |
|
||||
| -o filename | Nom du fichier de sortie | |
|
||||
| -obfuscated | Cacher le code de l'application en utilisant [garble](https://github.com/burrowers/garble) | |
|
||||
| -platform | Construit pour les [plates-formes](../reference/cli.mdx#platforms) données (séparées par des virgules) par exemple. `windows/arm64`. Notez que si vous ne donnez pas l'architecture, `runtime.GOARCH` est utilisé. | platform = le contenu de la variable d'environnement `GOOS` si elle existe, autrement `runtime.GOOS`.<br/>arch = le contenu de la variable d'environnement `GOARCH` si elle existe, autrement `runtime.GOARCH`. |
|
||||
| -race | Construire avec le détecteur Go race | |
|
||||
| -s | Ignorer la construction du frontend | |
|
||||
| -skipbindings | Ignorer la génération des liaisons | |
|
||||
| -tags "extra tags" | Options de compilation à passer au compilateur Go. Doivent être entre guillemets. Séparés par un espace ou une virgule (pas les deux) | |
|
||||
| -trimpath | Supprimer tous les chemins vers les fichiers système de l'exécutable final. | |
|
||||
| -u | Met à jour le `go.mod de votre projet` pour utiliser la même version de Wails que le CLI | |
|
||||
| -upx | Compresser le binaire final en utilisant "upx" | |
|
||||
| -upxflags | Options à passer à upx | |
|
||||
| -v int | Niveau de verbosité (0 - silencieux, 1 - par défaut, 2 - verbeux) | 1 |
|
||||
| -webview2 | Stratégie d'installation WebView2 : download,embed,browser,error | download |
|
||||
| -windowsconsole | Garder la fenêtre de la console lors de la construction d'une version pour Windows | |
|
||||
| Option | Description | Par défaut |
|
||||
|:-------------------- |:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| -clean | Nettoie le répertoire `build/bin` | |
|
||||
| -compiler "compiler" | Utiliser un autre compilateur pour compiler, par exemple go1.15beta1 | go |
|
||||
| -debug | Conserve les informations de débogage dans l'application et affiche la console de débogage. Permet l'utilisation des outils de développement dans la fenêtre de l'application | |
|
||||
| -devtools | Allows the use of the devtools in the application window in production (when -debug is not used). Ctrl/Cmd+Shift+F12 may be used to open the devtools window. *NOTE*: This option will make your application FAIL Mac appstore guidelines. Use for debugging only. | |
|
||||
| -dryrun | Affiche la commande build sans l'exécuter | |
|
||||
| -f | Forcer la compilation de l'application | |
|
||||
| -garbleargs | Arguments à passer à garble | `-literals -tiny -seed=random` |
|
||||
| -ldflags "flags" | Options supplémentaires à passer au compilateur | |
|
||||
| -m | Permet d'ignorer mod tidy avant la compilation | |
|
||||
| -nopackage | Ne pas empaqueter l'application | |
|
||||
| -nocolour | Désactive la couleur des logs dans le terminal | |
|
||||
| -nosyncgomod | Ne pas synchroniser go.mod avec la version Wails | |
|
||||
| -nsis | Génère l'installateur NSIS pour Windows | |
|
||||
| -o filename | Nom du fichier de sortie | |
|
||||
| -obfuscated | Cacher le code de l'application en utilisant [garble](https://github.com/burrowers/garble) | |
|
||||
| -platform | Construit pour les [plates-formes](../reference/cli.mdx#platforms) données (séparées par des virgules) par exemple. `windows/arm64`. Notez que si vous ne donnez pas l'architecture, `runtime.GOARCH` est utilisé. | platform = le contenu de la variable d'environnement `GOOS` si elle existe, autrement `runtime.GOOS`.<br/>arch = le contenu de la variable d'environnement `GOARCH` si elle existe, autrement `runtime.GOARCH`. |
|
||||
| -race | Construire avec le détecteur Go race | |
|
||||
| -s | Ignorer la construction du frontend | |
|
||||
| -skipbindings | Ignorer la génération des liaisons | |
|
||||
| -tags "extra tags" | Options de compilation à passer au compilateur Go. Doivent être entre guillemets. Séparés par un espace ou une virgule (pas les deux) | |
|
||||
| -trimpath | Supprimer tous les chemins vers les fichiers système de l'exécutable final. | |
|
||||
| -u | Met à jour le `go.mod de votre projet` pour utiliser la même version de Wails que le CLI | |
|
||||
| -upx | Compresser le binaire final en utilisant "upx" | |
|
||||
| -upxflags | Options à passer à upx | |
|
||||
| -v int | Niveau de verbosité (0 - silencieux, 1 - par défaut, 2 - verbeux) | 1 |
|
||||
| -webview2 | Stratégie d'installation WebView2 : download,embed,browser,error | download |
|
||||
| -windowsconsole | Garder la fenêtre de la console lors de la construction d'une version pour Windows | |
|
||||
|
||||
Pour une description détaillée des options `webview2` , veuillez vous référer au Guide de [Windows](../guides/windows.mdx).
|
||||
|
||||
@@ -167,8 +167,8 @@ Your system is ready for Wails development!
|
||||
- Un serveur web est lancé sur `http://localhost:34115` qui sert votre application (et pas seulement le frontend) sur http. Cela vous permet d'utiliser les extensions de développement de votre navigateur favori
|
||||
- Tous les assets de l'application sont chargés à partir du disque. Si elles sont modifiées, l'application se rechargera automatiquement (pas de recompilation). Tous les navigateurs connectés rechargeront également
|
||||
- Un module JS est généré fournissant les éléments suivants :
|
||||
- Les méthodes Javascript permettant d'appeler vos méthodes Go avec JSDoc autogénérée, vous fournissant des indications sur les méthodes
|
||||
- Les versions TypeScript de vos structures Go, qui peuvent être construites et transmises à vos méthodes
|
||||
- Les méthodes Javascript permettant d'appeler vos méthodes Go avec JSDoc autogénérée, vous fournissant des indications sur les méthodes
|
||||
- Les versions TypeScript de vos structures Go, qui peuvent être construites et transmises à vos méthodes
|
||||
- Un second module JS est généré qui fournit une déclaration des méthodes et structures pour l'exécutable
|
||||
- Sur macOS, il regroupera l'application dans un fichier `.app` et l'exécutera. Il utilisera un `build/darwin/Info.dev.plist` pour le développement.
|
||||
|
||||
|
||||
@@ -366,7 +366,7 @@ Nom: CSSDragValue<br/> Type: `string`
|
||||
|
||||
EnableDefaultContextMenu active le menu contextuel par défaut du navigateur en production.
|
||||
|
||||
Par défaut, le menu contextuel par défaut du navigateur n'est disponible qu'en développement et dans un `-debug` ou `-devtools` [build](../reference/cli.mdx#build) avec l'inspecteur de devtools, En utilisant cette option, vous pouvez activer le menu contextuel par défaut dans `production` alors que l'inspecteur devtools ne sera pas disponible à moins que le drapeau `-devtools` ne soit utilisé.
|
||||
By default, the browser's default context-menu is only available in development and in a `-debug` [build](../reference/cli.mdx#build) along with the devtools inspector, Using this option you can enable the default context-menu in `production` while the devtools inspector won't be available unless the `-devtools` build flag is used.
|
||||
|
||||
Lorsque cette option est activée, par défaut, le menu contextuel ne sera affiché que pour du texte (où Couper/Copier/Coller est nécessaire), pour remplacer ce comportement, vous pouvez utiliser la propriété CSS `--default-contextmenu` sur n'importe quel élément HTML (y compris le corps ``) avec les valeurs suivantes :
|
||||
|
||||
@@ -593,6 +593,12 @@ Définir ceci à `true` désactivera l'accélération matérielle GPU pour la we
|
||||
|
||||
Nom: WebviewGpuIsDisabled<br/> Type: `bool`
|
||||
|
||||
#### EnableSwipeGestures
|
||||
|
||||
Setting this to `true` will enable swipe gestures for the webview.
|
||||
|
||||
Name: EnableSwipeGestures<br/> Type: `bool`
|
||||
|
||||
### Mac
|
||||
|
||||
Ceci définit [les options spécifiques à Mac](#mac).
|
||||
@@ -688,6 +694,42 @@ Définir ceci à `true` rendra l'arrière-plan de la fenêtre translucide. Souve
|
||||
|
||||
Nom: WindowIsTranslucent<br/> Type: `bool`
|
||||
|
||||
#### Preferences
|
||||
|
||||
The Preferences struct provides the ability to configure the Webview preferences.
|
||||
|
||||
Name: Preferences<br/> Type: [`*mac.Preferences`](#preferences-struct)
|
||||
|
||||
##### Preferences struct
|
||||
|
||||
You can specify the webview preferences.
|
||||
|
||||
```go
|
||||
type Preferences struct {
|
||||
TabFocusesLinks u.Bool
|
||||
TextInteractionEnabled u.Bool
|
||||
FullscreenEnabled u.Bool
|
||||
}
|
||||
```
|
||||
|
||||
| Nom | Description |
|
||||
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| TabFocusesLinks | A Boolean value that indicates whether pressing the tab key changes the focus to links and form controls. [Apple Docs](https://developer.apple.com/documentation/webkit/wkpreferences/2818595-tabfocuseslinks?language=objc) |
|
||||
| TextInteractionEnabled | A Boolean value that indicates whether to allow people to select or otherwise interact with text. [Apple Docs](https://developer.apple.com/documentation/webkit/wkpreferences/3727362-textinteractionenabled?language=objc) |
|
||||
| FullscreenEnabled | A Boolean value that indicates whether a web view can display content full screen. [Apple Docs](https://developer.apple.com/documentation/webkit/wkpreferences/3917769-elementfullscreenenabled?language=objc) |
|
||||
|
||||
Exemple:
|
||||
|
||||
```go
|
||||
Mac: &mac.Options{
|
||||
Preferences: &mac.Preferences{
|
||||
TabFocusesLinks: mac.Enabled,
|
||||
TextInteractionEnabled: mac.Disabled,
|
||||
FullscreenEnabled: mac.Enabled,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### About
|
||||
|
||||
Cette configuration vous permet de définir le titre, le message et l'icône pour l'élément de menu "À propos" dans le menu de l'application créé par le rôle "AppMenu".
|
||||
|
||||
@@ -13,6 +13,28 @@ Le format est basé sur [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Ajouts
|
||||
|
||||
- Added support for enabling/disabling swipe gestures for Windows WebView2. Added by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/2878)
|
||||
- When building with `-devtools` flag, CMD/CTRL+SHIFT+F12 can be used to open the devtools. Added by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/2915) – Added file association support for macOS and Windows. Added by @APshenkin in [PR](https://github.com/wailsapp/wails/pull/2918)
|
||||
- Added support for setting some of the Webview preferences, `textInteractionEnabled` and `tabFocusesLinks` on Mac. Added by @fkhadra in [PR](https://github.com/wailsapp/wails/pull/2937)
|
||||
- Added support for enabling/disabling fullscreen of the Webview on Mac. Added by @fkhadra in [PR](https://github.com/wailsapp/wails/pull/2953)
|
||||
- Added French README.fr.md page. Added by @nejos97 in [PR](https://github.com/wailsapp/wails/pull/2943)
|
||||
- New task created for linting v2 `task v2:lint`. Workflow updated to run the task. Added by @mikeee in [PR](https://github.com/wailsapp/wails/pull/2957)
|
||||
- Added new community template wails-htmx-templ-chi-tailwind. Added by [@pylotlight](https://github.com/pylotlight) in [PR](https://github.com/wailsapp/wails/pull/2984)
|
||||
- Added CPU/GPU/Memory detection for `wails doctor`. Added by @leaanthony in #d51268b8d0680430f3a614775b13e6cd2b906d1c
|
||||
|
||||
### Changements
|
||||
|
||||
- AssetServer requests are now processed asynchronously without blocking the main thread on Windows. Changed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2926)
|
||||
- AssetServer requests are now processed concurrently by spawning a goroutine per request. Changed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2926)
|
||||
- Now building with `-devtools` flag doesn't enable the default context-menu. Changed by @mmghv in [PR](https://github.com/wailsapp/wails/pull/2923)
|
||||
- Change Window Level. Changed by @almas1992 in [PR](https://github.com/wailsapp/wails/pull/2944)
|
||||
#### Corrections
|
||||
|
||||
- Fixed typo on docs/reference/options page. Added by [@pylotlight](https://github.com/pylotlight) in [PR](https://github.com/wailsapp/wails/pull/2887)
|
||||
- Fixed issue with npm being called npm20 on openSUSE-Tumbleweed. Fixed by @TuffenDuffen in [PR] in (https://github.com/wailsapp/wails/pull/2941)
|
||||
|
||||
## v2.6.0 - 2023-09-06
|
||||
|
||||
### Modifications importantes
|
||||
@@ -27,6 +49,7 @@ Le format est basé sur [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
- Fixed `SetBackgroundColour` so it sets the window's background color to reduce resize flickering on Linux. Added by @lyimmi in [PR](https://github.com/wailsapp/wails/pull/2853)
|
||||
- Fixed disable window resize option and wrong initial window size when its enabled. Added by @lyimmi in [PR](https://github.com/wailsapp/wails/pull/2863)
|
||||
- Fixed build hook command parsing. Added by @smac89 in [PR](https://github.com/wailsapp/wails/pull/2836)
|
||||
- Fixed filesystem watcher from filtering top level project directory if binary name is included in .gitignore. Added by [@haukened](https://github.com/haukened) in [PR #2869](https://github.com/wailsapp/wails/pull/2869)
|
||||
- Fixed `-reloaddir` flag to watch additional directories (non-recursively). [@haukened](https://github.com/haukened) in [PR #2871](https://github.com/wailsapp/wails/pull/2871)
|
||||
- Fixed support for Go 1.21 `go.mod` files. Fixed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2876)
|
||||
|
||||
@@ -44,6 +67,7 @@ Le format est basé sur [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
- Added new community template wails-sveltekit-tailwind. Added by [@pylotlight](https://github.com/pylotlight) in [PR](https://github.com/wailsapp/wails/pull/2851)
|
||||
- Added support for print dialogs. Added by [@aangelisc](https://github.com/aangelisc) in [PR](https://github.com/wailsapp/wails/pull/2822)
|
||||
- Added new `wails dev -nogorebuild` flag to prevent restarts on back end file changes. [@haukened](https://github.com/haukened) in [PR #2870](https://github.com/wailsapp/wails/pull/2870)
|
||||
- Added a guide to describe a cross-platform build using GitHub Actions. Added by [@dennypenta](https://github.com/dennypenta) in [PR](https://github.com/wailsapp/wails/pull/2879)
|
||||
|
||||
### Changements
|
||||
|
||||
@@ -680,9 +704,6 @@ Experimental: &options.Experimental{
|
||||
|
||||
- [v2, nsis] On dirait que / comme séparateur de chemin ne fonctionne que pour certaines directives de manière cross-platform par [@stffabi](https://github.com/stffabi) dans #1227
|
||||
- import des modèles sur la définition de bindings par [@adalessa](https://github.com/adalessa) dans #123
|
||||
|
||||
1
|
||||
|
||||
- Utilisation de la recherche locale sur le site web par [@leaanthony](https://github.com/leaanthony) en #1234
|
||||
- Ensure binary resources can be served by [@napalu](https://github.com/napalu) in #1240
|
||||
- Only retry loading assets when loading from disk by [@leaanthony](https://github.com/leaanthony) in #1241
|
||||
|
||||
@@ -47,7 +47,7 @@ sidebar_position: 1
|
||||
- [wails-svelte-template](https://github.com/raitonoberu/wails-svelte-template) - Svelteを使用したテンプレート
|
||||
- [wails-vite-svelte-template](https://github.com/BillBuilt/wails-vite-svelte-template) - SvelteおよびViteを使用したテンプレート
|
||||
- [wails-vite-svelte-tailwind-template](https://github.com/BillBuilt/wails-vite-svelte-tailwind-template) - TailwindCSS v3を含んだ、SvelteおよびViteを使用したテンプレート
|
||||
- [wails-svelte-tailwind-vite-template](https://github.com/PylotLight/wails-vite-svelte-tailwind-template/tree/master) - An updated template using Svelte v4.2.0 and Vite with TailwindCSS v3.3.3
|
||||
- [wails-svelte-tailwind-vite-template](https://github.com/PylotLight/wails-vite-svelte-tailwind-template/tree/master) - Svelte v4.2.0、Vite、TailwindCSS v3.3.3を使用したテンプレート
|
||||
- [wails-sveltekit-template](https://github.com/h8gi/wails-sveltekit-template) - SvelteKitを使用したテンプレート
|
||||
|
||||
## Solid
|
||||
@@ -60,6 +60,10 @@ sidebar_position: 1
|
||||
- [wails-elm-template](https://github.com/benjamin-thomas/wails-elm-template) - 関数型プログラミングと**高速な**ホットリロードを使ったGUIアプリ開発 :tada: :rocket:
|
||||
- [wails-template-elm-tailwind](https://github.com/rnice01/wails-template-elm-tailwind) - Elm + Tailwind CSS + Wailsのパワー:muscle:を組み合わせたテンプレート (ホットリロードサポートあり)
|
||||
|
||||
## HTMX
|
||||
|
||||
- [wails-htmx-templ-chi-tailwind](https://github.com/PylotLight/wails-hmtx-templ-template) - インタラクティビティを実現するためのピュアなhtmxに、コンポーネントおよびフォームを作成するためのテンプレートが合わさったテンプレート
|
||||
|
||||
## ピュアJavaScript (バニラ)
|
||||
|
||||
- [wails-pure-js-template](https://github.com/KiddoV/wails-pure-js-template) - 基本的なJavaScript、HTML、CSSのみを含むテンプレート
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
# Crossplatform build with Github Actions
|
||||
|
||||
To build a Wails project for all the available platforms, you need to create an application build for each operating system. One effective method to achieve this is by utilizing GitHub Actions.
|
||||
|
||||
An action that facilitates building a Wails app is available at:
|
||||
https://github.com/dAppServer/wails-build-action
|
||||
|
||||
In case the existing action doesn't fulfill your requirements, you can select only the necessary steps from the source:
|
||||
https://github.com/dAppServer/wails-build-action/blob/main/action.yml
|
||||
|
||||
Below is a comprehensive example that demonstrates building an app upon the creation of a new Git tag and subsequently uploading it to the Actions artifacts:
|
||||
|
||||
```yaml
|
||||
name: Wails build
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
# Match any new tag
|
||||
- '*'
|
||||
|
||||
env:
|
||||
# Necessary for most environments as build failure can occur due to OOM issues
|
||||
NODE_OPTIONS: "--max-old-space-size=4096"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
# Failure in one platform build won't impact the others
|
||||
fail-fast: false
|
||||
matrix:
|
||||
build:
|
||||
- name: 'App'
|
||||
platform: 'linux/amd64'
|
||||
os: 'ubuntu-latest'
|
||||
- name: 'App'
|
||||
platform: 'windows/amd64'
|
||||
os: 'windows-latest'
|
||||
- name: 'App'
|
||||
platform: 'darwin/universal'
|
||||
os: 'macos-latest'
|
||||
|
||||
runs-on: ${{ matrix.build.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Build wails
|
||||
uses: dAppServer/wails-build-action@v2.2
|
||||
id: build
|
||||
with:
|
||||
build-name: ${{ matrix.build.name }}
|
||||
build-platform: ${{ matrix.build.platform }}
|
||||
package: false
|
||||
go-version: '1.20'
|
||||
```
|
||||
|
||||
This example offers opportunities for various enhancements, including:
|
||||
|
||||
- Caching dependencies
|
||||
- Code signing
|
||||
- Uploading to platforms like S3, Supbase, etc.
|
||||
- Injecting secrets as environment variables
|
||||
- Utilizing environment variables as build variables (such as version variable extracted from the current Git tag)
|
||||
@@ -0,0 +1,199 @@
|
||||
# File Association
|
||||
|
||||
File association feature allows you to associate specific file types with your app so that when users open those files,
|
||||
your app is launched to handle them. This can be particularly useful for text editors, image viewers, or any application
|
||||
that works with specific file formats. In this guide, we'll walk through the steps to implement file association in Wails app.
|
||||
|
||||
## Set Up File Association:
|
||||
|
||||
To set up file association, you need to modify your application's wails.json file.
|
||||
In "info" section add a "fileAssociations" section specifying the file types your app should be associated with.
|
||||
|
||||
For example:
|
||||
|
||||
```json
|
||||
{
|
||||
"info": {
|
||||
"fileAssociations": [
|
||||
{
|
||||
"ext": "wails",
|
||||
"name": "Wails",
|
||||
"description": "Wails Application File",
|
||||
"iconName": "wailsFileIcon",
|
||||
"role": "Editor"
|
||||
},
|
||||
{
|
||||
"ext": "jpg",
|
||||
"name": "JPEG",
|
||||
"description": "Image File",
|
||||
"iconName": "jpegFileIcon",
|
||||
"role": "Editor"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Property | Description |
|
||||
| :---------- | :------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| ext | The extension (minus the leading period). e.g. png |
|
||||
| name | The name. e.g. PNG File |
|
||||
| iconName | The icon name without extension. Icons should be located in build folder. Proper icons will be generated from .png file for both macOS and Windows |
|
||||
| description | Windows-only. The description. It is displayed on the `Type` column on Windows Explorer. |
|
||||
| role | macOS-only. The app’s role with respect to the type. Corresponds to CFBundleTypeRole. |
|
||||
|
||||
## Platform Specifics:
|
||||
|
||||
### macOS
|
||||
|
||||
When you open file (or files) with your app, the system will launch your app and call the `OnFileOpen` function in your Wails app. Example:
|
||||
|
||||
```go title="main.go"
|
||||
func main() {
|
||||
// Create application with options
|
||||
err := wails.Run(&options.App{
|
||||
Title: "wails-open-file",
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
AssetServer: &assetserver.Options{
|
||||
Assets: assets,
|
||||
},
|
||||
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
|
||||
Mac: &mac.Options{
|
||||
OnFileOpen: func(filePaths []string) { println(filestring) },
|
||||
},
|
||||
Bind: []interface{}{
|
||||
app,
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
println("Error:", err.Error())
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Windows
|
||||
|
||||
On Windows file association is supported only with NSIS installer. During installation, the installer will create a
|
||||
registry entry for your file associations. When you open file with your app, new instance of app is launched and file path is passed
|
||||
as argument to your app. To handle this you should parse command line arguments in your app. Example:
|
||||
|
||||
```go title="main.go"
|
||||
func main() {
|
||||
argsWithoutProg := os.Args[1:]
|
||||
|
||||
if len(argsWithoutProg) != 0 {
|
||||
println("launchArgs", argsWithoutProg)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Linux
|
||||
|
||||
Currently, Wails doesn't support bundling for Linux. So, you need to create file associations manually.
|
||||
For example if you distribute your app as a .deb package, you can create file associations by adding required files in you bundle.
|
||||
You can use [nfpm](https://nfpm.goreleaser.com/) to create .deb package for your app.
|
||||
|
||||
1. Create a .desktop file for your app and specify file associations there. Example:
|
||||
|
||||
```ini
|
||||
[Desktop Entry]
|
||||
Categories=Office
|
||||
Exec=/usr/bin/wails-open-file %u
|
||||
Icon=wails-open-file.png
|
||||
Name=wails-open-file
|
||||
Terminal=false
|
||||
Type=Application
|
||||
MimeType=application/x-wails;application/x-test
|
||||
```
|
||||
|
||||
2. Create mime types file. Example:
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
|
||||
<mime-type type="application/x-wails">
|
||||
<comment>Wails Application File</comment>
|
||||
<glob pattern="*.wails"/>
|
||||
</mime-type>
|
||||
</mime-info>
|
||||
```
|
||||
|
||||
3. Create icons for your file types. SVG icons are recommended.
|
||||
4. Prepare postInstall/postRemove scripts for your package. Example:
|
||||
|
||||
```sh
|
||||
# reload mime types to register file associations
|
||||
update-mime-database /usr/share/mime
|
||||
# reload desktop database to load app in list of available
|
||||
update-desktop-database /usr/share/applications
|
||||
# update icons
|
||||
update-icon-caches /usr/share/icons/*
|
||||
```
|
||||
|
||||
5. Configure nfpm to use your scripts and files. Example:
|
||||
|
||||
```yaml
|
||||
name: "wails-open-file"
|
||||
arch: "arm64"
|
||||
platform: "linux"
|
||||
version: "1.0.0"
|
||||
section: "default"
|
||||
priority: "extra"
|
||||
maintainer: "FooBarCorp <FooBarCorp@gmail.com>"
|
||||
description: "Sample Package"
|
||||
vendor: "FooBarCorp"
|
||||
homepage: "http://example.com"
|
||||
license: "MIT"
|
||||
contents:
|
||||
- src: ../bin/wails-open-file
|
||||
dst: /usr/bin/wails-open-file
|
||||
- src: ./main.desktop
|
||||
dst: /usr/share/applications/wails-open-file.desktop
|
||||
- src: ./application-wails-mime.xml
|
||||
dst: /usr/share/mime/packages/application-x-wails.xml
|
||||
- src: ./application-test-mime.xml
|
||||
dst: /usr/share/mime/packages/application-x-test.xml
|
||||
- src: ../appicon.svg
|
||||
dst: /usr/share/icons/hicolor/scalable/apps/wails-open-file.svg
|
||||
- src: ../wailsFileIcon.svg
|
||||
dst: /usr/share/icons/hicolor/scalable/mimetypes/application-x-wails.svg
|
||||
- src: ../testFileIcon.svg
|
||||
dst: /usr/share/icons/hicolor/scalable/mimetypes/application-x-test.svg
|
||||
# copy icons to Yaru theme as well. For some reason Ubuntu didn't pick up fileicons from hicolor theme
|
||||
- src: ../appicon.svg
|
||||
dst: /usr/share/icons/Yaru/scalable/apps/wails-open-file.svg
|
||||
- src: ../wailsFileIcon.svg
|
||||
dst: /usr/share/icons/Yaru/scalable/mimetypes/application-x-wails.svg
|
||||
- src: ../testFileIcon.svg
|
||||
dst: /usr/share/icons/Yaru/scalable/mimetypes/application-x-test.svg
|
||||
scripts:
|
||||
postinstall: ./postInstall.sh
|
||||
postremove: ./postRemove.sh
|
||||
```
|
||||
|
||||
6. Build your .deb package using nfpm:
|
||||
|
||||
```sh
|
||||
nfpm pkg --packager deb --target .
|
||||
```
|
||||
|
||||
7. Now when your package is installed, your app will be associated with specified file types. When you open file with your app,
|
||||
new instance of app is launched and file path is passed as argument to your app.
|
||||
To handle this you should parse command line arguments in your app. Example:
|
||||
|
||||
```go title="main.go"
|
||||
func main() {
|
||||
argsWithoutProg := os.Args[1:]
|
||||
|
||||
if len(argsWithoutProg) != 0 {
|
||||
println("launchArgs", argsWithoutProg)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Limitations:
|
||||
|
||||
On Windows and Linux when associated file is opened, new instance of your app is launched.
|
||||
Currently, Wails doesn't support opening files in already running app. There is plugin for single instance support for v3 in development.
|
||||
@@ -159,6 +159,28 @@ XCodeコマンドラインツールの再インストールが引き続き失敗
|
||||
|
||||
出典: https://github.com/wailsapp/wails/issues/1806 および https://github.com/wailsapp/wails/issues/1140#issuecomment-1290446496
|
||||
|
||||
## My application won't compile on Mac
|
||||
|
||||
次のようなエラーが発生する場合:
|
||||
|
||||
```shell
|
||||
l1@m2 GoEasyDesigner % go build -tags dev -gcflags "all=-N -l"
|
||||
/Users/l1/sdk/go1.20.5/pkg/tool/darwin_arm64/link: running clang failed: exit status 1
|
||||
Undefined symbols for architecture arm64:
|
||||
"_OBJC_CLASS_$_UTType", referenced from:
|
||||
objc-class-ref in 000016.o
|
||||
ld: symbol(s) not found for architecture arm64
|
||||
clang: error: linker command failed with exit code 1 (use -v to see invocation)
|
||||
```
|
||||
Ensure you have the latest SDK installed. If so and you're still experiencing this issue, try the following:
|
||||
|
||||
```shell
|
||||
export CGO_LDFLAGS="-framework UniformTypeIdentifiers" && go build -tags dev -gcflags "all=-N -l"
|
||||
```
|
||||
|
||||
Sources: https://github.com/wailsapp/wails/pull/2925#issuecomment-1726828562
|
||||
|
||||
|
||||
--
|
||||
|
||||
## Cannot start service: Host version "x.x.x does not match binary version "x.x.x"
|
||||
@@ -185,4 +207,162 @@ This is due to the default background of the webview being white. If you want to
|
||||
WebviewIsTransparent: true,
|
||||
},
|
||||
})
|
||||
```
|
||||
```
|
||||
|
||||
## I get a "Microsoft Edge can't read or write to its data directory" error when running my program as admin on Windows
|
||||
|
||||
You set your program to require admin permissions and it worked great! Unfortunately, some users are seeing a "Microsoft Edge can't read or write to its data directory" error when running it.
|
||||
|
||||
When a Windows machine has two local accounts:
|
||||
|
||||
- Alice, an admin
|
||||
- Bob, a regular user
|
||||
|
||||
Bob sees a UAC prompt when running your program. Bob enters Alice's admin credentials into this prompt. The app launches with admin permissions under Alice's account.
|
||||
|
||||
Wails instructs WebView2 to store user data at the specified `WebviewUserDataPath`. It defaults to `%APPDATA%\[BinaryName.exe]`.
|
||||
|
||||
Because the application is running under Alice's account, `%APPDATA%\[BinaryName.exe]` resolves to `C:\Users\Alice\AppData\Roaming\[BinaryName.exe]`.
|
||||
|
||||
WebView2 [creates some child processes under Bob's logged-in account instead of Alice's admin account](https://github.com/MicrosoftEdge/WebView2Feedback/issues/932#issue-807464179). Since Bob cannot access `C:\Users\Alice\AppData\Roaming\[BinaryName.exe]`, the "Microsoft Edge can't read or write to its data directory" error is shown.
|
||||
|
||||
Possible solution #1:
|
||||
|
||||
Refactor your application to work without constant admin permissions. If you just need to perform a small set of admin tasks (such as running an updater), you can run your application with the minimum permissions and then use the `runas` command to run these tasks with admin permissions as needed:
|
||||
|
||||
```go
|
||||
//go:build windows
|
||||
|
||||
package sample
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/windows"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// Calling RunAs("C:\path\to\my\updater.exe") shows Bob a UAC prompt. Bob enters Alice's admin credentials. The updater launches with admin permissions under Alice's account.
|
||||
func RunAs(path string) error {
|
||||
verbPtr, _ := syscall.UTF16PtrFromString("runas")
|
||||
exePtr, _ := syscall.UTF16PtrFromString(path)
|
||||
cwdPtr, _ := syscall.UTF16PtrFromString("")
|
||||
argPtr, _ := syscall.UTF16PtrFromString("")
|
||||
|
||||
var showCmd int32 = 1 //SW_NORMAL
|
||||
|
||||
err := windows.ShellExecute(0, verbPtr, exePtr, argPtr, cwdPtr, showCmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
```
|
||||
|
||||
Possible solution #2:
|
||||
|
||||
Run your application with extended permissions. If you absolutely must run with constant admin permissions, WebView2 will function correctly if you use a data directory accessible by both users and you also launch your app with the `SeBackupPrivilege`, `SeDebugPrivilege`, and `SeRestorePrivilege` permissions. Here's an example:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/fourcorelabs/wintoken"
|
||||
"github.com/hectane/go-acl"
|
||||
"github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/windows"
|
||||
)
|
||||
|
||||
//go:embed all:frontend/dist
|
||||
var assets embed.FS
|
||||
|
||||
const (
|
||||
fixedTokenKey = "SAMPLE_RANDOM_KEY"
|
||||
fixedTokenVal = "with-fixed-token"
|
||||
webviewDir = "C:\\ProgramData\\Sample"
|
||||
)
|
||||
|
||||
func runWithFixedToken() {
|
||||
println("Re-launching self")
|
||||
token, err := wintoken.OpenProcessToken(0, wintoken.TokenPrimary) //pass 0 for own process
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer token.Close()
|
||||
|
||||
token.EnableTokenPrivileges([]string{
|
||||
"SeBackupPrivilege",
|
||||
"SeDebugPrivilege",
|
||||
"SeRestorePrivilege",
|
||||
})
|
||||
|
||||
cmd := exec.Command(os.Args[0])
|
||||
cmd.Args = os.Args
|
||||
cmd.Env = os.Environ()
|
||||
cmd.Env = append(cmd.Env, fmt.Sprintf("%v=%v", fixedTokenKey, fixedTokenVal))
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Token: syscall.Token(token.Token())}
|
||||
if err := cmd.Run(); err != nil {
|
||||
println("Error after launching self:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
println("Clean self launch :)")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func main() {
|
||||
if runtime.GOOS == "windows" && os.Getenv(fixedTokenKey) != fixedTokenVal {
|
||||
runWithFixedToken()
|
||||
}
|
||||
|
||||
println("Setting data dir to", webviewDir)
|
||||
if err := os.MkdirAll(webviewDir, os.ModePerm); err != nil {
|
||||
println("Failed creating dir:", err)
|
||||
}
|
||||
if err := acl.Chmod(webviewDir, 0777); err != nil {
|
||||
println("Failed setting ACL on dir:", err)
|
||||
}
|
||||
|
||||
app := NewApp()
|
||||
|
||||
err := wails.Run(&options.App{
|
||||
Title: "sample-data-dir",
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
AssetServer: &assetserver.Options{
|
||||
Assets: assets,
|
||||
},
|
||||
Bind: []interface{}{
|
||||
app,
|
||||
},
|
||||
Windows: &windows.Options{
|
||||
WebviewUserDataPath: webviewDir,
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
println("Error:", err.Error())
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you use a data directory accessible by both users but not the extended privileges, you will receive a WebView2 `80010108 The object invoked has disconnected from its clients` error.
|
||||
|
||||
Possible future solution #3: [run WebView2 using an in-memory mode if implemented](https://github.com/MicrosoftEdge/WebView2Feedback/issues/3637#issuecomment-1728300982).
|
||||
|
||||
## WebView2 installation succeeded, but the wails doctor command shows that it is not installed
|
||||
|
||||
If you have installed WebView2, but the `wails doctor` command shows that it is not installed, it is likely that the WebView2 runtime installed was for a different architecture. You can download the correct runtime from [here](https://developer.microsoft.com/en-us/microsoft-edge/webview2/).
|
||||
|
||||
Source: https://github.com/wailsapp/wails/issues/2917
|
||||
|
||||
## WebVie2wProcess failed with kind
|
||||
|
||||
If your Windows app generates this kind of error, you can check out what the error means [here](https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2processfailedkind?view=webview2-winrt-1.0.2045.28).
|
||||
|
||||
|
||||
@@ -49,35 +49,35 @@ WailsではGitHubでホストされているリモートテンプレートをサ
|
||||
|
||||
`wails build`は、プロジェクトを本番配布用のバイナリにコンパイルするときに使用します。
|
||||
|
||||
| フラグ | 説明 | デフォルト |
|
||||
|:-------------------- |:-------------------------------------------------------------------------------------------------------------------------------- |:--------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| -clean | `build/bin`ディレクトリをクリーンする | |
|
||||
| -compiler "compiler" | 違うGoコンパイラを使用する。例: go1.15beta1 | go |
|
||||
| -debug | アプリケーションのデバッグ情報を保持し、デバッグコンソールを表示する。 これにより、アプリケーションウィンドウで開発者ツールを使用することを許可できます。 | |
|
||||
| -devtools | 本番用のアプリケーションウィンドウにおいて開発者ツールの使用を許可する (-debugが使用されていないとき) | |
|
||||
| -dryrun | 実際には実行せずにbuildコマンドの結果を表示する | |
|
||||
| -f | アプリケーションを強制的にビルド | |
|
||||
| -garbleargs | garbleへ渡す引数 | `-literals -tiny -seed=random` |
|
||||
| -ldflags "flags" | コンパイラに渡す追加のldflags | |
|
||||
| -m | コンパイル前のmod tidyの実行をスキップする | |
|
||||
| -nopackage | アプリケーションをパッケージ化しない | |
|
||||
| -nocolour | 出力文字に色をつけない | |
|
||||
| -nosyncgomod | go.modとWailsのバージョンを同期させない | |
|
||||
| -nsis | Windows向けのNSISインストーラを生成する | |
|
||||
| -o filename | 出力ファイル名 | |
|
||||
| -obfuscated | [garble](https://github.com/burrowers/garble)を使用してアプリケーションを難読化する | |
|
||||
| -platform | 指定された[プラットフォーム](../reference/cli.mdx#platforms)(カンマ区切り) 向けにビルドする。例: `windows/arm64`。 アーキテクチャを指定しない場合は、`runtime.GOARCH`の値が使用されます。 | platform = `GOOS` environment variable if given else `runtime.GOOS`.<br/>arch = `GOARCH` envrionment variable if given else `runtime.GOARCH`. |
|
||||
| -race | Goのrace detectorを使用してビルドする | |
|
||||
| -s | フロントエンドのビルドをスキップ | |
|
||||
| -skipbindings | バインディングの生成をスキップする | |
|
||||
| -tags "extra tags" | Goコンパイラに渡すビルドタグ。 値は引用符で囲んでください。 また、スペースまたはカンマで区切ってください(両方は使用しないでください)。 | |
|
||||
| -trimpath | 実行可能ファイルから、すべてのファイルシステムパスを削除する | |
|
||||
| -u | プロジェクトの`go.mod`を更新し、CLIと同じバージョンのWailsを使用する | |
|
||||
| -upx | "upx"を使用して最終的にバイナリを圧縮する | |
|
||||
| -upxflags | upxに渡すフラグ | |
|
||||
| -v int | 詳細度レベル (0 - サイレント, 1 - デフォルト, 2 - 詳細) | 1 |
|
||||
| -webview2 | WebView2インストーラーのストラテジ: download,embed,browser,error | download |
|
||||
| -windowsconsole | Windiws向けビルドでコンソールウィンドウを維持する | |
|
||||
| フラグ | 説明 | デフォルト |
|
||||
|:-------------------- |:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |:--------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| -clean | `build/bin`ディレクトリをクリーンする | |
|
||||
| -compiler "compiler" | 違うGoコンパイラを使用する。例: go1.15beta1 | go |
|
||||
| -debug | アプリケーションのデバッグ情報を保持し、デバッグコンソールを表示する。 これにより、アプリケーションウィンドウで開発者ツールを使用することを許可できます。 | |
|
||||
| -devtools | Allows the use of the devtools in the application window in production (when -debug is not used). Ctrl/Cmd+Shift+F12 may be used to open the devtools window. *NOTE*: This option will make your application FAIL Mac appstore guidelines. Use for debugging only. | |
|
||||
| -dryrun | 実際には実行せずにbuildコマンドの結果を表示する | |
|
||||
| -f | アプリケーションを強制的にビルド | |
|
||||
| -garbleargs | garbleへ渡す引数 | `-literals -tiny -seed=random` |
|
||||
| -ldflags "flags" | コンパイラに渡す追加のldflags | |
|
||||
| -m | コンパイル前のmod tidyの実行をスキップする | |
|
||||
| -nopackage | アプリケーションをパッケージ化しない | |
|
||||
| -nocolour | 出力文字に色をつけない | |
|
||||
| -nosyncgomod | go.modとWailsのバージョンを同期させない | |
|
||||
| -nsis | Windows向けのNSISインストーラを生成する | |
|
||||
| -o filename | 出力ファイル名 | |
|
||||
| -obfuscated | [garble](https://github.com/burrowers/garble)を使用してアプリケーションを難読化する | |
|
||||
| -platform | 指定された[プラットフォーム](../reference/cli.mdx#platforms)(カンマ区切り) 向けにビルドする。例: `windows/arm64`。 アーキテクチャを指定しない場合は、`runtime.GOARCH`の値が使用されます。 | platform = `GOOS` environment variable if given else `runtime.GOOS`.<br/>arch = `GOARCH` envrionment variable if given else `runtime.GOARCH`. |
|
||||
| -race | Goのrace detectorを使用してビルドする | |
|
||||
| -s | フロントエンドのビルドをスキップ | |
|
||||
| -skipbindings | バインディングの生成をスキップする | |
|
||||
| -tags "extra tags" | Goコンパイラに渡すビルドタグ。 値は引用符で囲んでください。 また、スペースまたはカンマで区切ってください(両方は使用しないでください)。 | |
|
||||
| -trimpath | 実行可能ファイルから、すべてのファイルシステムパスを削除する | |
|
||||
| -u | プロジェクトの`go.mod`を更新し、CLIと同じバージョンのWailsを使用する | |
|
||||
| -upx | "upx"を使用して最終的にバイナリを圧縮する | |
|
||||
| -upxflags | upxに渡すフラグ | |
|
||||
| -v int | 詳細度レベル (0 - サイレント, 1 - デフォルト, 2 - 詳細) | 1 |
|
||||
| -webview2 | WebView2インストーラーのストラテジ: download,embed,browser,error | download |
|
||||
| -windowsconsole | Windiws向けビルドでコンソールウィンドウを維持する | |
|
||||
|
||||
`webview2`フラグの詳細については、[Windows](../guides/windows.mdx)ガイドをご覧ください。
|
||||
|
||||
@@ -166,8 +166,8 @@ Your system is ready for Wails development!
|
||||
- `http://localhost:34115`でWebサーバが起動し、HTTP経由でアプリケーション(フロントエンドだけではありません)が提供されます。 これにより、任意のブラウザ拡張機能を使用することができます
|
||||
- すべてのアプリケーションアセットはディスクから読み込まれます。 アセットが変更された場合、アプリケーションは自動的に、リビルドではなくリロードされます。 接続されているすべてのブラウザもリロードされます
|
||||
- 以下のものを含むJSモジュールが生成されます:
|
||||
- GoメソッドのJavaScriptラッパー (コードヒントに有用なJSDocも自動付与されています)
|
||||
- Goの構造体のTypeScriptバージョン (構造体のインスタンスを生成したり、Goメソッドの引数として渡したりすることができます)
|
||||
- GoメソッドのJavaScriptラッパー (コードヒントに有用なJSDocも自動付与されています)
|
||||
- Goの構造体のTypeScriptバージョン (構造体のインスタンスを生成したり、Goメソッドの引数として渡したりすることができます)
|
||||
- 別のJSモジュールとして、ランタイムのラッパーおよびTS定義も生成されます
|
||||
- macOSの場合、アプリケーションは`.app`ファイルにバンドルされて実行されます。 これには、開発用の`build/darwin/Info.dev.plist`を使用します。
|
||||
|
||||
|
||||
@@ -366,7 +366,7 @@ func (b *App) beforeClose(ctx context.Context) (prevent bool) {
|
||||
|
||||
EnableDefaultContextMenuは、本番環境において、ブラウザのデフォルトコンテキストメニューを有効にします。
|
||||
|
||||
通常、ブラウザのデフォルトコンテキストメニューは、開発環境での動作時、または`-debug`・`-devtools`フラグをつけて開発者ツールを有効にして[ビルド](../reference/cli.mdx#build)したときのみ利用できますが、本オプションを使うと、`-devtools`フラグをつけない限り開発者ツールは使用できませんが、`本番`環境でもコンテキストメニューを有効にすることができます。
|
||||
By default, the browser's default context-menu is only available in development and in a `-debug` [build](../reference/cli.mdx#build) along with the devtools inspector, Using this option you can enable the default context-menu in `production` while the devtools inspector won't be available unless the `-devtools` build flag is used.
|
||||
|
||||
このオプションを有効にすると、デフォルトでは、テキストに関するコンテキスト(切り取り/コピー/貼り付け) のみがコンテキストメニューに表示されます。この動作をオーバーライドするには、`--default-contextmenu`というCSSプロパティを任意のHTML要素(`body`含む) で以下の値と共に使用してください:
|
||||
|
||||
@@ -593,6 +593,12 @@ Windowsがローパワーモード(サスペンド/休止状態) から復帰し
|
||||
|
||||
名前: WebviewGpuIsDisabled<br/> データ型: `bool`
|
||||
|
||||
#### EnableSwipeGestures
|
||||
|
||||
Setting this to `true` will enable swipe gestures for the webview.
|
||||
|
||||
Name: EnableSwipeGestures<br/> Type: `bool`
|
||||
|
||||
### Mac
|
||||
|
||||
[Mac固有のオプション](#mac)を定義します。
|
||||
@@ -688,6 +694,42 @@ Mac: &mac.Options{
|
||||
|
||||
名前: WindowIsTranslucent<br/> データ型: `bool`
|
||||
|
||||
#### Preferences
|
||||
|
||||
The Preferences struct provides the ability to configure the Webview preferences.
|
||||
|
||||
Name: Preferences<br/> Type: [`*mac.Preferences`](#preferences-struct)
|
||||
|
||||
##### Preferences struct
|
||||
|
||||
You can specify the webview preferences.
|
||||
|
||||
```go
|
||||
type Preferences struct {
|
||||
TabFocusesLinks u.Bool
|
||||
TextInteractionEnabled u.Bool
|
||||
FullscreenEnabled u.Bool
|
||||
}
|
||||
```
|
||||
|
||||
| 名前 | 説明 |
|
||||
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| TabFocusesLinks | A Boolean value that indicates whether pressing the tab key changes the focus to links and form controls. [Apple Docs](https://developer.apple.com/documentation/webkit/wkpreferences/2818595-tabfocuseslinks?language=objc) |
|
||||
| TextInteractionEnabled | A Boolean value that indicates whether to allow people to select or otherwise interact with text. [Apple Docs](https://developer.apple.com/documentation/webkit/wkpreferences/3727362-textinteractionenabled?language=objc) |
|
||||
| FullscreenEnabled | A Boolean value that indicates whether a web view can display content full screen. [Apple Docs](https://developer.apple.com/documentation/webkit/wkpreferences/3917769-elementfullscreenenabled?language=objc) |
|
||||
|
||||
例:
|
||||
|
||||
```go
|
||||
Mac: &mac.Options{
|
||||
Preferences: &mac.Preferences{
|
||||
TabFocusesLinks: mac.Enabled,
|
||||
TextInteractionEnabled: mac.Disabled,
|
||||
FullscreenEnabled: mac.Enabled,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### About
|
||||
|
||||
"AppMenu"ロールで作成されたアプリケーションメニューの中にある"About"メニュー項目において、タイトル、メッセージ、アイコンを設定できます。
|
||||
|
||||
@@ -202,7 +202,7 @@ Go: `WindowSetBackgroundColour(ctx context.Context, R, G, B, A uint8)`<br/> JS:
|
||||
|
||||
### WindowPrint
|
||||
|
||||
Opens tha native print dialog.
|
||||
ネイティブな印刷ダイアログを開きます。
|
||||
|
||||
Go: `WindowPrint(ctx context.Context)`<br/> JS: `WindowPrint()`
|
||||
|
||||
|
||||
@@ -4,35 +4,35 @@
|
||||
"description": "The label for version v2.6.0"
|
||||
},
|
||||
"sidebar.docs.category.Getting Started": {
|
||||
"message": "Getting Started",
|
||||
"message": "はじめよう",
|
||||
"description": "The label for category Getting Started in sidebar docs"
|
||||
},
|
||||
"sidebar.docs.category.Reference": {
|
||||
"message": "Reference",
|
||||
"message": "リファレンス",
|
||||
"description": "The label for category Reference in sidebar docs"
|
||||
},
|
||||
"sidebar.docs.category.Runtime": {
|
||||
"message": "Runtime",
|
||||
"message": "ランタイム",
|
||||
"description": "The label for category Runtime in sidebar docs"
|
||||
},
|
||||
"sidebar.docs.category.Community": {
|
||||
"message": "Community",
|
||||
"message": "コミュニティ",
|
||||
"description": "The label for category Community in sidebar docs"
|
||||
},
|
||||
"sidebar.docs.category.Showcase": {
|
||||
"message": "Showcase",
|
||||
"message": "事例紹介",
|
||||
"description": "The label for category Showcase in sidebar docs"
|
||||
},
|
||||
"sidebar.docs.category.Guides": {
|
||||
"message": "Guides",
|
||||
"message": "ガイド",
|
||||
"description": "The label for category Guides in sidebar docs"
|
||||
},
|
||||
"sidebar.docs.category.Tutorials": {
|
||||
"message": "Tutorials",
|
||||
"message": "チュートリアル",
|
||||
"description": "The label for category Tutorials in sidebar docs"
|
||||
},
|
||||
"sidebar.docs.link.Contributing": {
|
||||
"message": "Contributing",
|
||||
"message": "コントリビューション",
|
||||
"description": "The label for link Contributing in sidebar docs, linking to /community-guide#ways-of-contributing"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,28 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- Added support for enabling/disabling swipe gestures for Windows WebView2. Added by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/2878)
|
||||
- When building with `-devtools` flag, CMD/CTRL+SHIFT+F12 can be used to open the devtools. Added by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/2915) – Added file association support for macOS and Windows. Added by @APshenkin in [PR](https://github.com/wailsapp/wails/pull/2918)
|
||||
- Added support for setting some of the Webview preferences, `textInteractionEnabled` and `tabFocusesLinks` on Mac. Added by @fkhadra in [PR](https://github.com/wailsapp/wails/pull/2937)
|
||||
- Added support for enabling/disabling fullscreen of the Webview on Mac. Added by @fkhadra in [PR](https://github.com/wailsapp/wails/pull/2953)
|
||||
- Added French README.fr.md page. Added by @nejos97 in [PR](https://github.com/wailsapp/wails/pull/2943)
|
||||
- New task created for linting v2 `task v2:lint`. Workflow updated to run the task. Added by @mikeee in [PR](https://github.com/wailsapp/wails/pull/2957)
|
||||
- Added new community template wails-htmx-templ-chi-tailwind. Added by [@pylotlight](https://github.com/pylotlight) in [PR](https://github.com/wailsapp/wails/pull/2984)
|
||||
- Added CPU/GPU/Memory detection for `wails doctor`. Added by @leaanthony in #d51268b8d0680430f3a614775b13e6cd2b906d1c
|
||||
|
||||
### Changed
|
||||
|
||||
- AssetServer requests are now processed asynchronously without blocking the main thread on Windows. Changed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2926)
|
||||
- AssetServer requests are now processed concurrently by spawning a goroutine per request. Changed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2926)
|
||||
- Now building with `-devtools` flag doesn't enable the default context-menu. Changed by @mmghv in [PR](https://github.com/wailsapp/wails/pull/2923)
|
||||
- Change Window Level. Changed by @almas1992 in [PR](https://github.com/wailsapp/wails/pull/2944)
|
||||
#### Fixed
|
||||
|
||||
- Fixed typo on docs/reference/options page. Added by [@pylotlight](https://github.com/pylotlight) in [PR](https://github.com/wailsapp/wails/pull/2887)
|
||||
- Fixed issue with npm being called npm20 on openSUSE-Tumbleweed. Fixed by @TuffenDuffen in [PR] in (https://github.com/wailsapp/wails/pull/2941)
|
||||
|
||||
## v2.6.0 - 2023-09-06
|
||||
|
||||
### Breaking Changes
|
||||
@@ -27,6 +49,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
- Fixed `SetBackgroundColour` so it sets the window's background color to reduce resize flickering on Linux. Added by @lyimmi in [PR](https://github.com/wailsapp/wails/pull/2853)
|
||||
- Fixed disable window resize option and wrong initial window size when its enabled. Added by @lyimmi in [PR](https://github.com/wailsapp/wails/pull/2863)
|
||||
- Fixed build hook command parsing. Added by @smac89 in [PR](https://github.com/wailsapp/wails/pull/2836)
|
||||
- Fixed filesystem watcher from filtering top level project directory if binary name is included in .gitignore. Added by [@haukened](https://github.com/haukened) in [PR #2869](https://github.com/wailsapp/wails/pull/2869)
|
||||
- Fixed `-reloaddir` flag to watch additional directories (non-recursively). [@haukened](https://github.com/haukened) in [PR #2871](https://github.com/wailsapp/wails/pull/2871)
|
||||
- Fixed support for Go 1.21 `go.mod` files. Fixed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2876)
|
||||
|
||||
@@ -44,6 +67,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
- Added new community template wails-sveltekit-tailwind. Added by [@pylotlight](https://github.com/pylotlight) in [PR](https://github.com/wailsapp/wails/pull/2851)
|
||||
- Added support for print dialogs. Added by [@aangelisc](https://github.com/aangelisc) in [PR](https://github.com/wailsapp/wails/pull/2822)
|
||||
- Added new `wails dev -nogorebuild` flag to prevent restarts on back end file changes. [@haukened](https://github.com/haukened) in [PR #2870](https://github.com/wailsapp/wails/pull/2870)
|
||||
- Added a guide to describe a cross-platform build using GitHub Actions. Added by [@dennypenta](https://github.com/dennypenta) in [PR](https://github.com/wailsapp/wails/pull/2879)
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -680,9 +704,6 @@ Experimental: &options.Experimental{
|
||||
|
||||
- [v2, nsis] Seems like / as path separator works only for some directives in a cross platform way by [@stffabi](https://github.com/stffabi) in #1227
|
||||
- import models on binding definition by [@adalessa](https://github.com/adalessa) in #123
|
||||
|
||||
1
|
||||
|
||||
- Use local search on website by [@leaanthony](https://github.com/leaanthony) in #1234
|
||||
- Ensure binary resources can be served by [@napalu](https://github.com/napalu) in #1240
|
||||
- Only retry loading assets when loading from disk by [@leaanthony](https://github.com/leaanthony) in #1241
|
||||
|
||||
@@ -60,6 +60,10 @@ If you are unsure about a template, inspect `package.json` and `wails.json` for
|
||||
- [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-template-elm-tailwind](https://github.com/rnice01/wails-template-elm-tailwind) - Combine the powers :muscle: of Elm + Tailwind CSS + Wails! Hot reloading supported.
|
||||
|
||||
## HTMX
|
||||
|
||||
- [wails-htmx-templ-chi-tailwind](https://github.com/PylotLight/wails-hmtx-templ-template) - Use a unique combination of pure htmx for interactivity plus templ for creating components and forms
|
||||
|
||||
## 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
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
# Crossplatform build with Github Actions
|
||||
|
||||
To build a Wails project for all the available platforms, you need to create an application build for each operating system. One effective method to achieve this is by utilizing GitHub Actions.
|
||||
|
||||
An action that facilitates building a Wails app is available at:
|
||||
https://github.com/dAppServer/wails-build-action
|
||||
|
||||
In case the existing action doesn't fulfill your requirements, you can select only the necessary steps from the source:
|
||||
https://github.com/dAppServer/wails-build-action/blob/main/action.yml
|
||||
|
||||
Below is a comprehensive example that demonstrates building an app upon the creation of a new Git tag and subsequently uploading it to the Actions artifacts:
|
||||
|
||||
```yaml
|
||||
name: Wails build
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
# Match any new tag
|
||||
- '*'
|
||||
|
||||
env:
|
||||
# Necessary for most environments as build failure can occur due to OOM issues
|
||||
NODE_OPTIONS: "--max-old-space-size=4096"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
# Failure in one platform build won't impact the others
|
||||
fail-fast: false
|
||||
matrix:
|
||||
build:
|
||||
- name: 'App'
|
||||
platform: 'linux/amd64'
|
||||
os: 'ubuntu-latest'
|
||||
- name: 'App'
|
||||
platform: 'windows/amd64'
|
||||
os: 'windows-latest'
|
||||
- name: 'App'
|
||||
platform: 'darwin/universal'
|
||||
os: 'macos-latest'
|
||||
|
||||
runs-on: ${{ matrix.build.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Build wails
|
||||
uses: dAppServer/wails-build-action@v2.2
|
||||
id: build
|
||||
with:
|
||||
build-name: ${{ matrix.build.name }}
|
||||
build-platform: ${{ matrix.build.platform }}
|
||||
package: false
|
||||
go-version: '1.20'
|
||||
```
|
||||
|
||||
This example offers opportunities for various enhancements, including:
|
||||
|
||||
- Caching dependencies
|
||||
- Code signing
|
||||
- Uploading to platforms like S3, Supbase, etc.
|
||||
- Injecting secrets as environment variables
|
||||
- Utilizing environment variables as build variables (such as version variable extracted from the current Git tag)
|
||||
@@ -0,0 +1,199 @@
|
||||
# File Association
|
||||
|
||||
File association feature allows you to associate specific file types with your app so that when users open those files,
|
||||
your app is launched to handle them. This can be particularly useful for text editors, image viewers, or any application
|
||||
that works with specific file formats. In this guide, we'll walk through the steps to implement file association in Wails app.
|
||||
|
||||
## Set Up File Association:
|
||||
|
||||
To set up file association, you need to modify your application's wails.json file.
|
||||
In "info" section add a "fileAssociations" section specifying the file types your app should be associated with.
|
||||
|
||||
For example:
|
||||
|
||||
```json
|
||||
{
|
||||
"info": {
|
||||
"fileAssociations": [
|
||||
{
|
||||
"ext": "wails",
|
||||
"name": "Wails",
|
||||
"description": "Wails Application File",
|
||||
"iconName": "wailsFileIcon",
|
||||
"role": "Editor"
|
||||
},
|
||||
{
|
||||
"ext": "jpg",
|
||||
"name": "JPEG",
|
||||
"description": "Image File",
|
||||
"iconName": "jpegFileIcon",
|
||||
"role": "Editor"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Property | Description |
|
||||
| :---------- | :------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| ext | The extension (minus the leading period). e.g. png |
|
||||
| name | The name. e.g. PNG File |
|
||||
| iconName | The icon name without extension. Icons should be located in build folder. Proper icons will be generated from .png file for both macOS and Windows |
|
||||
| description | Windows-only. The description. It is displayed on the `Type` column on Windows Explorer. |
|
||||
| role | macOS-only. The app’s role with respect to the type. Corresponds to CFBundleTypeRole. |
|
||||
|
||||
## Platform Specifics:
|
||||
|
||||
### macOS
|
||||
|
||||
When you open file (or files) with your app, the system will launch your app and call the `OnFileOpen` function in your Wails app. Example:
|
||||
|
||||
```go title="main.go"
|
||||
func main() {
|
||||
// Create application with options
|
||||
err := wails.Run(&options.App{
|
||||
Title: "wails-open-file",
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
AssetServer: &assetserver.Options{
|
||||
Assets: assets,
|
||||
},
|
||||
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
|
||||
Mac: &mac.Options{
|
||||
OnFileOpen: func(filePaths []string) { println(filestring) },
|
||||
},
|
||||
Bind: []interface{}{
|
||||
app,
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
println("Error:", err.Error())
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Windows
|
||||
|
||||
On Windows file association is supported only with NSIS installer. During installation, the installer will create a
|
||||
registry entry for your file associations. When you open file with your app, new instance of app is launched and file path is passed
|
||||
as argument to your app. To handle this you should parse command line arguments in your app. Example:
|
||||
|
||||
```go title="main.go"
|
||||
func main() {
|
||||
argsWithoutProg := os.Args[1:]
|
||||
|
||||
if len(argsWithoutProg) != 0 {
|
||||
println("launchArgs", argsWithoutProg)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Linux
|
||||
|
||||
Currently, Wails doesn't support bundling for Linux. So, you need to create file associations manually.
|
||||
For example if you distribute your app as a .deb package, you can create file associations by adding required files in you bundle.
|
||||
You can use [nfpm](https://nfpm.goreleaser.com/) to create .deb package for your app.
|
||||
|
||||
1. Create a .desktop file for your app and specify file associations there. Example:
|
||||
|
||||
```ini
|
||||
[Desktop Entry]
|
||||
Categories=Office
|
||||
Exec=/usr/bin/wails-open-file %u
|
||||
Icon=wails-open-file.png
|
||||
Name=wails-open-file
|
||||
Terminal=false
|
||||
Type=Application
|
||||
MimeType=application/x-wails;application/x-test
|
||||
```
|
||||
|
||||
2. Create mime types file. Example:
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
|
||||
<mime-type type="application/x-wails">
|
||||
<comment>Wails Application File</comment>
|
||||
<glob pattern="*.wails"/>
|
||||
</mime-type>
|
||||
</mime-info>
|
||||
```
|
||||
|
||||
3. Create icons for your file types. SVG icons are recommended.
|
||||
4. Prepare postInstall/postRemove scripts for your package. Example:
|
||||
|
||||
```sh
|
||||
# reload mime types to register file associations
|
||||
update-mime-database /usr/share/mime
|
||||
# reload desktop database to load app in list of available
|
||||
update-desktop-database /usr/share/applications
|
||||
# update icons
|
||||
update-icon-caches /usr/share/icons/*
|
||||
```
|
||||
|
||||
5. Configure nfpm to use your scripts and files. Example:
|
||||
|
||||
```yaml
|
||||
name: "wails-open-file"
|
||||
arch: "arm64"
|
||||
platform: "linux"
|
||||
version: "1.0.0"
|
||||
section: "default"
|
||||
priority: "extra"
|
||||
maintainer: "FooBarCorp <FooBarCorp@gmail.com>"
|
||||
description: "Sample Package"
|
||||
vendor: "FooBarCorp"
|
||||
homepage: "http://example.com"
|
||||
license: "MIT"
|
||||
contents:
|
||||
- src: ../bin/wails-open-file
|
||||
dst: /usr/bin/wails-open-file
|
||||
- src: ./main.desktop
|
||||
dst: /usr/share/applications/wails-open-file.desktop
|
||||
- src: ./application-wails-mime.xml
|
||||
dst: /usr/share/mime/packages/application-x-wails.xml
|
||||
- src: ./application-test-mime.xml
|
||||
dst: /usr/share/mime/packages/application-x-test.xml
|
||||
- src: ../appicon.svg
|
||||
dst: /usr/share/icons/hicolor/scalable/apps/wails-open-file.svg
|
||||
- src: ../wailsFileIcon.svg
|
||||
dst: /usr/share/icons/hicolor/scalable/mimetypes/application-x-wails.svg
|
||||
- src: ../testFileIcon.svg
|
||||
dst: /usr/share/icons/hicolor/scalable/mimetypes/application-x-test.svg
|
||||
# copy icons to Yaru theme as well. For some reason Ubuntu didn't pick up fileicons from hicolor theme
|
||||
- src: ../appicon.svg
|
||||
dst: /usr/share/icons/Yaru/scalable/apps/wails-open-file.svg
|
||||
- src: ../wailsFileIcon.svg
|
||||
dst: /usr/share/icons/Yaru/scalable/mimetypes/application-x-wails.svg
|
||||
- src: ../testFileIcon.svg
|
||||
dst: /usr/share/icons/Yaru/scalable/mimetypes/application-x-test.svg
|
||||
scripts:
|
||||
postinstall: ./postInstall.sh
|
||||
postremove: ./postRemove.sh
|
||||
```
|
||||
|
||||
6. Build your .deb package using nfpm:
|
||||
|
||||
```sh
|
||||
nfpm pkg --packager deb --target .
|
||||
```
|
||||
|
||||
7. Now when your package is installed, your app will be associated with specified file types. When you open file with your app,
|
||||
new instance of app is launched and file path is passed as argument to your app.
|
||||
To handle this you should parse command line arguments in your app. Example:
|
||||
|
||||
```go title="main.go"
|
||||
func main() {
|
||||
argsWithoutProg := os.Args[1:]
|
||||
|
||||
if len(argsWithoutProg) != 0 {
|
||||
println("launchArgs", argsWithoutProg)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Limitations:
|
||||
|
||||
On Windows and Linux when associated file is opened, new instance of your app is launched.
|
||||
Currently, Wails doesn't support opening files in already running app. There is plugin for single instance support for v3 in development.
|
||||
@@ -159,6 +159,28 @@ If `/Applications/Xcode.app/Contents/Developer` is displayed, run `sudo xcode-se
|
||||
|
||||
Sources: https://github.com/wailsapp/wails/issues/1806 and https://github.com/wailsapp/wails/issues/1140#issuecomment-1290446496
|
||||
|
||||
## My application won't compile on Mac
|
||||
|
||||
If you are getting errors like this:
|
||||
|
||||
```shell
|
||||
l1@m2 GoEasyDesigner % go build -tags dev -gcflags "all=-N -l"
|
||||
/Users/l1/sdk/go1.20.5/pkg/tool/darwin_arm64/link: running clang failed: exit status 1
|
||||
Undefined symbols for architecture arm64:
|
||||
"_OBJC_CLASS_$_UTType", referenced from:
|
||||
objc-class-ref in 000016.o
|
||||
ld: symbol(s) not found for architecture arm64
|
||||
clang: error: linker command failed with exit code 1 (use -v to see invocation)
|
||||
```
|
||||
Ensure you have the latest SDK installed. If so and you're still experiencing this issue, try the following:
|
||||
|
||||
```shell
|
||||
export CGO_LDFLAGS="-framework UniformTypeIdentifiers" && go build -tags dev -gcflags "all=-N -l"
|
||||
```
|
||||
|
||||
Sources: https://github.com/wailsapp/wails/pull/2925#issuecomment-1726828562
|
||||
|
||||
|
||||
--
|
||||
|
||||
## Cannot start service: Host version "x.x.x does not match binary version "x.x.x"
|
||||
@@ -185,4 +207,162 @@ This is due to the default background of the webview being white. If you want to
|
||||
WebviewIsTransparent: true,
|
||||
},
|
||||
})
|
||||
```
|
||||
```
|
||||
|
||||
## I get a "Microsoft Edge can't read or write to its data directory" error when running my program as admin on Windows
|
||||
|
||||
You set your program to require admin permissions and it worked great! Unfortunately, some users are seeing a "Microsoft Edge can't read or write to its data directory" error when running it.
|
||||
|
||||
When a Windows machine has two local accounts:
|
||||
|
||||
- Alice, an admin
|
||||
- Bob, a regular user
|
||||
|
||||
Bob sees a UAC prompt when running your program. Bob enters Alice's admin credentials into this prompt. The app launches with admin permissions under Alice's account.
|
||||
|
||||
Wails instructs WebView2 to store user data at the specified `WebviewUserDataPath`. It defaults to `%APPDATA%\[BinaryName.exe]`.
|
||||
|
||||
Because the application is running under Alice's account, `%APPDATA%\[BinaryName.exe]` resolves to `C:\Users\Alice\AppData\Roaming\[BinaryName.exe]`.
|
||||
|
||||
WebView2 [creates some child processes under Bob's logged-in account instead of Alice's admin account](https://github.com/MicrosoftEdge/WebView2Feedback/issues/932#issue-807464179). Since Bob cannot access `C:\Users\Alice\AppData\Roaming\[BinaryName.exe]`, the "Microsoft Edge can't read or write to its data directory" error is shown.
|
||||
|
||||
Possible solution #1:
|
||||
|
||||
Refactor your application to work without constant admin permissions. If you just need to perform a small set of admin tasks (such as running an updater), you can run your application with the minimum permissions and then use the `runas` command to run these tasks with admin permissions as needed:
|
||||
|
||||
```go
|
||||
//go:build windows
|
||||
|
||||
package sample
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/windows"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// Calling RunAs("C:\path\to\my\updater.exe") shows Bob a UAC prompt. Bob enters Alice's admin credentials. The updater launches with admin permissions under Alice's account.
|
||||
func RunAs(path string) error {
|
||||
verbPtr, _ := syscall.UTF16PtrFromString("runas")
|
||||
exePtr, _ := syscall.UTF16PtrFromString(path)
|
||||
cwdPtr, _ := syscall.UTF16PtrFromString("")
|
||||
argPtr, _ := syscall.UTF16PtrFromString("")
|
||||
|
||||
var showCmd int32 = 1 //SW_NORMAL
|
||||
|
||||
err := windows.ShellExecute(0, verbPtr, exePtr, argPtr, cwdPtr, showCmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
```
|
||||
|
||||
Possible solution #2:
|
||||
|
||||
Run your application with extended permissions. If you absolutely must run with constant admin permissions, WebView2 will function correctly if you use a data directory accessible by both users and you also launch your app with the `SeBackupPrivilege`, `SeDebugPrivilege`, and `SeRestorePrivilege` permissions. Here's an example:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/fourcorelabs/wintoken"
|
||||
"github.com/hectane/go-acl"
|
||||
"github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/windows"
|
||||
)
|
||||
|
||||
//go:embed all:frontend/dist
|
||||
var assets embed.FS
|
||||
|
||||
const (
|
||||
fixedTokenKey = "SAMPLE_RANDOM_KEY"
|
||||
fixedTokenVal = "with-fixed-token"
|
||||
webviewDir = "C:\\ProgramData\\Sample"
|
||||
)
|
||||
|
||||
func runWithFixedToken() {
|
||||
println("Re-launching self")
|
||||
token, err := wintoken.OpenProcessToken(0, wintoken.TokenPrimary) //pass 0 for own process
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer token.Close()
|
||||
|
||||
token.EnableTokenPrivileges([]string{
|
||||
"SeBackupPrivilege",
|
||||
"SeDebugPrivilege",
|
||||
"SeRestorePrivilege",
|
||||
})
|
||||
|
||||
cmd := exec.Command(os.Args[0])
|
||||
cmd.Args = os.Args
|
||||
cmd.Env = os.Environ()
|
||||
cmd.Env = append(cmd.Env, fmt.Sprintf("%v=%v", fixedTokenKey, fixedTokenVal))
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Token: syscall.Token(token.Token())}
|
||||
if err := cmd.Run(); err != nil {
|
||||
println("Error after launching self:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
println("Clean self launch :)")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func main() {
|
||||
if runtime.GOOS == "windows" && os.Getenv(fixedTokenKey) != fixedTokenVal {
|
||||
runWithFixedToken()
|
||||
}
|
||||
|
||||
println("Setting data dir to", webviewDir)
|
||||
if err := os.MkdirAll(webviewDir, os.ModePerm); err != nil {
|
||||
println("Failed creating dir:", err)
|
||||
}
|
||||
if err := acl.Chmod(webviewDir, 0777); err != nil {
|
||||
println("Failed setting ACL on dir:", err)
|
||||
}
|
||||
|
||||
app := NewApp()
|
||||
|
||||
err := wails.Run(&options.App{
|
||||
Title: "sample-data-dir",
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
AssetServer: &assetserver.Options{
|
||||
Assets: assets,
|
||||
},
|
||||
Bind: []interface{}{
|
||||
app,
|
||||
},
|
||||
Windows: &windows.Options{
|
||||
WebviewUserDataPath: webviewDir,
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
println("Error:", err.Error())
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you use a data directory accessible by both users but not the extended privileges, you will receive a WebView2 `80010108 The object invoked has disconnected from its clients` error.
|
||||
|
||||
Possible future solution #3: [run WebView2 using an in-memory mode if implemented](https://github.com/MicrosoftEdge/WebView2Feedback/issues/3637#issuecomment-1728300982).
|
||||
|
||||
## WebView2 installation succeeded, but the wails doctor command shows that it is not installed
|
||||
|
||||
If you have installed WebView2, but the `wails doctor` command shows that it is not installed, it is likely that the WebView2 runtime installed was for a different architecture. You can download the correct runtime from [here](https://developer.microsoft.com/en-us/microsoft-edge/webview2/).
|
||||
|
||||
Source: https://github.com/wailsapp/wails/issues/2917
|
||||
|
||||
## WebVie2wProcess failed with kind
|
||||
|
||||
If your Windows app generates this kind of error, you can check out what the error means [here](https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2processfailedkind?view=webview2-winrt-1.0.2045.28).
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user