asticode / go-astilectron

Build cross platform GUI apps with GO and HTML/JS/CSS (powered by Electron)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to catch the log info from vue?

heliping opened this issue · comments

like the console.log()?
I only can debug after build the app.
Is there other way to debug?

cannot open the dev tools .

`var (
AppName string
BuiltAt string
VersionAstilectron string
VersionElectron string
)

// Application Vars
var (
fs = flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
//debug = fs.Bool("d", false, "enables the debug mode")
w *astilectron.Window
)

func main() {
var w *astilectron.Window
//初始化数据库
models.Init()
// Create logger
l := log.New(log.Writer(), log.Prefix(), log.Flags())
// Parse flags
fs.Parse(os.Args[1:])
//日志
logs.InitLogger()
// Run bootstrap
logs.SLogger.Infof("Running app built at %s\n", BuiltAt)
if err := bootstrap.Run(bootstrap.Options{
Asset: Asset,
AssetDir: AssetDir,
AstilectronOptions: astilectron.Options{
AppName: AppName,
AppIconDarwinPath: "mmqfront/dist/icon.icns",
AppIconDefaultPath: "mmqfront/dist/icon.png",
SingleInstance: true,
VersionAstilectron: VersionAstilectron,
VersionElectron: VersionElectron,
},
Debug: true, //*debug,
Logger: l,
OnWait: func(_ *astilectron.Astilectron, ws []*astilectron.Window, _ *astilectron.Menu, _ *astilectron.Tray, _ *astilectron.Menu) error {
w = ws[0]
return nil
},
ResourcesPath: "mmqfront/dist",
RestoreAssets: RestoreAssets,
Windows: []*bootstrap.Window{{
Homepage: "index.html",
Adapter: func(i *astilectron.Window) {
w = i
},
MessageHandler: message.HandleMessages,
Options: &astilectron.WindowOptions{
BackgroundColor: astikit.StrPtr("#fff"),
Center: astikit.BoolPtr(true),
Height: astikit.IntPtr(900),
Width: astikit.IntPtr(900),
},
}},
}); err != nil {
logs.SLogger.Infof(fmt.Errorf("running bootstrap failed: %w", err).Error())
}
time.Sleep(2 * time.Second)
w.OpenDevTools()
}`

image

You should try running w.OpenDevTools() in the OnWait attribute