Compare commits

..

15 Commits

Author SHA1 Message Date
Lea Anthony
f6d7ec3d50 Merge pull request #1059 from GargantuaX/master
update zh-hans docs
2022-01-06 06:28:35 +11:00
GargantuaX
d2a116fe55 update zh-hans docs 2022-01-05 16:01:48 +08:00
Lea Anthony
eb3cf9d130 Merge pull request #1058 from yesgs/master
add uos linux distro
2022-01-05 17:13:48 +11:00
king
7e2258be7d add uos linux distro 2022-01-05 11:13:34 +08:00
Lea Anthony
bb5d446001 Merge pull request #1053 from pierrejoye/master
Allow window resizing regardless of frameless or other options (#1049)
2021-12-31 06:58:05 +11:00
Pierre Joye
e9aba4795f Allow window resizing regardless of frameless or other options
Fix bug on Windows where the disableResize option depends on the frameless option.
2021-12-30 16:55:47 +07:00
Lea\Anthony
c16bb9715f Fix for bad default directories in dialog options. Fixes #1052 2021-12-30 17:34:06 +11:00
Lea\Anthony
0f09e8d433 Fix signatures 2021-12-30 11:17:29 +11:00
Lea\Anthony
f338dff171 Fix EventsOff in JS runtime 2021-12-29 09:11:12 +11:00
Lea\Anthony
3c6ed12637 New build flag: -debug 2021-12-29 06:54:52 +11:00
Lea Anthony
e2f3a11a33 [mac] Fix for cancelling Dialogs. Fixes #1047 2021-12-28 20:04:30 +11:00
Lea Anthony
0571deb290 Merge pull request #1046 from buddyabaddon/master
Make linuxdb.yaml an embedded resource
2021-12-28 17:27:59 +11:00
Matt McKenzie
451b357e40 Make linuxdb.yaml an embedded resource 2021-12-27 18:22:03 -08:00
Lea\Anthony
84b67a8f53 Add -u flag to sync project go.mod with CLI version 2021-12-28 06:40:44 +11:00
Lea Anthony
448cf731bb [mac] Fix for Save Dialog 2021-12-27 20:09:03 +11:00
18 changed files with 126 additions and 36 deletions

View File

@@ -148,16 +148,6 @@ func (fs *FSHelper) LocalDir(dir string) (*Dir, error) {
}, err }, err
} }
// LoadRelativeFile loads the given file relative to the caller's directory
func (fs *FSHelper) LoadRelativeFile(relativePath string) ([]byte, error) {
_, filename, _, _ := runtime.Caller(0)
fullPath, err := filepath.Abs(filepath.Join(path.Dir(filename), relativePath))
if err != nil {
return nil, err
}
return os.ReadFile(fullPath)
}
// GetSubdirs will return a list of FQPs to subdirectories in the given directory // GetSubdirs will return a list of FQPs to subdirectories in the given directory
func (d *Dir) GetSubdirs() (map[string]string, error) { func (d *Dir) GetSubdirs() (map[string]string, error) {

View File

@@ -74,6 +74,8 @@ const (
NixOS NixOS
// Artix linux distribution // Artix linux distribution
ArtixLinux ArtixLinux
//Uos distribution
Uos
) )
// DistroInfo contains all the information relating to a linux distribution // DistroInfo contains all the information relating to a linux distribution
@@ -190,6 +192,8 @@ func parseOsRelease(osRelease string) *DistroInfo {
result.Distribution = NixOS result.Distribution = NixOS
case "artix": case "artix":
result.Distribution = ArtixLinux result.Distribution = ArtixLinux
case "uos":
result.Distribution = Uos
default: default:
result.Distribution = Unknown result.Distribution = Unknown
} }

View File

@@ -1,11 +1,15 @@
package cmd package cmd
import ( import (
_ "embed"
"log" "log"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
) )
//go:embed linuxdb.yaml
var LinuxDBYaml []byte
// LinuxDB is the database for linux distribution data. // LinuxDB is the database for linux distribution data.
type LinuxDB struct { type LinuxDB struct {
Distributions map[string]*Distribution `yaml:"distributions"` Distributions map[string]*Distribution `yaml:"distributions"`
@@ -78,14 +82,10 @@ func (l *LinuxDB) GetDistro(distro string) *Distribution {
// NewLinuxDB creates a new LinuxDB instance from the bundled // NewLinuxDB creates a new LinuxDB instance from the bundled
// linuxdb.yaml file. // linuxdb.yaml file.
func NewLinuxDB() *LinuxDB { func NewLinuxDB() *LinuxDB {
data, err := fs.LoadRelativeFile("./linuxdb.yaml")
if err != nil {
log.Fatal("Could not load linuxdb.yaml")
}
result := LinuxDB{ result := LinuxDB{
Distributions: make(map[string]*Distribution), Distributions: make(map[string]*Distribution),
} }
err = result.ImportData(data) err := result.ImportData(LinuxDBYaml)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@@ -100,6 +100,15 @@ distributions:
gccversioncommand: *gccdumpfullversion gccversioncommand: *gccdumpfullversion
programs: *debiandefaultprograms programs: *debiandefaultprograms
libraries: *debiandefaultlibraries libraries: *debiandefaultlibraries
uos:
id: uos
releases:
default:
version: default
name: Uos
gccversioncommand: *gccdumpfullversion
programs: *debiandefaultprograms
libraries: *debiandefaultlibraries
void: void:
id: void id: void
releases: releases:

View File

@@ -278,7 +278,7 @@ func CheckDependencies(logger *Logger) (bool, error) {
distroInfo := GetLinuxDistroInfo() distroInfo := GetLinuxDistroInfo()
switch distroInfo.Distribution { switch distroInfo.Distribution {
case Ubuntu, Debian, Zorin, Parrot, Linuxmint, Elementary, Kali, Neon, Deepin, Raspbian, PopOS: case Ubuntu, Debian, Zorin, Parrot, Linuxmint, Elementary, Kali, Neon, Deepin, Raspbian, PopOS, Uos:
libraryChecker = DpkgInstalled libraryChecker = DpkgInstalled
case Arch, ArcoLinux, ArchLabs, Ctlos, Manjaro, ManjaroARM, EndeavourOS, ArtixLinux: case Arch, ArcoLinux, ArchLabs, Ctlos, Manjaro, ManjaroARM, EndeavourOS, ArtixLinux:
libraryChecker = PacmanInstalled libraryChecker = PacmanInstalled

View File

@@ -2,6 +2,7 @@ package build
import ( import (
"fmt" "fmt"
"github.com/wailsapp/wails/v2/internal/colour"
"io" "io"
"os" "os"
"os/exec" "os/exec"
@@ -79,6 +80,12 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
forceBuild := false forceBuild := false
command.BoolFlag("f", "Force build application", &forceBuild) command.BoolFlag("f", "Force build application", &forceBuild)
updateGoMod := false
command.BoolFlag("u", "Updates go.mod to use the same Wails version as the CLI", &updateGoMod)
debug := false
command.BoolFlag("debug", "Retains debug data in the compiled application", &debug)
command.Action(func() error { command.Action(func() error {
quiet := verbosity == 0 quiet := verbosity == 0
@@ -160,13 +167,20 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
} }
} }
mode := build.Production
modeString := "Production"
if debug {
mode = build.Debug
modeString = "Debug"
}
// Create BuildOptions // Create BuildOptions
buildOptions := &build.Options{ buildOptions := &build.Options{
Logger: logger, Logger: logger,
OutputType: outputType, OutputType: outputType,
OutputFile: outputFilename, OutputFile: outputFilename,
CleanBuildDirectory: cleanBuildDirectory, CleanBuildDirectory: cleanBuildDirectory,
Mode: build.Production, Mode: mode,
Pack: !noPackage, Pack: !noPackage,
LDFlags: ldflags, LDFlags: ldflags,
Compiler: compilerCommand, Compiler: compilerCommand,
@@ -202,6 +216,7 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
fmt.Fprintf(w, "Platform: \t%s\n", buildOptions.Platform) fmt.Fprintf(w, "Platform: \t%s\n", buildOptions.Platform)
fmt.Fprintf(w, "Arch: \t%s\n", buildOptions.Arch) fmt.Fprintf(w, "Arch: \t%s\n", buildOptions.Arch)
fmt.Fprintf(w, "Compiler: \t%s\n", compilerPath) fmt.Fprintf(w, "Compiler: \t%s\n", compilerPath)
fmt.Fprintf(w, "Build Mode: \t%s\n", modeString)
fmt.Fprintf(w, "Skip Frontend: \t%t\n", skipFrontend) fmt.Fprintf(w, "Skip Frontend: \t%t\n", skipFrontend)
fmt.Fprintf(w, "Compress: \t%t\n", buildOptions.Compress) fmt.Fprintf(w, "Compress: \t%t\n", buildOptions.Compress)
fmt.Fprintf(w, "Package: \t%t\n", buildOptions.Pack) fmt.Fprintf(w, "Package: \t%t\n", buildOptions.Pack)
@@ -214,7 +229,7 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
fmt.Fprintf(w, "\n") fmt.Fprintf(w, "\n")
w.Flush() w.Flush()
err = checkGoModVersion(logger) err = checkGoModVersion(logger, updateGoMod)
if err != nil { if err != nil {
return err return err
} }
@@ -243,7 +258,7 @@ func doBuild(buildOptions *build.Options) error {
return nil return nil
} }
func checkGoModVersion(logger *clilogger.CLILogger) error { func checkGoModVersion(logger *clilogger.CLILogger, updateGoMod bool) error {
cwd, err := os.Getwd() cwd, err := os.Getwd()
if err != nil { if err != nil {
return err return err
@@ -265,6 +280,36 @@ func checkGoModVersion(logger *clilogger.CLILogger) error {
return err return err
} }
logger.Println("Warning: go.mod is using Wails '%s' but the CLI is '%s'. Consider updating it.\n", gomodversion.String(), internal.Version) if updateGoMod {
return syncGoModVersion(cwd)
}
logger.Println("Warning: go.mod is using Wails '%s' but the CLI is '%s'. Consider updating your project's `go.mod` file.\n", gomodversion.String(), internal.Version)
return nil return nil
} }
func LogGreen(message string, args ...interface{}) {
text := fmt.Sprintf(message, args...)
println(colour.Green(text))
}
func syncGoModVersion(cwd string) error {
gomodFilename := filepath.Join(cwd, "go.mod")
gomodData, err := os.ReadFile(gomodFilename)
if err != nil {
return err
}
outOfSync, err := gomod.GoModOutOfSync(gomodData, internal.Version)
if err != nil {
return err
}
if !outOfSync {
return nil
}
LogGreen("Updating go.mod to use Wails '%s'", internal.Version)
newGoData, err := gomod.UpdateGoModVersion(gomodData, internal.Version)
if err != nil {
return err
}
return os.WriteFile(gomodFilename, newGoData, 0755)
}

View File

@@ -540,6 +540,10 @@
// Setup callback handler // Setup callback handler
[dialog beginSheetModalForWindow:self.mainWindow completionHandler:^(NSModalResponse returnCode) { [dialog beginSheetModalForWindow:self.mainWindow completionHandler:^(NSModalResponse returnCode) {
if ( returnCode != NSModalResponseOK) {
processOpenFileDialogResponse("[]");
return;
}
NSMutableArray *arr = [NSMutableArray new]; NSMutableArray *arr = [NSMutableArray new];
for (NSURL *url in [dialog URLs]) { for (NSURL *url in [dialog URLs]) {
[arr addObject:[url path]]; [arr addObject:[url path]];
@@ -558,7 +562,7 @@
// Create the dialog // Create the dialog
NSSavePanel *dialog = [NSOpenPanel savePanel]; NSSavePanel *dialog = [NSSavePanel savePanel];
// Valid but appears to do nothing.... :/ // Valid but appears to do nothing.... :/
if( title != nil ) { if( title != nil ) {
@@ -592,10 +596,12 @@
// Setup callback handler // Setup callback handler
[dialog beginSheetModalForWindow:self.mainWindow completionHandler:^(NSModalResponse returnCode) { [dialog beginSheetModalForWindow:self.mainWindow completionHandler:^(NSModalResponse returnCode) {
NSURL *url = [dialog URL]; if ( returnCode == NSModalResponseOK ) {
if ( url != nil ) { NSURL *url = [dialog URL];
processSaveFileDialogResponse([url.path UTF8String]); if ( url != nil ) {
return; processSaveFileDialogResponse([url.path UTF8String]);
return;
}
} }
processSaveFileDialogResponse(""); processSaveFileDialogResponse("");
}]; }];

View File

@@ -83,7 +83,7 @@ extern void processMessage(char*);
static void sendMessageToBackend(WebKitUserContentManager *contentManager, static void sendMessageToBackend(WebKitUserContentManager *contentManager,
WebKitJavascriptResult *result, WebKitJavascriptResult *result,
void*) void* data)
{ {
#if WEBKIT_MAJOR_VERSION >= 2 && WEBKIT_MINOR_VERSION >= 22 #if WEBKIT_MAJOR_VERSION >= 2 && WEBKIT_MINOR_VERSION >= 22
JSCValue *value = webkit_javascript_result_get_js_value(result); JSCValue *value = webkit_javascript_result_get_js_value(result);
@@ -145,7 +145,7 @@ void connectButtons(void* webview) {
extern void processURLRequest(WebKitURISchemeRequest *request); extern void processURLRequest(WebKitURISchemeRequest *request);
// This is called when the close button on the window is pressed // This is called when the close button on the window is pressed
gboolean close_button_pressed(GtkWidget *widget, GdkEvent *event, void*) gboolean close_button_pressed(GtkWidget *widget, GdkEvent *event, void* data)
{ {
processMessage("Q"); processMessage("Q");
return FALSE; return FALSE;

View File

@@ -57,10 +57,10 @@ func NewWindow(parent winc.Controller, appoptions *options.App) *Window {
result.SetText(appoptions.Title) result.SetText(appoptions.Title)
if appoptions.Frameless == false && !appoptions.Fullscreen { if appoptions.Frameless == false && !appoptions.Fullscreen {
result.EnableMaxButton(!appoptions.DisableResize) result.EnableMaxButton(!appoptions.DisableResize)
result.EnableSizable(!appoptions.DisableResize)
result.SetMinSize(appoptions.MinWidth, appoptions.MinHeight) result.SetMinSize(appoptions.MinWidth, appoptions.MinHeight)
result.SetMaxSize(appoptions.MaxWidth, appoptions.MaxHeight) result.SetMaxSize(appoptions.MaxWidth, appoptions.MaxHeight)
} }
result.EnableSizable(!appoptions.DisableResize)
if appoptions.Windows != nil { if appoptions.Windows != nil {
if appoptions.Windows.WindowIsTranslucent { if appoptions.Windows.WindowIsTranslucent {

View File

@@ -152,7 +152,7 @@ export function EventsEmit(eventName) {
export function EventsOff(eventName) { export function EventsOff(eventName) {
// Remove local listeners // Remove local listeners
eventListeners.delete(eventName); delete eventListeners[eventName];
// Notify Go listeners // Notify Go listeners
window.WailsInvoke('EX' + eventName); window.WailsInvoke('EX' + eventName);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -215,7 +215,7 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
commands := slicer.String([]string{"build"}) commands := slicer.String([]string{"build"})
// Add better debugging flags // Add better debugging flags
if options.Mode == Dev { if options.Mode == Dev || options.Mode == Debug {
commands.Add("-gcflags") commands.Add("-gcflags")
commands.Add(`"all=-N -l"`) commands.Add(`"all=-N -l"`)
} }
@@ -233,7 +233,7 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
tags.Add(options.WebView2Strategy) tags.Add(options.WebView2Strategy)
} }
if options.Mode == Production { if options.Mode == Production || options.Mode == Debug {
tags.Add("production") tags.Add("production")
} }

View File

@@ -23,6 +23,8 @@ const (
Dev Mode = iota Dev Mode = iota
// Production mode // Production mode
Production Production
// Debug build
Debug
) )
// Options contains all the build options as well as the project data // Options contains all the build options as well as the project data

View File

@@ -2,7 +2,9 @@ package runtime
import ( import (
"context" "context"
"fmt"
"github.com/wailsapp/wails/v2/internal/frontend" "github.com/wailsapp/wails/v2/internal/frontend"
"github.com/wailsapp/wails/v2/internal/fs"
) )
// FileFilter defines a filter for dialog boxes // FileFilter defines a filter for dialog boxes
@@ -29,24 +31,44 @@ type MessageDialogOptions = frontend.MessageDialogOptions
// OpenDirectoryDialog prompts the user to select a directory // OpenDirectoryDialog prompts the user to select a directory
func OpenDirectoryDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error) { func OpenDirectoryDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error) {
appFrontend := getFrontend(ctx) appFrontend := getFrontend(ctx)
if dialogOptions.DefaultDirectory != "" {
if !fs.DirExists(dialogOptions.DefaultDirectory) {
return "", fmt.Errorf("default directory '%s' does not exist", dialogOptions.DefaultDirectory)
}
}
return appFrontend.OpenDirectoryDialog(dialogOptions) return appFrontend.OpenDirectoryDialog(dialogOptions)
} }
// OpenFileDialog prompts the user to select a file // OpenFileDialog prompts the user to select a file
func OpenFileDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error) { func OpenFileDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error) {
appFrontend := getFrontend(ctx) appFrontend := getFrontend(ctx)
if dialogOptions.DefaultDirectory != "" {
if !fs.DirExists(dialogOptions.DefaultDirectory) {
return "", fmt.Errorf("default directory '%s' does not exist", dialogOptions.DefaultDirectory)
}
}
return appFrontend.OpenFileDialog(dialogOptions) return appFrontend.OpenFileDialog(dialogOptions)
} }
// OpenMultipleFilesDialog prompts the user to select a file // OpenMultipleFilesDialog prompts the user to select a file
func OpenMultipleFilesDialog(ctx context.Context, dialogOptions OpenDialogOptions) ([]string, error) { func OpenMultipleFilesDialog(ctx context.Context, dialogOptions OpenDialogOptions) ([]string, error) {
appFrontend := getFrontend(ctx) appFrontend := getFrontend(ctx)
if dialogOptions.DefaultDirectory != "" {
if !fs.DirExists(dialogOptions.DefaultDirectory) {
return nil, fmt.Errorf("default directory '%s' does not exist", dialogOptions.DefaultDirectory)
}
}
return appFrontend.OpenMultipleFilesDialog(dialogOptions) return appFrontend.OpenMultipleFilesDialog(dialogOptions)
} }
// SaveFileDialog prompts the user to select a file // SaveFileDialog prompts the user to select a file
func SaveFileDialog(ctx context.Context, dialogOptions SaveDialogOptions) (string, error) { func SaveFileDialog(ctx context.Context, dialogOptions SaveDialogOptions) (string, error) {
appFrontend := getFrontend(ctx) appFrontend := getFrontend(ctx)
if dialogOptions.DefaultDirectory != "" {
if !fs.DirExists(dialogOptions.DefaultDirectory) {
return "", fmt.Errorf("default directory '%s' does not exist", dialogOptions.DefaultDirectory)
}
}
return appFrontend.SaveFileDialog(dialogOptions) return appFrontend.SaveFileDialog(dialogOptions)
} }

View File

@@ -66,6 +66,8 @@ A list of community maintained templates can be found [here](/docs/community/tem
| -upxflags | Flags to pass to upx | | | -upxflags | Flags to pass to upx | |
| -v int | Verbosity level (0 - silent, 1 - default, 2 - verbose) | 1 | | -v int | Verbosity level (0 - silent, 1 - default, 2 - verbose) | 1 |
| -webview2 | WebView2 installer strategy: download,embed,browser,error | download | | -webview2 | WebView2 installer strategy: download,embed,browser,error | download |
| -u | Updates your project's `go.mod` to use the same version of Wails as the CLI | |
| -debug | Retains debug information in the application | false |
For a detailed description of the `webview2` flag, please refer to the [Windows](/docs/guides/windows) Guide. For a detailed description of the `webview2` flag, please refer to the [Windows](/docs/guides/windows) Guide.

View File

@@ -27,3 +27,13 @@ sidebar_position: 1
## Angular ## Angular
- [wails-angular-template](https://github.com/TAINCER/wails-angular-template) - 带有 TypeScript, Sass, 热重载, 代码拆分和 i18n 的 Angular - [wails-angular-template](https://github.com/TAINCER/wails-angular-template) - 带有 TypeScript, Sass, 热重载, 代码拆分和 i18n 的 Angular
## React
- [wails-react-template](https://github.com/AlienRecall/wails-react-template) - 基于 reactjs 的模板
- [wails-react-template](https://github.com/flin7/wails-react-template) - 基于 React 并支持实时开发模式的轻量级模板
## Svelte
- [wails-svelte-template](https://github.com/raitonoberu/wails-svelte-template) - 基于 Svelte 的模板