mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-22 17:31:03 +01:00
fixed 版本无法显示问题
This commit is contained in:
@@ -34,13 +34,7 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {},
|
||||
async created () {
|
||||
await this.$store.dispatch('setting/getSetting')
|
||||
},
|
||||
async mounted () {
|
||||
const res = await this.$request.get('/version')
|
||||
this.version = res.data.data
|
||||
sessionStorage.setItem('v', this.version)
|
||||
window.setUseStats = (value) => {
|
||||
document.querySelector('.el-message__closeBtn').click()
|
||||
if (value === 1) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import Vue from 'vue'
|
||||
import Router from 'vue-router'
|
||||
|
||||
import store from '../store'
|
||||
import request from '../api/request'
|
||||
import stats from '../utils/stats'
|
||||
|
||||
/* Layout */
|
||||
@@ -257,8 +259,13 @@ router.beforeEach((to, from, next) => {
|
||||
}
|
||||
})
|
||||
|
||||
router.afterEach((to, from, next) => {
|
||||
router.afterEach(async (to, from, next) => {
|
||||
if (to.path) {
|
||||
await store.dispatch('setting/getSetting')
|
||||
const res = await request.get('/version')
|
||||
const version = res.data.data
|
||||
store.commit('version/SET_VERSION', version)
|
||||
sessionStorage.setItem('v', version)
|
||||
stats.sendPv(to.path)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -14,6 +14,7 @@ import lang from './modules/lang'
|
||||
import site from './modules/site'
|
||||
import stats from './modules/stats'
|
||||
import setting from './modules/setting'
|
||||
import version from './modules/version'
|
||||
import getters from './getters'
|
||||
|
||||
Vue.use(Vuex)
|
||||
@@ -33,7 +34,8 @@ const store = new Vuex.Store({
|
||||
lang,
|
||||
site,
|
||||
setting,
|
||||
// 百度统计
|
||||
version,
|
||||
// 统计
|
||||
stats
|
||||
},
|
||||
getters
|
||||
|
||||
21
frontend/src/store/modules/version.js
Normal file
21
frontend/src/store/modules/version.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const state = {
|
||||
version: ''
|
||||
}
|
||||
|
||||
const getters = {}
|
||||
|
||||
const mutations = {
|
||||
SET_VERSION: (state, value) => {
|
||||
state.version = value
|
||||
}
|
||||
}
|
||||
|
||||
const actions = {}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
getters,
|
||||
mutations,
|
||||
actions
|
||||
}
|
||||
@@ -49,7 +49,7 @@ export default {
|
||||
return !this.sidebar.opened
|
||||
},
|
||||
version () {
|
||||
return window.sessionStorage.getItem('v')
|
||||
return this.$store.state.version.version || window.sessionStorage.getItem('v')
|
||||
}
|
||||
},
|
||||
data () {
|
||||
|
||||
Reference in New Issue
Block a user