A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
fix(cdn): fix cdn path render
kumfo17703c2ed711
diff --git a/internal/controller/template_controller.go b/internal/controller/template_controller.goindex e76a96c0..b484dc4f 100644--- a/internal/controller/template_controller.go+++ b/internal/controller/template_controller.go@@ -70,12 +70,6 @@ func NewTemplateController(}}func GetStyle() (script []string, css string) {- prefix := ""- _ = plugin.CallCDN(func(fn plugin.CDN) error {- prefix = fn.GetStaticPrefix()- return nil- })-file, err := ui.Build.ReadFile("build/index.html")if err != nil {return@@ -84,14 +78,14 @@ func GetStyle() (script []string, css string) {scriptData := scriptRegexp.FindAllStringSubmatch(string(file), -1)for _, s := range scriptData {if len(s) == 2 {- script = append(script, prefix+s[1])+ script = append(script, s[1])}}cssRegexp := regexp.MustCompile(`<link href="(.*)" rel="stylesheet">`)cssListData := cssRegexp.FindStringSubmatch(string(file))if len(cssListData) == 2 {- css = prefix + cssListData[1]+ css = cssListData[1]}return}@@ -511,13 +505,34 @@ func (tc *TemplateController) Page404(ctx *gin.Context) {}func (tc *TemplateController) html(ctx *gin.Context, code int, tpl string, siteInfo *schema.TemplateSiteInfoResp, data gin.H) {+ var (+ prefix = ""+ cssPath = ""+ scriptPath = make([]string, len(tc.scriptPath))+ )++ _ = plugin.CallCDN(func(fn plugin.CDN) error {+ prefix = fn.GetStaticPrefix()+ return nil+ })++ if prefix != "" {+ cssPath = prefix + tc.cssPath+ for i, path := range tc.scriptPath {+ scriptPath[i] = prefix + path+ }+ } else {+ cssPath = tc.cssPath+ scriptPath = tc.scriptPath+ }+data["siteinfo"] = siteInfodata["baseURL"] = ""if parsedUrl, err := url.Parse(siteInfo.General.SiteUrl); err == nil {data["baseURL"] = parsedUrl.Path}- data["scriptPath"] = tc.scriptPath- data["cssPath"] = tc.cssPath+ data["scriptPath"] = scriptPath+ data["cssPath"] = cssPathdata["keywords"] = siteInfo.Keywordsif siteInfo.Description == "" {siteInfo.Description = siteInfo.General.Description