提交 bcafc995 编写于 作者: 雪洛's avatar 雪洛

feat: 兼容性提升,完全兼容旧版本uni-id配置文件

上级 0848fd4f
......@@ -93,6 +93,17 @@ class UniID {
if (this._clientInfo.platform === 'h5') {
this._clientInfo.platform = 'web'
}
let fallbackPlatform
switch (this._clientInfo.platform) {
case 'web':
fallbackPlatform = 'h5'
break
case 'app':
fallbackPlatform = 'app-plus'
break
default:
break
}
const defaultConfig = {
tokenExpiresIn: 7200,
tokenExpiresThreshold: 1200,
......@@ -100,7 +111,12 @@ class UniID {
passwordErrorRetryTime: 3600
}
const argsRequired = ['tokenSecret', 'tokenExpiresIn']
const config = Object.assign(defaultConfig, appConfig, appConfig[this._clientInfo.platform])
const configList = [defaultConfig, appConfig]
if (fallbackPlatform && appConfig[fallbackPlatform]) {
configList.push(appConfig[fallbackPlatform])
}
configList.push(appConfig[this._clientInfo.platform])
const config = Object.assign(...configList)
argsRequired.forEach((item) => {
if (!config || !config[item]) {
throw new Error(`Config parameter missing, ${item} is required`)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册