简化登录报错的信息

This commit is contained in:
cebgcontract 2022-04-18 09:53:31 +08:00
parent f942160131
commit 551ae030cc
3 changed files with 7 additions and 25 deletions

View File

@ -275,13 +275,13 @@ export class Blockchain {
public async disconnect() {
try {
await UserModule.LogOut()
await this.provider?.disconnect()
this.currentChain = 0
this.walletType = 0
this.coinInstanceMap.clear()
this.clearCachedProvider()
AppModule.updateStep(0)
AppModule.updateNonce('')
await this.provider?.disconnect()
} catch (err) {
}
this.clearCachedProvider()

View File

@ -40,7 +40,7 @@ class User extends VuexModule implements IUserState {
public sex = '0'
public account = ''
@Action
@Action({ rawError: true })
public async Login({ bcInstance, account, chainId, nonce }: {bcInstance: any, account: string, chainId: string | number, nonce: string}) {
nonce += ''
const tips = 'This signature is only used for verify your account'

View File

@ -33,33 +33,15 @@ service.interceptors.response.use(
(response) => {
// Some example codes here:
// code == 0: success
// code == 50001: invalid access token
// code == 50002: already login in other place
// code == 50003: access token expired
// code == 50004: invalid user (user not exist)
// code == 10: username or password is incorrect
// You can change this part for your own usage.
const res = response.data
if (res.errcode) {
Message({
message: res.errmsg || 'Error',
type: 'error',
duration: 5 * 1000
})
if (res.errcode === 50008 || res.errcode === 50012 || res.errcode === 50014) {
MessageBox.confirm(
'You have been logged out, try to login again.',
'Log out',
{
confirmButtonText: 'Relogin',
cancelButtonText: 'Cancel',
type: 'warning'
}
).then(() => {
UserModule.ResetToken()
location.reload() // To prevent bugs from vue-router
})
}
// Message({
// message: res.errmsg || 'Error',
// type: 'error',
// duration: 5 * 1000
// })
return Promise.reject(new Error(res.errmsg || 'Error'))
} else {
return response.data