@@ -13,7 +13,7 @@ interface TimezoneHandler {
1313 value : string ;
1414 } [ ]
1515 > ;
16- onTimezoneChange ?: ( timezone : string ) => Promise < void > ;
16+ setTimezone ?: ( timezone : string ) => Promise < void > ;
1717}
1818
1919/**
@@ -63,13 +63,12 @@ const useTimezoneStore = defineStore(
6363 getTimezone ( ) || new Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone ,
6464 ) ;
6565
66- const timezoneHandler = getTimezoneHandler ( ) ;
67-
6866 /**
6967 * 初始化时区
7068 * Initialize the timezone
7169 */
7270 async function initTimezone ( ) {
71+ const timezoneHandler = getTimezoneHandler ( ) ;
7372 const timezone = await timezoneHandler . getTimezone ?.( ) ;
7473 if ( timezone ) {
7574 timezoneRef . value = timezone ;
@@ -84,7 +83,8 @@ const useTimezoneStore = defineStore(
8483 * @param timezone 时区字符串
8584 */
8685 async function setTimezone ( timezone : string ) {
87- await timezoneHandler . onTimezoneChange ?.( timezone ) ;
86+ const timezoneHandler = getTimezoneHandler ( ) ;
87+ await timezoneHandler . setTimezone ?.( timezone ) ;
8888 timezoneRef . value = timezone ;
8989 // 设置dayjs默认时区
9090 setDefaultTimezone ( timezone ) ;
@@ -95,7 +95,8 @@ const useTimezoneStore = defineStore(
9595 * Get the timezone options
9696 */
9797 async function getTimezoneOptions ( ) {
98- return await timezoneHandler . getTimezoneOptions ( ) ;
98+ const timezoneHandler = getTimezoneHandler ( ) ;
99+ return ( await timezoneHandler . getTimezoneOptions ?.( ) ) || [ ] ;
99100 }
100101
101102 initTimezone ( ) . catch ( ( error ) => {
0 commit comments