@svadmin/core 0.19.5 → 0.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svadmin/core",
3
- "version": "0.19.5",
3
+ "version": "0.20.1",
4
4
  "author": "zuohuadong",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,6 +40,7 @@ const locales: Record<string, Locale> = {
40
40
  'common.logout': '退出登录',
41
41
  'common.toggleTheme': '切换主题',
42
42
  'common.switchLanguage': '切换语言',
43
+ 'common.goToSite': '返回工作台',
43
44
  'common.clear': '清除',
44
45
  'common.menu': '菜单',
45
46
  'common.darkMode': '暗色模式',
@@ -276,6 +277,7 @@ const locales: Record<string, Locale> = {
276
277
  'common.logout': 'Log out',
277
278
  'common.toggleTheme': 'Toggle theme',
278
279
  'common.switchLanguage': 'Switch language',
280
+ 'common.goToSite': 'Go to Workspace',
279
281
  'common.clear': 'Clear',
280
282
  'common.menu': 'Menu',
281
283
  'common.darkMode': 'Dark mode',
@@ -341,7 +341,12 @@ applyTheme(getStoredTheme());
341
341
  // Listen for system preference changes
342
342
  if (typeof window !== 'undefined') {
343
343
  window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
344
- if (mode === 'system') applyTheme('system');
344
+ if (mode === 'system') {
345
+ applyTheme('system');
346
+ // Re-apply color preset for new resolved mode (light/dark values differ)
347
+ const preset = builtinPresets[colorTheme];
348
+ if (preset) applyColorPreset(preset);
349
+ }
345
350
  });
346
351
  }
347
352
 
@@ -355,6 +360,9 @@ export function setTheme(newMode: ThemeMode): void {
355
360
  localStorage.setItem(STORAGE_KEY, newMode);
356
361
  }
357
362
  applyTheme(newMode);
363
+ // Re-apply color preset — light/dark CSS variable overrides differ
364
+ const preset = builtinPresets[colorTheme];
365
+ if (preset) applyColorPreset(preset);
358
366
  }
359
367
 
360
368
  export function toggleTheme(): void {
@@ -384,6 +392,10 @@ function applyColorTheme(ct: ColorTheme): void {
384
392
 
385
393
  // Apply on init
386
394
  applyColorTheme(getStoredColorTheme());
395
+ {
396
+ const initPreset = builtinPresets[getStoredColorTheme()];
397
+ if (initPreset) applyColorPreset(initPreset);
398
+ }
387
399
 
388
400
  export function getColorTheme(): ColorTheme {
389
401
  return colorTheme;
@@ -395,4 +407,7 @@ export function setColorTheme(ct: ColorTheme): void {
395
407
  localStorage.setItem(COLOR_STORAGE_KEY, ct);
396
408
  }
397
409
  applyColorTheme(ct);
410
+ // Apply the preset's CSS variable overrides for the current resolved theme
411
+ const preset = builtinPresets[ct];
412
+ if (preset) applyColorPreset(preset);
398
413
  }