This commit is contained in:
ann 2022-04-21 17:31:50 +08:00
parent f383fb4736
commit 12b7e4ff0e
6 changed files with 20 additions and 13 deletions

View File

@ -92,11 +92,12 @@ export function postVirtualMachine(query) {
} }
export function getHostYaml(name, isYaml = false) { export function getHostYaml(name, isYaml = false) {
console.log(isYaml)
return request({ return request({
url: '/virtual/v1/nodes/' + name, url: '/virtual/v1/nodes/' + name,
method: 'get', method: 'get',
headers: { 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, url: '/virtual/api/v1/namespaces/' + namespace + '/persistentvolumeclaims/' + name,
method: 'get', method: 'get',
headers: { 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, url: '/virtual/apis/kubevirt.io/v1/namespaces/default/virtualmachines/' + name,
method: 'get', method: 'get',
headers: { 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, url: '/virtual/apis/harvesterhci.io/v1beta1/namespaces/default/virtualmachineimages/' + name,
method: 'get', method: 'get',
headers: { headers: {
'accept': isYaml ? 'application/yaml' : 'application/json' 'Accept': isYaml ? 'application/yaml' : 'application/json'
} }
}) })
} }

View File

@ -68,7 +68,7 @@ export default {
}, },
mounted() { mounted() {
this.loading = true 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.yaml = res
this.loading = false this.loading = false
}) })

View File

@ -5,6 +5,7 @@ export default {
return { return {
dialogYamlFormVisible: false, dialogYamlFormVisible: false,
yamlName: '', yamlName: '',
yamlNamespace: '',
editYaml: false editYaml: false
} }
}, },
@ -22,7 +23,7 @@ export default {
this.yamlNamespace = namespace this.yamlNamespace = namespace
this.dialogYamlFormVisible = true this.dialogYamlFormVisible = true
}, },
downloadYamlFunc(name, namespace, getFunc) { downloadYamlFunc(name, getFunc, namespace) {
getFunc(name, true, namespace).then(res => { getFunc(name, true, namespace).then(res => {
var data = res var data = res
// encodeURIComponent解决中文乱码 // encodeURIComponent解决中文乱码

View File

@ -1,5 +1,5 @@
import axios from 'axios' import axios from 'axios'
import { Message } from 'element-ui' import { Message, MessageBox } from 'element-ui'
import store from '@/store' import store from '@/store'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
@ -107,9 +107,14 @@ service.interceptors.response.use(
duration: 5 * 1000 duration: 5 * 1000
}) })
if (error.response.status === 401) { if (error.response.status === 401) {
console.log('401') MessageBox.confirm('您的登录已过期或者当前账号没有权限,是否重新登录?', '无权限', {
store.dispatch('user/resetToken').then(() => { confirmButtonText: '重新登录',
location.reload() cancelButtonText: '取消',
type: 'warning'
}).then(() => {
store.dispatch('user/resetToken').then(() => {
location.reload()
})
}) })
// window.location.href = '/monitor/login' // window.location.href = '/monitor/login'
} }

View File

@ -127,7 +127,7 @@ export default {
this.editYamlFunc(row.name, row.namespace) this.editYamlFunc(row.name, row.namespace)
break break
case 4: case 4:
this.downloadYamlFunc(row.name, row.namespace, getDataVolumeYaml) this.downloadYamlFunc(row.name, getDataVolumeYaml, row.namespace)
break break
case 5: case 5:
this.deleteDialogVisible = true this.deleteDialogVisible = true
@ -137,7 +137,7 @@ export default {
} }
}, },
viewVMDetail(row) { viewVMDetail(row) {
this.$router.push({ path: `virtual-machine/detail`, query: row }) this.$router.push({ path: `virtual-machine/detail`, query: { name: row.name }})
this.loading() this.loading()
}, },
async deleteDataVolumes(name) { async deleteDataVolumes(name) {

View File

@ -99,7 +99,7 @@ module.exports = {
}, },
'^/virtual': { '^/virtual': {
ws: false, ws: false,
target: 'https://106.53.150.192/', target: 'https://jointcloud.net/',
changeOrigin: true, changeOrigin: true,
secure: false secure: false
}, },