feat: Add sourceRoots to Static struct in types.go

This commit is contained in:
Max 2024-08-01 18:16:59 +08:00
parent 681b3f9514
commit fc1f80e0f5
3 changed files with 6 additions and 2 deletions

View file

@ -98,6 +98,7 @@ type Moapi struct {
// Static setting // Static setting
type Static struct { type Static struct {
Rewrite []map[string]string `json:"rewrite,omitempty"` Rewrite []map[string]string `json:"rewrite,omitempty"`
SourceRoots map[string]string `json:"sourceRoots,omitempty"`
} }
// AppStorage 应用存储 // AppStorage 应用存储

View file

@ -270,7 +270,7 @@ func (r *Request) MakeCache() (*core.Cache, int, error) {
} }
// Backend script // Backend script
script, err := core.LoadScript(r.File) script, err := core.LoadScript(r.File, true)
if err != nil { if err != nil {
return nil, 500, fmt.Errorf("script error, please re-complie the page %s", err.Error()) return nil, 500, fmt.Errorf("script error, please re-complie the page %s", err.Error())
} }

View file

@ -10,6 +10,7 @@ import (
"github.com/yaoapp/gou/application" "github.com/yaoapp/gou/application"
v8 "github.com/yaoapp/gou/runtime/v8" v8 "github.com/yaoapp/gou/runtime/v8"
"github.com/yaoapp/gou/runtime/v8/bridge" "github.com/yaoapp/gou/runtime/v8/bridge"
"github.com/yaoapp/yao/share"
) )
// Scripts loaded scripts // Scripts loaded scripts
@ -81,6 +82,8 @@ func LoadScript(file string, disableCache ...bool) (*Script, error) {
return nil, err return nil, err
} }
v8script.SourceRoots = share.App.Static.SourceRoots
script := &Script{Script: v8script} script := &Script{Script: v8script}
chScript <- &scriptData{base, script, saveScript} chScript <- &scriptData{base, script, saveScript}
return script, nil return script, nil