show confirm dialog when user click log out button

This commit is contained in:
MaysWind
2020-10-21 00:47:22 +08:00
parent 4e36558b43
commit 7226a262ce
3 changed files with 32 additions and 10 deletions
+6 -3
View File
@@ -1,7 +1,7 @@
export default { export default {
'global': { 'global': {
'app': { 'app': {
'title': 'lab account book' 'title': 'lab account book',
} }
}, },
'error': { 'error': {
@@ -20,8 +20,10 @@ export default {
'two factor recovery code is invalid': 'Two factor recovery code is invalid', 'two factor recovery code is invalid': 'Two factor recovery code is invalid',
'two factor is not enabled': 'Two factor is not enabled', 'two factor is not enabled': 'Two factor is not enabled',
'two factor has already been enabled': 'Two factor has already been enabled', 'two factor has already been enabled': 'Two factor has already been enabled',
'two factor recovery code does not exist': 'Two factor recovery code does not exist' 'two factor recovery code does not exist': 'Two factor recovery code does not exist',
}, },
'OK': 'OK',
'Cancel': 'Cancel',
'Done': 'Done', 'Done': 'Done',
'Home': 'Home', 'Home': 'Home',
'Journals': 'Journals', 'Journals': 'Journals',
@@ -46,5 +48,6 @@ export default {
'Unable to verify': 'Unable to verify', 'Unable to verify': 'Unable to verify',
'Use a scratch code': 'Use a scratch code', 'Use a scratch code': 'Use a scratch code',
'Language': 'Language', 'Language': 'Language',
'Logout': 'Logout' 'Log Out': 'Log Out',
'Are you sure you want to log out?': 'Are you sure you want to log out?',
}; };
+6 -3
View File
@@ -1,7 +1,7 @@
export default { export default {
'global': { 'global': {
'app': { 'app': {
'title': 'lab 轻记账' 'title': 'lab 轻记账',
} }
}, },
'error': { 'error': {
@@ -20,8 +20,10 @@ export default {
'two factor recovery code is invalid': '两步验证恢复口令无效', 'two factor recovery code is invalid': '两步验证恢复口令无效',
'two factor is not enabled': '两步验证没有启用', 'two factor is not enabled': '两步验证没有启用',
'two factor has already been enabled': '两步验证已经启用', 'two factor has already been enabled': '两步验证已经启用',
'two factor recovery code does not exist': '两步验证恢复口令不存在' 'two factor recovery code does not exist': '两步验证恢复口令不存在',
}, },
'OK': '确定',
'Cancel': '取消',
'Done': '完成', 'Done': '完成',
'Home': '首页', 'Home': '首页',
'Journals': '流水', 'Journals': '流水',
@@ -46,5 +48,6 @@ export default {
'Unable to verify': '无法验证', 'Unable to verify': '无法验证',
'Use a scratch code': '使用验证口令', 'Use a scratch code': '使用验证口令',
'Language': '语言', 'Language': '语言',
'Logout': '退出登录' 'Log Out': '退出登录',
'Are you sure you want to log out?': '您确定是否要退出登录?',
}; };
+20 -4
View File
@@ -11,7 +11,7 @@
:value="locale">{{ lang.displayName }}</option> :value="locale">{{ lang.displayName }}</option>
</select> </select>
</f7-list-item> </f7-list-item>
<f7-list-button @click="logout">{{ $t('Logout') }}</f7-list-button> <f7-list-button @click="logout">{{ $t('Log Out') }}</f7-list-button>
</f7-list> </f7-list>
</f7-page> </f7-page>
</template> </template>
@@ -37,10 +37,26 @@ export default {
}, },
methods: { methods: {
logout() { logout() {
const router = this.$f7router; const self = this;
const app = self.$f7;
const router = self.$f7router;
this.$user.clearToken(); app.dialog.create({
router.navigate('/'); title: self.$i18n.t('global.app.title'),
text: self.$i18n.t('Are you sure you want to log out?'),
buttons: [
{
text: self.$i18n.t('Cancel'),
},
{
text: self.$i18n.t('OK'),
onClick: () => {
this.$user.clearToken();
router.navigate('/');
}
}
]
}).open();
} }
} }
}; };