fix(cmdb-ui):set localstorage '' after unsubscribe ci (#296)

This commit is contained in:
wang-liang0615 2023-12-12 09:38:50 +08:00 committed by GitHub
parent e0c8263542
commit cf0ad7bad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View File

@ -95,6 +95,10 @@ export default {
const unsubTree = subscribeTreeView(citypeId, '') const unsubTree = subscribeTreeView(citypeId, '')
Promise.all([unsubCIType, unsubTree]).then(() => { Promise.all([unsubCIType, unsubTree]).then(() => {
that.$message.success('取消订阅成功') that.$message.success('取消订阅成功')
const lastTypeId = window.localStorage.getItem('ops_ci_typeid') || undefined
if (Number(citypeId) === Number(lastTypeId)) {
localStorage.setItem('ops_ci_typeid', '')
}
// 删除路由 // 删除路由
const href = window.location.href const href = window.location.href
const hrefSplit = href.split('/') const hrefSplit = href.split('/')

View File

@ -879,6 +879,10 @@ export default {
unsubscribe(ciType, type = 'all') { unsubscribe(ciType, type = 'all') {
const promises = [subscribeCIType(this.typeId, ''), subscribeTreeView(this.typeId, '')] const promises = [subscribeCIType(this.typeId, ''), subscribeTreeView(this.typeId, '')]
Promise.all(promises).then(() => { Promise.all(promises).then(() => {
const lastTypeId = window.localStorage.getItem('ops_ci_typeid') || undefined
if (Number(ciType) === Number(lastTypeId)) {
localStorage.setItem('ops_ci_typeid', '')
}
this.$message.success('取消订阅成功') this.$message.success('取消订阅成功')
this.resetRoute() this.resetRoute()
this.$router.push('/cmdb/preference') this.$router.push('/cmdb/preference')

View File

@ -314,6 +314,12 @@ export default {
} }
Promise.all(promises).then(() => { Promise.all(promises).then(() => {
if (type === 'all' || type === 'ci') {
const lastTypeId = window.localStorage.getItem('ops_ci_typeid') || undefined
if (Number(ciType.id) === Number(lastTypeId)) {
localStorage.setItem('ops_ci_typeid', '')
}
}
that.$message.success('取消订阅成功') that.$message.success('取消订阅成功')
that.resetRoute() that.resetRoute()
}) })