Parcourir la source

移除昨天错误代码

huangrf il y a 6 ans
Parent
commit
acc85eea08
2 fichiers modifiés avec 2 ajouts et 75 suppressions
  1. 0 73
      custom_routers/frontend_router.go
  2. 2 2
      engine/apiengine.go

+ 0 - 73
custom_routers/frontend_router.go

@@ -1,73 +0,0 @@
-package custom_routers
-
-import (
-	"fmt"
-	"git.qianqiusoft.com/qianqiusoft/light-apiengine/engine"
-	sysmodel "git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
-	"github.com/gin-gonic/gin"
-	"strings"
-	"time"
-)
-
-var Domain_String_Cache map[string]string
-var Refresh_Cache_Time int64 = 0
-
-func Register(e *engine.ApiEngine) {
-	ctrl := NewFrontendController(e)
-	e.GinEngine.StaticFile("/", "web/index.html")
-	e.GinEngine.StaticFile("/index.html", "web/index.html")
-
-	//e.GinEngine.StaticFile("/favicon.ico", "web/favicon.ico")
-	e.GinEngine.StaticFile("/config.js", "web/config.js")
-	e.GinEngine.GET("/domains.js", ctrl.GetDomainsJs)
-	e.GinEngine.GET("/favicon.ico", ctrl.GetDomainLogo)
-	e.GinEngine.Static("/static", "web/static")
-
-	Domain_String_Cache = make(map[string]string)
-	go RefreshDomainString(e)
-}
-
-type FrontendController struct {
-	apiengine *engine.ApiEngine
-}
-
-func NewFrontendController(e *engine.ApiEngine) *FrontendController {
-	controller := &FrontendController{e}
-	return controller
-}
-
-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]
-	}
-	ctx.Data(200, "application/javascript", []byte(Domain_String_Cache[req_domain]))
-}
-
-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]
-	}
-	ctx.File("static/domain/" + req_domain + "images/sidebar_logo.png")
-}
-
-func RefreshDomainString(e *engine.ApiEngine) {
-	if time.Now().UnixNano()/int64(time.Second) > 10 {
-		var domain []sysmodel.SysDomain
-		e.PlatformOrmEngine.SQL("select * from sys_domain where del_flag = 0").Find(&domain)
-		for _, v := range domain {
-			domain_js := "window.Domains = {"
-			domain_js += fmt.Sprintf("'%s': {login: '%s', name: '%s', fullName: '%s', title: '%s', theme: '%s'},",
-				v.DomainUrl, v.LoginUrl, v.Name, v.FullName, v.FullName, v.Theme)
-			domain_js += "};"
-			Domain_String_Cache[v.DomainUrl] = domain_js
-		}
-		Refresh_Cache_Time = time.Now().UnixNano() / int64(time.Second)
-	}
-}

+ 2 - 2
engine/apiengine.go

@@ -105,7 +105,7 @@ func (g *ApiEngine) SyncDb(beans ...interface{}) error {
 
 func (g *ApiEngine) Run() {
 	InitDbData(g)
-	//g.GinEngine.StaticFile("/", "web/index.html")
-	//g.GinEngine.Static("/static", "web/static")
+	g.GinEngine.StaticFile("/", "web/index.html")
+	g.GinEngine.Static("/static", "web/static")
 	g.GinEngine.Run(g.listen_addr)
 }