mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
🎨 访问授权页支持多语言 https://github.com/siyuan-note/siyuan/issues/6824
This commit is contained in:
parent
442c675be0
commit
f5943cac15
7 changed files with 53 additions and 11 deletions
|
|
@ -17,7 +17,9 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
|
|
@ -267,6 +269,27 @@ func serveCheckAuth(c *gin.Context) {
|
|||
c.Status(500)
|
||||
return
|
||||
}
|
||||
|
||||
tpl, err := template.New("auth").Parse(string(data))
|
||||
if nil != err {
|
||||
logging.LogErrorf("parse auth page failed: %s", err)
|
||||
c.Status(500)
|
||||
return
|
||||
}
|
||||
|
||||
model := map[string]interface{}{
|
||||
"l0": model.Conf.Language(173),
|
||||
"l1": model.Conf.Language(174),
|
||||
"l2": template.HTML(model.Conf.Language(172)),
|
||||
"l3": model.Conf.Language(175),
|
||||
}
|
||||
buf := &bytes.Buffer{}
|
||||
if err = tpl.Execute(buf, model); nil != err {
|
||||
logging.LogErrorf("execute auth page failed: %s", err)
|
||||
c.Status(500)
|
||||
return
|
||||
}
|
||||
data = buf.Bytes()
|
||||
c.Data(http.StatusOK, "text/html; charset=utf-8", data)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue