|
|
@@ -5,6 +5,8 @@ import (
|
|
|
"Vali-Tools/utils"
|
|
|
"context"
|
|
|
"fmt"
|
|
|
+ "github.com/wailsapp/wails/v2/pkg/options"
|
|
|
+ "github.com/wailsapp/wails/v2/pkg/runtime"
|
|
|
"os"
|
|
|
"strings"
|
|
|
)
|
|
|
@@ -21,6 +23,8 @@ type App struct {
|
|
|
handlerRequest *handlers.HandlerRequests
|
|
|
}
|
|
|
|
|
|
+var wailsContext *context.Context
|
|
|
+
|
|
|
// NewApp creates a new App application struct
|
|
|
func NewApp() *App {
|
|
|
return &App{}
|
|
|
@@ -29,6 +33,7 @@ func NewApp() *App {
|
|
|
// startup is called when the app starts
|
|
|
func (a *App) startup(ctx context.Context) {
|
|
|
a.ctx = ctx
|
|
|
+ wailsContext = &ctx
|
|
|
a.directoryHandler = handlers.NewDirectoryHandler(ctx)
|
|
|
a.dialogHandler = handlers.NewDialogHandler(ctx)
|
|
|
fmt.Printf("All startup args: %v\n", os.Args)
|
|
|
@@ -51,6 +56,14 @@ func (a *App) startup(ctx context.Context) {
|
|
|
fmt.Printf("获取到了Token信息: %s\n", a.Token)
|
|
|
}
|
|
|
}
|
|
|
+func (a *App) onSecondInstanceLaunch(secondInstanceData options.SecondInstanceData) {
|
|
|
+ secondInstanceArgs := secondInstanceData.Args
|
|
|
+ println("user opened second instance", strings.Join(secondInstanceData.Args, ","))
|
|
|
+ println("user opened second from", secondInstanceData.WorkingDirectory)
|
|
|
+ runtime.WindowUnminimise(*wailsContext)
|
|
|
+ runtime.Show(*wailsContext)
|
|
|
+ go runtime.EventsEmit(*wailsContext, "launchArgs", secondInstanceArgs)
|
|
|
+}
|
|
|
|
|
|
// 解析参数
|
|
|
func (a *App) parsArguments(params string) map[string]string {
|