@@ -164,53 +164,63 @@ const changeDarkColor = (color: string) => {
164164
165165const onSave = async (formEl : FormInstance | undefined ) => {
166166 if (! formEl ) return ;
167- await formEl .validate (async (valid ) => {
168- if (! valid ) return ;
169- form .themeColor = { light: form .light , dark: form .dark };
167+ ElMessageBox .confirm (i18n .global .t (' xpack.theme.setHelper' ), i18n .global .t (' commons.button.save' ), {
168+ confirmButtonText: i18n .global .t (' commons.button.confirm' ),
169+ cancelButtonText: i18n .global .t (' commons.button.cancel' ),
170+ type: ' info' ,
171+ }).then (async () => {
172+ await formEl .validate (async (valid ) => {
173+ if (! valid ) return ;
174+ form .themeColor = { light: form .light , dark: form .dark };
175+ if (globalStore .isProductPro ) {
176+ await updateXpackSettingByKey (' ThemeColor' , JSON .stringify (form .themeColor ));
177+ MsgSuccess (i18n .global .t (' commons.msg.operationSuccess' ));
178+ globalStore .themeConfig .themeColor = JSON .stringify (form .themeColor );
179+ loading .value = false ;
180+ let color: string ;
181+ if (form .theme === ' auto' ) {
182+ const prefersDark = window .matchMedia (' (prefers-color-scheme: dark)' );
183+ color = prefersDark .matches ? form .dark : form .light ;
184+ } else {
185+ color = form .theme === ' dark' ? form .dark : form .light ;
186+ }
187+ globalStore .themeConfig .primary = color ;
188+ setPrimaryColor (color );
189+ initFavicon ();
190+ drawerVisible .value = false ;
191+ emit (' search' );
192+ }
193+ });
194+ });
195+ };
196+
197+ const onReSet = async () => {
198+ ElMessageBox .confirm (i18n .global .t (' xpack.theme.setDefaultHelper' ), i18n .global .t (' xpack.theme.setDefault' ), {
199+ confirmButtonText: i18n .global .t (' commons.button.confirm' ),
200+ cancelButtonText: i18n .global .t (' commons.button.cancel' ),
201+ type: ' info' ,
202+ }).then (async () => {
203+ form .themeColor = { light: ' #005eeb' , dark: ' #F0BE96' };
170204 if (globalStore .isProductPro ) {
171205 await updateXpackSettingByKey (' ThemeColor' , JSON .stringify (form .themeColor ));
172206 MsgSuccess (i18n .global .t (' commons.msg.operationSuccess' ));
173- globalStore .themeConfig .themeColor = JSON .stringify (form .themeColor );
174207 loading .value = false ;
208+ globalStore .themeConfig .themeColor = JSON .stringify (form .themeColor );
175209 let color: string ;
176210 if (form .theme === ' auto' ) {
177211 const prefersDark = window .matchMedia (' (prefers-color-scheme: dark)' );
178- color = prefersDark .matches ? form . dark : form . light ;
212+ color = prefersDark .matches ? ' #F0BE96 ' : ' #005eeb ' ;
179213 } else {
180- color = form .theme === ' dark' ? form . dark : form . light ;
214+ color = form .theme === ' dark' ? ' #F0BE96 ' : ' #005eeb ' ;
181215 }
182216 globalStore .themeConfig .primary = color ;
183217 setPrimaryColor (color );
184218 initFavicon ();
185219 drawerVisible .value = false ;
186- emit (' search' );
187- return ;
188220 }
189221 });
190222};
191223
192- const onReSet = async () => {
193- form .themeColor = { light: ' #005eeb' , dark: ' #F0BE96' };
194- if (globalStore .isProductPro ) {
195- await updateXpackSettingByKey (' ThemeColor' , JSON .stringify (form .themeColor ));
196- MsgSuccess (i18n .global .t (' commons.msg.operationSuccess' ));
197- loading .value = false ;
198- globalStore .themeConfig .themeColor = JSON .stringify (form .themeColor );
199- let color: string ;
200- if (form .theme === ' auto' ) {
201- const prefersDark = window .matchMedia (' (prefers-color-scheme: dark)' );
202- color = prefersDark .matches ? ' #F0BE96' : ' #005eeb' ;
203- } else {
204- color = form .theme === ' dark' ? ' #F0BE96' : ' #005eeb' ;
205- }
206- globalStore .themeConfig .primary = color ;
207- setPrimaryColor (color );
208- initFavicon ();
209- drawerVisible .value = false ;
210- return ;
211- }
212- };
213-
214224const handleClose = () => {
215225 drawerVisible .value = false ;
216226};
0 commit comments