mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-04 02:02:55 +08: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:
parent
263e1b527a
commit
4c75b288bb
@ -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,
|
||||
|
24
v3/internal/runtime/desktop/api/browser.js
Normal file
24
v3/internal/runtime/desktop/api/browser.js
Normal file
@ -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);
|
||||
},
|
||||
};
|
25
v3/internal/runtime/desktop/browser.js
Normal file
25
v3/internal/runtime/desktop/browser.js
Normal file
@ -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
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
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -3,6 +3,7 @@ package application
|
||||
import (
|
||||
"embed"
|
||||
"encoding/json"
|
||||
"github.com/pkg/browser"
|
||||
"io"
|
||||
"log"
|
||||
"log/slog"
|
||||
@ -802,3 +803,11 @@ func (a *App) UnregisterWindow(id uint) {
|
||||
defer a.windowsLock.Unlock()
|
||||
delete(a.windows, id)
|
||||
}
|
||||
|
||||
func (a *App) BrowserOpenURL(url string) error {
|
||||
return browser.OpenURL(url)
|
||||
}
|
||||
|
||||
func (a *App) BrowserOpenFile(path string) error {
|
||||
return browser.OpenFile(path)
|
||||
}
|
||||
|
@ -73,7 +73,7 @@
|
||||
<div>Alpha</div>
|
||||
<div>
|
||||
<p class="button-42" onclick="window.open('https://wailsapp.github.io/wails/')">Documentation</p>
|
||||
<p class="button-42" onclick="window.open('https://wailsapp.github.io/wails/')">Feedback</p>
|
||||
<p class="button-42" onclick="window.open('https://wailsapp.github.io/wails/getting-started/feedback/')">Feedback</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -21,6 +21,7 @@ const (
|
||||
windowRequest = 6
|
||||
screensRequest = 7
|
||||
systemRequest = 8
|
||||
browserRequest = 9
|
||||
)
|
||||
|
||||
type MessageProcessor struct {
|
||||
@ -139,6 +140,8 @@ func (m *MessageProcessor) HandleRuntimeCallWithIDs(rw http.ResponseWriter, r *h
|
||||
m.processCallMethod(method, rw, r, targetWindow, params)
|
||||
case systemRequest:
|
||||
m.processSystemMethod(method, rw, r, targetWindow, params)
|
||||
case browserRequest:
|
||||
m.processBrowserMethod(method, rw, r, targetWindow, params)
|
||||
default:
|
||||
m.httpError(rw, "Unknown runtime call: %d", object)
|
||||
}
|
||||
|
43
v3/pkg/application/messageprocessor_browser.go
Normal file
43
v3/pkg/application/messageprocessor_browser.go
Normal file
@ -0,0 +1,43 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"github.com/pkg/browser"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const (
|
||||
BrowserOpenURL = 0
|
||||
)
|
||||
|
||||
var browserMethods = map[int]string{
|
||||
BrowserOpenURL: "OpenURL",
|
||||
}
|
||||
|
||||
func (m *MessageProcessor) processBrowserMethod(method int, rw http.ResponseWriter, _ *http.Request, _ Window, params QueryParams) {
|
||||
|
||||
args, err := params.Args()
|
||||
if err != nil {
|
||||
m.httpError(rw, "Unable to parse arguments: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
switch method {
|
||||
case BrowserOpenURL:
|
||||
url := args.String("url")
|
||||
if url == nil {
|
||||
m.Error("OpenURL: url is required")
|
||||
return
|
||||
}
|
||||
err := browser.OpenURL(*url)
|
||||
if err != nil {
|
||||
m.Error("OpenURL: %s", err.Error())
|
||||
return
|
||||
}
|
||||
m.ok(rw)
|
||||
m.Info("Runtime Call:", "method", "Browser."+browserMethods[method], "url", *url)
|
||||
default:
|
||||
m.httpError(rw, "Unknown browser method: %d", method)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
@ -32,7 +32,7 @@ func (m *MessageProcessor) dialogErrorCallback(window Window, message string, di
|
||||
}
|
||||
|
||||
func (m *MessageProcessor) dialogCallback(window Window, dialogID *string, result string, isJSON bool) {
|
||||
window.DialogResponse(*dialogID, result)
|
||||
window.DialogResponse(*dialogID, result, isJSON)
|
||||
}
|
||||
|
||||
func (m *MessageProcessor) processDialogMethod(method int, rw http.ResponseWriter, r *http.Request, window Window, params QueryParams) {
|
||||
|
@ -255,9 +255,13 @@ func (w *WebviewWindow) DialogError(dialogID string, result string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WebviewWindow) DialogResponse(dialogID string, result string) {
|
||||
func (w *WebviewWindow) DialogResponse(dialogID string, result string, isJSON bool) {
|
||||
if w.impl != nil {
|
||||
w.impl.execJS(w.formatJS("_wails.dialogCallback('%s', %s, true);", dialogID, result))
|
||||
if isJSON {
|
||||
w.impl.execJS(w.formatJS("_wails.dialogCallback('%s', %s, true);", dialogID, result))
|
||||
} else {
|
||||
w.impl.execJS(fmt.Sprintf("_wails.dialogCallback('%s', '%s', false);", dialogID, result))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ type Callback interface {
|
||||
CallError(callID string, result string)
|
||||
CallResponse(callID string, result string)
|
||||
DialogError(dialogID string, result string)
|
||||
DialogResponse(dialogID string, result string)
|
||||
DialogResponse(dialogID string, result string, isJSON bool)
|
||||
}
|
||||
|
||||
type Window interface {
|
||||
|
Loading…
Reference in New Issue
Block a user