mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-19 02:19:31 +08:00
Support for File-Associations on macOS
This commit is contained in:
parent
4a2dc2875f
commit
8c3ee8f1bd
@ -76,6 +76,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Add cancellation support for query methods on `sqlite` service by [@fbbdev](https://github.com/fbbdev) in [#4067](https://github.com/wailsapp/wails/pull/4067)
|
- Add cancellation support for query methods on `sqlite` service by [@fbbdev](https://github.com/fbbdev) in [#4067](https://github.com/wailsapp/wails/pull/4067)
|
||||||
- Add prepared statement support to `sqlite` service with JS bindings by [@fbbdev](https://github.com/fbbdev) in [#4067](https://github.com/wailsapp/wails/pull/4067)
|
- Add prepared statement support to `sqlite` service with JS bindings by [@fbbdev](https://github.com/fbbdev) in [#4067](https://github.com/wailsapp/wails/pull/4067)
|
||||||
- Add `SetMenu()` on window to allow for setting a menu on a window by [@leaanthony](https://github.com/leaanthony)
|
- Add `SetMenu()` on window to allow for setting a menu on a window by [@leaanthony](https://github.com/leaanthony)
|
||||||
|
- Add File Association support for mac by [@wimaha]
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ fileAssociations:
|
|||||||
| description | Description shown in file properties | Windows |
|
| description | Description shown in file properties | Windows |
|
||||||
| iconName | Name of the icon file (without extension) in the build folder | All |
|
| iconName | Name of the icon file (without extension) in the build folder | All |
|
||||||
| role | Application's role for this file type (e.g., `Editor`, `Viewer`) | macOS |
|
| role | Application's role for this file type (e.g., `Editor`, `Viewer`) | macOS |
|
||||||
|
| mimeType | MIME type for the file (e.g., `image/jpeg`) | macOS |
|
||||||
|
|
||||||
## Listening for File Open Events
|
## Listening for File Open Events
|
||||||
|
|
||||||
@ -105,6 +106,8 @@ Let's walk through setting up file associations for a simple text editor:
|
|||||||
Run `wails3 generate icons --help` for more information.
|
Run `wails3 generate icons --help` for more information.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
- For macOS add copy statement like `cp build/darwin/documenticon.icns {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/Resources` in the `create:app:bundle:` task.
|
||||||
|
|
||||||
2. ### Configure File Associations
|
2. ### Configure File Associations
|
||||||
|
|
||||||
Edit the `build/config.yml` file to add your file associations:
|
Edit the `build/config.yml` file to add your file associations:
|
||||||
|
@ -4,14 +4,15 @@ import (
|
|||||||
"embed"
|
"embed"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/leaanthony/gosod"
|
|
||||||
"gopkg.in/yaml.v3"
|
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/leaanthony/gosod"
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed build_assets
|
//go:embed build_assets
|
||||||
@ -121,6 +122,7 @@ type FileAssociation struct {
|
|||||||
Description string `yaml:"description"`
|
Description string `yaml:"description"`
|
||||||
IconName string `yaml:"iconName"`
|
IconName string `yaml:"iconName"`
|
||||||
Role string `yaml:"role"`
|
Role string `yaml:"role"`
|
||||||
|
MimeType string `yaml:"mimeType"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateConfig struct {
|
type UpdateConfig struct {
|
||||||
|
@ -56,6 +56,7 @@ fileAssociations:
|
|||||||
# description: Image File
|
# description: Image File
|
||||||
# iconName: jpegFileIcon
|
# iconName: jpegFileIcon
|
||||||
# role: Editor
|
# role: Editor
|
||||||
|
# mimeType: image/jpeg # (optional)
|
||||||
|
|
||||||
# Other data
|
# Other data
|
||||||
other:
|
other:
|
||||||
|
@ -2,27 +2,50 @@
|
|||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>{{.ProductName}}</string>
|
<string>{{.ProductName}}</string>
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>{{.BinaryName}}</string>
|
<string>{{.BinaryName}}</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>{{.ProductIdentifier}}</string>
|
<string>{{.ProductIdentifier}}</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>{{.ProductVersion}}</string>
|
<string>{{.ProductVersion}}</string>
|
||||||
<key>CFBundleGetInfoString</key>
|
<key>CFBundleGetInfoString</key>
|
||||||
<string>{{.ProductComments}}</string>
|
<string>{{.ProductComments}}</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>{{.ProductVersion}}</string>
|
<string>{{.ProductVersion}}</string>
|
||||||
<key>CFBundleIconFile</key>
|
<key>CFBundleIconFile</key>
|
||||||
<string>icons</string>
|
<string>icons</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
<string>10.15.0</string>
|
<string>10.15.0</string>
|
||||||
<key>NSHighResolutionCapable</key>
|
<key>NSHighResolutionCapable</key>
|
||||||
<string>true</string>
|
<string>true</string>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>{{.ProductCopyright}}</string>
|
<string>{{.ProductCopyright}}</string>
|
||||||
|
{{- if .FileAssociations}}
|
||||||
|
<key>CFBundleDocumentTypes</key>
|
||||||
|
<array>
|
||||||
|
{{- range .FileAssociations}}
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>{{.Ext}}</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>{{.Name}}</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>{{.Role}}</string>
|
||||||
|
<key>CFBundleTypeIconFile</key>
|
||||||
|
<string>{{.IconName}}</string>
|
||||||
|
{{- if .MimeType}}
|
||||||
|
<key>CFBundleTypeMimeType</key>
|
||||||
|
<string>{{.MimeType}}</string>
|
||||||
|
{{- end}}
|
||||||
|
</dict>
|
||||||
|
{{- end}}
|
||||||
|
</array>
|
||||||
|
{{- end}}
|
||||||
<key>NSAppTransportSecurity</key>
|
<key>NSAppTransportSecurity</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSAllowsLocalNetworking</key>
|
<key>NSAllowsLocalNetworking</key>
|
||||||
|
@ -2,26 +2,49 @@
|
|||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>{{.ProductName}}</string>
|
<string>{{.ProductName}}</string>
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>{{.BinaryName}}</string>
|
<string>{{.BinaryName}}</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>{{.ProductIdentifier}}</string>
|
<string>{{.ProductIdentifier}}</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>{{.ProductVersion}}</string>
|
<string>{{.ProductVersion}}</string>
|
||||||
<key>CFBundleGetInfoString</key>
|
<key>CFBundleGetInfoString</key>
|
||||||
<string>{{.ProductComments}}</string>
|
<string>{{.ProductComments}}</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>{{.ProductVersion}}</string>
|
<string>{{.ProductVersion}}</string>
|
||||||
<key>CFBundleIconFile</key>
|
<key>CFBundleIconFile</key>
|
||||||
<string>icons</string>
|
<string>icons</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
<string>10.15.0</string>
|
<string>10.15.0</string>
|
||||||
<key>NSHighResolutionCapable</key>
|
<key>NSHighResolutionCapable</key>
|
||||||
<string>true</string>
|
<string>true</string>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>{{.ProductCopyright}}</string>
|
<string>{{.ProductCopyright}}</string>
|
||||||
|
{{- if .FileAssociations}}
|
||||||
|
<key>CFBundleDocumentTypes</key>
|
||||||
|
<array>
|
||||||
|
{{- range .FileAssociations}}
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>{{.Ext}}</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>{{.Name}}</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>{{.Role}}</string>
|
||||||
|
<key>CFBundleTypeIconFile</key>
|
||||||
|
<string>{{.IconName}}</string>
|
||||||
|
{{- if .MimeType}}
|
||||||
|
<key>CFBundleTypeMimeType</key>
|
||||||
|
<string>{{.MimeType}}</string>
|
||||||
|
{{- end}}
|
||||||
|
</dict>
|
||||||
|
{{- end}}
|
||||||
|
</array>
|
||||||
|
{{- end}}
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
Loading…
Reference in New Issue
Block a user