|
@@ -22,56 +22,60 @@ export const actions = {
|
|
localStorage.setItem('accounts', '')
|
|
localStorage.setItem('accounts', '')
|
|
setUserOpt('isChangeIndentity', 0)
|
|
setUserOpt('isChangeIndentity', 0)
|
|
}
|
|
}
|
|
- alert('networkConfig before')
|
|
|
|
// 获取最快主网
|
|
// 获取最快主网
|
|
let networkConfig = await getNetwork()
|
|
let networkConfig = await getNetwork()
|
|
- alert('networkConfig next')
|
|
|
|
|
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
|
- state.scatter.getIdentity({
|
|
|
|
|
|
+ // 调用getIdentity方法获取用户名
|
|
|
|
+ try {
|
|
|
|
+ var identity = await state.scatter.getIdentity({
|
|
accounts: [networkConfig]
|
|
accounts: [networkConfig]
|
|
- }).then(async (identity) => {
|
|
|
|
- let accounts = identity.accounts.find(x => x.blockchain === 'eos')
|
|
|
|
-
|
|
|
|
- let lastAccounts = localStorage.getItem('accounts')
|
|
|
|
-
|
|
|
|
- if (lastAccounts && JSON.parse(lastAccounts).name !== accounts.name) {
|
|
|
|
- await actions.doScatterLogout(...arguments)
|
|
|
|
- h5Router.push({ path: '/login' })
|
|
|
|
- commit('setUserInfo', null)
|
|
|
|
- commit('initChatData')
|
|
|
|
- commit('initGroupData')
|
|
|
|
- commit('chatAppLogin', false)
|
|
|
|
- commit('toApp', false)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- commit('setAccount', accounts)
|
|
|
|
- localStorage.setItem('accounts', JSON.stringify(accounts))
|
|
|
|
-
|
|
|
|
- // 如果当前登录的用户名和cookie中保存的account不一致
|
|
|
|
- // 则删除cookie中保存的account
|
|
|
|
- // 避免某些用户在移动端钱包中切换账号时跳过注销流程导致账号不一致的问题
|
|
|
|
- // if (Cookie.getCookie('account') !== accounts.name) {
|
|
|
|
- // Cookie.delCookie('account')
|
|
|
|
- // }
|
|
|
|
- // 设置全局EOS对象
|
|
|
|
- window.EOS = state.scatter.eos(networkConfig, Eos, {})
|
|
|
|
-
|
|
|
|
- // 调用scatter登录成功后获取用户EOS、GT
|
|
|
|
- // dispatch('getUserEOS')
|
|
|
|
- // dispatch('getUserGT')
|
|
|
|
- await dispatch('getAccount')
|
|
|
|
-
|
|
|
|
- // 每分钟刷新一次
|
|
|
|
- // this.limitTimer = setInterval(() => {
|
|
|
|
- // dispatch('getAccount')
|
|
|
|
- // }, 60000)
|
|
|
|
-
|
|
|
|
- resolve(true)
|
|
|
|
- }).catch(e => {
|
|
|
|
- reject(e)
|
|
|
|
})
|
|
})
|
|
- })
|
|
|
|
|
|
+ alert('identity next')
|
|
|
|
+ } catch (error) {
|
|
|
|
+ alert('identity error', error)
|
|
|
|
+ if (error.type !== 'identity_rejected') {
|
|
|
|
+ showError(error.message)
|
|
|
|
+ }
|
|
|
|
+ return Promise.reject(error)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let accounts = identity.accounts.find(x => x.blockchain === 'eos')
|
|
|
|
+
|
|
|
|
+ let lastAccounts = localStorage.getItem('accounts')
|
|
|
|
+
|
|
|
|
+ if (lastAccounts && JSON.parse(lastAccounts).name !== accounts.name) {
|
|
|
|
+ await actions.doScatterLogout(...arguments)
|
|
|
|
+ h5Router.push({ path: '/login' })
|
|
|
|
+ commit('setUserInfo', null)
|
|
|
|
+ commit('initChatData')
|
|
|
|
+ commit('initGroupData')
|
|
|
|
+ commit('chatAppLogin', false)
|
|
|
|
+ commit('toApp', false)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ commit('setAccount', accounts)
|
|
|
|
+ localStorage.setItem('accounts', JSON.stringify(accounts))
|
|
|
|
+
|
|
|
|
+ // 如果当前登录的用户名和cookie中保存的account不一致
|
|
|
|
+ // 则删除cookie中保存的account
|
|
|
|
+ // 避免某些用户在移动端钱包中切换账号时跳过注销流程导致账号不一致的问题
|
|
|
|
+ // if (Cookie.getCookie('account') !== accounts.name) {
|
|
|
|
+ // Cookie.delCookie('account')
|
|
|
|
+ // }
|
|
|
|
+ // 设置全局EOS对象
|
|
|
|
+ window.EOS = state.scatter.eos(networkConfig, Eos, {})
|
|
|
|
+
|
|
|
|
+ // 调用scatter登录成功后获取用户EOS、GT
|
|
|
|
+ // dispatch('getUserEOS')
|
|
|
|
+ // dispatch('getUserGT')
|
|
|
|
+ await dispatch('getAccount')
|
|
|
|
+
|
|
|
|
+ // 每分钟刷新一次
|
|
|
|
+ // this.limitTimer = setInterval(() => {
|
|
|
|
+ // dispatch('getAccount')
|
|
|
|
+ // }, 60000)
|
|
|
|
+
|
|
|
|
+ return Promise.resolve(true)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
/**
|
|
/**
|
|
@@ -226,7 +230,8 @@ export const actions = {
|
|
commit('setAccount', '')
|
|
commit('setAccount', '')
|
|
setUserOpt('isChangeIndentity', 0)
|
|
setUserOpt('isChangeIndentity', 0)
|
|
|
|
|
|
- return state.scatter && state.scatter.identity ? state.scatter.forgetIdentity && state.scatter.forgetIdentity() : true
|
|
|
|
|
|
+ // return state.scatter && state.scatter.identity ? state.scatter.forgetIdentity && state.scatter.forgetIdentity() : true
|
|
|
|
+ return (state.scatter && state.scatter.identity && state.scatter.forgetIdentity && state.scatter.forgetIdentity()) || true
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|