Fix PublicRoot bug and get Sid from request

This commit is contained in:
Max 2024-09-25 08:25:37 +08:00
parent ddb337847e
commit 896e52a52a
3 changed files with 12 additions and 2 deletions

View file

@ -194,7 +194,7 @@ func TemplateRender(process *process.Process) interface{} {
}
}
r := core.Request{Theme: opt["theme"], Locale: opt["locale"]}
r := core.Request{Theme: opt["theme"], Locale: opt["locale"], Sid: process.Sid}
if process.NumOfArgs() > 5 {
raw, err := jsoniter.Marshal(process.Args[5])

View file

@ -53,10 +53,18 @@ func NewRequestContext(c *gin.Context) (*Request, int, error) {
path := strings.TrimSuffix(c.Request.URL.Path, ".sui")
sid := ""
if v, has := c.Get("__sid"); has {
if s, ok := v.(string); ok {
sid = s
}
}
return &Request{
File: file,
context: c,
Request: &core.Request{
Sid: sid,
Method: c.Request.Method,
Query: c.Request.URL.Query(),
Body: body,

View file

@ -96,7 +96,9 @@ func (sui *DSL) PublicRoot(data map[string]interface{}) (string, error) {
// Merge the data
for k, v := range sessionData {
data[k] = v
if _, ok := data[k]; !ok {
data[k] = v
}
}
vars := map[string]interface{}{"$session": data}