Merge pull request #2248 from dataease/pr@dev@fix_default_type_async

fix: 异步加载默认登录方式
This commit is contained in:
fit2cloud-chenyw
2022-05-12 16:31:21 +08:00
committed by GitHub

View File

@@ -99,7 +99,8 @@ export default {
'panel-default-tree',
'chart-tree',
'dataset-tree'
]
],
defaultType: 0
}
},
computed: {
@@ -116,14 +117,10 @@ export default {
}
},
beforeCreate() {
let p1 = null
let p2 = null
let p3 = null
pluginLoaded().then(res => {
this.isPluginLoaded = res.success && res.data
this.isPluginLoaded && initTheme()
this.contentShow = true
p1 = Promise.resolve(1)
}).catch(() => {
this.contentShow = true
})
@@ -132,14 +129,14 @@ export default {
if (res.success && res.data) {
this.loginTypes.push(1)
}
p2 = Promise.resolve(2)
this.setDefaultType()
})
oidcStatus().then(res => {
if (res.success && res.data) {
this.loginTypes.push(2)
}
p3 = Promise.resolve(3)
this.setDefaultType()
})
getPublicKey().then(res => {
if (res.success && res.data) {
@@ -147,17 +144,12 @@ export default {
localStorage.setItem('publicKey', res.data)
}
})
Promise.all([p1, p2, p3]).then(() => {
defaultLoginType().then(res => {
const result = res
console.log('default login type is :' + res.data)
if (result.success && result.data && this.loginTypes.includes(result.data)) {
this.loginForm.loginType = result.data
this.$nextTick(() => {
this.changeLoginType(this.loginForm.loginType)
})
}
})
defaultLoginType().then(res => {
console.log('default login type is :' + res.data)
if (res && res.success) {
this.defaultType = res.data
}
this.setDefaultType()
})
},
@@ -183,6 +175,14 @@ export default {
},
methods: {
setDefaultType() {
if (this.loginTypes.includes(this.defaultType)) {
this.loginForm.loginType = this.defaultType
this.$nextTick(() => {
this.changeLoginType(this.loginForm.loginType)
})
}
},
clearOidcMsg() {
Cookies.remove('OidcError')
Cookies.remove('IdToken')