Merge pull request #715 from trheyi/main
Optimize SUI core to load script with disableCache option
This commit is contained in:
commit
2efe1b5836
2 changed files with 8 additions and 4 deletions
|
|
@ -266,6 +266,7 @@ func (parser *TemplateParser) parseElementComponent(sel *goquery.Selection) {
|
|||
if _, exist := sel.Attr("json-attr-" + attr.Key); exist {
|
||||
val = ValueJSON(attr.Val)
|
||||
}
|
||||
key = ToCamelCase(key)
|
||||
props[key] = val
|
||||
}
|
||||
}
|
||||
|
|
@ -276,7 +277,7 @@ func (parser *TemplateParser) parseElementComponent(sel *goquery.Selection) {
|
|||
if parser.option.Imports != nil {
|
||||
if route, has := parser.option.Imports[com]; has {
|
||||
file := filepath.Join(string(os.PathSeparator), "public", parser.option.Root, route)
|
||||
script, err = LoadScript(file)
|
||||
script, err = LoadScript(file, parser.disableCache())
|
||||
if err != nil {
|
||||
parser.errors = append(parser.errors, err)
|
||||
setError(sel, err)
|
||||
|
|
|
|||
|
|
@ -52,11 +52,14 @@ func scriptWriter() {
|
|||
}
|
||||
|
||||
// LoadScript load the script
|
||||
func LoadScript(file string) (*Script, error) {
|
||||
func LoadScript(file string, disableCache ...bool) (*Script, error) {
|
||||
|
||||
base := strings.TrimSuffix(strings.TrimSuffix(file, ".sui"), ".jit")
|
||||
if script, has := Scripts[base]; has {
|
||||
return script, nil
|
||||
// LOAD FROM CACHE
|
||||
if disableCache == nil || !disableCache[0] {
|
||||
if script, has := Scripts[base]; has {
|
||||
return script, nil
|
||||
}
|
||||
}
|
||||
|
||||
file = base + ".ts"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue