perf: 优化刷新页面方法,避免刷新时页面出现空白

This commit is contained in:
“huailei000”
2022-10-11 14:56:27 +08:00
committed by 老广
parent b79fefdee8
commit a514e88b78
13 changed files with 31 additions and 16 deletions

View File

@@ -1,12 +1,19 @@
<template>
<div id="app">
<router-view />
<router-view v-if="isRouterAlive" />
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'App'
name: 'App',
computed: {
...mapState({
isRouterAlive: state => state.common.isRouterAlive
})
}
}
</script>

View File

@@ -2,7 +2,8 @@ import { optionUrlMeta } from '@/api/common'
const getDefaultState = () => {
return {
metaMap: {}
metaMap: {},
isRouterAlive: true
}
}
@@ -11,6 +12,12 @@ const state = getDefaultState()
const mutations = {
SET_URL_META: (state, { url, meta }) => {
state.metaMap[url] = meta
},
reload: (state) => {
state.isRouterAlive = false
setTimeout(() => {
state.isRouterAlive = true
}, 0)
}
}

View File

@@ -30,7 +30,7 @@ async function changeOrg(org) {
if (index !== -1) {
location.href = path.substring(0, index)
}
setTimeout(() => location.reload(), 400)
setTimeout(() => store.commit('common/reload'), 400)
}
}

View File

@@ -98,7 +98,7 @@ export default {
that.iHasObjects = [...that.iHasObjects, ...objects]
that.$refs.select2.clearSelected()
this.$message.success(this.$t('common.updateSuccessMsg'))
window.location.reload()
this.$store.commit('common/reload')
this.$refs.listTable.$refs.ListTable.reloadTable()
}
}

View File

@@ -93,7 +93,7 @@ export default {
onAddSuccess: (items, that) => {
this.$log.debug('AssetSelect value', that.assets)
this.$message.success(this.$t('common.updateSuccessMsg'))
window.location.reload()
this.$store.commit('common/reload')
}
},
nodeRelationConfig: {
@@ -120,7 +120,7 @@ export default {
that.iHasObjects = [...that.iHasObjects, ...objects]
that.$refs.select2.clearSelected()
this.$message.success(this.$t('common.updateSuccessMsg'))
window.location.reload()
this.$store.commit('common/reload')
},
performDelete: (item) => {
const data = {

View File

@@ -93,7 +93,7 @@ export default {
this.$message.success(this.$t('common.updateSuccessMsg'))
this.$refs.ListTable.reloadTable()
that.$refs.assetSelect.$refs.select2.clearSelected()
window.location.reload()
this.$store.commit('common/reload')
}
},
nodeRelationConfig: {

View File

@@ -49,7 +49,7 @@ export default {
const msg = vm.$t('sessions.TerminateTaskSendSuccessMsg')
vm.$message.success(msg)
window.setTimeout(function() {
window.location.reload()
this.$store.commit('common/reload')
}, 50000)
})
}

View File

@@ -175,7 +175,7 @@ export default {
}).then(() => {
restoreInterface().then(res => {
this.$message.success(res.success)
location.reload()
this.$store.commit('common/reload')
})
})
}.bind(this)
@@ -221,7 +221,7 @@ export default {
}
}
updateInterface(form).then(res => {
location.reload()
this.$store.commit('common/reload')
})
}
}

View File

@@ -140,6 +140,7 @@ export default {
window.open(url, '_blank')
},
importLicense() {
const vm = this
if (this.licenseFile['file'] === undefined) {
return
}
@@ -148,7 +149,7 @@ export default {
importLicense(formData).then(res => {
if (res.status) {
this.$message.success(res.msg)
setTimeout(() => location.reload(), 500)
setTimeout(() => vm.$store.commit('common/reload'), 500)
} else {
this.$message.error(res.msg)
}

View File

@@ -236,7 +236,7 @@ export default {
return toSafeLocalDateStr(dataStr)
},
reloadPage() {
window.location.reload()
this.$store.commit('common/reload')
},
handleApprove() {
if (this.object.approval_step === this.object.process_map.length) {

View File

@@ -244,7 +244,7 @@ export default {
return toSafeLocalDateStr(dataStr)
},
reloadPage() {
window.location.reload()
this.$store.commit('common/reload')
},
handleApprove() {
if (this.object.approval_step === this.object.process_map.length) {

View File

@@ -88,7 +88,7 @@ export default {
return toSafeLocalDateStr(dataStr)
},
reloadPage() {
window.location.reload()
this.$store.commit('common/reload')
}
}
}

View File

@@ -199,7 +199,7 @@ export default {
)
},
reloadPage() {
window.location.reload()
this.$store.commit('common/reload')
}
}