mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
Add BrowserOpenURL and BrowserOpenFile to App.
Better WML assets for demo Fix dialog responses. Add `wml-openurl` Rename: data-wml -> wml Fix Alpha Feedback URL
This commit is contained in:
@@ -35,7 +35,7 @@ require (
|
||||
github.com/samber/lo v1.38.1 // indirect
|
||||
github.com/sergi/go-diff v1.2.0 // indirect
|
||||
github.com/stretchr/testify v1.8.4 // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.8-0.20231010092311-42cbb98eb53b // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.8 // indirect
|
||||
github.com/wailsapp/mimetype v1.4.1 // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.0 // indirect
|
||||
golang.org/x/crypto v0.9.0 // indirect
|
||||
|
||||
@@ -106,6 +106,7 @@ github.com/tmclane/purego v0.0.0-20230601213035-1f25e70d7b01/go.mod h1:ah1In8AOt
|
||||
github.com/wailsapp/go-webview2 v1.0.7 h1:s95+7irJsAsTy1RsjJ6N0cYX7tZ4gP7Uzawds0L2urs=
|
||||
github.com/wailsapp/go-webview2 v1.0.7/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/go-webview2 v1.0.8-0.20231010092311-42cbb98eb53b/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/go-webview2 v1.0.8/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
||||
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
||||
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
|
||||
|
||||
@@ -33,7 +33,7 @@ require (
|
||||
github.com/samber/lo v1.38.1 // indirect
|
||||
github.com/sergi/go-diff v1.2.0 // indirect
|
||||
github.com/stretchr/testify v1.8.4 // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.8-0.20231010092311-42cbb98eb53b // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.8 // indirect
|
||||
github.com/wailsapp/mimetype v1.4.1 // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.0 // indirect
|
||||
golang.org/x/crypto v0.9.0 // indirect
|
||||
|
||||
@@ -106,6 +106,7 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
|
||||
github.com/wailsapp/go-webview2 v1.0.7 h1:s95+7irJsAsTy1RsjJ6N0cYX7tZ4gP7Uzawds0L2urs=
|
||||
github.com/wailsapp/go-webview2 v1.0.7/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/go-webview2 v1.0.8-0.20231010092311-42cbb98eb53b/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/go-webview2 v1.0.8/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
||||
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
||||
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
|
||||
|
||||
@@ -32,7 +32,7 @@ require (
|
||||
github.com/rivo/uniseg v0.4.4 // indirect
|
||||
github.com/samber/lo v1.38.1 // indirect
|
||||
github.com/sergi/go-diff v1.2.0 // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.8-0.20231010092311-42cbb98eb53b // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.8 // indirect
|
||||
github.com/wailsapp/mimetype v1.4.1 // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.0 // indirect
|
||||
golang.org/x/crypto v0.9.0 // indirect
|
||||
|
||||
@@ -100,6 +100,7 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
|
||||
github.com/wailsapp/go-webview2 v1.0.7 h1:s95+7irJsAsTy1RsjJ6N0cYX7tZ4gP7Uzawds0L2urs=
|
||||
github.com/wailsapp/go-webview2 v1.0.7/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/go-webview2 v1.0.8-0.20231010092311-42cbb98eb53b/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/go-webview2 v1.0.8/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
||||
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
||||
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
<div class="jumbotron text-center text-success" style="padding-top:70px;">
|
||||
<h1><span class="fa fa-lock"></span> Social Authentication</h1>
|
||||
<p>Login or Register with:</p>
|
||||
<a data-wml-event="github-login" class="btn btn-primary"><span class="fa fa-github" style="color: #FFF"></span> SignIn with Github</a>
|
||||
<a wml-event="github-login" class="btn btn-primary"><span class="fa fa-github" style="color: #FFF"></span> SignIn with Github</a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="details" class="text-center" style="display: none">
|
||||
<image id="logo" style="width:250px"></image>
|
||||
<h3 id="name" style="padding-top: 10px"></h3>
|
||||
<a data-wml-event="github-logout" class="btn btn-primary"><span class="fa fa-github" style="color: #FFF"></span> Logout </a>
|
||||
<a wml-event="github-logout" class="btn btn-primary"><span class="fa fa-github" style="color: #FFF"></span> Logout </a>
|
||||
</div>
|
||||
<script>
|
||||
window.wails.Events.On("wails:oauth:success", (event) => {
|
||||
|
||||
@@ -19,7 +19,7 @@ func main() {
|
||||
Assets: application.AssetOptions{
|
||||
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte(`<html><head><title>Plain Bundle</title></head><body><div class="main"><h1>Plain Bundle</h1><p>This is a plain bundle. It has no frontend code but this was Served by the AssetServer's Handler.</p><br/><br/><p data-wml-event="clicked">Clicking this paragraph emits an event...<p></div></body></html>`))
|
||||
w.Write([]byte(`<html><head><title>Plain Bundle</title></head><body><div class="main"><h1>Plain Bundle</h1><p>This is a plain bundle. It has no frontend code but this was Served by the AssetServer's Handler.</p><br/><br/><p wml-event="clicked">Clicking this paragraph emits an event...<p></div></body></html>`))
|
||||
}),
|
||||
},
|
||||
})
|
||||
|
||||
@@ -40,7 +40,7 @@ require (
|
||||
github.com/samber/lo v1.38.1 // indirect
|
||||
github.com/sergi/go-diff v1.2.0 // indirect
|
||||
github.com/stretchr/testify v1.8.4 // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.8-0.20231010092311-42cbb98eb53b // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.8 // indirect
|
||||
github.com/wailsapp/mimetype v1.4.1 // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.0 // indirect
|
||||
golang.org/x/crypto v0.9.0 // indirect
|
||||
|
||||
@@ -119,6 +119,7 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
|
||||
github.com/wailsapp/go-webview2 v1.0.7 h1:s95+7irJsAsTy1RsjJ6N0cYX7tZ4gP7Uzawds0L2urs=
|
||||
github.com/wailsapp/go-webview2 v1.0.7/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/go-webview2 v1.0.8-0.20231010092311-42cbb98eb53b/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/go-webview2 v1.0.8/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
||||
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
||||
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
|
||||
|
||||
@@ -35,7 +35,7 @@ require (
|
||||
github.com/samber/lo v1.38.1 // indirect
|
||||
github.com/sergi/go-diff v1.2.0 // indirect
|
||||
github.com/stretchr/testify v1.8.4 // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.8-0.20231010092311-42cbb98eb53b // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.8 // indirect
|
||||
github.com/wailsapp/mimetype v1.4.1 // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.0 // indirect
|
||||
golang.org/x/crypto v0.9.0 // indirect
|
||||
|
||||
@@ -106,6 +106,7 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
|
||||
github.com/wailsapp/go-webview2 v1.0.7 h1:s95+7irJsAsTy1RsjJ6N0cYX7tZ4gP7Uzawds0L2urs=
|
||||
github.com/wailsapp/go-webview2 v1.0.7/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/go-webview2 v1.0.8-0.20231010092311-42cbb98eb53b/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/go-webview2 v1.0.8/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
||||
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
||||
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -26,8 +26,8 @@ func main() {
|
||||
|
||||
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
|
||||
Title: "Wails ML Demo",
|
||||
Width: 800,
|
||||
Height: 600,
|
||||
Width: 1280,
|
||||
Height: 1024,
|
||||
Mac: application.MacWindow{
|
||||
Backdrop: application.MacBackdropTranslucent,
|
||||
TitleBar: application.MacTitleBarHiddenInsetUnified,
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The electron alternative for Go
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
|
||||
/* jshint esversion: 9 */
|
||||
|
||||
/**
|
||||
* The Browser API provides methods to interact with the system browser.
|
||||
*/
|
||||
export const Browser = {
|
||||
/**
|
||||
* Opens a browser window to the given URL
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
OpenURL: (url) => {
|
||||
return wails.Browser.OpenURL(url);
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The electron alternative for Go
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
|
||||
/* jshint esversion: 9 */
|
||||
|
||||
import {newRuntimeCallerWithID, objectNames} from "./runtime";
|
||||
|
||||
let call = newRuntimeCallerWithID(objectNames.Browser);
|
||||
|
||||
let BrowserOpenURL = 0;
|
||||
|
||||
/**
|
||||
* Open a browser window to the given URL
|
||||
* @param {string} url - The URL to open
|
||||
*/
|
||||
export function OpenURL(url) {
|
||||
void call(BrowserOpenURL, {url});
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import * as Clipboard from './clipboard';
|
||||
import * as Application from './application';
|
||||
import * as Screens from './screens';
|
||||
import * as System from './system';
|
||||
import * as Browser from './browser';
|
||||
import {Plugin, Call, callErrorCallback, callCallback, CallByID, CallByName} from "./calls";
|
||||
import {clientId} from './runtime';
|
||||
import {newWindow} from "./window";
|
||||
@@ -58,6 +59,7 @@ export function newRuntime(windowName) {
|
||||
},
|
||||
System,
|
||||
Screens,
|
||||
Browser,
|
||||
Call,
|
||||
CallByID,
|
||||
CallByName,
|
||||
|
||||
@@ -23,6 +23,7 @@ export const objectNames = {
|
||||
Window: 6,
|
||||
Screens: 7,
|
||||
System: 8,
|
||||
Browser: 9,
|
||||
}
|
||||
export let clientId = nanoid();
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@ function sendEvent(eventName, data=null) {
|
||||
}
|
||||
|
||||
function addWMLEventListeners() {
|
||||
const elements = document.querySelectorAll('[data-wml-event]');
|
||||
const elements = document.querySelectorAll('[wml-event]');
|
||||
elements.forEach(function (element) {
|
||||
const eventType = element.getAttribute('data-wml-event');
|
||||
const confirm = element.getAttribute('data-wml-confirm');
|
||||
const trigger = element.getAttribute('data-wml-trigger') || "click";
|
||||
const eventType = element.getAttribute('wml-event');
|
||||
const confirm = element.getAttribute('wml-confirm');
|
||||
const trigger = element.getAttribute('wml-trigger') || "click";
|
||||
|
||||
let callback = function () {
|
||||
if (confirm) {
|
||||
@@ -42,11 +42,11 @@ function callWindowMethod(method) {
|
||||
}
|
||||
|
||||
function addWMLWindowListeners() {
|
||||
const elements = document.querySelectorAll('[data-wml-window]');
|
||||
const elements = document.querySelectorAll('[wml-window]');
|
||||
elements.forEach(function (element) {
|
||||
const windowMethod = element.getAttribute('data-wml-window');
|
||||
const confirm = element.getAttribute('data-wml-confirm');
|
||||
const trigger = element.getAttribute('data-wml-trigger') || "click";
|
||||
const windowMethod = element.getAttribute('wml-window');
|
||||
const confirm = element.getAttribute('wml-confirm');
|
||||
const trigger = element.getAttribute('wml-trigger') || "click";
|
||||
|
||||
let callback = function () {
|
||||
if (confirm) {
|
||||
@@ -68,7 +68,35 @@ function addWMLWindowListeners() {
|
||||
});
|
||||
}
|
||||
|
||||
function addWMLOpenBrowserListener() {
|
||||
const elements = document.querySelectorAll('[wml-openurl]');
|
||||
elements.forEach(function (element) {
|
||||
const url = element.getAttribute('wml-openurl');
|
||||
const confirm = element.getAttribute('wml-confirm');
|
||||
const trigger = element.getAttribute('wml-trigger') || "click";
|
||||
|
||||
let callback = function () {
|
||||
if (confirm) {
|
||||
Question({Title: "Confirm", Message:confirm, Buttons:[{Label:"Yes"},{Label:"No", IsDefault:true}]}).then(function (result) {
|
||||
if (result !== "No") {
|
||||
void wails.Browser.OpenURL(url);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
void wails.Browser.OpenURL(url);
|
||||
};
|
||||
|
||||
// Remove existing listeners
|
||||
element.removeEventListener(trigger, callback);
|
||||
|
||||
// Add new listener
|
||||
element.addEventListener(trigger, callback);
|
||||
});
|
||||
}
|
||||
|
||||
export function reloadWML() {
|
||||
addWMLEventListeners();
|
||||
addWMLWindowListeners();
|
||||
addWMLOpenBrowserListener();
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user