Skip to content

Commit 10b6848

Browse files
authored
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
1 parent 06f5d56 commit 10b6848

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

apps/web-antd/src/layouts/basic.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ const avatar = computed(() => {
101101
const router = useRouter();
102102
103103
async function handleLogout() {
104-
await appStore.resetAppState();
104+
appStore.resetAppState();
105+
appStore.unlockScreen();
105106
resetRoutes();
106-
router.replace(LOGIN_PATH);
107+
await router.replace(LOGIN_PATH);
107108
}
108109
109110
function handleNoticeClear() {

packages/business/layouts/src/widgets/lock-screen/lock-screen.vue

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { computed, reactive, ref, watchEffect } from 'vue';
33
44
import { IcRoundLock } from '@vben-core/iconify';
5-
import { $t } from '@vben-core/locales';
5+
import { $t, useI18n } from '@vben-core/locales';
66
import {
77
VbenAvatar,
88
VbenButton,
@@ -27,14 +27,13 @@ const props = withDefaults(defineProps<Props>(), {
2727
2828
const emit = defineEmits<{ toLogin: []; unlock: [string] }>();
2929
30+
const { locale } = useI18n();
31+
3032
const now = useNow();
31-
const year = useDateFormat(now, 'YYYY');
32-
const month = useDateFormat(now, 'MM');
33-
const day = useDateFormat(now, 'DD');
34-
const week = useDateFormat(now, 'dddd');
35-
const hour = useDateFormat(now, 'HH');
3633
const meridiem = useDateFormat(now, 'A');
34+
const hour = useDateFormat(now, 'HH');
3735
const minute = useDateFormat(now, 'mm');
36+
const date = useDateFormat(now, 'YYYY-MM-DD dddd', { locales: locale.value });
3837
3938
const showUnlockForm = ref(false);
4039
const validPass = ref(true);
@@ -102,9 +101,9 @@ function toggleUnlockForm() {
102101
<div
103102
class="bg-accent flex-center relative mb-14 mr-20 h-4/5 w-2/5 flex-auto rounded-3xl text-center text-[260px]"
104103
>
105-
<span class="absolute left-4 top-4 text-xl font-semibold">{{
106-
meridiem
107-
}}</span>
104+
<span class="absolute left-4 top-4 text-xl font-semibold">
105+
{{ meridiem }}
106+
</span>
108107
{{ hour }}
109108
</div>
110109
<div
@@ -124,7 +123,7 @@ function toggleUnlockForm() {
124123
>
125124
<div class="flex-col-center mb-10 w-[300px]">
126125
<VbenAvatar :src="avatar" class="enter-x mb-6 size-20" />
127-
<div class="items-cente enter-x mb-2 w-full">
126+
<div class="enter-x mb-2 w-full items-center">
128127
<VbenInputPassword
129128
v-model="formState.password"
130129
:autofocus="true"
@@ -164,7 +163,7 @@ function toggleUnlockForm() {
164163
<div v-if="showUnlockForm" class="enter-x mb-2 text-3xl">
165164
{{ hour }}:{{ minute }} <span class="text-lg">{{ meridiem }}</span>
166165
</div>
167-
<div class="text-3xl">{{ year }}/{{ month }}/{{ day }} {{ week }}</div>
166+
<div class="text-3xl">{{ date }}</div>
168167
</div>
169168
</div>
170169
</template>

packages/business/layouts/src/widgets/user-dropdown/user-dropdown.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ if (enableShortcutKey.value) {
170170
<div class="hover:bg-accent ml-1 mr-2 cursor-pointer rounded-full p-1.5">
171171
<div class="hover:text-accent-foreground flex-center">
172172
<VbenAvatar :alt="text" :src="avatar" class="size-8" dot />
173-
<!-- <div v-if="text" class="ml-2 text-sm">{{ text }}</div> -->
174173
</div>
175174
</div>
176175
</DropdownMenuTrigger>
@@ -201,7 +200,7 @@ if (enableShortcutKey.value) {
201200
<DropdownMenuItem
202201
v-for="menu in menus"
203202
:key="menu.text"
204-
class="lineh mx-1 flex cursor-pointer items-center rounded-sm py-1 leading-8"
203+
class="mx-1 flex cursor-pointer items-center rounded-sm py-1 leading-8"
205204
@click="menu.handler"
206205
>
207206
<VbenIcon :icon="menu.icon" class="mr-2 size-5" />

0 commit comments

Comments
 (0)