diff --git a/nezha-fronted/src/components/common/login.vue b/nezha-fronted/src/components/common/login.vue index 637f48604..f4c342272 100644 --- a/nezha-fronted/src/components/common/login.vue +++ b/nezha-fronted/src/components/common/login.vue @@ -147,6 +147,7 @@ export default { fileShow: false, fileContent: '', recoveryCode: [], + userInfo: {}, bgImg: '' // 背景图 } }, @@ -165,6 +166,7 @@ export default { this.lang = res.data.user.lang || localStorage.getItem('nz-language') this.$i18n.locale = this.lang this.theme = res.data.user.theme + this.userInfo = res.data.user // 获取可选语言 get('/sys/dict/all?type=lang').then(response => { if (response.code === 200) { @@ -221,8 +223,7 @@ export default { localStorage.setItem('nz-prometheus-federation-enabled', res.data.prometheusFederationEnabled) localStorage.setItem('nz-language', this.lang) res.data.user = { - lang: this.lang, - theme: this.theme + ...this.userInfo } this.loginSuccess(res) } else { diff --git a/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js b/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js index 3a240a8c8..461ca8aca 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js +++ b/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js @@ -435,7 +435,6 @@ export default { }, showError () { this.$refs.chartForm.validate((blooen, object) => { - console.log(blooen, object) Object.keys(object).forEach(item => { const keyArr = item.split('.') if (keyArr.length >= 4) { diff --git a/nezha-fronted/src/components/page/alert/alertMessage.vue b/nezha-fronted/src/components/page/alert/alertMessage.vue index 07cdd32a9..eb2d7bdd9 100644 --- a/nezha-fronted/src/components/page/alert/alertMessage.vue +++ b/nezha-fronted/src/components/page/alert/alertMessage.vue @@ -556,7 +556,6 @@ export default { } }) .catch(response => { - console.log(response) this.$message.error(response.msg) }) }) @@ -620,7 +619,6 @@ export default { chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, '') chartInfo.elements[0].filter = encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels))) chartInfo.unit = this.currentMsg.alertRule.unit - console.log(chartInfo.unit) this.showFullscreen(true, chartInfo) } else if (this.currentMsg.alertRule.type === 2) { const chartInfo = lodash.cloneDeep(logData) diff --git a/nezha-fronted/src/http.js b/nezha-fronted/src/http.js index d062eeb36..c2df199c5 100644 --- a/nezha-fronted/src/http.js +++ b/nezha-fronted/src/http.js @@ -5,7 +5,7 @@ export const requestsArr = [] axios.interceptors.request.use(config => { const source = CancelToken.source() // 申明CancelToken,也可new CancelToken.source()实例一个 config.cancelToken = source.token // 讲实例对象的token赋予该请求 - requestsArr.push({ source, config }) // 将该实例添加到队列中 + requestsArr.push(source) // 将该实例添加到队列中 const token = localStorage.getItem('nz-token') if (token) { config.headers.Authorization = token // 请求头token diff --git a/nezha-fronted/src/permission.js b/nezha-fronted/src/permission.js index 6cb51f123..c41126090 100644 --- a/nezha-fronted/src/permission.js +++ b/nezha-fronted/src/permission.js @@ -10,15 +10,9 @@ Vue.use(VueResource) const loginWhiteList = ['/setup', '/sys/license/upload', '/sys/license/state', '/sys/appearance'] // 免登陆白名单 const permissionWhiteList = ['/profile', '/menu', ...loginWhiteList] // 权限白名单 -const requestsWhiteList = ['js', 'css', 'png', 'woff', 'ttf', 'woff2', 'gif', ''] router.beforeEach((to, from, next) => { if (store.getters.getNowPath !== to.path && store.getters.getNowPath !== '/login') { - requestsArr.forEach(xhr => { - const arr = xhr.config.url.split('.') - if (requestsWhiteList.indexOf(arr[arr.length - 1]) === -1) { - xhr.source.cancel() - } - }) + requestsArr.forEach(xhr => xhr.cancel()) } store.commit('setNowPath', to.path) const configUrl = 'static/config.json?Timestamp=' + new Date().getTime() @@ -140,7 +134,8 @@ router.beforeEach((to, from, next) => { returnMenuCode(res.data.menus, arr) store.commit('setButtonList', arr) store.commit('setRoleList', res.data.roles) - document.getElementsByTagName('body')[0].setAttribute('class', 'theme-' + localStorage.getItem(`nz-user-${localStorage.getItem('nz-user-id')}-theme`)) + const theme = localStorage.getItem(`nz-user-${localStorage.getItem('nz-user-id')}-theme`) || 'light' + document.getElementsByTagName('body')[0].setAttribute('class', 'theme-' + theme) resolve() } else { localStorage.removeItem('nz-token') diff --git a/nezha-fronted/src/store/user.js b/nezha-fronted/src/store/user.js index 05dc416ed..6e8aadaf4 100644 --- a/nezha-fronted/src/store/user.js +++ b/nezha-fronted/src/store/user.js @@ -12,7 +12,7 @@ const user = { roleList: [], language: localStorage.getItem('nz-language'), severityData: localStorage.getItem('nz-severityData') ? JSON.parse(localStorage.getItem('nz-severityData')) : [], - severityDataWeight: localStorage.getItem('nz-severityDataWeight') ? JSON.parse(localStorage.getItem('nz-severityDataWeight')) : [] + severityDataWeight: localStorage.getItem('nz-severityDataWeight') ? JSON.parse(localStorage.getItem('nz-severityDataWeight')) : [] }, mutations: { setLanguage (state, language) { @@ -71,6 +71,7 @@ const user = { }, actions: { loginSuccess (store, res) { + const defaultAppearance = { system_name: localStorage.getItem('nz-sys-name'), system_logo: localStorage.getItem('nz-sys-logo'),