Skip to content

Commit 4d713db

Browse files
committed
feat: increase support for multiple time zones
* 优化实现方法
1 parent e01803c commit 4d713db

File tree

31 files changed

+272
-422
lines changed

31 files changed

+272
-422
lines changed

apps/backend-mock/api/user/setTimezone.ts renamed to apps/backend-mock/api/timezone/setTimezone.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ export default eventHandler(async (event) => {
1010
}
1111
const { timezone } = await readBody(event);
1212
setTimezone(timezone);
13-
return useResponseSuccess();
13+
return useResponseSuccess({});
1414
});

apps/backend-mock/utils/mock-data.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface UserInfo {
77
homePath?: string;
88
}
99

10-
export interface TimeZoneOption {
10+
export interface TimezoneOption {
1111
offset: number;
1212
timeZone: string;
1313
}
@@ -397,7 +397,7 @@ export function getMenuIds(menus: any[]) {
397397
/**
398398
* 时区选项
399399
*/
400-
export const TIME_ZONE_OPTIONS: TimeZoneOption[] = [
400+
export const TIME_ZONE_OPTIONS: TimezoneOption[] = [
401401
{
402402
offset: -5,
403403
timezone: 'America/New_York',
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export * from './auth';
22
export * from './menu';
33
export * from './user';
4-
export * from './user-profile';

apps/web-antd/src/api/core/user-profile.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

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

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<script lang="ts" setup>
2-
import type { ExtendedModalApi } from '@vben/common-ui';
32
import type { NotificationItem } from '@vben/layouts';
43
5-
import { computed, onMounted, ref, unref, watch } from 'vue';
4+
import { computed, ref, watch } from 'vue';
65
76
import { AuthenticationLoginExpiredModal } from '@vben/common-ui';
87
import { VBEN_DOC_URL, VBEN_GITHUB_URL } from '@vben/constants';
@@ -12,18 +11,14 @@ import {
1211
BasicLayout,
1312
LockScreen,
1413
Notification,
15-
TimezoneButton,
1614
UserDropdown,
1715
} from '@vben/layouts';
1816
import { preferences } from '@vben/preferences';
1917
import { useAccessStore, useUserStore } from '@vben/stores';
2018
import { openWindow } from '@vben/utils';
2119
22-
import { message } from 'ant-design-vue';
23-
24-
import { getTimezoneOptionsApi } from '#/api';
2520
import { $t } from '#/locales';
26-
import { useAuthStore, useUserProfileStore } from '#/store';
21+
import { useAuthStore } from '#/store';
2722
import LoginForm from '#/views/_core/authentication/login.vue';
2823
2924
const notifications = ref<NotificationItem[]>([
@@ -65,32 +60,6 @@ const showDot = computed(() =>
6560
notifications.value.some((item) => !item.isRead),
6661
);
6762
68-
const userProfileStore = useUserProfileStore();
69-
const computedTimezone = computed(() => unref(userProfileStore.timezone));
70-
71-
const timezoneOptions = ref<string[]>([]);
72-
onMounted(async () => {
73-
timezoneOptions.value = ((await getTimezoneOptionsApi()) || []).map(
74-
(item) => item.timezone,
75-
);
76-
});
77-
const handleSetTimezone = async (
78-
modalApi: ExtendedModalApi,
79-
timezone?: string,
80-
) => {
81-
if (!timezone) {
82-
return;
83-
}
84-
try {
85-
modalApi.setState({ confirmLoading: true });
86-
await userProfileStore.setTimezone(timezone);
87-
message.success($t('ui.widgets.timezone.setSuccess'));
88-
modalApi.close();
89-
} finally {
90-
modalApi.setState({ confirmLoading: false });
91-
}
92-
};
93-
9463
const menus = computed(() => [
9564
{
9665
handler: () => {
@@ -178,14 +147,6 @@ watch(
178147
@make-all="handleMakeAll"
179148
/>
180149
</template>
181-
<template #timezone>
182-
<TimezoneButton
183-
:ok-handler="handleSetTimezone"
184-
:timezone="computedTimezone"
185-
:timezone-options="timezoneOptions"
186-
name="out"
187-
/>
188-
</template>
189150
<template #extra>
190151
<AuthenticationLoginExpiredModal
191152
v-model:open="accessStore.loginExpired"

apps/web-antd/src/store/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export * from './auth';
2-
export * from './user-profile';

apps/web-antd/src/store/user-profile.ts

Lines changed: 0 additions & 58 deletions
This file was deleted.

apps/web-ele/src/api/core/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export * from './auth';
22
export * from './menu';
33
export * from './user';
4-
export * from './user-profile';

0 commit comments

Comments
 (0)