@svadmin/ui 0.116.0 → 0.118.0

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.
Files changed (61) hide show
  1. package/dist/app.css +320 -26
  2. package/dist/app.theme.css +320 -26
  3. package/dist/components/AboutSettings.svelte +1 -1
  4. package/dist/components/ApprovalTimeline.svelte +170 -0
  5. package/dist/components/ApprovalTimeline.svelte.d.ts +26 -0
  6. package/dist/components/CopyableText.svelte +90 -0
  7. package/dist/components/CopyableText.svelte.d.ts +13 -0
  8. package/dist/components/Divider.svelte +89 -0
  9. package/dist/components/Divider.svelte.d.ts +19 -0
  10. package/dist/components/EllipsisText.svelte +78 -0
  11. package/dist/components/EllipsisText.svelte.d.ts +15 -0
  12. package/dist/components/ExcelExportButton.svelte +142 -0
  13. package/dist/components/ExcelExportButton.svelte.d.ts +21 -0
  14. package/dist/components/ExcelImportWizard.svelte +571 -0
  15. package/dist/components/ExcelImportWizard.svelte.d.ts +26 -0
  16. package/dist/components/FloatButtonGroup.svelte +162 -0
  17. package/dist/components/FloatButtonGroup.svelte.d.ts +34 -0
  18. package/dist/components/FullscreenButton.svelte +88 -0
  19. package/dist/components/FullscreenButton.svelte.d.ts +10 -0
  20. package/dist/components/GlobalShortcuts.svelte +229 -0
  21. package/dist/components/GlobalShortcuts.svelte.d.ts +18 -0
  22. package/dist/components/Header.svelte +17 -1
  23. package/dist/components/Header.svelte.d.ts +3 -0
  24. package/dist/components/Layout.svelte +3 -0
  25. package/dist/components/Layout.svelte.d.ts +1 -0
  26. package/dist/components/LightFilter.svelte +281 -0
  27. package/dist/components/LightFilter.svelte.d.ts +36 -0
  28. package/dist/components/LockScreen.svelte +295 -0
  29. package/dist/components/LockScreen.svelte.d.ts +21 -0
  30. package/dist/components/OrgTreePicker.svelte +325 -0
  31. package/dist/components/OrgTreePicker.svelte.d.ts +32 -0
  32. package/dist/components/PivotDrilldownModal.svelte +228 -0
  33. package/dist/components/PivotDrilldownModal.svelte.d.ts +22 -0
  34. package/dist/components/PricingCard.svelte +12 -12
  35. package/dist/components/PricingCard.svelte.d.ts +12 -12
  36. package/dist/components/PricingTable.svelte +185 -0
  37. package/dist/components/PricingTable.svelte.d.ts +40 -0
  38. package/dist/components/ProCard.svelte +267 -0
  39. package/dist/components/ProCard.svelte.d.ts +56 -0
  40. package/dist/components/ProSkeleton.svelte +186 -0
  41. package/dist/components/ProSkeleton.svelte.d.ts +20 -0
  42. package/dist/components/QuotaProgressBar.svelte +8 -8
  43. package/dist/components/QuotaProgressBar.svelte.d.ts +8 -8
  44. package/dist/components/Ribbon.svelte +97 -0
  45. package/dist/components/Ribbon.svelte.d.ts +19 -0
  46. package/dist/components/TreeTransfer.svelte +288 -0
  47. package/dist/components/TreeTransfer.svelte.d.ts +25 -0
  48. package/dist/components/TypographyEllipsis.svelte +12 -9
  49. package/dist/components/TypographyEllipsis.svelte.d.ts +9 -8
  50. package/dist/components/TypographyText.svelte +41 -3
  51. package/dist/components/TypographyText.svelte.d.ts +10 -2
  52. package/dist/components/UsageCard.svelte +97 -0
  53. package/dist/components/UsageCard.svelte.d.ts +26 -0
  54. package/dist/components/WorkflowProcessCard.svelte +93 -0
  55. package/dist/components/WorkflowProcessCard.svelte.d.ts +21 -0
  56. package/dist/components/ui/badge/badge.svelte +156 -12
  57. package/dist/components/ui/badge/badge.svelte.d.ts +9 -0
  58. package/dist/components/ui/badge/index.d.ts +1 -1
  59. package/dist/index.d.ts +44 -3
  60. package/dist/index.js +28 -2
  61. package/package.json +5 -5
@@ -0,0 +1,281 @@
1
+ <script lang="ts">
2
+ import { Filter, X, RotateCcw, ChevronDown, Check } from '@lucide/svelte';
3
+ import * as Popover from './ui/popover/index.js';
4
+ import { cn } from '../utils.js';
5
+ import { useTranslation } from '@svadmin/core/i18n';
6
+
7
+ export interface LightFilterOption {
8
+ label: string;
9
+ value: string | number;
10
+ }
11
+
12
+ export interface LightFilterItem {
13
+ key: string;
14
+ label: string;
15
+ placeholder?: string;
16
+ type?: 'select' | 'input' | 'date';
17
+ options?: LightFilterOption[];
18
+ allowClear?: boolean;
19
+ }
20
+
21
+ export interface LightFilterProps {
22
+ /** Filter field definitions */
23
+ items: LightFilterItem[];
24
+ /** Bound values object: key -> value */
25
+ values?: Record<string, unknown>;
26
+ /** Callback when filter values change */
27
+ onchange?: (values: Record<string, unknown>) => void;
28
+ /** Callback when all filters are reset */
29
+ onreset?: () => void;
30
+ /** Whether the filter bar has an outer border */
31
+ bordered?: boolean;
32
+ /** Size tier */
33
+ size?: 'small' | 'default';
34
+ /** Maximum visible items before collapsing into 'More' */
35
+ maxDisplayCount?: number;
36
+ /** Extra elements on the right */
37
+ extra?: import('svelte').Snippet;
38
+ /** Custom class name */
39
+ class?: string;
40
+ [key: string]: unknown;
41
+ }
42
+
43
+ let {
44
+ items = [],
45
+ values = $bindable({}),
46
+ onchange,
47
+ onreset,
48
+ bordered = false,
49
+ size = 'default',
50
+ maxDisplayCount = 5,
51
+ extra,
52
+ class: className = '',
53
+ ...restProps
54
+ }: LightFilterProps = $props();
55
+
56
+ const i18n = useTranslation();
57
+
58
+ const primaryItems = $derived(items.slice(0, maxDisplayCount));
59
+ const overflowItems = $derived(items.slice(maxDisplayCount));
60
+
61
+ const activeCount = $derived(
62
+ Object.values(values).filter((v) => v !== undefined && v !== '' && v !== null).length
63
+ );
64
+
65
+ function setFieldValue(key: string, val: unknown) {
66
+ const next: Record<string, unknown> = {};
67
+ for (const [k, v] of Object.entries(values)) {
68
+ if (k !== key && v !== undefined && v !== '' && v !== null) {
69
+ next[k] = v;
70
+ }
71
+ }
72
+ if (val !== undefined && val !== '' && val !== null) {
73
+ next[key] = val;
74
+ }
75
+ values = next;
76
+ onchange?.(next);
77
+ }
78
+
79
+ function clearField(key: string, e?: MouseEvent) {
80
+ e?.stopPropagation();
81
+ setFieldValue(key, undefined);
82
+ }
83
+
84
+ function handleResetAll() {
85
+ values = {};
86
+ onreset?.();
87
+ onchange?.({});
88
+ }
89
+
90
+ function getDisplayLabel(item: LightFilterItem): string {
91
+ const currentVal = values[item.key];
92
+ if (currentVal === undefined || currentVal === '' || currentVal === null) {
93
+ return item.label;
94
+ }
95
+ if (item.options) {
96
+ const match = item.options.find((o) => String(o.value) === String(currentVal));
97
+ if (match) return `${item.label}: ${match.label}`;
98
+ }
99
+ return `${item.label}: ${String(currentVal)}`;
100
+ }
101
+ </script>
102
+
103
+ <div
104
+ data-svadmin-component="LightFilter"
105
+ data-size={size}
106
+ class={cn(
107
+ 'flex flex-wrap items-center gap-1.5',
108
+ bordered && 'border border-border p-2 rounded-[4px] bg-background',
109
+ className
110
+ )}
111
+ {...restProps}
112
+ >
113
+ {#each primaryItems as item (item.key)}
114
+ {@const hasValue = values[item.key] !== undefined && values[item.key] !== '' && values[item.key] !== null}
115
+ <Popover.Root>
116
+ <Popover.Trigger>
117
+ {#snippet child({ props })}
118
+ <button
119
+ type="button"
120
+ class={cn(
121
+ 'inline-flex items-center gap-1.5 transition-colors font-normal rounded-[4px] border select-none',
122
+ size === 'small' ? 'h-7 px-2 text-xs' : 'h-8 px-2.5 text-xs',
123
+ hasValue
124
+ ? 'bg-primary/10 text-primary border-primary/30 font-medium'
125
+ : 'bg-muted/40 text-muted-foreground border-border/80 hover:bg-muted hover:text-foreground'
126
+ )}
127
+ {...props}
128
+ >
129
+ <span class="truncate max-w-[160px]">{getDisplayLabel(item)}</span>
130
+
131
+ {#if hasValue && item.allowClear !== false}
132
+ <span
133
+ role="button"
134
+ tabindex={-1}
135
+ aria-label="Clear filter"
136
+ class="hover:text-destructive rounded-full p-0.5"
137
+ onclick={(e) => clearField(item.key, e)}
138
+ onkeydown={(e) => {
139
+ if (e.key === 'Enter') clearField(item.key);
140
+ }}
141
+ >
142
+ <X class="h-3 w-3" />
143
+ </span>
144
+ {:else}
145
+ <ChevronDown class="h-3 w-3 opacity-60" />
146
+ {/if}
147
+ </button>
148
+ {/snippet}
149
+ </Popover.Trigger>
150
+ <Popover.Content align="start" class="w-56 p-2 rounded-[4px] shadow-md border border-border">
151
+ {#if item.type === 'input'}
152
+ <div class="space-y-2">
153
+ <div class="text-xs font-medium text-foreground">{item.label}</div>
154
+ <input
155
+ type="text"
156
+ value={String(values[item.key] ?? '')}
157
+ placeholder={item.placeholder ?? item.label}
158
+ oninput={(e) => setFieldValue(item.key, (e.target as HTMLInputElement).value)}
159
+ class="w-full h-8 px-2.5 text-xs rounded-[4px] border border-input bg-background focus:outline-none focus:ring-1 focus:ring-primary"
160
+ />
161
+ </div>
162
+ {:else if item.type === 'date'}
163
+ <div class="space-y-2">
164
+ <div class="text-xs font-medium text-foreground">{item.label}</div>
165
+ <input
166
+ type="date"
167
+ value={String(values[item.key] ?? '')}
168
+ onchange={(e) => setFieldValue(item.key, (e.target as HTMLInputElement).value)}
169
+ class="w-full h-8 px-2.5 text-xs rounded-[4px] border border-input bg-background focus:outline-none focus:ring-1 focus:ring-primary"
170
+ />
171
+ </div>
172
+ {:else}
173
+ <!-- Default: select options -->
174
+ <div class="space-y-1">
175
+ <div class="px-2 py-1 text-xs font-semibold text-muted-foreground">{item.label}</div>
176
+ <button
177
+ type="button"
178
+ class={cn(
179
+ 'w-full flex items-center justify-between px-2 py-1.5 text-xs rounded-[2px] text-left transition-colors',
180
+ !values[item.key] ? 'bg-accent text-accent-foreground font-medium' : 'hover:bg-muted text-foreground'
181
+ )}
182
+ onclick={() => setFieldValue(item.key, undefined)}
183
+ >
184
+ <span>{i18n.t('common.all') || 'All'}</span>
185
+ {#if !values[item.key]}
186
+ <Check class="h-3.5 w-3.5 text-primary" />
187
+ {/if}
188
+ </button>
189
+ {#each (item.options ?? []) as opt (opt.value)}
190
+ {@const selected = String(values[item.key]) === String(opt.value)}
191
+ <button
192
+ type="button"
193
+ class={cn(
194
+ 'w-full flex items-center justify-between px-2 py-1.5 text-xs rounded-[2px] text-left transition-colors',
195
+ selected ? 'bg-accent text-accent-foreground font-medium' : 'hover:bg-muted text-foreground'
196
+ )}
197
+ onclick={() => setFieldValue(item.key, opt.value)}
198
+ >
199
+ <span>{opt.label}</span>
200
+ {#if selected}
201
+ <Check class="h-3.5 w-3.5 text-primary" />
202
+ {/if}
203
+ </button>
204
+ {/each}
205
+ </div>
206
+ {/if}
207
+ </Popover.Content>
208
+ </Popover.Root>
209
+ {/each}
210
+
211
+ <!-- Overflow items grouped into 'More Filters' -->
212
+ {#if overflowItems.length > 0}
213
+ <Popover.Root>
214
+ <Popover.Trigger>
215
+ {#snippet child({ props })}
216
+ <button
217
+ type="button"
218
+ class={cn(
219
+ 'inline-flex items-center gap-1.5 transition-colors font-normal rounded-[4px] border select-none',
220
+ size === 'small' ? 'h-7 px-2 text-xs' : 'h-8 px-2.5 text-xs',
221
+ 'bg-muted/40 text-muted-foreground border-border/80 hover:bg-muted hover:text-foreground'
222
+ )}
223
+ {...props}
224
+ >
225
+ <Filter class="h-3 w-3" />
226
+ <span>{i18n.t('common.filter') || 'More Filters'} ({overflowItems.length})</span>
227
+ <ChevronDown class="h-3 w-3 opacity-60" />
228
+ </button>
229
+ {/snippet}
230
+ </Popover.Trigger>
231
+ <Popover.Content align="start" class="w-64 p-3 rounded-[4px] shadow-md border border-border space-y-3">
232
+ {#each overflowItems as item (item.key)}
233
+ <div class="space-y-1">
234
+ <div class="text-xs font-medium text-foreground">{item.label}</div>
235
+ {#if item.options}
236
+ <select
237
+ class="w-full h-8 px-2 text-xs rounded-[4px] border border-input bg-background"
238
+ value={String(values[item.key] ?? '')}
239
+ onchange={(e) => setFieldValue(item.key, (e.target as HTMLSelectElement).value)}
240
+ >
241
+ <option value="">{i18n.t('common.all') || 'All'}</option>
242
+ {#each item.options as opt (opt.value)}
243
+ <option value={opt.value}>{opt.label}</option>
244
+ {/each}
245
+ </select>
246
+ {:else}
247
+ <input
248
+ type="text"
249
+ value={String(values[item.key] ?? '')}
250
+ placeholder={item.placeholder ?? item.label}
251
+ oninput={(e) => setFieldValue(item.key, (e.target as HTMLInputElement).value)}
252
+ class="w-full h-8 px-2 text-xs rounded-[4px] border border-input bg-background"
253
+ />
254
+ {/if}
255
+ </div>
256
+ {/each}
257
+ </Popover.Content>
258
+ </Popover.Root>
259
+ {/if}
260
+
261
+ {#if activeCount > 0}
262
+ <button
263
+ type="button"
264
+ class={cn(
265
+ 'inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors px-1.5 py-1 rounded-[2px]',
266
+ size === 'small' ? 'text-[11px]' : 'text-xs'
267
+ )}
268
+ onclick={handleResetAll}
269
+ title={i18n.t('common.reset') || 'Reset'}
270
+ >
271
+ <RotateCcw class="h-3 w-3" />
272
+ <span>{i18n.t('common.reset') || 'Reset'}</span>
273
+ </button>
274
+ {/if}
275
+
276
+ {#if extra}
277
+ <div class="ml-auto flex items-center gap-2">
278
+ {@render extra()}
279
+ </div>
280
+ {/if}
281
+ </div>
@@ -0,0 +1,36 @@
1
+ export interface LightFilterOption {
2
+ label: string;
3
+ value: string | number;
4
+ }
5
+ export interface LightFilterItem {
6
+ key: string;
7
+ label: string;
8
+ placeholder?: string;
9
+ type?: 'select' | 'input' | 'date';
10
+ options?: LightFilterOption[];
11
+ allowClear?: boolean;
12
+ }
13
+ export interface LightFilterProps {
14
+ /** Filter field definitions */
15
+ items: LightFilterItem[];
16
+ /** Bound values object: key -> value */
17
+ values?: Record<string, unknown>;
18
+ /** Callback when filter values change */
19
+ onchange?: (values: Record<string, unknown>) => void;
20
+ /** Callback when all filters are reset */
21
+ onreset?: () => void;
22
+ /** Whether the filter bar has an outer border */
23
+ bordered?: boolean;
24
+ /** Size tier */
25
+ size?: 'small' | 'default';
26
+ /** Maximum visible items before collapsing into 'More' */
27
+ maxDisplayCount?: number;
28
+ /** Extra elements on the right */
29
+ extra?: import('svelte').Snippet;
30
+ /** Custom class name */
31
+ class?: string;
32
+ [key: string]: unknown;
33
+ }
34
+ declare const LightFilter: import("svelte").Component<LightFilterProps, {}, "values">;
35
+ type LightFilter = ReturnType<typeof LightFilter>;
36
+ export default LightFilter;
@@ -0,0 +1,295 @@
1
+ <script lang="ts">
2
+ import { onMount, onDestroy, type Snippet } from 'svelte';
3
+ import { Lock, Unlock, Eye, EyeOff, ShieldCheck, Clock } from '@lucide/svelte';
4
+ import { useTranslation } from '@svadmin/core';
5
+ import { cn } from '../utils.js';
6
+ import MediaThumbnail from './content/MediaThumbnail.svelte';
7
+
8
+ export interface LockScreenUser {
9
+ name?: string;
10
+ avatar?: string;
11
+ role?: string;
12
+ }
13
+
14
+ interface Props {
15
+ locked?: boolean;
16
+ user?: LockScreenUser;
17
+ idleTimeout?: number; // 分钟,默认 0 表示不启用自动超时锁屏
18
+ showTrigger?: boolean;
19
+ onUnlock?: (password: string) => Promise<boolean> | boolean;
20
+ onLock?: () => void;
21
+ class?: string;
22
+ children?: Snippet;
23
+ }
24
+
25
+ let {
26
+ locked = $bindable(false),
27
+ user = { name: 'Admin', role: 'Administrator' },
28
+ idleTimeout = 0,
29
+ showTrigger = false,
30
+ onUnlock,
31
+ onLock,
32
+ class: className = '',
33
+ children,
34
+ }: Props = $props();
35
+
36
+ const i18n = useTranslation();
37
+
38
+ let password = $state('');
39
+ let showPassword = $state(false);
40
+ let errorMsg = $state('');
41
+ let verifying = $state(false);
42
+ let isShaking = $state(false);
43
+ const initial = $derived((user?.name?.trim()?.charAt(0) || 'A').toUpperCase());
44
+
45
+ // 时钟状态
46
+ let currentTime = $state('');
47
+ let currentDate = $state('');
48
+ let clockTimer: ReturnType<typeof setInterval> | null = null;
49
+
50
+ function updateClock() {
51
+ const now = new Date();
52
+ const hours = String(now.getHours()).padStart(2, '0');
53
+ const minutes = String(now.getMinutes()).padStart(2, '0');
54
+ const seconds = String(now.getSeconds()).padStart(2, '0');
55
+ currentTime = `${hours}:${minutes}:${seconds}`;
56
+
57
+ const options: Intl.DateTimeFormatOptions = {
58
+ month: 'long',
59
+ day: 'numeric',
60
+ weekday: 'long',
61
+ };
62
+ currentDate = now.toLocaleDateString(i18n.locale === 'zh-CN' ? 'zh-CN' : 'en-US', options);
63
+ }
64
+
65
+ // 自动空闲超时检测
66
+ let idleTimer: ReturnType<typeof setTimeout> | null = null;
67
+
68
+ function resetIdleTimer() {
69
+ if (idleTimeout <= 0 || locked) return;
70
+ if (idleTimer) clearTimeout(idleTimer);
71
+ idleTimer = setTimeout(() => {
72
+ triggerLock();
73
+ }, idleTimeout * 60 * 1000);
74
+ }
75
+
76
+ export function triggerLock() {
77
+ locked = true;
78
+ password = '';
79
+ errorMsg = '';
80
+ onLock?.();
81
+ }
82
+
83
+ async function handleUnlock() {
84
+ if (!password.trim()) {
85
+ errorMsg = i18n.t('common.enterPassword');
86
+ triggerShake();
87
+ return;
88
+ }
89
+
90
+ verifying = true;
91
+ errorMsg = '';
92
+
93
+ try {
94
+ if (!onUnlock) {
95
+ // 没有宿主鉴权回调时必须保持锁定,避免默认绕过会话保护。
96
+ errorMsg = i18n.t('common.passwordError');
97
+ triggerShake();
98
+ return;
99
+ }
100
+ const success = await onUnlock(password);
101
+ if (success) {
102
+ locked = false;
103
+ password = '';
104
+ } else {
105
+ errorMsg = i18n.t('common.passwordError');
106
+ triggerShake();
107
+ }
108
+ } catch {
109
+ errorMsg = i18n.t('common.passwordError');
110
+ triggerShake();
111
+ } finally {
112
+ verifying = false;
113
+ }
114
+ }
115
+
116
+ function triggerShake() {
117
+ isShaking = true;
118
+ setTimeout(() => {
119
+ isShaking = false;
120
+ }, 500);
121
+ }
122
+
123
+ function handleKeydown(event: KeyboardEvent) {
124
+ // Alt + L 快捷锁屏
125
+ if (event.altKey && (event.key === 'l' || event.key === 'L')) {
126
+ event.preventDefault();
127
+ triggerLock();
128
+ return;
129
+ }
130
+
131
+ if (locked) {
132
+ if (event.key === 'Enter') {
133
+ event.preventDefault();
134
+ handleUnlock();
135
+ }
136
+ } else {
137
+ resetIdleTimer();
138
+ }
139
+ }
140
+
141
+ onMount(() => {
142
+ updateClock();
143
+ clockTimer = setInterval(updateClock, 1000);
144
+
145
+ const activityEvents = ['mousemove', 'mousedown', 'keydown', 'touchstart', 'scroll'];
146
+ const handleActivity = () => resetIdleTimer();
147
+
148
+ activityEvents.forEach((evt) => {
149
+ window.addEventListener(evt, handleActivity, { passive: true });
150
+ });
151
+ window.addEventListener('keydown', handleKeydown);
152
+
153
+ resetIdleTimer();
154
+
155
+ return () => {
156
+ if (clockTimer) clearInterval(clockTimer);
157
+ if (idleTimer) clearTimeout(idleTimer);
158
+ activityEvents.forEach((evt) => {
159
+ window.removeEventListener(evt, handleActivity);
160
+ });
161
+ window.removeEventListener('keydown', handleKeydown);
162
+ };
163
+ });
164
+
165
+ onDestroy(() => {
166
+ if (clockTimer) clearInterval(clockTimer);
167
+ if (idleTimer) clearTimeout(idleTimer);
168
+ });
169
+ </script>
170
+
171
+ {#if showTrigger}
172
+ <button
173
+ type="button"
174
+ class={cn(
175
+ 'inline-flex items-center justify-center rounded-md p-2 text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring',
176
+ className,
177
+ )}
178
+ title={i18n.t('common.lockScreen')}
179
+ aria-label={i18n.t('common.lockScreen')}
180
+ onclick={triggerLock}
181
+ >
182
+ <Lock size={18} />
183
+ </button>
184
+ {/if}
185
+
186
+ {#if children}
187
+ {@render children()}
188
+ {/if}
189
+
190
+ {#if locked}
191
+ <div
192
+ data-svadmin-component="lock-screen"
193
+ class="fixed inset-0 z-50 flex flex-col items-center justify-between bg-background/95 p-6 backdrop-blur-md select-none text-foreground transition-all duration-300"
194
+ role="dialog"
195
+ aria-modal="true"
196
+ aria-label={i18n.t('common.lockScreen')}
197
+ >
198
+ <!-- 顶部状态栏 -->
199
+ <div class="flex w-full items-center justify-between text-xs text-muted-foreground">
200
+ <div class="flex items-center gap-1.5 font-medium">
201
+ <ShieldCheck size={16} class="text-primary" />
202
+ <span>SVAdmin Enterprise Session Guard</span>
203
+ </div>
204
+ <div class="flex items-center gap-1">
205
+ <Clock size={14} />
206
+ <span>{currentDate}</span>
207
+ </div>
208
+ </div>
209
+
210
+ <!-- 中间核心时钟与解锁表单 -->
211
+ <div class="flex flex-col items-center gap-6 max-w-sm w-full my-auto text-center">
212
+ <!-- 动态时钟 -->
213
+ <div class="space-y-1">
214
+ <div class="text-6xl font-light tracking-tight font-mono text-foreground">{currentTime}</div>
215
+ <div class="text-sm text-muted-foreground">{currentDate}</div>
216
+ </div>
217
+
218
+ <!-- 用户信息与头像 -->
219
+ <div class="flex flex-col items-center gap-2">
220
+ <div class="relative flex h-20 w-20 items-center justify-center rounded-full bg-muted border-2 border-primary/20 shadow-sm overflow-hidden">
221
+ {#if user?.avatar}
222
+ <MediaThumbnail
223
+ src={user.avatar}
224
+ alt={user.name || 'User'}
225
+ size="full"
226
+ fit="cover"
227
+ showOverlay={false}
228
+ class="h-full w-full rounded-full border-0"
229
+ />
230
+ {:else}
231
+ <div class="text-2xl font-semibold text-primary">{initial}</div>
232
+ {/if}
233
+ <div class="absolute bottom-0 right-0 rounded-full bg-primary p-1 text-primary-foreground shadow-xs">
234
+ <Lock size={12} />
235
+ </div>
236
+ </div>
237
+ <div class="space-y-0.5">
238
+ <div class="text-base font-semibold text-foreground">{user?.name || 'User'}</div>
239
+ {#if user?.role}
240
+ <div class="text-xs text-muted-foreground">{user.role}</div>
241
+ {/if}
242
+ </div>
243
+ </div>
244
+
245
+ <!-- 解锁表单 -->
246
+ <div class={cn('w-full space-y-3', isShaking && 'animate-shake')}>
247
+ <div class="relative flex items-center">
248
+ <input
249
+ type={showPassword ? 'text' : 'password'}
250
+ bind:value={password}
251
+ placeholder={i18n.t('common.enterPassword')}
252
+ class="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 pr-10 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"
253
+ disabled={verifying}
254
+ />
255
+ <button
256
+ type="button"
257
+ class="absolute right-2.5 text-muted-foreground hover:text-foreground"
258
+ onclick={() => (showPassword = !showPassword)}
259
+ tabindex="-1"
260
+ aria-label={showPassword ? 'Hide password' : 'Show password'}
261
+ >
262
+ {#if showPassword}
263
+ <EyeOff size={16} />
264
+ {:else}
265
+ <Eye size={16} />
266
+ {/if}
267
+ </button>
268
+ </div>
269
+
270
+ {#if errorMsg}
271
+ <div class="text-xs font-medium text-destructive">{errorMsg}</div>
272
+ {/if}
273
+
274
+ <button
275
+ type="button"
276
+ class="inline-flex w-full h-10 items-center justify-center gap-2 rounded-md bg-primary text-primary-foreground text-sm font-medium shadow-xs hover:bg-primary/90 transition-colors disabled:opacity-50"
277
+ disabled={verifying}
278
+ onclick={handleUnlock}
279
+ >
280
+ {#if verifying}
281
+ <span class="h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground border-t-transparent"></span>
282
+ {:else}
283
+ <Unlock size={16} />
284
+ {/if}
285
+ <span>{i18n.t('common.unlock')}</span>
286
+ </button>
287
+ </div>
288
+ </div>
289
+
290
+ <!-- 底部版权/提示 -->
291
+ <div class="text-center text-xs text-muted-foreground">
292
+ Press <kbd class="px-1.5 py-0.5 rounded bg-muted border text-[10px]">Enter</kbd> to unlock
293
+ </div>
294
+ </div>
295
+ {/if}
@@ -0,0 +1,21 @@
1
+ import { type Snippet } from 'svelte';
2
+ export interface LockScreenUser {
3
+ name?: string;
4
+ avatar?: string;
5
+ role?: string;
6
+ }
7
+ interface Props {
8
+ locked?: boolean;
9
+ user?: LockScreenUser;
10
+ idleTimeout?: number;
11
+ showTrigger?: boolean;
12
+ onUnlock?: (password: string) => Promise<boolean> | boolean;
13
+ onLock?: () => void;
14
+ class?: string;
15
+ children?: Snippet;
16
+ }
17
+ declare const LockScreen: import("svelte").Component<Props, {
18
+ triggerLock: () => void;
19
+ }, "locked">;
20
+ type LockScreen = ReturnType<typeof LockScreen>;
21
+ export default LockScreen;