首页跳转语言可配置

pull/23/head
陶士涵 4 years ago
parent ae81ce0f85
commit 4432cb7012

@ -109,6 +109,7 @@ CREATE TABLE `config` (
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '是否开启Server酱微信提醒', 'NoticeServerJiang', 'false')|
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'Server酱API', 'ServerJiangAPI', '')|
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '微信小程序Token', 'WeixinToken', '')|
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '首页跳转语言', 'JumpLang', 'cn')|
DROP TABLE IF EXISTS `about`|
CREATE TABLE `about` (

@ -2,29 +2,13 @@ package controller
import (
"github.com/gin-gonic/gin"
"github.com/taoshihan1991/imaptool/tools"
"net/http"
"github.com/taoshihan1991/imaptool/models"
)
func Index(c *gin.Context) {
c.Redirect(302, "/index_en")
}
//首页跳转
func ActionIndex(w http.ResponseWriter, r *http.Request) {
if r.URL.RequestURI() == "/favicon.ico" {
return
}
mailServer := tools.GetMailServerFromCookie(r)
if mailServer == nil {
http.Redirect(w, r, "/login", 302)
} else {
res := tools.CheckEmailPassword(mailServer.Server, mailServer.Email, mailServer.Password)
if res {
http.Redirect(w, r, "/main", 302)
} else {
http.Redirect(w, r, "/login", 302)
}
jump := models.FindConfig("JumpLang")
if jump != "cn" {
jump = "en"
}
c.Redirect(302, "/index_"+jump)
}

Loading…
Cancel
Save