@@ -94,13 +94,24 @@ const drawerVisible = ref();
94
94
const loading = ref ();
95
95
96
96
interface DialogProps {
97
- themeColor: { light: string ; dark: string };
97
+ themeColor: {
98
+ light: string ;
99
+ dark: string ;
100
+ themePredefineColors: {
101
+ light: string [];
102
+ dark: string [];
103
+ };
104
+ };
98
105
theme: ' ' ;
99
106
}
100
107
101
108
interface ThemeColor {
102
109
light: string ;
103
110
dark: string ;
111
+ themePredefineColors: {
112
+ light: string [];
113
+ dark: string [];
114
+ };
104
115
}
105
116
106
117
const form = reactive ({
@@ -124,6 +135,7 @@ const lightPredefineColors = ref([
124
135
' #ff4500' ,
125
136
' #ff8c00' ,
126
137
' #ffd700' ,
138
+ ' #333539' ,
127
139
]);
128
140
const darkPredefineColors = ref ([
129
141
' #238636' ,
@@ -135,6 +147,7 @@ const darkPredefineColors = ref([
135
147
' #ff4500' ,
136
148
' #ff8c00' ,
137
149
' #ffd700' ,
150
+ ' #333539' ,
138
151
]);
139
152
140
153
const defaultDarkColors = [
@@ -191,9 +204,13 @@ const acceptParams = (params: DialogProps): void => {
191
204
form .theme = params .theme ;
192
205
form .dark = form .themeColor .dark ;
193
206
form .light = form .themeColor .light ;
207
+ if (form .themeColor .themePredefineColors ) {
208
+ localStorage .setItem (STORAGE_KEY , JSON .stringify (form .themeColor .themePredefineColors ));
209
+ }
194
210
initThemeColors ();
195
211
lightPredefineColors .value = themeColors .value [' light' ];
196
212
darkPredefineColors .value = themeColors .value [' dark' ];
213
+ lightColors = defaultLightColors ;
197
214
lightPredefineColors .value .slice (0 , 2 ).forEach ((color ) => {
198
215
const exists = lightColors .some ((item ) => item .color === color );
199
216
if (! exists ) {
@@ -203,6 +220,7 @@ const acceptParams = (params: DialogProps): void => {
203
220
});
204
221
}
205
222
});
223
+ darkColors = defaultDarkColors ;
206
224
darkPredefineColors .value .slice (0 , 2 ).forEach ((color ) => {
207
225
const exists = darkColors .some ((item ) => item .color === color );
208
226
if (! exists ) {
@@ -259,7 +277,7 @@ const onSave = async (formEl: FormInstance | undefined) => {
259
277
}).then (async () => {
260
278
await formEl .validate (async (valid ) => {
261
279
if (! valid ) return ;
262
- form .themeColor = { light: form .light , dark: form .dark };
280
+ form .themeColor = { light: form .light , dark: form .dark , themePredefineColors: themeColors . value };
263
281
if (globalStore .isProductPro ) {
264
282
await updateXpackSettingByKey (' ThemeColor' , JSON .stringify (form .themeColor ));
265
283
MsgSuccess (i18n .global .t (' commons.msg.operationSuccess' ));
@@ -288,12 +306,8 @@ const onReSet = async () => {
288
306
cancelButtonText: i18n .global .t (' commons.button.cancel' ),
289
307
type: ' info' ,
290
308
}).then (async () => {
291
- form .themeColor = { light: ' #005eeb' , dark: ' #F0BE96' };
309
+ form .themeColor = { light: ' #005eeb' , dark: ' #F0BE96' , themePredefineColors: themeColors . value };
292
310
if (globalStore .isProductPro ) {
293
- localStorage .setItem (STORAGE_KEY , JSON .stringify (defaultColors ));
294
- themeColors .value = { ... defaultColors };
295
- darkColors = [... defaultDarkColors ];
296
- lightColors = [... defaultLightColors ];
297
311
await updateXpackSettingByKey (' ThemeColor' , JSON .stringify (form .themeColor ));
298
312
MsgSuccess (i18n .global .t (' commons.msg.operationSuccess' ));
299
313
loading .value = false ;
0 commit comments