@svadmin/ui 0.116.0 → 0.117.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.
- package/dist/app.css +167 -26
- package/dist/app.theme.css +167 -26
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/CopyableText.svelte +90 -0
- package/dist/components/CopyableText.svelte.d.ts +13 -0
- package/dist/components/Divider.svelte +89 -0
- package/dist/components/Divider.svelte.d.ts +19 -0
- package/dist/components/EllipsisText.svelte +78 -0
- package/dist/components/EllipsisText.svelte.d.ts +15 -0
- package/dist/components/FullscreenButton.svelte +88 -0
- package/dist/components/FullscreenButton.svelte.d.ts +10 -0
- package/dist/components/GlobalShortcuts.svelte +229 -0
- package/dist/components/GlobalShortcuts.svelte.d.ts +18 -0
- package/dist/components/Header.svelte +17 -1
- package/dist/components/Header.svelte.d.ts +3 -0
- package/dist/components/Layout.svelte +3 -0
- package/dist/components/Layout.svelte.d.ts +1 -0
- package/dist/components/LightFilter.svelte +281 -0
- package/dist/components/LightFilter.svelte.d.ts +36 -0
- package/dist/components/LockScreen.svelte +295 -0
- package/dist/components/LockScreen.svelte.d.ts +21 -0
- package/dist/components/PricingCard.svelte +12 -12
- package/dist/components/PricingCard.svelte.d.ts +12 -12
- package/dist/components/PricingTable.svelte +185 -0
- package/dist/components/PricingTable.svelte.d.ts +40 -0
- package/dist/components/ProCard.svelte +267 -0
- package/dist/components/ProCard.svelte.d.ts +56 -0
- package/dist/components/QuotaProgressBar.svelte +8 -8
- package/dist/components/QuotaProgressBar.svelte.d.ts +8 -8
- package/dist/components/TypographyEllipsis.svelte +12 -9
- package/dist/components/TypographyEllipsis.svelte.d.ts +9 -8
- package/dist/components/TypographyText.svelte +41 -3
- package/dist/components/TypographyText.svelte.d.ts +10 -2
- package/dist/components/UsageCard.svelte +97 -0
- package/dist/components/UsageCard.svelte.d.ts +26 -0
- package/dist/components/ui/badge/badge.svelte +156 -12
- package/dist/components/ui/badge/badge.svelte.d.ts +9 -0
- package/dist/components/ui/badge/index.d.ts +1 -1
- package/dist/index.d.ts +24 -3
- package/dist/index.js +15 -2
- package/package.json +5 -5
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface DividerProps {
|
|
3
|
+
/** Direction of the divider */
|
|
4
|
+
type?: 'horizontal' | 'vertical';
|
|
5
|
+
/** Alignment of the text title inside the horizontal divider */
|
|
6
|
+
orientation?: 'left' | 'center' | 'right';
|
|
7
|
+
/** Whether the divider line is dashed */
|
|
8
|
+
dashed?: boolean;
|
|
9
|
+
/** Whether to use plain style text without extra bolding */
|
|
10
|
+
plain?: boolean;
|
|
11
|
+
/** Custom CSS class names */
|
|
12
|
+
class?: string;
|
|
13
|
+
/** Slot for divider text/content */
|
|
14
|
+
children?: Snippet;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
declare const Divider: import("svelte").Component<DividerProps, {}, "">;
|
|
18
|
+
type Divider = ReturnType<typeof Divider>;
|
|
19
|
+
export default Divider;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../utils.js';
|
|
3
|
+
import { useTranslation } from '@svadmin/core';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
|
|
6
|
+
const i18n = useTranslation();
|
|
7
|
+
|
|
8
|
+
export interface EllipsisTextProps {
|
|
9
|
+
text?: string;
|
|
10
|
+
maxLines?: number;
|
|
11
|
+
expandable?: boolean;
|
|
12
|
+
defaultExpanded?: boolean;
|
|
13
|
+
expandText?: string;
|
|
14
|
+
collapseText?: string;
|
|
15
|
+
tooltip?: boolean | string;
|
|
16
|
+
class?: string;
|
|
17
|
+
children?: Snippet;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
text = '',
|
|
22
|
+
maxLines = 3,
|
|
23
|
+
expandable = true,
|
|
24
|
+
defaultExpanded = false,
|
|
25
|
+
expandText,
|
|
26
|
+
collapseText,
|
|
27
|
+
tooltip = false,
|
|
28
|
+
class: className = '',
|
|
29
|
+
children,
|
|
30
|
+
}: EllipsisTextProps = $props();
|
|
31
|
+
|
|
32
|
+
let expandedState = $state<boolean | undefined>(undefined);
|
|
33
|
+
const expanded = $derived(expandedState ?? defaultExpanded);
|
|
34
|
+
|
|
35
|
+
const actualExpandText = $derived(expandText ?? i18n.t('common.expand'));
|
|
36
|
+
const actualCollapseText = $derived(collapseText ?? i18n.t('common.collapse'));
|
|
37
|
+
const tooltipText = $derived.by(() => {
|
|
38
|
+
if (!tooltip) return undefined;
|
|
39
|
+
if (typeof tooltip === 'string') return tooltip;
|
|
40
|
+
return text || undefined;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
function toggleExpand() {
|
|
44
|
+
expandedState = !expanded;
|
|
45
|
+
}
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<div
|
|
49
|
+
class={cn('relative text-sm text-foreground leading-relaxed', className)}
|
|
50
|
+
data-svadmin-component="EllipsisText"
|
|
51
|
+
data-expanded={expanded}
|
|
52
|
+
title={!expanded ? tooltipText : undefined}
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
class={cn(
|
|
56
|
+
'transition-all duration-200',
|
|
57
|
+
!expanded && 'overflow-hidden [-webkit-box-orient:vertical] [-webkit-line-clamp:var(--line-clamp)] [display:-webkit-box]'
|
|
58
|
+
)}
|
|
59
|
+
style="--line-clamp: {maxLines};"
|
|
60
|
+
>
|
|
61
|
+
{#if children}
|
|
62
|
+
{@render children()}
|
|
63
|
+
{:else}
|
|
64
|
+
{text}
|
|
65
|
+
{/if}
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
{#if expandable}
|
|
69
|
+
<button
|
|
70
|
+
type="button"
|
|
71
|
+
class="mt-1 inline-flex items-center text-xs font-medium text-primary hover:text-primary/80 transition-colors focus:outline-none focus-visible:underline"
|
|
72
|
+
onclick={toggleExpand}
|
|
73
|
+
aria-expanded={expanded}
|
|
74
|
+
>
|
|
75
|
+
{expanded ? actualCollapseText : actualExpandText}
|
|
76
|
+
</button>
|
|
77
|
+
{/if}
|
|
78
|
+
</div>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface EllipsisTextProps {
|
|
3
|
+
text?: string;
|
|
4
|
+
maxLines?: number;
|
|
5
|
+
expandable?: boolean;
|
|
6
|
+
defaultExpanded?: boolean;
|
|
7
|
+
expandText?: string;
|
|
8
|
+
collapseText?: string;
|
|
9
|
+
tooltip?: boolean | string;
|
|
10
|
+
class?: string;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
}
|
|
13
|
+
declare const EllipsisText: import("svelte").Component<EllipsisTextProps, {}, "">;
|
|
14
|
+
type EllipsisText = ReturnType<typeof EllipsisText>;
|
|
15
|
+
export default EllipsisText;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import { Maximize2, Minimize2 } from '@lucide/svelte';
|
|
4
|
+
import { cn } from '../utils.js';
|
|
5
|
+
import { useTranslation } from '@svadmin/core';
|
|
6
|
+
|
|
7
|
+
const i18n = useTranslation();
|
|
8
|
+
|
|
9
|
+
export interface FullscreenButtonProps {
|
|
10
|
+
target?: HTMLElement | undefined;
|
|
11
|
+
title?: string;
|
|
12
|
+
class?: string;
|
|
13
|
+
onchange?: ((isFullscreen: boolean) => void) | undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type FullScreenButtonProps = FullscreenButtonProps;
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
target,
|
|
20
|
+
title,
|
|
21
|
+
class: className = '',
|
|
22
|
+
onchange,
|
|
23
|
+
}: FullscreenButtonProps = $props();
|
|
24
|
+
|
|
25
|
+
let isFullscreen = $state(false);
|
|
26
|
+
|
|
27
|
+
function checkFullscreen(): boolean {
|
|
28
|
+
if (typeof document === 'undefined') return false;
|
|
29
|
+
return Boolean(document.fullscreenElement);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
onMount(() => {
|
|
33
|
+
isFullscreen = checkFullscreen();
|
|
34
|
+
|
|
35
|
+
const handleFullscreenChange = () => {
|
|
36
|
+
const active = checkFullscreen();
|
|
37
|
+
isFullscreen = active;
|
|
38
|
+
onchange?.(active);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
document.addEventListener('fullscreenchange', handleFullscreenChange);
|
|
42
|
+
return () => {
|
|
43
|
+
document.removeEventListener('fullscreenchange', handleFullscreenChange);
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
async function toggleFullscreen() {
|
|
48
|
+
if (typeof document === 'undefined') return;
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
if (document.fullscreenElement) {
|
|
52
|
+
if (document.exitFullscreen) {
|
|
53
|
+
await document.exitFullscreen();
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
const el = target ?? document.documentElement;
|
|
57
|
+
if (el && el.requestFullscreen) {
|
|
58
|
+
await el.requestFullscreen();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
} catch {
|
|
62
|
+
// Gracefully ignore permission or security restrictions in iframes
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const tooltipText = $derived(
|
|
67
|
+
title ?? (isFullscreen ? i18n.t('common.exitFullscreen') : i18n.t('common.fullscreen'))
|
|
68
|
+
);
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<button
|
|
72
|
+
type="button"
|
|
73
|
+
class={cn(
|
|
74
|
+
'inline-flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring',
|
|
75
|
+
className
|
|
76
|
+
)}
|
|
77
|
+
onclick={toggleFullscreen}
|
|
78
|
+
title={tooltipText}
|
|
79
|
+
aria-label={tooltipText}
|
|
80
|
+
aria-pressed={isFullscreen}
|
|
81
|
+
data-svadmin-component="FullscreenButton"
|
|
82
|
+
>
|
|
83
|
+
{#if isFullscreen}
|
|
84
|
+
<Minimize2 class="h-4 w-4" />
|
|
85
|
+
{:else}
|
|
86
|
+
<Maximize2 class="h-4 w-4" />
|
|
87
|
+
{/if}
|
|
88
|
+
</button>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface FullscreenButtonProps {
|
|
2
|
+
target?: HTMLElement | undefined;
|
|
3
|
+
title?: string;
|
|
4
|
+
class?: string;
|
|
5
|
+
onchange?: ((isFullscreen: boolean) => void) | undefined;
|
|
6
|
+
}
|
|
7
|
+
export type FullScreenButtonProps = FullscreenButtonProps;
|
|
8
|
+
declare const FullscreenButton: import("svelte").Component<FullscreenButtonProps, {}, "">;
|
|
9
|
+
type FullscreenButton = ReturnType<typeof FullscreenButton>;
|
|
10
|
+
export default FullscreenButton;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import { Keyboard, Search, X } from '@lucide/svelte';
|
|
4
|
+
import { useTranslation } from '@svadmin/core';
|
|
5
|
+
import { cn } from '../utils.js';
|
|
6
|
+
|
|
7
|
+
export interface ShortcutItem {
|
|
8
|
+
id: string;
|
|
9
|
+
category: 'navigation' | 'view' | 'action' | 'system';
|
|
10
|
+
label: string;
|
|
11
|
+
keys: string[];
|
|
12
|
+
description?: string;
|
|
13
|
+
action?: () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface Props {
|
|
17
|
+
open?: boolean;
|
|
18
|
+
shortcuts?: ShortcutItem[];
|
|
19
|
+
enableBuiltins?: boolean;
|
|
20
|
+
class?: string;
|
|
21
|
+
onAction?: (shortcutId: string) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let {
|
|
25
|
+
open = $bindable(false),
|
|
26
|
+
shortcuts = [],
|
|
27
|
+
enableBuiltins = true,
|
|
28
|
+
class: className = '',
|
|
29
|
+
onAction,
|
|
30
|
+
}: Props = $props();
|
|
31
|
+
|
|
32
|
+
const i18n = useTranslation();
|
|
33
|
+
let query = $state('');
|
|
34
|
+
|
|
35
|
+
const defaultShortcuts: ShortcutItem[] = [
|
|
36
|
+
{
|
|
37
|
+
id: 'command-palette',
|
|
38
|
+
category: 'navigation',
|
|
39
|
+
label: '全局搜索 / 命令面板',
|
|
40
|
+
keys: ['⌘ / Ctrl', 'K'],
|
|
41
|
+
description: '快速定位资源、页面与菜单',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: 'toggle-lock',
|
|
45
|
+
category: 'system',
|
|
46
|
+
label: '会话安全锁屏',
|
|
47
|
+
keys: ['Alt', 'L'],
|
|
48
|
+
description: '离开工位时快速锁定当前会话',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'toggle-fullscreen',
|
|
52
|
+
category: 'view',
|
|
53
|
+
label: '全屏模式切换',
|
|
54
|
+
keys: ['F11'],
|
|
55
|
+
description: '展开全屏或退出全屏',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 'toggle-theme',
|
|
59
|
+
category: 'view',
|
|
60
|
+
label: '切换主题外观',
|
|
61
|
+
keys: ['Alt', 'T'],
|
|
62
|
+
description: '在浅色与深色主题间切换',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 'shortcuts-help',
|
|
66
|
+
category: 'system',
|
|
67
|
+
label: '打开快捷键向导',
|
|
68
|
+
keys: ['?'],
|
|
69
|
+
description: '查看当前系统全部可用快捷键',
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
const allShortcuts = $derived(enableBuiltins ? [...defaultShortcuts, ...shortcuts] : shortcuts);
|
|
74
|
+
|
|
75
|
+
const filteredShortcuts = $derived.by(() => {
|
|
76
|
+
if (!query.trim()) return allShortcuts;
|
|
77
|
+
const q = query.toLowerCase();
|
|
78
|
+
return allShortcuts.filter(
|
|
79
|
+
(item) =>
|
|
80
|
+
item.label.toLowerCase().includes(q) ||
|
|
81
|
+
item.description?.toLowerCase().includes(q) ||
|
|
82
|
+
item.keys.some((k) => k.toLowerCase().includes(q)),
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const categories: Record<string, string> = {
|
|
87
|
+
navigation: '导航与检索',
|
|
88
|
+
view: '视图与外观',
|
|
89
|
+
action: '数据操作',
|
|
90
|
+
system: '系统安全',
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const groupedShortcuts = $derived.by(() => {
|
|
94
|
+
const groups: Record<string, ShortcutItem[]> = {};
|
|
95
|
+
for (const item of filteredShortcuts) {
|
|
96
|
+
const group = groups[item.category] ?? (groups[item.category] = []);
|
|
97
|
+
group.push(item);
|
|
98
|
+
}
|
|
99
|
+
return groups;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
103
|
+
const target = event.target as HTMLElement | null;
|
|
104
|
+
const isEditing = target && (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable);
|
|
105
|
+
|
|
106
|
+
// 按 ? (Shift + /) 且非编辑状态唤出帮助面板
|
|
107
|
+
if (event.key === '?' && !isEditing) {
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
open = !open;
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Cmd + / 或 Ctrl + /
|
|
114
|
+
if ((event.metaKey || event.ctrlKey) && event.key === '/') {
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
open = !open;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (open && event.key === 'Escape') {
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
open = false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function triggerItem(item: ShortcutItem) {
|
|
127
|
+
item.action?.();
|
|
128
|
+
onAction?.(item.id);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
onMount(() => {
|
|
132
|
+
window.addEventListener('keydown', handleKeydown);
|
|
133
|
+
return () => {
|
|
134
|
+
window.removeEventListener('keydown', handleKeydown);
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
</script>
|
|
138
|
+
|
|
139
|
+
{#if open}
|
|
140
|
+
<div
|
|
141
|
+
data-svadmin-component="global-shortcuts"
|
|
142
|
+
class="fixed inset-0 z-50 flex items-center justify-center bg-background/80 p-4 backdrop-blur-xs select-none"
|
|
143
|
+
role="dialog"
|
|
144
|
+
aria-modal="true"
|
|
145
|
+
aria-label={i18n.t('common.shortcutsHelp')}
|
|
146
|
+
>
|
|
147
|
+
<div
|
|
148
|
+
class={cn(
|
|
149
|
+
'relative flex flex-col w-full max-w-xl max-h-[85vh] rounded-xl border border-border bg-card text-card-foreground shadow-2xl overflow-hidden',
|
|
150
|
+
className,
|
|
151
|
+
)}
|
|
152
|
+
>
|
|
153
|
+
<!-- 头部 -->
|
|
154
|
+
<div class="flex items-center justify-between border-b border-border px-6 py-4">
|
|
155
|
+
<div class="flex items-center gap-2">
|
|
156
|
+
<Keyboard class="h-5 w-5 text-primary" />
|
|
157
|
+
<h2 class="text-base font-semibold">{i18n.t('common.shortcutsHelp')}</h2>
|
|
158
|
+
</div>
|
|
159
|
+
<button
|
|
160
|
+
type="button"
|
|
161
|
+
class="rounded-md p-1.5 text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
|
162
|
+
onclick={() => (open = false)}
|
|
163
|
+
aria-label="Close"
|
|
164
|
+
>
|
|
165
|
+
<X size={16} />
|
|
166
|
+
</button>
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
<!-- 搜索过滤栏 -->
|
|
170
|
+
<div class="px-6 py-3 border-b border-border/50 bg-muted/30">
|
|
171
|
+
<div class="relative flex items-center">
|
|
172
|
+
<Search size={16} class="absolute left-3 text-muted-foreground pointer-events-none" />
|
|
173
|
+
<input
|
|
174
|
+
type="text"
|
|
175
|
+
bind:value={query}
|
|
176
|
+
placeholder="搜索快捷键..."
|
|
177
|
+
class="flex h-9 w-full rounded-md border border-input bg-background pl-9 pr-3 py-1 text-sm shadow-2xs placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring"
|
|
178
|
+
/>
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
|
|
182
|
+
<!-- 快捷键列表 -->
|
|
183
|
+
<div class="flex-1 overflow-y-auto px-6 py-4 space-y-6">
|
|
184
|
+
{#each Object.entries(groupedShortcuts) as [categoryKey, items] (categoryKey)}
|
|
185
|
+
<div class="space-y-2.5">
|
|
186
|
+
<div class="text-xs font-medium text-muted-foreground uppercase tracking-wider">
|
|
187
|
+
{categories[categoryKey] || categoryKey}
|
|
188
|
+
</div>
|
|
189
|
+
<div class="space-y-1.5">
|
|
190
|
+
{#each items as item (item.id)}
|
|
191
|
+
<div
|
|
192
|
+
class="flex items-center justify-between rounded-lg px-3 py-2 text-sm transition-colors hover:bg-accent/50 cursor-pointer"
|
|
193
|
+
onclick={() => triggerItem(item)}
|
|
194
|
+
role="button"
|
|
195
|
+
tabindex="0"
|
|
196
|
+
onkeydown={(e) => e.key === 'Enter' && triggerItem(item)}
|
|
197
|
+
>
|
|
198
|
+
<div class="flex flex-col">
|
|
199
|
+
<span class="font-medium text-foreground">{item.label}</span>
|
|
200
|
+
{#if item.description}
|
|
201
|
+
<span class="text-xs text-muted-foreground">{item.description}</span>
|
|
202
|
+
{/if}
|
|
203
|
+
</div>
|
|
204
|
+
<div class="flex items-center gap-1.5 shrink-0">
|
|
205
|
+
{#each item.keys as key, keyIdx (keyIdx)}
|
|
206
|
+
<kbd class="inline-flex min-w-6 h-6 items-center justify-center rounded-md border border-border bg-muted px-1.5 text-xs font-mono font-medium text-muted-foreground shadow-2xs">
|
|
207
|
+
{key}
|
|
208
|
+
</kbd>
|
|
209
|
+
{/each}
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
{/each}
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
{/each}
|
|
216
|
+
|
|
217
|
+
{#if filteredShortcuts.length === 0}
|
|
218
|
+
<div class="text-center py-8 text-sm text-muted-foreground">未找到匹配的快捷键</div>
|
|
219
|
+
{/if}
|
|
220
|
+
</div>
|
|
221
|
+
|
|
222
|
+
<!-- 底部提示 -->
|
|
223
|
+
<div class="border-t border-border px-6 py-3 bg-muted/20 text-xs text-muted-foreground flex items-center justify-between">
|
|
224
|
+
<span>按 <kbd class="px-1 py-0.5 rounded bg-muted border text-[10px]">Esc</kbd> 退出向导</span>
|
|
225
|
+
<span>按 <kbd class="px-1 py-0.5 rounded bg-muted border text-[10px]">?</kbd> 随时唤出</span>
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
{/if}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface ShortcutItem {
|
|
2
|
+
id: string;
|
|
3
|
+
category: 'navigation' | 'view' | 'action' | 'system';
|
|
4
|
+
label: string;
|
|
5
|
+
keys: string[];
|
|
6
|
+
description?: string;
|
|
7
|
+
action?: () => void;
|
|
8
|
+
}
|
|
9
|
+
interface Props {
|
|
10
|
+
open?: boolean;
|
|
11
|
+
shortcuts?: ShortcutItem[];
|
|
12
|
+
enableBuiltins?: boolean;
|
|
13
|
+
class?: string;
|
|
14
|
+
onAction?: (shortcutId: string) => void;
|
|
15
|
+
}
|
|
16
|
+
declare const GlobalShortcuts: import("svelte").Component<Props, {}, "open">;
|
|
17
|
+
type GlobalShortcuts = ReturnType<typeof GlobalShortcuts>;
|
|
18
|
+
export default GlobalShortcuts;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { Moon, Sun, Search, MonitorUp } from '@lucide/svelte';
|
|
2
|
+
import { Moon, Sun, Search, MonitorUp, Lock } from '@lucide/svelte';
|
|
3
3
|
import { Button } from './ui/button';
|
|
4
4
|
import TooltipButton from './TooltipButton.svelte';
|
|
5
5
|
import { getResolvedTheme, toggleTheme, type MenuItem } from '@svadmin/core';
|
|
6
6
|
import Breadcrumbs from './Breadcrumbs.svelte';
|
|
7
7
|
import NotificationCenter, { type NotificationItem } from './NotificationCenter.svelte';
|
|
8
8
|
import ThemeSettingsDrawer from './ThemeSettingsDrawer.svelte';
|
|
9
|
+
import FullscreenButton from './FullscreenButton.svelte';
|
|
9
10
|
import { useTranslation } from '@svadmin/core/i18n';
|
|
10
11
|
|
|
11
12
|
import { getComponentRegistry } from '../component-registry.svelte.js';
|
|
@@ -15,6 +16,7 @@
|
|
|
15
16
|
let {
|
|
16
17
|
showThemeToggle = false,
|
|
17
18
|
showThemeSettings = true,
|
|
19
|
+
showFullscreen = false,
|
|
18
20
|
showNotifications = true,
|
|
19
21
|
notificationItems = [],
|
|
20
22
|
notificationUnreadCount,
|
|
@@ -29,9 +31,12 @@
|
|
|
29
31
|
rightActions,
|
|
30
32
|
siteUrl,
|
|
31
33
|
menu,
|
|
34
|
+
showLock = false,
|
|
35
|
+
onlock,
|
|
32
36
|
} = $props<{
|
|
33
37
|
showThemeToggle?: boolean;
|
|
34
38
|
showThemeSettings?: boolean;
|
|
39
|
+
showFullscreen?: boolean;
|
|
35
40
|
showNotifications?: boolean;
|
|
36
41
|
notificationItems?: NotificationItem[];
|
|
37
42
|
notificationUnreadCount?: number;
|
|
@@ -45,6 +50,8 @@
|
|
|
45
50
|
rightActions?: import('svelte').Snippet;
|
|
46
51
|
siteUrl?: string;
|
|
47
52
|
menu?: MenuItem[];
|
|
53
|
+
showLock?: boolean;
|
|
54
|
+
onlock?: () => void;
|
|
48
55
|
}>();
|
|
49
56
|
|
|
50
57
|
// Retrieve optional component overrides from registry
|
|
@@ -95,6 +102,15 @@
|
|
|
95
102
|
<ThemeSettingsDrawer />
|
|
96
103
|
{/if}
|
|
97
104
|
|
|
105
|
+
{#if showFullscreen}
|
|
106
|
+
<FullscreenButton />
|
|
107
|
+
{/if}
|
|
108
|
+
{#if showLock}
|
|
109
|
+
<TooltipButton tooltip={i18n.t('common.lockScreen')} onclick={() => onlock?.()} class="rounded-full">
|
|
110
|
+
<Lock class="h-4 w-4" />
|
|
111
|
+
</TooltipButton>
|
|
112
|
+
{/if}
|
|
113
|
+
|
|
98
114
|
{#if showSearch && onSearchClick}
|
|
99
115
|
<Button variant="outline" size="sm" onclick={onSearchClick} aria-label={i18n.t('common.search')} class="svadmin-header-search gap-2 text-muted-foreground h-9 px-3 rounded-lg border-border/60">
|
|
100
116
|
<Search class="h-3.5 w-3.5" />
|
|
@@ -3,6 +3,7 @@ import { type NotificationItem } from './NotificationCenter.svelte';
|
|
|
3
3
|
type $$ComponentProps = {
|
|
4
4
|
showThemeToggle?: boolean;
|
|
5
5
|
showThemeSettings?: boolean;
|
|
6
|
+
showFullscreen?: boolean;
|
|
6
7
|
showNotifications?: boolean;
|
|
7
8
|
notificationItems?: NotificationItem[];
|
|
8
9
|
notificationUnreadCount?: number;
|
|
@@ -16,6 +17,8 @@ type $$ComponentProps = {
|
|
|
16
17
|
rightActions?: import('svelte').Snippet;
|
|
17
18
|
siteUrl?: string;
|
|
18
19
|
menu?: MenuItem[];
|
|
20
|
+
showLock?: boolean;
|
|
21
|
+
onlock?: () => void;
|
|
19
22
|
};
|
|
20
23
|
declare const Header: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
21
24
|
type Header = ReturnType<typeof Header>;
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
onnotificationread?: (item: NotificationItem) => void | Promise<void>;
|
|
50
50
|
onnotificationreadall?: () => void | Promise<void>;
|
|
51
51
|
onnotificationopen?: (item: NotificationItem) => void | Promise<void>;
|
|
52
|
+
showFullscreen?: boolean;
|
|
52
53
|
class?: string;
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -64,6 +65,7 @@
|
|
|
64
65
|
onnotificationread,
|
|
65
66
|
onnotificationreadall,
|
|
66
67
|
onnotificationopen,
|
|
68
|
+
showFullscreen = false,
|
|
67
69
|
class: className = '',
|
|
68
70
|
}: Props = $props();
|
|
69
71
|
const layoutId = $props.id();
|
|
@@ -298,6 +300,7 @@
|
|
|
298
300
|
<Header
|
|
299
301
|
{...definedOptions({ "siteUrl": siteUrl })}
|
|
300
302
|
{...definedOptions({ "menu": menu })}
|
|
303
|
+
{showFullscreen}
|
|
301
304
|
showSearch={true}
|
|
302
305
|
showThemeToggle={true}
|
|
303
306
|
notificationItems={notifications ?? []}
|
|
@@ -18,6 +18,7 @@ interface Props {
|
|
|
18
18
|
onnotificationread?: (item: NotificationItem) => void | Promise<void>;
|
|
19
19
|
onnotificationreadall?: () => void | Promise<void>;
|
|
20
20
|
onnotificationopen?: (item: NotificationItem) => void | Promise<void>;
|
|
21
|
+
showFullscreen?: boolean;
|
|
21
22
|
class?: string;
|
|
22
23
|
}
|
|
23
24
|
declare const Layout: import("svelte").Component<Props, {}, "">;
|