mirror of https://github.com/ouqiang/gocron
安装系统页面,不显示导航栏
parent
d3d7350fc7
commit
ebb5139a7b
|
@ -1,10 +1,12 @@
|
||||||
[](https://travis-ci.org/ouqiang/gocron)
|
[](https://travis-ci.org/ouqiang/gocron)
|
||||||
# gocron - 定时任务web管理系统
|
# gocron - 定时任务web管理系统
|
||||||
|
|
||||||
|
# 项目简介
|
||||||
|
使用Go语言开发的定时任务集中调度和管理系统, 用于替代Linux-crontab
|
||||||
|
|
||||||
## 功能特性
|
## 功能特性
|
||||||
* 定时任务统一调度和管理
|
|
||||||
* 支持任务CURD
|
* 支持任务CURD
|
||||||
* crontab时间表达式,支持秒级任务定义
|
* crontab时间表达式,可精确到每秒
|
||||||
* 任务执行失败重试设置
|
* 任务执行失败重试设置
|
||||||
* 任务超时设置
|
* 任务超时设置
|
||||||
* 任务执行方式
|
* 任务执行方式
|
||||||
|
|
|
@ -101,6 +101,7 @@ func writeConfig(form InstallForm) error {
|
||||||
"db.prefix": form.DbTablePrefix,
|
"db.prefix": form.DbTablePrefix,
|
||||||
"db.charset": "utf8",
|
"db.charset": "utf8",
|
||||||
"allow_ips" : "",
|
"allow_ips" : "",
|
||||||
|
"app.name": "定时任务管理系统", // 应用名称
|
||||||
}
|
}
|
||||||
|
|
||||||
return setting.Write(dbConfig, app.AppConfig)
|
return setting.Write(dbConfig, app.AppConfig)
|
||||||
|
|
|
@ -16,7 +16,6 @@ import (
|
||||||
"github.com/ouqiang/gocron/routers/user"
|
"github.com/ouqiang/gocron/routers/user"
|
||||||
"github.com/go-macaron/gzip"
|
"github.com/go-macaron/gzip"
|
||||||
"github.com/ouqiang/gocron/routers/manage"
|
"github.com/ouqiang/gocron/routers/manage"
|
||||||
"github.com/go-macaron/csrf"
|
|
||||||
"github.com/ouqiang/gocron/routers/loginlog"
|
"github.com/ouqiang/gocron/routers/loginlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -139,12 +138,15 @@ func RegisterMiddleware(m *macaron.Macaron) {
|
||||||
Provider: "file",
|
Provider: "file",
|
||||||
ProviderConfig: app.DataDir + "/sessions",
|
ProviderConfig: app.DataDir + "/sessions",
|
||||||
}))
|
}))
|
||||||
m.Use(csrf.Csrfer())
|
|
||||||
m.Use(toolbox.Toolboxer(m))
|
m.Use(toolbox.Toolboxer(m))
|
||||||
checkAppInstall(m)
|
checkAppInstall(m)
|
||||||
ipAuth(m)
|
m.Use(func(ctx *macaron.Context, sess session.Store){
|
||||||
userAuth(m)
|
if app.Installed {
|
||||||
setShareData(m)
|
ipAuth(ctx)
|
||||||
|
userAuth(ctx, sess)
|
||||||
|
setShareData(ctx, sess)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 系统未安装,重定向到安装页面
|
// 系统未安装,重定向到安装页面
|
||||||
|
@ -161,22 +163,21 @@ func checkAppInstall(m *macaron.Macaron) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// IP验证, 通过反向代理访问gocron,需设置Header X-Real-IP才能获取到客户端真实IP
|
// IP验证, 通过反向代理访问gocron,需设置Header X-Real-IP才能获取到客户端真实IP
|
||||||
func ipAuth(m *macaron.Macaron) {
|
func ipAuth(ctx *macaron.Context) {
|
||||||
m.Use(func(ctx *macaron.Context) {
|
|
||||||
allowIpsStr := app.Setting.Key("allow_ips").String()
|
allowIpsStr := app.Setting.Key("allow_ips").String()
|
||||||
if allowIpsStr == "" {
|
if allowIpsStr == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
clientIp := ctx.RemoteAddr()
|
clientIp := ctx.RemoteAddr()
|
||||||
|
allowIps := strings.Split(allowIpsStr, ",")
|
||||||
if !utils.InStringSlice(allowIps, clientIp) {
|
if !utils.InStringSlice(allowIps, clientIp) {
|
||||||
|
logger.Warnf("非法IP访问-%s", clientIp)
|
||||||
ctx.Status(403)
|
ctx.Status(403)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户认证
|
// 用户认证
|
||||||
func userAuth(m *macaron.Macaron) {
|
func userAuth(ctx *macaron.Context, sess session.Store) {
|
||||||
m.Use(func(ctx *macaron.Context, sess session.Store) {
|
|
||||||
if user.IsLogin(sess) {
|
if user.IsLogin(sess) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -192,12 +193,10 @@ func userAuth(m *macaron.Macaron) {
|
||||||
if !found {
|
if !found {
|
||||||
ctx.Redirect("/user/login")
|
ctx.Redirect("/user/login")
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置共享数据
|
// 设置共享数据
|
||||||
func setShareData(m *macaron.Macaron) {
|
func setShareData(ctx *macaron.Context, sess session.Store) {
|
||||||
m.Use(func(ctx *macaron.Context, sess session.Store) {
|
|
||||||
ctx.Data["URI"] = ctx.Req.URL.Path
|
ctx.Data["URI"] = ctx.Req.URL.Path
|
||||||
urlPath := strings.TrimPrefix(ctx.Req.URL.Path, "/")
|
urlPath := strings.TrimPrefix(ctx.Req.URL.Path, "/")
|
||||||
paths := strings.Split(urlPath, "/")
|
paths := strings.Split(urlPath, "/")
|
||||||
|
@ -211,7 +210,7 @@ func setShareData(m *macaron.Macaron) {
|
||||||
}
|
}
|
||||||
ctx.Data["LoginUsername"] = user.Username(sess)
|
ctx.Data["LoginUsername"] = user.Username(sess)
|
||||||
ctx.Data["LoginUid"] = user.Uid(sess)
|
ctx.Data["LoginUid"] = user.Uid(sess)
|
||||||
})
|
ctx.Data["AppName"] = app.Setting.Key("app.name").String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func isAjaxRequest(ctx *macaron.Context) bool {
|
func isAjaxRequest(ctx *macaron.Context) bool {
|
||||||
|
|
|
@ -29,11 +29,12 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
|
{{{if not .DisableNav}}}
|
||||||
<!--header begin-->
|
<!--header begin-->
|
||||||
<header>
|
<header>
|
||||||
<div class="bigcontainer">
|
<div class="bigcontainer">
|
||||||
<div id="logo">
|
<div id="logo">
|
||||||
定时任务管理平台
|
{{{.AppName}}}
|
||||||
</div>
|
</div>
|
||||||
<div class="user">
|
<div class="user">
|
||||||
<div class="ui inline labeled icon top right pointing dropdown">
|
<div class="ui inline labeled icon top right pointing dropdown">
|
||||||
|
@ -69,3 +70,4 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{{end}}}
|
|
@ -2,17 +2,7 @@
|
||||||
|
|
||||||
<div class="ui grid">
|
<div class="ui grid">
|
||||||
{{{ template "install/menu" . }}}
|
{{{ template "install/menu" . }}}
|
||||||
<div class="twelve wide column">
|
<div class="ten wide column">
|
||||||
<div class="pageHeader">
|
|
||||||
<div class="segment">
|
|
||||||
<h3 class="ui dividing header">
|
|
||||||
<i class="large add icon"></i>
|
|
||||||
<div class="content">
|
|
||||||
安装gocron
|
|
||||||
</div>
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<form class="ui form">
|
<form class="ui form">
|
||||||
<div class="ui blue center aligned segment">
|
<div class="ui blue center aligned segment">
|
||||||
<p>数据库配置</p>
|
<p>数据库配置</p>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="verticalMenu">
|
<div class="verticalMenu">
|
||||||
<div class="ui vertical pointing menu fluid">
|
<div class="ui vertical pointing menu fluid">
|
||||||
<a class="active teal item" href="/install">
|
<a class="active teal item" href="/install">
|
||||||
<i class="linux icon"></i> 安装
|
<i class="chevron right icon"></i> 安装
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue