From 10b684832d2dec49966aa9f89ff414e878009ade Mon Sep 17 00:00:00 2001 From: Li Kui <90845831+likui628@users.noreply.github.com> Date: Fri, 12 Jul 2024 22:22:36 +0800 Subject: [PATCH] fix: back to login does not clear lock-screen state (#41) * refactor: replace separate date variables with formatted date string * fix: back to login does not clear lock-screen state --- apps/web-antd/src/layouts/basic.vue | 5 +++-- .../src/widgets/lock-screen/lock-screen.vue | 21 +++++++++---------- .../widgets/user-dropdown/user-dropdown.vue | 3 +-- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/apps/web-antd/src/layouts/basic.vue b/apps/web-antd/src/layouts/basic.vue index c9af11b1..a30481bd 100644 --- a/apps/web-antd/src/layouts/basic.vue +++ b/apps/web-antd/src/layouts/basic.vue @@ -101,9 +101,10 @@ const avatar = computed(() => { const router = useRouter(); async function handleLogout() { - await appStore.resetAppState(); + appStore.resetAppState(); + appStore.unlockScreen(); resetRoutes(); - router.replace(LOGIN_PATH); + await router.replace(LOGIN_PATH); } function handleNoticeClear() { diff --git a/packages/business/layouts/src/widgets/lock-screen/lock-screen.vue b/packages/business/layouts/src/widgets/lock-screen/lock-screen.vue index ad34f9ec..1339a873 100644 --- a/packages/business/layouts/src/widgets/lock-screen/lock-screen.vue +++ b/packages/business/layouts/src/widgets/lock-screen/lock-screen.vue @@ -2,7 +2,7 @@ import { computed, reactive, ref, watchEffect } from 'vue'; import { IcRoundLock } from '@vben-core/iconify'; -import { $t } from '@vben-core/locales'; +import { $t, useI18n } from '@vben-core/locales'; import { VbenAvatar, VbenButton, @@ -27,14 +27,13 @@ const props = withDefaults(defineProps(), { const emit = defineEmits<{ toLogin: []; unlock: [string] }>(); +const { locale } = useI18n(); + const now = useNow(); -const year = useDateFormat(now, 'YYYY'); -const month = useDateFormat(now, 'MM'); -const day = useDateFormat(now, 'DD'); -const week = useDateFormat(now, 'dddd'); -const hour = useDateFormat(now, 'HH'); const meridiem = useDateFormat(now, 'A'); +const hour = useDateFormat(now, 'HH'); const minute = useDateFormat(now, 'mm'); +const date = useDateFormat(now, 'YYYY-MM-DD dddd', { locales: locale.value }); const showUnlockForm = ref(false); const validPass = ref(true); @@ -102,9 +101,9 @@ function toggleUnlockForm() {
- {{ - meridiem - }} + + {{ meridiem }} + {{ hour }}
-
+
{{ hour }}:{{ minute }} {{ meridiem }}
-
{{ year }}/{{ month }}/{{ day }} {{ week }}
+
{{ date }}
diff --git a/packages/business/layouts/src/widgets/user-dropdown/user-dropdown.vue b/packages/business/layouts/src/widgets/user-dropdown/user-dropdown.vue index 76ee856e..b171d53b 100644 --- a/packages/business/layouts/src/widgets/user-dropdown/user-dropdown.vue +++ b/packages/business/layouts/src/widgets/user-dropdown/user-dropdown.vue @@ -170,7 +170,6 @@ if (enableShortcutKey.value) {
-
@@ -201,7 +200,7 @@ if (enableShortcutKey.value) {