feat: increase support for multiple time zones

* 优化实现方法
This commit is contained in:
zhongming4762
2025-10-29 19:47:10 +08:00
parent e01803ce9d
commit 4d713db546
31 changed files with 273 additions and 423 deletions

View File

@@ -1,3 +1,4 @@
export * from './auth';
export * from './menu';
export * from './timezone';
export * from './user';

View File

@@ -0,0 +1,30 @@
import type { TimezoneOption } from '@vben/types';
import { requestClient } from '#/api/request';
/**
* 获取系统支持的时区列表
*/
export async function getTimezoneOptionsApi() {
const dataList =
(await requestClient.get<TimezoneOption[]>(
'/timezone/getTimezoneOptions',
)) || [];
return dataList.map((item) => ({
label: item.timezone,
value: item.timezone,
}));
}
/**
* 获取用户时区
*/
export async function getTimezoneApi(): Promise<null | string | undefined> {
return requestClient.get<null | string | undefined>('/timezone/getTimezone');
}
/**
* 设置用户时区
* @param timezone 时区
*/
export async function setTimezoneApi(timezone: string) {
return requestClient.post('/timezone/setTimezone', { timezone });
}