@svadmin/ui 0.125.0 → 0.126.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.
Files changed (53) hide show
  1. package/dist/app.css +20 -0
  2. package/dist/app.theme.css +20 -0
  3. package/dist/components/AboutSettings.svelte +1 -1
  4. package/dist/components/ApiPlayground.svelte +1 -1
  5. package/dist/components/ApiSettings.svelte +1 -1
  6. package/dist/components/AppearanceSettings.svelte +1 -1
  7. package/dist/components/ApprovalChainBuilder.svelte +2 -2
  8. package/dist/components/AuditLogDrawer.svelte +2 -2
  9. package/dist/components/AutoTable.svelte +20 -1
  10. package/dist/components/AutoTable.svelte.d.ts +2 -0
  11. package/dist/components/BatchEditModal.svelte +6 -6
  12. package/dist/components/CheckCard.svelte +1 -1
  13. package/dist/components/ColumnHeaderFilter.svelte +6 -6
  14. package/dist/components/ColumnMappingTable.svelte +1 -1
  15. package/dist/components/DataFreshnessIndicator.svelte +4 -1
  16. package/dist/components/DataMaskPolicyEngine.svelte +2 -2
  17. package/dist/components/EditableTable.svelte +2 -2
  18. package/dist/components/ExcelImportWizard.svelte +2 -2
  19. package/dist/components/FieldRenderer.svelte +1 -1
  20. package/dist/components/FilterTagBar.svelte +8 -5
  21. package/dist/components/HmacSignatureCalculator.svelte +2 -2
  22. package/dist/components/ImportWizard.svelte +2 -2
  23. package/dist/components/InputGroup.svelte +133 -0
  24. package/dist/components/InputGroup.svelte.d.ts +16 -0
  25. package/dist/components/LightFilter.svelte +2 -2
  26. package/dist/components/MicroAppRouteSync.svelte +185 -0
  27. package/dist/components/MicroAppRouteSync.svelte.d.ts +12 -0
  28. package/dist/components/MicroAppSandbox.svelte +200 -0
  29. package/dist/components/MicroAppSandbox.svelte.d.ts +16 -0
  30. package/dist/components/MicroAppStateBusIndicator.svelte +159 -0
  31. package/dist/components/MicroAppStateBusIndicator.svelte.d.ts +12 -0
  32. package/dist/components/PermissionMatrix.svelte +1 -1
  33. package/dist/components/QueryBuilder.svelte +6 -6
  34. package/dist/components/Rate.svelte +19 -2
  35. package/dist/components/Result.svelte +36 -4
  36. package/dist/components/Result.svelte.d.ts +4 -2
  37. package/dist/components/RuleExpressionBuilder.svelte +10 -10
  38. package/dist/components/SchemaVisualModeler.svelte +2 -2
  39. package/dist/components/Spin.svelte +33 -11
  40. package/dist/components/Spin.svelte.d.ts +7 -4
  41. package/dist/components/Steps.svelte +44 -3
  42. package/dist/components/ThemeSettingsDrawer.svelte +6 -14
  43. package/dist/components/Timeline.svelte +12 -3
  44. package/dist/components/Timeline.svelte.d.ts +2 -0
  45. package/dist/components/WebhookSimulator.svelte +2 -2
  46. package/dist/components/ui/badge/badge.svelte +3 -3
  47. package/dist/components/useMicroAppState.d.svelte.ts +1 -0
  48. package/dist/components/useMicroAppState.svelte.d.ts +17 -0
  49. package/dist/components/useMicroAppState.svelte.js +38 -0
  50. package/dist/components.css +4 -0
  51. package/dist/index.d.ts +6 -0
  52. package/dist/index.js +6 -0
  53. package/package.json +4 -4
@@ -0,0 +1,185 @@
1
+ <script lang="ts">
2
+ import { untrack } from 'svelte';
3
+ import {
4
+ Compass,
5
+ ArrowLeft,
6
+ Check,
7
+ Copy,
8
+ } from '@lucide/svelte';
9
+ import { cn } from '../utils.js';
10
+ import { Button } from './ui/button/index.js';
11
+
12
+ export interface MicroAppRouteSyncProps {
13
+ hostBaseUrl?: string | undefined;
14
+ queryKey?: string | undefined;
15
+ initialRoute?: string | undefined;
16
+ title?: string | undefined;
17
+ description?: string | undefined;
18
+ class?: string | undefined;
19
+ onRouteChange?: ((route: string, syncedUrl: string) => void) | undefined;
20
+ }
21
+
22
+ let {
23
+ hostBaseUrl = 'https://admin.example.com/portal/bi-workspace',
24
+ queryKey = 'subAppRoute',
25
+ initialRoute = '/reports/quarterly-gmv/details',
26
+ title = '微前端父子应用路由双向无感同步器 (Route Sync)',
27
+ description = '实时协调宿主浏览器 URL 与子应用内部单页路由,消除页面刷新 404 与前进后退断裂',
28
+ class: className = '',
29
+ onRouteChange,
30
+ }: MicroAppRouteSyncProps = $props();
31
+
32
+ let currentSubRoute = $state(untrack(() => initialRoute));
33
+ let routeHistory = $state<string[]>([
34
+ '/reports/overview',
35
+ '/reports/quarterly-gmv',
36
+ untrack(() => initialRoute),
37
+ ]);
38
+ let copied = $state(false);
39
+
40
+ let syncedHostUrl = $derived(
41
+ `${hostBaseUrl}?${queryKey}=${encodeURIComponent(currentSubRoute)}`
42
+ );
43
+
44
+ function navigateTo(targetRoute: string) {
45
+ currentSubRoute = targetRoute;
46
+ if (!routeHistory.includes(targetRoute)) {
47
+ routeHistory = [...routeHistory, targetRoute];
48
+ }
49
+ onRouteChange?.(currentSubRoute, syncedHostUrl);
50
+ }
51
+
52
+ function handleBack() {
53
+ const idx = routeHistory.indexOf(currentSubRoute);
54
+ if (idx > 0) {
55
+ const prev = routeHistory[idx - 1];
56
+ if (prev) {
57
+ currentSubRoute = prev;
58
+ onRouteChange?.(currentSubRoute, syncedHostUrl);
59
+ }
60
+ }
61
+ }
62
+
63
+ function copyUrl() {
64
+ if (typeof navigator !== 'undefined' && navigator.clipboard) {
65
+ navigator.clipboard.writeText(syncedHostUrl);
66
+ copied = true;
67
+ setTimeout(() => (copied = false), 2000);
68
+ }
69
+ }
70
+ </script>
71
+
72
+ <div
73
+ class={cn('w-full rounded-2xl border border-border bg-card text-foreground shadow-sm flex flex-col p-5 gap-4', className)}
74
+ data-svadmin-component="micro-app-route-sync"
75
+ >
76
+ <!-- 头部控制栏 -->
77
+ <div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3">
78
+ <div class="flex items-center gap-2.5">
79
+ <div class="flex items-center justify-center w-8 h-8 rounded-lg bg-primary/10 text-primary border border-primary/20 shrink-0">
80
+ <Compass class="w-4 h-4" />
81
+ </div>
82
+ <div>
83
+ <h3 class="text-sm font-semibold text-foreground tracking-tight">{title}</h3>
84
+ <p class="text-xs text-muted-foreground">{description}</p>
85
+ </div>
86
+ </div>
87
+
88
+ <!-- 状态指示 -->
89
+ <div class="flex items-center gap-1.5 text-xs text-success font-medium bg-success/10 border border-success/20 px-2.5 py-1 rounded-full">
90
+ <Check class="w-3.5 h-3.5" />
91
+ <span>双向 PopState 监听正常</span>
92
+ </div>
93
+ </div>
94
+
95
+ <!-- 双向映射可视化卡片 -->
96
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-3">
97
+ <!-- 子应用内部路径 -->
98
+ <div class="p-3.5 rounded-xl border border-border bg-muted/20 flex flex-col gap-1.5">
99
+ <div class="flex items-center justify-between text-xs">
100
+ <span class="text-muted-foreground font-medium">子应用单页路由 (Internal SubApp Path):</span>
101
+ <span class="text-[10px] px-1.5 py-0.2 rounded bg-muted border border-border font-mono text-primary">
102
+ Active
103
+ </span>
104
+ </div>
105
+
106
+ <div class="flex items-center gap-2">
107
+ <input
108
+ type="text"
109
+ bind:value={currentSubRoute}
110
+ class="flex-1 px-3 py-1.5 text-xs font-mono rounded-lg border border-border bg-background text-foreground focus:outline-none focus:ring-1 focus:ring-primary"
111
+ />
112
+ <Button
113
+ variant="outline"
114
+ size="sm"
115
+ class="h-8 text-xs shrink-0"
116
+ onclick={() => navigateTo(currentSubRoute)}
117
+ >
118
+ 推送跳转
119
+ </Button>
120
+ </div>
121
+ </div>
122
+
123
+ <!-- 宿主浏览器同步映射 URL -->
124
+ <div class="p-3.5 rounded-xl border border-border bg-muted/20 flex flex-col gap-1.5">
125
+ <div class="flex items-center justify-between text-xs">
126
+ <span class="text-muted-foreground font-medium">宿主浏览器地址栏同步映射 (Host URL):</span>
127
+ <button
128
+ type="button"
129
+ class="flex items-center gap-1 text-[11px] text-primary hover:underline"
130
+ onclick={copyUrl}
131
+ >
132
+ {#if copied}
133
+ <Check class="w-3 h-3 text-success" />
134
+ <span>已复制</span>
135
+ {:else}
136
+ <Copy class="w-3 h-3" />
137
+ <span>复制 URL</span>
138
+ {/if}
139
+ </button>
140
+ </div>
141
+
142
+ <div class="p-2 rounded-lg border border-border bg-card font-mono text-[11px] text-foreground truncate select-all">
143
+ {syncedHostUrl}
144
+ </div>
145
+ </div>
146
+ </div>
147
+
148
+ <!-- 历史前进/后退与快捷直达 -->
149
+ <div class="p-3 rounded-xl border border-border bg-muted/10 flex flex-col sm:flex-row items-center justify-between gap-3 text-xs">
150
+ <div class="flex items-center gap-2 w-full sm:w-auto">
151
+ <Button
152
+ variant="outline"
153
+ size="sm"
154
+ class="h-7 text-xs gap-1"
155
+ disabled={routeHistory.indexOf(currentSubRoute) <= 0}
156
+ onclick={handleBack}
157
+ >
158
+ <ArrowLeft class="w-3 h-3" />
159
+ <span>浏览器后退仿真</span>
160
+ </Button>
161
+
162
+ <span class="text-muted-foreground text-[11px]">快捷路由栈:</span>
163
+ <div class="flex items-center gap-1 flex-wrap">
164
+ {#each routeHistory as route (route)}
165
+ <button
166
+ type="button"
167
+ class={cn(
168
+ 'px-2 py-0.5 rounded font-mono text-[10px] transition-colors',
169
+ route === currentSubRoute
170
+ ? 'bg-primary text-primary-foreground font-semibold'
171
+ : 'bg-muted text-muted-foreground hover:text-foreground'
172
+ )}
173
+ onclick={() => navigateTo(route)}
174
+ >
175
+ {route}
176
+ </button>
177
+ {/each}
178
+ </div>
179
+ </div>
180
+
181
+ <span class="text-[11px] text-muted-foreground shrink-0">
182
+ 页面刷新自动恢复子应用深层路径
183
+ </span>
184
+ </div>
185
+ </div>
@@ -0,0 +1,12 @@
1
+ export interface MicroAppRouteSyncProps {
2
+ hostBaseUrl?: string | undefined;
3
+ queryKey?: string | undefined;
4
+ initialRoute?: string | undefined;
5
+ title?: string | undefined;
6
+ description?: string | undefined;
7
+ class?: string | undefined;
8
+ onRouteChange?: ((route: string, syncedUrl: string) => void) | undefined;
9
+ }
10
+ declare const MicroAppRouteSync: import("svelte").Component<MicroAppRouteSyncProps, {}, "">;
11
+ type MicroAppRouteSync = ReturnType<typeof MicroAppRouteSync>;
12
+ export default MicroAppRouteSync;
@@ -0,0 +1,200 @@
1
+ <script lang="ts">
2
+ import {
3
+ Layers,
4
+ RotateCcw,
5
+ ExternalLink,
6
+ AlertTriangle,
7
+ CheckCircle2,
8
+ Shield,
9
+ Activity,
10
+ Maximize2,
11
+ } from '@lucide/svelte';
12
+ import { cn } from '../utils.js';
13
+ import { Button } from './ui/button/index.js';
14
+
15
+ export interface MicroAppSandboxProps {
16
+ src?: string | undefined;
17
+ appName?: string | undefined;
18
+ appId?: string | undefined;
19
+ token?: string | undefined;
20
+ theme?: 'light' | 'dark' | 'system' | undefined;
21
+ locale?: string | undefined;
22
+ height?: string | number | undefined;
23
+ class?: string | undefined;
24
+ onLoad?: (() => void) | undefined;
25
+ onError?: ((error: string) => void) | undefined;
26
+ onReload?: (() => void) | undefined;
27
+ }
28
+
29
+ let {
30
+ src = 'https://sub-bi.example.internal/embed',
31
+ appName = '企业商业智能 (BI) 报表子应用',
32
+ appId = 'app-bi-micro-01',
33
+ token = 'Bearer subapp-mock-jwt-token-9821',
34
+ theme = 'dark',
35
+ locale = 'zh-CN',
36
+ height = 420,
37
+ class: className = '',
38
+ onLoad,
39
+ onError,
40
+ onReload,
41
+ }: MicroAppSandboxProps = $props();
42
+
43
+ let status = $state<'loading' | 'ready' | 'error'>('ready');
44
+ let errorMessage = $state<string | null>(null);
45
+ let isFullscreen = $state(false);
46
+
47
+ function handleReload() {
48
+ status = 'loading';
49
+ errorMessage = null;
50
+ onReload?.();
51
+ setTimeout(() => {
52
+ status = 'ready';
53
+ onLoad?.();
54
+ }, 600);
55
+ }
56
+
57
+ function simulateCrash() {
58
+ status = 'error';
59
+ errorMessage = '子应用渲染进程未响应 (Script Execution Timeout / Error 502)';
60
+ onError?.(errorMessage);
61
+ }
62
+ </script>
63
+
64
+ <div
65
+ class={cn(
66
+ 'w-full rounded-2xl border border-border bg-card text-foreground shadow-sm flex flex-col overflow-hidden transition-all duration-200',
67
+ isFullscreen && 'fixed inset-4 z-50 shadow-2xl',
68
+ className
69
+ )}
70
+ data-svadmin-component="micro-app-sandbox"
71
+ >
72
+ <!-- 沙箱顶栏控制条 -->
73
+ <div class="px-4 py-3 border-b border-border bg-muted/20 flex flex-wrap items-center justify-between gap-3">
74
+ <div class="flex items-center gap-2.5 min-w-0">
75
+ <div class="flex items-center justify-center w-7 h-7 rounded-lg bg-primary/10 text-primary border border-primary/20 shrink-0">
76
+ <Layers class="w-4 h-4" />
77
+ </div>
78
+
79
+ <div class="flex flex-col min-w-0">
80
+ <div class="flex items-center gap-2">
81
+ <span class="text-xs font-semibold text-foreground truncate">{appName}</span>
82
+ <span class="text-[10px] font-mono px-1.5 py-0.2 rounded bg-muted text-muted-foreground border border-border shrink-0">
83
+ {appId}
84
+ </span>
85
+ </div>
86
+ <span class="text-[10px] text-muted-foreground truncate">
87
+ 安全沙箱源: {src} · 语言: {locale} · 主题: {theme}
88
+ </span>
89
+ </div>
90
+ </div>
91
+
92
+ <!-- 运行状态指示与动作按钮 -->
93
+ <div class="flex items-center gap-2 shrink-0">
94
+ {#if status === 'ready'}
95
+ <span class="flex items-center gap-1 text-[11px] text-success font-medium px-2 py-0.5 rounded-full bg-success/10 border border-success/20">
96
+ <CheckCircle2 class="w-3 h-3" />
97
+ 运行健康 (Mounted)
98
+ </span>
99
+ {:else if status === 'loading'}
100
+ <span class="flex items-center gap-1 text-[11px] text-info font-medium px-2 py-0.5 rounded-full bg-info/10 border border-info/20">
101
+ <Activity class="w-3 h-3 animate-spin" />
102
+ 沙箱初始化...
103
+ </span>
104
+ {:else}
105
+ <span class="flex items-center gap-1 text-[11px] text-destructive font-medium px-2 py-0.5 rounded-full bg-destructive/10 border border-destructive/20">
106
+ <AlertTriangle class="w-3 h-3" />
107
+ 沙箱异常拦截
108
+ </span>
109
+ {/if}
110
+
111
+ <div class="flex items-center gap-1 border-l border-border/60 pl-2">
112
+ <button
113
+ type="button"
114
+ class="p-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted transition-colors"
115
+ title="重新加载沙箱"
116
+ onclick={handleReload}
117
+ >
118
+ <RotateCcw class="w-3.5 h-3.5" />
119
+ </button>
120
+
121
+ <button
122
+ type="button"
123
+ class="p-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted transition-colors"
124
+ title={isFullscreen ? '退出全屏' : '全屏沙箱'}
125
+ onclick={() => (isFullscreen = !isFullscreen)}
126
+ >
127
+ <Maximize2 class="w-3.5 h-3.5" />
128
+ </button>
129
+
130
+ <a
131
+ href={src}
132
+ target="_blank"
133
+ rel="noopener noreferrer"
134
+ class="p-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted transition-colors"
135
+ title="独立窗口打开"
136
+ >
137
+ <ExternalLink class="w-3.5 h-3.5" />
138
+ </a>
139
+ </div>
140
+ </div>
141
+ </div>
142
+
143
+ <!-- 沙箱主体视窗 -->
144
+ <div
145
+ class="relative w-full bg-muted/10 flex flex-col justify-center overflow-hidden"
146
+ style="height: {typeof height === 'number' ? `${height}px` : height};"
147
+ >
148
+ {#if status === 'loading'}
149
+ <!-- 加载过渡态骨架 -->
150
+ <div class="p-6 flex flex-col items-center justify-center gap-3 text-muted-foreground">
151
+ <Activity class="w-8 h-8 text-primary animate-spin" />
152
+ <div class="text-xs">正在向子应用注入登录令牌与安全样式表...</div>
153
+ </div>
154
+ {:else if status === 'error'}
155
+ <!-- 异常崩溃容灾降级面板 -->
156
+ <div class="p-8 flex flex-col items-center justify-center text-center max-w-md mx-auto gap-3">
157
+ <div class="w-12 h-12 rounded-2xl bg-destructive/10 text-destructive border border-destructive/20 flex items-center justify-center">
158
+ <AlertTriangle class="w-6 h-6" />
159
+ </div>
160
+ <div>
161
+ <h4 class="text-sm font-semibold text-foreground">子应用隔离拦截与崩溃保护</h4>
162
+ <p class="text-xs text-muted-foreground mt-1">{errorMessage}</p>
163
+ </div>
164
+ <div class="flex items-center gap-2 mt-2">
165
+ <Button variant="outline" size="sm" class="h-8 text-xs" onclick={handleReload}>
166
+ <RotateCcw class="w-3.5 h-3.5 mr-1" />
167
+ 尝试自愈重启
168
+ </Button>
169
+ </div>
170
+ </div>
171
+ {:else}
172
+ <!-- 模拟/真实 沙箱视图 -->
173
+ <div class="w-full h-full p-4 flex flex-col justify-between">
174
+ <div class="p-4 rounded-xl border border-border bg-card flex flex-col gap-2">
175
+ <div class="flex items-center justify-between">
176
+ <span class="text-xs font-semibold text-foreground">微前端隔离沙箱运行时 (Shadow DOM / iframe Guard)</span>
177
+ <span class="text-[10px] text-muted-foreground font-mono">Token 已就绪: {token.slice(0, 16)}...</span>
178
+ </div>
179
+ <p class="text-[11px] text-muted-foreground leading-relaxed">
180
+ 宿主与子应用已建立受信任的跨域事件通道。子应用的 CSS 样式与全局 window 作用域完全隔离,不污染宿主管理平台全局规范。
181
+ </p>
182
+ </div>
183
+
184
+ <div class="flex items-center justify-between text-[10px] text-muted-foreground pt-2 border-t border-border/40">
185
+ <span class="flex items-center gap-1">
186
+ <Shield class="w-3 h-3 text-primary" />
187
+ Sandbox Isolation Level: Strict (allow-scripts, allow-same-origin, allow-forms)
188
+ </span>
189
+ <button
190
+ type="button"
191
+ class="text-[10px] text-muted-foreground hover:text-destructive underline"
192
+ onclick={simulateCrash}
193
+ >
194
+ 测试异常容灾兜底
195
+ </button>
196
+ </div>
197
+ </div>
198
+ {/if}
199
+ </div>
200
+ </div>
@@ -0,0 +1,16 @@
1
+ export interface MicroAppSandboxProps {
2
+ src?: string | undefined;
3
+ appName?: string | undefined;
4
+ appId?: string | undefined;
5
+ token?: string | undefined;
6
+ theme?: 'light' | 'dark' | 'system' | undefined;
7
+ locale?: string | undefined;
8
+ height?: string | number | undefined;
9
+ class?: string | undefined;
10
+ onLoad?: (() => void) | undefined;
11
+ onError?: ((error: string) => void) | undefined;
12
+ onReload?: (() => void) | undefined;
13
+ }
14
+ declare const MicroAppSandbox: import("svelte").Component<MicroAppSandboxProps, {}, "">;
15
+ type MicroAppSandbox = ReturnType<typeof MicroAppSandbox>;
16
+ export default MicroAppSandbox;
@@ -0,0 +1,159 @@
1
+ <script lang="ts">
2
+ import { untrack } from 'svelte';
3
+ import {
4
+ Radio,
5
+ Send,
6
+ Activity,
7
+ CheckCircle2,
8
+ Trash2,
9
+ Share2,
10
+ } from '@lucide/svelte';
11
+ import { cn } from '../utils.js';
12
+ import { Button } from './ui/button/index.js';
13
+ import { useMicroAppState, type MicroAppStateMessage } from './useMicroAppState.svelte.js';
14
+
15
+ export interface MicroAppStateBusIndicatorProps {
16
+ channel?: string | undefined;
17
+ appId?: string | undefined;
18
+ title?: string | undefined;
19
+ description?: string | undefined;
20
+ class?: string | undefined;
21
+ onBroadcast?: ((msg: MicroAppStateMessage) => void) | undefined;
22
+ }
23
+
24
+ let {
25
+ channel = 'svadmin_microapp_global_bus',
26
+ appId = 'host_admin_root',
27
+ title = '微前端全局响应式状态总线 (MicroApp State Bus)',
28
+ description = '跨技术栈父子应用双向状态同步、租户上下文广播与事件流转中枢',
29
+ class: className = '',
30
+ onBroadcast,
31
+ }: MicroAppStateBusIndicatorProps = $props();
32
+
33
+ const bus = useMicroAppState({ channel: untrack(() => channel), appId: untrack(() => appId) });
34
+
35
+ let broadcastType = $state('tenant:context:change');
36
+ let broadcastPayload = $state('{"tenantId": "tenant-east-02", "name": "华东大区创新科技中心"}');
37
+
38
+ function handleSend() {
39
+ try {
40
+ const parsed = JSON.parse(broadcastPayload);
41
+ const msg = bus.broadcast(broadcastType, parsed);
42
+ onBroadcast?.(msg);
43
+ } catch {
44
+ const msg = bus.broadcast(broadcastType, broadcastPayload);
45
+ onBroadcast?.(msg);
46
+ }
47
+ }
48
+
49
+ function formatTime(ts: number) {
50
+ const d = new Date(ts);
51
+ return `${d.getHours().toString().padStart(2, '0')}:${d.getMinutes().toString().padStart(2, '0')}:${d.getSeconds().toString().padStart(2, '0')}`;
52
+ }
53
+ </script>
54
+
55
+ <div
56
+ class={cn('w-full rounded-2xl border border-border bg-card text-foreground shadow-sm flex flex-col overflow-hidden', className)}
57
+ data-svadmin-component="micro-app-state-bus"
58
+ >
59
+ <!-- 头部控制栏 -->
60
+ <div class="p-5 border-b border-border bg-muted/10 flex flex-col md:flex-row md:items-center justify-between gap-4">
61
+ <div>
62
+ <div class="flex items-center gap-2">
63
+ <Radio class="w-5 h-5 text-primary" />
64
+ <h3 class="text-base font-semibold text-foreground tracking-tight">{title}</h3>
65
+ </div>
66
+ <p class="text-xs text-muted-foreground mt-1">{description}</p>
67
+ </div>
68
+
69
+ <!-- 运行状态指示 -->
70
+ <div class="flex items-center gap-2">
71
+ <div class="flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs">
72
+ <Share2 class="w-3.5 h-3.5 text-primary" />
73
+ <span class="text-muted-foreground">频道:</span>
74
+ <span class="font-mono font-medium text-foreground">{channel}</span>
75
+ </div>
76
+
77
+ <div class="flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-success/20 bg-success/10 text-xs">
78
+ <CheckCircle2 class="w-3.5 h-3.5 text-success" />
79
+ <span class="text-success font-medium">3 个子应用已连接</span>
80
+ </div>
81
+ </div>
82
+ </div>
83
+
84
+ <!-- 广播发送工具栏 -->
85
+ <div class="p-4 border-b border-border bg-muted/20 flex flex-col sm:flex-row items-center gap-2.5">
86
+ <div class="w-full sm:w-56 shrink-0">
87
+ <input
88
+ type="text"
89
+ bind:value={broadcastType}
90
+ placeholder="事件类型 (e.g. auth:token:refresh)"
91
+ class="w-full px-3 py-1.5 text-xs font-mono rounded-lg border border-border bg-background text-foreground focus:outline-none focus:ring-1 focus:ring-primary"
92
+ />
93
+ </div>
94
+
95
+ <div class="w-full sm:flex-1">
96
+ <input
97
+ type="text"
98
+ bind:value={broadcastPayload}
99
+ placeholder="JSON 载荷 (Payload)"
100
+ class="w-full px-3 py-1.5 text-xs font-mono rounded-lg border border-border bg-background text-foreground focus:outline-none focus:ring-1 focus:ring-primary"
101
+ />
102
+ </div>
103
+
104
+ <Button
105
+ variant="default"
106
+ size="sm"
107
+ class="h-8 gap-1.5 text-xs bg-primary text-primary-foreground shrink-0 w-full sm:w-auto"
108
+ onclick={handleSend}
109
+ >
110
+ <Send class="w-3.5 h-3.5" />
111
+ <span>广播状态变更</span>
112
+ </Button>
113
+ </div>
114
+
115
+ <!-- 最近接收到的跨应用状态消息流 -->
116
+ <div class="p-4 space-y-2">
117
+ <div class="flex items-center justify-between text-xs font-semibold text-foreground mb-1">
118
+ <div class="flex items-center gap-1.5">
119
+ <Activity class="w-4 h-4 text-primary" />
120
+ <span>跨端状态消息流 (Message Stream)</span>
121
+ </div>
122
+
123
+ {#if bus.messages.length > 0}
124
+ <button
125
+ type="button"
126
+ class="flex items-center gap-1 text-[11px] text-muted-foreground hover:text-destructive"
127
+ onclick={() => bus.clearMessages()}
128
+ >
129
+ <Trash2 class="w-3 h-3" />
130
+ <span>清空流</span>
131
+ </button>
132
+ {/if}
133
+ </div>
134
+
135
+ <div class="space-y-2 max-h-60 overflow-y-auto">
136
+ {#if bus.messages.length === 0}
137
+ <div class="p-4 rounded-xl border border-dashed border-border bg-muted/10 text-center text-xs text-muted-foreground">
138
+ 暂无跨端广播消息,点击上方按钮模拟向子应用广播全局状态
139
+ </div>
140
+ {:else}
141
+ {#each bus.messages as msg (msg.timestamp)}
142
+ <div class="p-2.5 rounded-xl border border-border bg-card flex flex-col gap-1 text-xs">
143
+ <div class="flex items-center justify-between">
144
+ <div class="flex items-center gap-2">
145
+ <span class="font-semibold text-primary font-mono">{msg.type}</span>
146
+ <span class="text-[10px] text-muted-foreground">来自: {msg.senderAppId}</span>
147
+ </div>
148
+ <span class="text-[10px] text-muted-foreground font-mono">
149
+ {formatTime(msg.timestamp)}
150
+ </span>
151
+ </div>
152
+
153
+ <pre class="p-2 rounded bg-muted/40 text-[11px] font-mono text-foreground overflow-x-auto">{JSON.stringify(msg.payload, null, 2)}</pre>
154
+ </div>
155
+ {/each}
156
+ {/if}
157
+ </div>
158
+ </div>
159
+ </div>
@@ -0,0 +1,12 @@
1
+ import { type MicroAppStateMessage } from './useMicroAppState.svelte.js';
2
+ export interface MicroAppStateBusIndicatorProps {
3
+ channel?: string | undefined;
4
+ appId?: string | undefined;
5
+ title?: string | undefined;
6
+ description?: string | undefined;
7
+ class?: string | undefined;
8
+ onBroadcast?: ((msg: MicroAppStateMessage) => void) | undefined;
9
+ }
10
+ declare const MicroAppStateBusIndicator: import("svelte").Component<MicroAppStateBusIndicatorProps, {}, "">;
11
+ type MicroAppStateBusIndicator = ReturnType<typeof MicroAppStateBusIndicator>;
12
+ export default MicroAppStateBusIndicator;
@@ -122,7 +122,7 @@
122
122
  <div class="flex flex-col lg:flex-row gap-6 flex-1 min-h-[500px]">
123
123
  <div class="svadmin-permission-matrix__mobile-sidebar w-full rounded-lg border border-border bg-card p-4 shadow-sm">
124
124
  <label for={`${instanceId}-permission-role-select`} class="mb-2 block text-sm font-medium text-foreground">{i18n.t('permissions.roles') || 'Roles'}</label>
125
- <select id={`${instanceId}-permission-role-select`} value={selectedRole} onchange={(event) => { selectedRole = event.currentTarget.value; }} class="h-9 w-full rounded-md border border-input bg-background px-3 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2" disabled={roles.length === 0}>
125
+ <select id={`${instanceId}-permission-role-select`} value={selectedRole} onchange={(event) => { selectedRole = event.currentTarget.value; }} class="svadmin-select h-9 w-full" disabled={roles.length === 0}>
126
126
  {#each roles as role (role.code)}<option value={role.code}>{role.name}</option>{/each}
127
127
  </select>
128
128
  {#if roles.length === 0}<p class="mt-2 text-sm text-muted-foreground">{i18n.t('permissions.noRoles') || 'No roles available'}</p>{/if}
@@ -362,8 +362,8 @@
362
362
  data-query-rule={item.id}
363
363
  >
364
364
  <!-- Field Picker -->
365
- <select
366
- class="rounded border border-input bg-background px-2.5 py-1 text-xs text-foreground focus:ring-1 focus:ring-primary"
365
+ <select data-size="compact"
366
+ class="svadmin-select svadmin-select--inline"
367
367
  bind:value={item.field}
368
368
  onchange={() => {
369
369
  const newField = fields.find((f) => f.key === item.field);
@@ -379,8 +379,8 @@
379
379
  </select>
380
380
 
381
381
  <!-- Operator Picker -->
382
- <select
383
- class="rounded border border-input bg-background px-2.5 py-1 text-xs text-foreground focus:ring-1 focus:ring-primary font-mono"
382
+ <select data-size="compact"
383
+ class="svadmin-select svadmin-select--inline font-mono"
384
384
  bind:value={item.operator}
385
385
  onchange={notifyChange}
386
386
  disabled={readOnly}
@@ -393,8 +393,8 @@
393
393
  <!-- Value Input (depending on operator / field type) -->
394
394
  {#if item.operator !== 'is_null' && item.operator !== 'is_not_null'}
395
395
  {#if fieldDef?.type === 'select' && fieldDef.options}
396
- <select
397
- class="rounded border border-input bg-background px-2.5 py-1 text-xs text-foreground focus:ring-1 focus:ring-primary min-w-[120px]"
396
+ <select data-size="compact"
397
+ class="svadmin-select min-w-[120px]"
398
398
  bind:value={item.value}
399
399
  onchange={notifyChange}
400
400
  disabled={readOnly}