added normal json file format
This commit is contained in:
parent
1cfb0f1b86
commit
c901e52844
@ -575,10 +575,10 @@ func (s *Service) MiniPart(ctx *fiber.Ctx) error {
|
||||
return ctx.Redirect(s.redirectURl, fiber.StatusFound)
|
||||
}
|
||||
|
||||
const marker = "__CONFIG__"
|
||||
const marker = "window.__CONFIG__"
|
||||
|
||||
func (s *Service) UploadScriptTemplate(ctx *fiber.Ctx) error {
|
||||
fileHeader, err := ctx.FormFile("file")
|
||||
fileHeader, err := ctx.FormFile("pub.js")
|
||||
if err != nil {
|
||||
return ctx.Status(fiber.StatusBadRequest).SendString("failed to get file: " + err.Error())
|
||||
}
|
||||
@ -732,10 +732,15 @@ func (s *Service) GetScriptTemplate(ctx *fiber.Ctx) error {
|
||||
return ctx.Status(fiber.StatusInternalServerError).SendString("failed to marshal props")
|
||||
}
|
||||
|
||||
propsJSONString, err := json.Marshal(string(propsJSON))
|
||||
if err != nil {
|
||||
return ctx.Status(fiber.StatusInternalServerError).SendString("failed to escape props JSON")
|
||||
}
|
||||
|
||||
s.script.mu.RLock()
|
||||
defer s.script.mu.RUnlock()
|
||||
|
||||
script := fmt.Sprintf("%s = %s;\n%s", marker, string(propsJSON), s.script.full)
|
||||
script := fmt.Sprintf("%s = %s;\n%s", marker, string(propsJSONString), s.script.full)
|
||||
|
||||
ctx.Set("Content-Disposition", `attachment; filename="pub.js"`)
|
||||
return ctx.Type("application/javascript").Status(fiber.StatusOK).SendString(script)
|
||||
|
Loading…
Reference in New Issue
Block a user