diff --git a/nezha-fronted/src/components/chart/chart/chartMap.vue b/nezha-fronted/src/components/chart/chart/chartMap.vue index 3162cdba9..9d1bf34a6 100644 --- a/nezha-fronted/src/components/chart/chart/chartMap.vue +++ b/nezha-fronted/src/components/chart/chart/chartMap.vue @@ -1,7 +1,7 @@ @@ -117,7 +119,8 @@ export default { permission: 'header_add_rule' } ], - showGuide: false + showGuide: false, + // fontData: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ' ', '@', '$', '-'] } }, methods: { @@ -193,11 +196,17 @@ export default { }, testUser () { if (this.username != localStorage.getItem('nz-username')) { - window.location.reload() + this.$router.go(0) } } }, mounted () { + // for (let i = 65; i < 91; i++) { + // this.fontData.push(String.fromCharCode(i)) + // } + // for (let i = 97; i < 123; i++) { + // this.fontData.push(String.fromCharCode(i)) + // } this.$i18n.locale = this.language if (localStorage.getItem('nz-token')) { this.initEvent() diff --git a/nezha-fronted/src/components/page/alert/alertMessage.vue b/nezha-fronted/src/components/page/alert/alertMessage.vue index 0793ceee0..07cdd32a9 100644 --- a/nezha-fronted/src/components/page/alert/alertMessage.vue +++ b/nezha-fronted/src/components/page/alert/alertMessage.vue @@ -526,15 +526,39 @@ export default { cancelButtonText: this.$t('tip.no'), type: 'warning' }).then(() => { - this.$delete(this.url + '?ids=' + this.batchDeleteObjs.map(m => m.id).join(',') + '&state=' + this.state).then(response => { - if (response.code === 200) { - this.delFlag = true - this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') }) - this.getTableData() - } else { - this.$message.error(response.msg) + const arrState = [] + const promiseArr = [] + this.batchDeleteObjs.forEach(item => { + if (arrState.indexOf(item.state) === -1) { + arrState.push(item.state) } }) + arrState.forEach(state => { + const batchDeleteArr = this.batchDeleteObjs.filter(m => m.state === state) + promiseArr.push(this.$delete(this.url + '?ids=' + batchDeleteArr.map(m => m.id).join(',') + '&state=' + state)) + }) + Promise.all(promiseArr) + .then(res => { + let error = '' + let flag = false + for (let i = 0; i < res.length; i++) { + if (res[i].code !== 200 && !flag) { + error = res[i].msg + flag = true + } + } + if (!flag) { + this.delFlag = true + this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') }) + this.getTableData() + } else { + this.$message.error(error) + } + }) + .catch(response => { + console.log(response) + this.$message.error(response.msg) + }) }) }, del (row) { @@ -543,7 +567,7 @@ export default { cancelButtonText: this.$t('tip.no'), type: 'warning' }).then(() => { - this.$delete(this.url + '?ids=' + row.id + '&state=' + this.state).then(response => { + this.$delete(this.url + '?ids=' + row.id + '&state=' + row.state).then(response => { if (response.code === 200) { this.delFlag = true this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') }) @@ -595,7 +619,8 @@ 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.unit + 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) @@ -609,7 +634,7 @@ export default { } chartInfo.elements[0].expression = encodeURIComponent(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.unit + chartInfo.unit = this.currentMsg.alertRule.unit this.showFullscreen(true, chartInfo) } }, diff --git a/nezha-fronted/src/components/page/dashboard/panel.vue b/nezha-fronted/src/components/page/dashboard/panel.vue index 6c09d0c50..0020148de 100644 --- a/nezha-fronted/src/components/page/dashboard/panel.vue +++ b/nezha-fronted/src/components/page/dashboard/panel.vue @@ -343,8 +343,11 @@ export default { this.getTableData(true) } else { this.$message.error(response.msg) + this.$store.dispatch('clearPanel') } }) + }).catch(() => { + this.$store.dispatch('clearPanel') }) }, edit (u) { @@ -512,6 +515,7 @@ export default { // this.getTableData(); //删除相关图表后,刷新面板数据 } else { this.$message.error(response.msg) + this.$store.dispatch('clearPanel') } }) }).catch(() => { diff --git a/nezha-fronted/src/permission.js b/nezha-fronted/src/permission.js index cc3ee03c3..1d8e7ff58 100644 --- a/nezha-fronted/src/permission.js +++ b/nezha-fronted/src/permission.js @@ -11,7 +11,10 @@ Vue.use(VueResource) const loginWhiteList = ['/setup', '/sys/license/upload', '/sys/license/state', '/sys/appearance'] // 免登陆白名单 const permissionWhiteList = ['/profile', '/menu', ...loginWhiteList] // 权限白名单 router.beforeEach((to, from, next) => { - requestsArr.forEach(xhr => xhr.cancel()) + if (store.getters.getNowPath !== to.path) { + requestsArr.forEach(xhr => xhr.cancel()) + } + store.commit('setNowPath', to.path) const configUrl = 'static/config.json?Timestamp=' + new Date().getTime() if (to.path === '/login') { // 拦截登录页面,现货区外观设置 再系统初始化检查 Vue.http.get(configUrl).then(config => { @@ -81,7 +84,7 @@ router.beforeEach((to, from, next) => { }) } else { localStorage.setItem('nz-token', '') - next({}) + next() } }) } else { @@ -165,6 +168,9 @@ router.beforeEach((to, from, next) => { } } }) +router.afterEach((to, from) => { + // store.commit('setNowPath', '') +}) // menuList中是否包含route权限 export function hasMenu (menuList, route) { diff --git a/nezha-fronted/src/store/index.js b/nezha-fronted/src/store/index.js index 5889bf33d..628a226c3 100644 --- a/nezha-fronted/src/store/index.js +++ b/nezha-fronted/src/store/index.js @@ -43,7 +43,8 @@ const store = new Vuex.Store({ timeFormatMain: localStorage.getItem('nz-default-dateFormat') || 'YYYY-MM-DD HH:mm:ss', globalShow: false, globalSearchId: '', - isRouteLive: true + isRouteLive: true, + nowPath: '' }, getters: { getGlobalSearchId (state) { @@ -94,6 +95,9 @@ const store = new Vuex.Store({ getIsRouteLive (state) { return state.isRouteLive }, + getNowPath (state) { + return state.nowPath + }, i18nIsReady (state) { return state.i18nReady } @@ -197,6 +201,9 @@ const store = new Vuex.Store({ state.isRouteLive = true }) }, + setNowPath (state, path) { + state.nowPath = path + }, i18nReady (state, ready) { state.i18nReady = ready }