mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
This commit is contained in:
@@ -32,4 +32,6 @@ task:
|
||||
workers: 4
|
||||
other:
|
||||
tmppath: "/tmp"
|
||||
version: 0.4.1
|
||||
version: 0.4.1
|
||||
setting:
|
||||
allowRegister: "N"
|
||||
@@ -114,9 +114,9 @@ func main() {
|
||||
app.Use(middlewares.CORSMiddleware())
|
||||
anonymousGroup := app.Group("/")
|
||||
{
|
||||
anonymousGroup.POST("/login", routes.Login) // 用户登录
|
||||
anonymousGroup.PUT("/users", routes.PutUser) // 添加用户
|
||||
|
||||
anonymousGroup.POST("/login", routes.Login) // 用户登录
|
||||
anonymousGroup.PUT("/users", routes.PutUser) // 添加用户
|
||||
anonymousGroup.GET("/setting", routes.GetSetting) // 获取配置信息
|
||||
}
|
||||
authGroup := app.Group("/", middlewares.AuthorizationMiddleware())
|
||||
{
|
||||
@@ -176,8 +176,8 @@ func main() {
|
||||
authGroup.POST("/users/:id", routes.PostUser) // 更改用户
|
||||
authGroup.DELETE("/users/:id", routes.DeleteUser) // 删除用户
|
||||
authGroup.GET("/me", routes.GetMe) // 获取自己账户
|
||||
//release版本
|
||||
authGroup.GET("/version", routes.GetVersion) //获取发布的版本
|
||||
// release版本
|
||||
authGroup.GET("/version", routes.GetVersion) // 获取发布的版本
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
33
backend/routes/setting.go
Normal file
33
backend/routes/setting.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/spf13/viper"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type SettingBody struct {
|
||||
AllowRegister string `json:"allow_register"`
|
||||
}
|
||||
|
||||
func GetVersion(c *gin.Context) {
|
||||
version := viper.GetString("version")
|
||||
|
||||
c.JSON(http.StatusOK, Response{
|
||||
Status: "ok",
|
||||
Message: "success",
|
||||
Data: version,
|
||||
})
|
||||
}
|
||||
|
||||
func GetSetting(c *gin.Context) {
|
||||
allowRegister := viper.GetString("setting.allowRegister")
|
||||
|
||||
body := SettingBody{AllowRegister: allowRegister}
|
||||
|
||||
c.JSON(http.StatusOK, Response{
|
||||
Status: "ok",
|
||||
Message: "success",
|
||||
Data: body,
|
||||
})
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/spf13/viper"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetVersion(c *gin.Context) {
|
||||
version := viper.GetString("version")
|
||||
|
||||
c.JSON(http.StatusOK, Response{
|
||||
Status: "ok",
|
||||
Message: "success",
|
||||
Data: version,
|
||||
})
|
||||
}
|
||||
@@ -6,6 +6,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
mapState
|
||||
} from 'vuex'
|
||||
import DialogView from './components/Common/DialogView'
|
||||
|
||||
export default {
|
||||
@@ -19,11 +22,15 @@ export default {
|
||||
DialogView
|
||||
},
|
||||
computed: {
|
||||
...mapState('setting', ['setting']),
|
||||
useStats () {
|
||||
return localStorage.getItem('useStats')
|
||||
}
|
||||
},
|
||||
methods: {},
|
||||
created () {
|
||||
this.$store.dispatch('setting/getSetting')
|
||||
},
|
||||
mounted () {
|
||||
window.setUseStats = (value) => {
|
||||
localStorage.setItem('useStats', value)
|
||||
|
||||
@@ -13,6 +13,7 @@ import schedule from './modules/schedule'
|
||||
import lang from './modules/lang'
|
||||
import site from './modules/site'
|
||||
import stats from './modules/stats'
|
||||
import setting from './modules/setting'
|
||||
import getters from './getters'
|
||||
|
||||
Vue.use(Vuex)
|
||||
@@ -31,6 +32,7 @@ const store = new Vuex.Store({
|
||||
schedule,
|
||||
lang,
|
||||
site,
|
||||
setting,
|
||||
// 百度统计
|
||||
stats
|
||||
},
|
||||
|
||||
28
frontend/src/store/modules/setting.js
Normal file
28
frontend/src/store/modules/setting.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import request from '../../api/request'
|
||||
|
||||
const state = {
|
||||
setting: {}
|
||||
}
|
||||
|
||||
const getters = {}
|
||||
|
||||
const mutations = {
|
||||
SET_SETTING (state, value) {
|
||||
state.setting = value
|
||||
}
|
||||
}
|
||||
|
||||
const actions = {
|
||||
async getSetting ({ commit }) {
|
||||
const res = await request.get('/setting')
|
||||
commit('SET_SETTING', res.data.data)
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
getters,
|
||||
mutations,
|
||||
actions
|
||||
}
|
||||
@@ -48,7 +48,7 @@
|
||||
<div class="left">
|
||||
<span v-if="!isSignUp" class="forgot-password">{{$t('Forgot Password')}}</span>
|
||||
</div>
|
||||
<div class="right">
|
||||
<div class="right" v-if="setting.allow_register === 'Y'">
|
||||
<span v-if="isSignUp">{{$t('Has Account')}}, </span>
|
||||
<span v-if="isSignUp" class="sign-in" @click="$router.push('/login')">{{$t('Sign-in')}} ></span>
|
||||
<span v-if="!isSignUp">{{$t('New to Crawlab')}}, </span>
|
||||
@@ -116,6 +116,9 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState('setting', [
|
||||
'setting'
|
||||
]),
|
||||
...mapState('lang', [
|
||||
'lang'
|
||||
]),
|
||||
|
||||
Reference in New Issue
Block a user