|
|
@@ -4,8 +4,8 @@ import (
|
|
|
"fmt"
|
|
|
"git.qianqiusoft.com/qianqiusoft/light-apiengine/engine"
|
|
|
sysmodel "git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
|
|
|
+ sysutils "git.qianqiusoft.com/qianqiusoft/light-apiengine/utils"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
- "strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
@@ -39,22 +39,29 @@ func NewFrontendController(e *engine.ApiEngine) *FrontendController {
|
|
|
func (c *FrontendController) GetDomainsJs(ctx *gin.Context) {
|
|
|
|
|
|
go RefreshDomainString(c.apiengine)
|
|
|
- req_domain := ctx.Request.Host
|
|
|
- n := strings.Index(req_domain, ":")
|
|
|
- if n > 0 {
|
|
|
- req_domain = req_domain[0:n]
|
|
|
+ hostnames := sysutils.GetHostnames(ctx)
|
|
|
+
|
|
|
+ for i := range hostnames {
|
|
|
+ hostname := hostnames[i]
|
|
|
+ if v, ok := Domain_String_Cache[hostname]; ok {
|
|
|
+ ctx.Data(200, "application/javascript", []byte(v))
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
- ctx.Data(200, "application/javascript", []byte(Domain_String_Cache[req_domain]))
|
|
|
+ ctx.Data(200, "application/javascript", []byte(`window.Domains = {}`))
|
|
|
}
|
|
|
|
|
|
func (c *FrontendController) GetDomainLogo(ctx *gin.Context) {
|
|
|
go RefreshDomainString(c.apiengine)
|
|
|
- req_domain := ctx.Request.Host
|
|
|
- n := strings.Index(req_domain, ":")
|
|
|
- if n > 0 {
|
|
|
- req_domain = req_domain[0:n]
|
|
|
+ hostnames := sysutils.GetHostnames(ctx)
|
|
|
+ for i := range hostnames{
|
|
|
+ logoFile := "web/static/domain/" + hostnames[i] + "/images/sidebar_logo.png"
|
|
|
+ if sysutils.Exists(logoFile){
|
|
|
+ ctx.File(logoFile)
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
- ctx.File("static/domain/" + req_domain + "images/sidebar_logo.png")
|
|
|
+ ctx.File("web/static/domain/default/images/sidebar_logo.png")
|
|
|
}
|
|
|
|
|
|
func RefreshDomainString(e *engine.ApiEngine) {
|