Add AfterLoad process execution in Load and Reload functions
This commit is contained in:
parent
64c6602beb
commit
0703743e72
2 changed files with 35 additions and 3 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"github.com/fatih/color"
|
||||
"github.com/yaoapp/gou/application"
|
||||
"github.com/yaoapp/gou/process"
|
||||
"github.com/yaoapp/kun/exception"
|
||||
"github.com/yaoapp/yao/aigc"
|
||||
"github.com/yaoapp/yao/api"
|
||||
|
|
@ -184,7 +185,7 @@ func Load(cfg config.Config) (err error) {
|
|||
// Load Neo
|
||||
err = neo.Load(cfg)
|
||||
if err != nil {
|
||||
printErr(cfg.Mode, "AIGC", err)
|
||||
printErr(cfg.Mode, "Neo", err)
|
||||
}
|
||||
|
||||
// Load Custom Widget
|
||||
|
|
@ -217,6 +218,21 @@ func Load(cfg config.Config) (err error) {
|
|||
printErr(cfg.Mode, "Pipe", err)
|
||||
}
|
||||
|
||||
// Execute AfterLoad Process if exists
|
||||
if share.App.AfterLoad != "" {
|
||||
p, err := process.Of(share.App.AfterLoad, false)
|
||||
if err != nil {
|
||||
printErr(cfg.Mode, "AfterLoad", err)
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = p.Exec()
|
||||
if err != nil {
|
||||
printErr(cfg.Mode, "AfterLoad", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -392,7 +408,22 @@ func Reload(cfg config.Config) (err error) {
|
|||
// Load Neo
|
||||
err = neo.Load(cfg)
|
||||
if err != nil {
|
||||
printErr(cfg.Mode, "AIGC", err)
|
||||
printErr(cfg.Mode, "Neo", err)
|
||||
}
|
||||
|
||||
// Execute AfterLoad Process if exists
|
||||
if share.App.AfterLoad != "" {
|
||||
p, err := process.Of(share.App.AfterLoad, true)
|
||||
if err != nil {
|
||||
printErr(cfg.Mode, "AfterLoad", err)
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = p.Exec()
|
||||
if err != nil {
|
||||
printErr(cfg.Mode, "AfterLoad", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -83,7 +83,8 @@ type AppInfo struct {
|
|||
AdminRoot string `json:"adminRoot,omitempty"`
|
||||
Static Static `json:"public,omitempty"`
|
||||
Optional map[string]interface{} `json:"optional,omitempty"`
|
||||
Moapi Moapi `json:"moapi"`
|
||||
Moapi Moapi `json:"moapi,omitempty"`
|
||||
AfterLoad string `json:"afterLoad,omitempty"` // Process executed after the app is loaded
|
||||
}
|
||||
|
||||
// Moapi AIGC App Store API
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue