From 12b7e4ff0e6150476a16dab85054767833a385dc Mon Sep 17 00:00:00 2001 From: ann Date: Thu, 21 Apr 2022 17:31:50 +0800 Subject: [PATCH] fix --- src/api/one-class-page/virtualMachine.js | 9 +++++---- src/components/virtualMachine/yaml.vue | 2 +- src/mixin/yaml.js | 3 ++- src/utils/request.js | 13 +++++++++---- src/views/virtualMachine/datavolume/list.vue | 4 ++-- vue.config.js | 2 +- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/api/one-class-page/virtualMachine.js b/src/api/one-class-page/virtualMachine.js index f45b5b1..9895785 100644 --- a/src/api/one-class-page/virtualMachine.js +++ b/src/api/one-class-page/virtualMachine.js @@ -92,11 +92,12 @@ export function postVirtualMachine(query) { } export function getHostYaml(name, isYaml = false) { + console.log(isYaml) return request({ url: '/virtual/v1/nodes/' + name, method: 'get', headers: { - 'accept': isYaml ? 'application/yaml' : 'application/json' + 'Accept': isYaml ? 'application/yaml' : 'application/json' } }) } @@ -161,7 +162,7 @@ export function getDataVolumeYaml(name, isYaml = false, namespace = 'default') { url: '/virtual/api/v1/namespaces/' + namespace + '/persistentvolumeclaims/' + name, method: 'get', headers: { - 'accept': isYaml ? 'application/yaml' : 'application/json' + 'Accept': isYaml ? 'application/yaml' : 'application/json' } }) } @@ -201,7 +202,7 @@ export function getVirtualMachineYaml(name, isYaml = false) { url: '/virtual/apis/kubevirt.io/v1/namespaces/default/virtualmachines/' + name, method: 'get', headers: { - 'accept': isYaml ? 'application/yaml' : 'application/json' + 'Accept': isYaml ? 'application/yaml' : 'application/json' } }) } @@ -261,7 +262,7 @@ export function getImagesYaml(name, isYaml = false) { url: '/virtual/apis/harvesterhci.io/v1beta1/namespaces/default/virtualmachineimages/' + name, method: 'get', headers: { - 'accept': isYaml ? 'application/yaml' : 'application/json' + 'Accept': isYaml ? 'application/yaml' : 'application/json' } }) } diff --git a/src/components/virtualMachine/yaml.vue b/src/components/virtualMachine/yaml.vue index 91b0c8f..510f6d5 100644 --- a/src/components/virtualMachine/yaml.vue +++ b/src/components/virtualMachine/yaml.vue @@ -68,7 +68,7 @@ export default { }, mounted() { this.loading = true - this.getYaml(this.name, true, this.namespace).then(res => { + this.getYaml(this.name, false, this.namespace).then(res => { this.yaml = res this.loading = false }) diff --git a/src/mixin/yaml.js b/src/mixin/yaml.js index e16c544..2d96405 100644 --- a/src/mixin/yaml.js +++ b/src/mixin/yaml.js @@ -5,6 +5,7 @@ export default { return { dialogYamlFormVisible: false, yamlName: '', + yamlNamespace: '', editYaml: false } }, @@ -22,7 +23,7 @@ export default { this.yamlNamespace = namespace this.dialogYamlFormVisible = true }, - downloadYamlFunc(name, namespace, getFunc) { + downloadYamlFunc(name, getFunc, namespace) { getFunc(name, true, namespace).then(res => { var data = res // encodeURIComponent解决中文乱码 diff --git a/src/utils/request.js b/src/utils/request.js index 422fd31..43d2301 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,5 +1,5 @@ import axios from 'axios' -import { Message } from 'element-ui' +import { Message, MessageBox } from 'element-ui' import store from '@/store' import { getToken } from '@/utils/auth' import Cookies from 'js-cookie' @@ -107,9 +107,14 @@ service.interceptors.response.use( duration: 5 * 1000 }) if (error.response.status === 401) { - console.log('401') - store.dispatch('user/resetToken').then(() => { - location.reload() + MessageBox.confirm('您的登录已过期或者当前账号没有权限,是否重新登录?', '无权限', { + confirmButtonText: '重新登录', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + store.dispatch('user/resetToken').then(() => { + location.reload() + }) }) // window.location.href = '/monitor/login' } diff --git a/src/views/virtualMachine/datavolume/list.vue b/src/views/virtualMachine/datavolume/list.vue index fa6da1d..b0344c8 100644 --- a/src/views/virtualMachine/datavolume/list.vue +++ b/src/views/virtualMachine/datavolume/list.vue @@ -127,7 +127,7 @@ export default { this.editYamlFunc(row.name, row.namespace) break case 4: - this.downloadYamlFunc(row.name, row.namespace, getDataVolumeYaml) + this.downloadYamlFunc(row.name, getDataVolumeYaml, row.namespace) break case 5: this.deleteDialogVisible = true @@ -137,7 +137,7 @@ export default { } }, viewVMDetail(row) { - this.$router.push({ path: `virtual-machine/detail`, query: row }) + this.$router.push({ path: `virtual-machine/detail`, query: { name: row.name }}) this.loading() }, async deleteDataVolumes(name) { diff --git a/vue.config.js b/vue.config.js index a0c21e7..bf05a6e 100644 --- a/vue.config.js +++ b/vue.config.js @@ -99,7 +99,7 @@ module.exports = { }, '^/virtual': { ws: false, - target: 'https://106.53.150.192/', + target: 'https://jointcloud.net/', changeOrigin: true, secure: false },