Perf: optimize echarts plugin warnf content

This commit is contained in:
Cell
2025-04-29 15:39:54 +08:00
parent 0cf0d4f4e7
commit 9c8c0b6dee
4 changed files with 23 additions and 9 deletions
@@ -1,2 +1,8 @@
{{- dict "Options" .Attributes "Inner" .Inner "Resources" .Page.Resources | partial "plugin/echarts.html" -}}
{{- dict
"Options" .Attributes
"Inner" .Inner
"Resources" .Page.Resources
"Position" .Position
| partial "plugin/echarts.html"
-}}
{{- .Page.Store.Set "hasEcharts" true -}}
+1 -1
View File
@@ -1,4 +1,4 @@
{{- .Scratch.Set "version" "v0.3.20-6eb582fe" -}}
{{- .Scratch.Set "version" "v0.3.20-0cf0d4f4" -}}
{{- .Scratch.Set "this" dict -}}
{{- partial "init/detection-env.html" . -}}
+8 -6
View File
@@ -16,23 +16,25 @@
{{- $content = replaceRE `[\s]+` " " $content -}}
{{- end -}}
{{- if not $content -}}
{{- warnf "ECharts JS Code is empty, please check the content." -}}
{{- warnf "ECharts: JS Code is empty, executing in file %s" $.Position -}}
{{- end -}}
<template data-fmt="js" data-async="{{ $async }}">{{ $content | safeJS }}</template>
{{- else -}}
{{ with $data }}
{{- $content = index site.Data.echarts . -}}
{{- if not $content -}}
{{- warnf "ECharts data not found, please ensure the data file \"/data/echarts/%s.{json|yml|yaml|toml}\" exists." . -}}
{{- warnf "ECharts: data not found, please ensure the data file \"data/echarts/%s.{json|yml|yaml|toml}\" exists." . -}}
{{- end -}}
{{- else -}}
{{- with dict "Path" $file "Resources" .Resources | partial "function/resource.html" }}
{{- $content = .Content -}}
{{- end }}
{{- $content = $content | transform.Unmarshal -}}
{{- if not $content -}}
{{- warnf "ECharts option is empty, please check the content." -}}
{{- else with $file -}}
{{- warnf "ECharts: no such data file: %s" . -}}
{{- end -}}
{{- $content = $content | transform.Unmarshal -}}
{{- end -}}
{{- if not $content -}}
{{- warnf "ECharts: option is empty, executing in file %s" $.Position -}}
{{- end -}}
<template>{{ $content | jsonify }}</template>
{{- end -}}
+7 -1
View File
@@ -4,5 +4,11 @@
{{- $options = .Get "async" | default false | dict "async" | merge $options -}}
{{- $options = .Get "data" | dict "data" | merge $options -}}
{{- $options = .Get "file" | dict "file" | merge $options -}}
{{- dict "Options" $options "Inner" .Inner "Resources" .Page.Resources | partial "plugin/echarts.html" -}}
{{- dict
"Options" $options
"Inner" .Inner
"Resources" .Page.Resources
"Position" .Position
| partial "plugin/echarts.html"
-}}
{{- .Page.Store.Set "hasEcharts" true -}}