add lock application menu
This commit is contained in:
@@ -164,6 +164,11 @@ function clearUserInfo() {
|
||||
localStorage.removeItem(userInfoLocalStorageKey);
|
||||
}
|
||||
|
||||
function clearSessionToken() {
|
||||
sessionStorage.removeItem(tokenSessionStorageKey);
|
||||
sessionStorage.removeItem(appLockStateSessionStorageKey);
|
||||
}
|
||||
|
||||
function clearTokenAndUserInfo(clearAppLockState) {
|
||||
if (clearAppLockState) {
|
||||
sessionStorage.removeItem(appLockStateSessionStorageKey);
|
||||
@@ -191,5 +196,6 @@ export default {
|
||||
updateToken,
|
||||
updateUserInfo,
|
||||
clearUserInfo,
|
||||
clearSessionToken,
|
||||
clearTokenAndUserInfo
|
||||
};
|
||||
|
||||
@@ -1124,6 +1124,7 @@ export default {
|
||||
'Unable to get current two factor authentication status': 'Unable to get current two factor authentication status',
|
||||
'Unable to enable two factor authentication': 'Unable to enable two factor authentication',
|
||||
'Unable to disable two factor authentication': 'Unable to disable two factor authentication',
|
||||
'Lock Application': 'Lock Application',
|
||||
'Log Out': 'Log Out',
|
||||
'Are you sure you want to log out?': 'Are you sure you want to log out?',
|
||||
'Unable to logout': 'Unable to logout',
|
||||
|
||||
@@ -1124,6 +1124,7 @@ export default {
|
||||
'Unable to get current two factor authentication status': '无法获取当前两步验证状态',
|
||||
'Unable to enable two factor authentication': '无法启用两步验证',
|
||||
'Unable to disable two factor authentication': '无法禁用两步验证',
|
||||
'Lock Application': '锁定应用',
|
||||
'Log Out': '退出登录',
|
||||
'Are you sure you want to log out?': '您确定要退出登录?',
|
||||
'Unable to logout': '无法退出登录',
|
||||
|
||||
+11
-3
@@ -17,9 +17,11 @@ import { isObject, isString } from '@/lib/common.js';
|
||||
|
||||
export const useRootStore = defineStore('root', {
|
||||
actions: {
|
||||
resetAllStates() {
|
||||
resetAllStates(resetUserInfoAndSettings) {
|
||||
if (resetUserInfoAndSettings) {
|
||||
const exchangeRatesStore = useExchangeRatesStore();
|
||||
exchangeRatesStore.resetLatestExchangeRates();
|
||||
}
|
||||
|
||||
const statisticsStore = useStatisticsStore();
|
||||
statisticsStore.resetTransactionStatistics();
|
||||
@@ -39,8 +41,10 @@ export const useRootStore = defineStore('root', {
|
||||
const accountsStore = useAccountsStore();
|
||||
accountsStore.resetAccounts();
|
||||
|
||||
if (resetUserInfoAndSettings) {
|
||||
const userStore = useUserStore();
|
||||
userStore.resetUserInfo();
|
||||
}
|
||||
},
|
||||
authorize({ loginName, password }) {
|
||||
const settingsStore = useSettingsStore();
|
||||
@@ -204,6 +208,10 @@ export const useRootStore = defineStore('root', {
|
||||
});
|
||||
});
|
||||
},
|
||||
lock() {
|
||||
userState.clearSessionToken();
|
||||
this.resetAllStates(false);
|
||||
},
|
||||
logout() {
|
||||
const self = this;
|
||||
|
||||
@@ -218,7 +226,7 @@ export const useRootStore = defineStore('root', {
|
||||
|
||||
userState.clearTokenAndUserInfo(true);
|
||||
userState.clearWebAuthnConfig();
|
||||
self.resetAllStates();
|
||||
self.resetAllStates(true);
|
||||
|
||||
resolve(data.result);
|
||||
}).catch(error => {
|
||||
@@ -237,7 +245,7 @@ export const useRootStore = defineStore('root', {
|
||||
forceLogout() {
|
||||
userState.clearTokenAndUserInfo(true);
|
||||
userState.clearWebAuthnConfig();
|
||||
this.resetAllStates();
|
||||
this.resetAllStates(true);
|
||||
},
|
||||
updateUserProfile({ profile, currentPassword }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
@@ -144,6 +144,10 @@
|
||||
:title="$t('Application Settings')"
|
||||
to="/app/settings"></v-list-item>
|
||||
<v-divider class="my-2"/>
|
||||
<v-list-item :prepend-icon="icons.lock"
|
||||
:title="$t('Lock Application')"
|
||||
v-if="isEnableApplicationLock"
|
||||
@click="lock"></v-list-item>
|
||||
<v-list-item :disabled="logouting"
|
||||
:prepend-icon="icons.logout"
|
||||
:title="$t('Log Out')"
|
||||
@@ -201,6 +205,7 @@ import {
|
||||
mdiWeatherNight,
|
||||
mdiAccount,
|
||||
mdiAccountCogOutline,
|
||||
mdiLockOutline,
|
||||
mdiLogout
|
||||
} from '@mdi/js';
|
||||
|
||||
@@ -229,6 +234,7 @@ export default {
|
||||
themeDark: mdiWeatherNight,
|
||||
user: mdiAccount,
|
||||
profile: mdiAccountCogOutline,
|
||||
lock: mdiLockOutline,
|
||||
logout: mdiLogout
|
||||
}
|
||||
}
|
||||
@@ -260,6 +266,9 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
isEnableApplicationLock() {
|
||||
return this.settingsStore.appSettings.applicationLock;
|
||||
}
|
||||
},
|
||||
setup() {
|
||||
@@ -273,6 +282,10 @@ export default {
|
||||
handleNavScroll(e) {
|
||||
this.isVerticalNavScrolled = e.target.scrollTop > 0;
|
||||
},
|
||||
lock() {
|
||||
this.rootStore.lock();
|
||||
this.$router.replace('/unlock');
|
||||
},
|
||||
logout() {
|
||||
const self = this;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user