代码拉取完成,页面将自动刷新
同步操作将从 湖南果度科技有限公司/GodoAI 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package main
import (
"context"
"errors"
"os"
"os/exec"
"runtime"
"godoai/cmd"
wruntime "github.com/wailsapp/wails/v2/pkg/runtime"
)
// App struct
type App struct {
ctx context.Context
}
// NewApp creates a new App application struct
func NewApp() *App {
return &App{}
}
// startup is called when the app starts. The context is saved
// so we can call the runtime methods
func (a *App) startup(ctx context.Context) {
a.ctx = ctx
cmd.Start()
}
func (a *App) shutdown(ctx context.Context) {
cmd.Stop()
}
func (a *App) OpenDirDialog() string {
path, err := wruntime.OpenDirectoryDialog(a.ctx, wruntime.OpenDialogOptions{
Title: "Select Folder",
})
if err != nil {
wruntime.LogErrorf(a.ctx, "Error: %+v\n", err)
}
return path
}
func (a *App) RestartApp() error {
name, err := os.Executable()
if err != nil {
return err
}
var cmd *exec.Cmd
switch runtime.GOOS {
case "windows":
cmd = exec.Command(name, os.Args[1:]...)
case "darwin": // macOS
cmd = exec.Command("/usr/bin/open", name)
case "linux":
cmd = exec.Command(name, os.Args[1:]...)
// Optionally, you could use 'xdg-open' or 'gnome-open' etc.
// cmd = exec.Command("/usr/bin/gnome-open", name)
default:
return errors.New("unsupported OS")
}
if cmd != nil {
cmd.Start()
wruntime.Quit(a.ctx)
return nil
}
return errors.New("failed to restart application")
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。