mirror of
https://github.com/taigrr/wails.git
synced 2026-04-17 04:05:12 -07:00
Compare commits
2 Commits
v2.0.0-alp
...
v2.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ac4990f89 | ||
|
|
509c70a97c |
@@ -1,3 +1,3 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
var version = "v2.0.0-alpha.67"
|
var version = "v2.0.0-alpha.68"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ require (
|
|||||||
github.com/leaanthony/clir v1.0.4
|
github.com/leaanthony/clir v1.0.4
|
||||||
github.com/leaanthony/debme v1.2.1
|
github.com/leaanthony/debme v1.2.1
|
||||||
github.com/leaanthony/go-ansi-parser v1.0.1
|
github.com/leaanthony/go-ansi-parser v1.0.1
|
||||||
github.com/leaanthony/go-common-file-dialog v1.0.2
|
github.com/leaanthony/go-common-file-dialog v1.0.3
|
||||||
github.com/leaanthony/gosod v1.0.1
|
github.com/leaanthony/gosod v1.0.1
|
||||||
github.com/leaanthony/slicer v1.5.0
|
github.com/leaanthony/slicer v1.5.0
|
||||||
github.com/leaanthony/webview2runtime v1.1.0
|
github.com/leaanthony/webview2runtime v1.1.0
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oO
|
|||||||
github.com/leaanthony/debme v1.2.1/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA=
|
github.com/leaanthony/debme v1.2.1/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA=
|
||||||
github.com/leaanthony/go-ansi-parser v1.0.1 h1:97v6c5kYppVsbScf4r/VZdXyQ21KQIfeQOk2DgKxGG4=
|
github.com/leaanthony/go-ansi-parser v1.0.1 h1:97v6c5kYppVsbScf4r/VZdXyQ21KQIfeQOk2DgKxGG4=
|
||||||
github.com/leaanthony/go-ansi-parser v1.0.1/go.mod h1:7arTzgVI47srICYhvgUV4CGd063sGEeoSlych5yeSPM=
|
github.com/leaanthony/go-ansi-parser v1.0.1/go.mod h1:7arTzgVI47srICYhvgUV4CGd063sGEeoSlych5yeSPM=
|
||||||
github.com/leaanthony/go-common-file-dialog v1.0.2 h1:uJ2zXCxP4GwbpR/k/y6unuNbSJn3WTjt4rvHolX3Eys=
|
github.com/leaanthony/go-common-file-dialog v1.0.3 h1:O0uGjKnWtdEADGrkg+TyAAbZylykMwwx/MNEXn9fp+Y=
|
||||||
github.com/leaanthony/go-common-file-dialog v1.0.2/go.mod h1:TGhEc9eSJgRsupZ+iH1ZgAOnEo9zp05cRH2j08RPrF0=
|
github.com/leaanthony/go-common-file-dialog v1.0.3/go.mod h1:TGhEc9eSJgRsupZ+iH1ZgAOnEo9zp05cRH2j08RPrF0=
|
||||||
github.com/leaanthony/gosod v1.0.1 h1:F+4c3DmEBfigi7oAswCV2RpQ+k4DcNbhuCZUGdBHacQ=
|
github.com/leaanthony/gosod v1.0.1 h1:F+4c3DmEBfigi7oAswCV2RpQ+k4DcNbhuCZUGdBHacQ=
|
||||||
github.com/leaanthony/gosod v1.0.1/go.mod h1:W8RyeSFBXu7RpIxPGEJfW4moSyGGEjlJMLV25wEbAdU=
|
github.com/leaanthony/gosod v1.0.1/go.mod h1:W8RyeSFBXu7RpIxPGEJfW4moSyGGEjlJMLV25wEbAdU=
|
||||||
github.com/leaanthony/slicer v1.5.0 h1:aHYTN8xbCCLxJmkNKiLB6tgcMARl4eWmH9/F+S/0HtY=
|
github.com/leaanthony/slicer v1.5.0 h1:aHYTN8xbCCLxJmkNKiLB6tgcMARl4eWmH9/F+S/0HtY=
|
||||||
|
|||||||
@@ -139,10 +139,6 @@ func convertFilters(filters []dialog.FileFilter) []cfd.FileFilter {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func userCancelled(err error) bool {
|
|
||||||
return err.Error() == "cancelled by user"
|
|
||||||
}
|
|
||||||
|
|
||||||
// OpenFileDialog will open a dialog with the given title and filter
|
// OpenFileDialog will open a dialog with the given title and filter
|
||||||
func (c *Client) OpenFileDialog(options *dialog.OpenDialog, callbackID string) {
|
func (c *Client) OpenFileDialog(options *dialog.OpenDialog, callbackID string) {
|
||||||
config := cfd.DialogConfig{
|
config := cfd.DialogConfig{
|
||||||
@@ -162,16 +158,11 @@ func (c *Client) OpenFileDialog(options *dialog.OpenDialog, callbackID string) {
|
|||||||
}
|
}
|
||||||
}(thisdialog)
|
}(thisdialog)
|
||||||
result, err := thisdialog.ShowAndGetResult()
|
result, err := thisdialog.ShowAndGetResult()
|
||||||
if err != nil && !userCancelled(err) {
|
if err != nil && err != cfd.ErrorCancelled {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
resultJSON, err := json.Marshal([]string{result})
|
dispatcher.DispatchMessage("DO" + callbackID + "|" + result)
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
dispatcher.DispatchMessage("DO" + callbackID + "|" + string(resultJSON))
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenDirectoryDialog will open a dialog with the given title and filter
|
// OpenDirectoryDialog will open a dialog with the given title and filter
|
||||||
@@ -193,11 +184,10 @@ func (c *Client) OpenDirectoryDialog(dialogOptions *dialog.OpenDialog, callbackI
|
|||||||
}
|
}
|
||||||
}(thisDialog)
|
}(thisDialog)
|
||||||
result, err := thisDialog.ShowAndGetResult()
|
result, err := thisDialog.ShowAndGetResult()
|
||||||
if err != nil && !userCancelled(err) {
|
if err != nil && err != cfd.ErrorCancelled {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
resultJSON, err := json.Marshal(result)
|
dispatcher.DispatchMessage("DD" + callbackID + "|" + result)
|
||||||
dispatcher.DispatchMessage("DD" + callbackID + "|" + string(resultJSON))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenMultipleFilesDialog will open a dialog with the given title and filter
|
// OpenMultipleFilesDialog will open a dialog with the given title and filter
|
||||||
@@ -221,7 +211,7 @@ func (c *Client) OpenMultipleFilesDialog(dialogOptions *dialog.OpenDialog, callb
|
|||||||
}
|
}
|
||||||
}(thisdialog)
|
}(thisdialog)
|
||||||
result, err := thisdialog.ShowAndGetResults()
|
result, err := thisdialog.ShowAndGetResults()
|
||||||
if err != nil && !userCancelled(err) {
|
if err != nil && err != cfd.ErrorCancelled {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
resultJSON, err := json.Marshal(result)
|
resultJSON, err := json.Marshal(result)
|
||||||
@@ -249,7 +239,7 @@ func (c *Client) SaveDialog(dialogOptions *dialog.SaveDialog, callbackID string)
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
result, err := saveDialog.GetResult()
|
result, err := saveDialog.GetResult()
|
||||||
if err != nil && !userCancelled(err) {
|
if err != nil && err != cfd.ErrorCancelled {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
dispatcher.DispatchMessage("DS" + callbackID + "|" + result)
|
dispatcher.DispatchMessage("DS" + callbackID + "|" + result)
|
||||||
|
|||||||
@@ -32,21 +32,11 @@ func dialogMessageParser(message string) (*parsedMessage, error) {
|
|||||||
|
|
||||||
switch dialogType {
|
switch dialogType {
|
||||||
case 'O':
|
case 'O':
|
||||||
var data string
|
|
||||||
topic = "dialog:openselected:" + callbackID
|
topic = "dialog:openselected:" + callbackID
|
||||||
err := json.Unmarshal([]byte(payloadData), &data)
|
responseMessage = &parsedMessage{Topic: topic, Data: payloadData}
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
responseMessage = &parsedMessage{Topic: topic, Data: data}
|
|
||||||
case 'D':
|
case 'D':
|
||||||
var data string
|
|
||||||
topic = "dialog:opendirectoryselected:" + callbackID
|
topic = "dialog:opendirectoryselected:" + callbackID
|
||||||
err := json.Unmarshal([]byte(payloadData), &data)
|
responseMessage = &parsedMessage{Topic: topic, Data: payloadData}
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
responseMessage = &parsedMessage{Topic: topic, Data: data}
|
|
||||||
case '*':
|
case '*':
|
||||||
var data []string
|
var data []string
|
||||||
topic = "dialog:openmultipleselected:" + callbackID
|
topic = "dialog:openmultipleselected:" + callbackID
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ func newDialog(bus *servicebus.ServiceBus) Dialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// processTitleAndFilter return the title and filter from the given params.
|
// processTitleAndFilter return the title and filter from the given params.
|
||||||
// title is the first string, filter is the second
|
// title is the first string, filter is the second
|
||||||
func (r *dialog) processTitleAndFilter(params ...string) (string, string) {
|
func (r *dialog) processTitleAndFilter(params ...string) (string, string) {
|
||||||
@@ -94,13 +93,7 @@ func (r *dialog) OpenFile(dialogOptions *dialogoptions.OpenDialog) (string, erro
|
|||||||
// Delete subscription to response topic
|
// Delete subscription to response topic
|
||||||
r.bus.UnSubscribe(responseTopic)
|
r.bus.UnSubscribe(responseTopic)
|
||||||
|
|
||||||
files := result.Data().([]string)
|
return result.Data().(string), nil
|
||||||
res := ""
|
|
||||||
if len(files) > 0 {
|
|
||||||
res = files[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
return res, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenMultipleFiles prompts the user to select a file
|
// OpenMultipleFiles prompts the user to select a file
|
||||||
|
|||||||
Reference in New Issue
Block a user