|
@@ -77,76 +77,6 @@ export const actions = {
|
|
|
}
|
|
|
},
|
|
|
/**
|
|
|
- * 调起授权登录
|
|
|
- * @param {Object} store
|
|
|
- * @param {Object} params
|
|
|
- */
|
|
|
- async doScatterLoginCopy ({ dispatch, commit, state }, h5Router) {
|
|
|
- if (!state.scatter) {
|
|
|
- showError('Please install the scatter', 'Scatter')
|
|
|
- } else {
|
|
|
- if (getUserOpt('isChangeIndentity') == 1) {
|
|
|
- await actions.doScatterLogout(...arguments)
|
|
|
- localStorage.setItem('accounts', '')
|
|
|
- setUserOpt('isChangeIndentity', 0)
|
|
|
- }
|
|
|
- alert('networkConfig before')
|
|
|
- // 获取最快主网
|
|
|
- let networkConfig = await getNetwork()
|
|
|
- alert('networkConfig next')
|
|
|
-
|
|
|
- // 调用getIdentity方法获取用户名
|
|
|
- try {
|
|
|
- var identity = await state.scatter.login({
|
|
|
- accounts: [networkConfig]
|
|
|
- })
|
|
|
- } catch (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)
|
|
|
- }
|
|
|
- },
|
|
|
- /**
|
|
|
* eos账号绑定
|
|
|
* @param {*} param0
|
|
|
*/
|
|
@@ -227,7 +157,7 @@ export const actions = {
|
|
|
setUserOpt('isChangeIndentity', 0)
|
|
|
|
|
|
// return state.scatter && state.scatter.identity ? state.scatter.logout && state.scatter.logout() : true
|
|
|
- return (state.scatter && state.scatter.identity && state.scatter.logout && state.scatter.logout()) || true
|
|
|
+ return state.scatter && state.scatter.logout && state.scatter.logout()
|
|
|
},
|
|
|
|
|
|
/**
|