@svadmin/core 0.19.0 → 0.19.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.0",
3
+ "version": "0.19.1",
4
4
  "author": "zuohuadong",
5
5
  "repository": {
6
6
  "type": "git",
@@ -326,10 +326,16 @@ export function useForm<
326
326
 
327
327
  if (!runValidation()) { toast.warning(t('validation.required')); return; }
328
328
  redirectOverride = overrides?.redirect;
329
- if (action === 'create' || action === 'clone') await createMut.mutateAsync(values);
330
- else await updateMut.mutateAsync(values);
331
- // Untaint on success
332
- tainted = {};
329
+ try {
330
+ if (action === 'create' || action === 'clone') await createMut.mutateAsync(values);
331
+ else await updateMut.mutateAsync(values);
332
+ // Untaint on success
333
+ tainted = {};
334
+ } catch (error) {
335
+ // Errors are already handled by the mutation's onError callback.
336
+ // We catch here to prevent unhandled promise rejections.
337
+ handleHttpError(error instanceof Error ? error : new Error(String(error)));
338
+ }
333
339
  }
334
340
 
335
341
  // ─── AutoSave ───────────────────────────────────────────────────
@@ -170,6 +170,11 @@ export function useSelect<TData extends BaseRecord = BaseRecord, TOption = { lab
170
170
  debounceTimer = setTimeout(() => { searchText = value; }, debounceMs);
171
171
  }
172
172
 
173
+ // Cleanup debounce timer on unmount
174
+ $effect(() => {
175
+ return () => { if (debounceTimer) clearTimeout(debounceTimer); };
176
+ });
177
+
173
178
  return {
174
179
  query,
175
180
  get options() { return selectOptions; },
@@ -336,7 +336,7 @@ function applyTheme(m: ThemeMode): void {
336
336
  }
337
337
 
338
338
  // Apply on init
339
- applyTheme(mode);
339
+ applyTheme(getStoredTheme());
340
340
 
341
341
  // Listen for system preference changes
342
342
  if (typeof window !== 'undefined') {
@@ -383,7 +383,7 @@ function applyColorTheme(ct: ColorTheme): void {
383
383
  }
384
384
 
385
385
  // Apply on init
386
- applyColorTheme(colorTheme);
386
+ applyColorTheme(getStoredColorTheme());
387
387
 
388
388
  export function getColorTheme(): ColorTheme {
389
389
  return colorTheme;
@@ -71,8 +71,6 @@ export function initUnsavedChangesNotifier(options?: {
71
71
  }) {
72
72
  if (typeof window === 'undefined') return;
73
73
 
74
- const message = t('common.unsavedChanges');
75
-
76
74
  // 1. Browser tab close / refresh
77
75
  const onBeforeUnload = (e: BeforeUnloadEvent) => {
78
76
  if (!dirty) return;
@@ -85,7 +83,7 @@ export function initUnsavedChangesNotifier(options?: {
85
83
  if (options?.beforeNavigate) {
86
84
  options.beforeNavigate(({ cancel }) => {
87
85
  if (dirty) {
88
- if (!confirm(message)) {
86
+ if (!confirm(t('common.unsavedChanges'))) {
89
87
  cancel();
90
88
  } else {
91
89
  dirty = false;
@@ -97,7 +95,7 @@ export function initUnsavedChangesNotifier(options?: {
97
95
  // 3. Hash-based fallback for SPAs without a framework router
98
96
  const onHashChange = (e: HashChangeEvent) => {
99
97
  if (!dirty) return;
100
- if (!confirm(message)) {
98
+ if (!confirm(t('common.unsavedChanges'))) {
101
99
  e.preventDefault();
102
100
  if (e.oldURL) {
103
101
  history.replaceState(null, '', new URL(e.oldURL).hash || '#');