mirror of
https://gitee.com/dapppp/ruoyi-plus-vben5.git
synced 2026-03-17 10:02:02 +08:00
Merge branch 'fork/ming4762/timezone-20251020'
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
export * from './auth';
|
||||
export * from './menu';
|
||||
export * from './timezone';
|
||||
export * from './user';
|
||||
|
||||
26
playground/src/api/core/timezone.ts
Normal file
26
playground/src/api/core/timezone.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* 获取系统支持的时区列表
|
||||
*/
|
||||
export async function getTimezoneOptionsApi() {
|
||||
return await requestClient.get<
|
||||
{
|
||||
label: string;
|
||||
value: string;
|
||||
}[]
|
||||
>('/timezone/getTimezoneOptions');
|
||||
}
|
||||
/**
|
||||
* 获取用户时区
|
||||
*/
|
||||
export async function getTimezoneApi(): Promise<null | string | undefined> {
|
||||
return requestClient.get<null | string | undefined>('/timezone/getTimezone');
|
||||
}
|
||||
/**
|
||||
* 设置用户时区
|
||||
* @param timezone 时区
|
||||
*/
|
||||
export async function setTimezoneApi(timezone: string): Promise<void> {
|
||||
return requestClient.post('/timezone/setTimezone', { timezone });
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import { router } from '#/router';
|
||||
import { initComponentAdapter } from './adapter/component';
|
||||
import { initSetupVbenForm } from './adapter/form';
|
||||
import App from './app.vue';
|
||||
import { initTimezone } from './timezone-init';
|
||||
|
||||
async function bootstrap(namespace: string) {
|
||||
// 初始化组件适配器
|
||||
@@ -46,6 +47,9 @@ async function bootstrap(namespace: string) {
|
||||
// 配置 pinia-tore
|
||||
await initStores(app, { namespace });
|
||||
|
||||
// 初始化时区HANDLER
|
||||
initTimezone();
|
||||
|
||||
// 安装权限指令
|
||||
registerAccessDirective(app);
|
||||
|
||||
|
||||
20
playground/src/timezone-init.ts
Normal file
20
playground/src/timezone-init.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { setTimezoneHandler } from '@vben/stores';
|
||||
|
||||
import { getTimezoneApi, getTimezoneOptionsApi, setTimezoneApi } from '#/api';
|
||||
|
||||
/**
|
||||
* 初始化时区处理,通过API保存时区设置
|
||||
*/
|
||||
export function initTimezone() {
|
||||
setTimezoneHandler({
|
||||
getTimezone() {
|
||||
return getTimezoneApi();
|
||||
},
|
||||
setTimezone(timezone: string) {
|
||||
return setTimezoneApi(timezone);
|
||||
},
|
||||
getTimezoneOptions() {
|
||||
return getTimezoneOptionsApi();
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user