@svadmin/ui 0.129.0 → 0.131.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 +403 -0
- package/dist/app.theme.css +403 -0
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/AccessRevocationMatrix.svelte +425 -0
- package/dist/components/AccessRevocationMatrix.svelte.d.ts +27 -0
- package/dist/components/AudioVisualInspector.svelte +458 -0
- package/dist/components/AudioVisualInspector.svelte.d.ts +53 -0
- package/dist/components/AuditSnapshotCapture.svelte +328 -0
- package/dist/components/AuditSnapshotCapture.svelte.d.ts +28 -0
- package/dist/components/CannedResponsePicker.svelte +257 -0
- package/dist/components/CannedResponsePicker.svelte.d.ts +22 -0
- package/dist/components/ContentModerationCenter.svelte +166 -0
- package/dist/components/ContentModerationCenter.svelte.d.ts +11 -0
- package/dist/components/ContractClauseDiffViewer.svelte +566 -0
- package/dist/components/ContractClauseDiffViewer.svelte.d.ts +53 -0
- package/dist/components/DataImportPipeline.svelte +577 -0
- package/dist/components/DataImportPipeline.svelte.d.ts +35 -0
- package/dist/components/DataRetentionPolicyEditor.svelte +455 -0
- package/dist/components/DataRetentionPolicyEditor.svelte.d.ts +10 -0
- package/dist/components/ElectronicSealInspector.svelte +450 -0
- package/dist/components/ElectronicSealInspector.svelte.d.ts +72 -0
- package/dist/components/EmployeeOffboardingAuditor.svelte +405 -0
- package/dist/components/EmployeeOffboardingAuditor.svelte.d.ts +39 -0
- package/dist/components/FeatureFlagStudio.svelte +583 -0
- package/dist/components/FeatureFlagStudio.svelte.d.ts +12 -0
- package/dist/components/FieldMappingBuilder.svelte +393 -0
- package/dist/components/FieldMappingBuilder.svelte.d.ts +39 -0
- package/dist/components/GatewayRouteEditor.svelte +493 -0
- package/dist/components/GatewayRouteEditor.svelte.d.ts +34 -0
- package/dist/components/HotkeysHelpModal.svelte +286 -0
- package/dist/components/HotkeysHelpModal.svelte.d.ts +21 -0
- package/dist/components/I18nStudio.svelte +635 -0
- package/dist/components/I18nStudio.svelte.d.ts +23 -0
- package/dist/components/IpAccessRuleEditor.svelte +290 -0
- package/dist/components/IpAccessRuleEditor.svelte.d.ts +19 -0
- package/dist/components/IpWhitelistDrawer.svelte +94 -0
- package/dist/components/IpWhitelistDrawer.svelte.d.ts +10 -0
- package/dist/components/MediaAuthenticityAuditCard.svelte +357 -0
- package/dist/components/MediaAuthenticityAuditCard.svelte.d.ts +64 -0
- package/dist/components/MediaGallery.svelte +575 -0
- package/dist/components/MediaGallery.svelte.d.ts +34 -0
- package/dist/components/NotificationCenter.svelte +20 -1
- package/dist/components/NotificationCenter.svelte.d.ts +2 -0
- package/dist/components/NotificationDrawer.svelte +242 -0
- package/dist/components/NotificationDrawer.svelte.d.ts +40 -0
- package/dist/components/PrintDocument.svelte +95 -0
- package/dist/components/PrintDocument.svelte.d.ts +10 -0
- package/dist/components/PrintPreviewModal.svelte +52 -0
- package/dist/components/PrintPreviewModal.svelte.d.ts +11 -0
- package/dist/components/PrintTemplateDesigner.svelte +280 -0
- package/dist/components/PrintTemplateDesigner.svelte.d.ts +11 -0
- package/dist/components/RateLimitPolicyPanel.svelte +369 -0
- package/dist/components/RateLimitPolicyPanel.svelte.d.ts +29 -0
- package/dist/components/ResizableSplitter.svelte +246 -0
- package/dist/components/ResizableSplitter.svelte.d.ts +18 -0
- package/dist/components/SensitiveWordAuditor.svelte +368 -0
- package/dist/components/SensitiveWordAuditor.svelte.d.ts +9 -0
- package/dist/components/ServiceDeskTicketCard.svelte +297 -0
- package/dist/components/ServiceDeskTicketCard.svelte.d.ts +52 -0
- package/dist/components/ShiftScheduler.svelte +490 -0
- package/dist/components/ShiftScheduler.svelte.d.ts +50 -0
- package/dist/components/SslCertificateMonitorCard.svelte +309 -0
- package/dist/components/SslCertificateMonitorCard.svelte.d.ts +30 -0
- package/dist/components/SsoConnectionStudio.svelte +784 -0
- package/dist/components/SsoConnectionStudio.svelte.d.ts +44 -0
- package/dist/components/SsoSpMetadataPanel.svelte +44 -0
- package/dist/components/SsoSpMetadataPanel.svelte.d.ts +8 -0
- package/dist/components/StepUpAuthModal.svelte +448 -0
- package/dist/components/StepUpAuthModal.svelte.d.ts +26 -0
- package/dist/components/TrafficTopologyInspector.svelte +361 -0
- package/dist/components/TrafficTopologyInspector.svelte.d.ts +43 -0
- package/dist/components/ip-access-rules.d.ts +24 -0
- package/dist/components/ip-access-rules.js +110 -0
- package/dist/components/moderation-utils.d.ts +45 -0
- package/dist/components/moderation-utils.js +74 -0
- package/dist/components/print-document.d.ts +3 -0
- package/dist/components/print-document.js +65 -0
- package/dist/components/print-utils.d.ts +44 -0
- package/dist/components/print-utils.js +68 -0
- package/dist/components/retention-utils.d.ts +31 -0
- package/dist/components/retention-utils.js +38 -0
- package/dist/components/sso-connection-presets.d.ts +2 -0
- package/dist/components/sso-connection-presets.js +59 -0
- package/dist/components/ui/sheet/sheet.svelte +3 -1
- package/dist/components/ui/sheet/sheet.svelte.d.ts +1 -0
- package/dist/components/useFeatureFlag.d.svelte.ts +1 -0
- package/dist/components/useFeatureFlag.svelte.d.ts +45 -0
- package/dist/components/useFeatureFlag.svelte.js +94 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +53 -0
- package/package.json +5 -4
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type CircuitBreakerState = 'closed' | 'open' | 'half_open';
|
|
2
|
+
export type RateLimitDimension = 'client_ip' | 'user_id' | 'api_key' | 'tenant_id';
|
|
3
|
+
export type FallbackStrategy = 'mock_json' | 'static_status' | 'secondary_upstream';
|
|
4
|
+
export interface RateLimitPolicyConfig {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
qps: number;
|
|
9
|
+
burst: number;
|
|
10
|
+
dimension: RateLimitDimension;
|
|
11
|
+
limitExceededStatusCode: number;
|
|
12
|
+
circuitBreakerState: CircuitBreakerState;
|
|
13
|
+
failureRateThreshold: number;
|
|
14
|
+
slowCallDurationMs: number;
|
|
15
|
+
minRequestVolume: number;
|
|
16
|
+
recoveryTimeoutSeconds: number;
|
|
17
|
+
fallbackStrategy: FallbackStrategy;
|
|
18
|
+
fallbackMockPayload: string;
|
|
19
|
+
}
|
|
20
|
+
interface Props {
|
|
21
|
+
config?: Partial<RateLimitPolicyConfig>;
|
|
22
|
+
title?: string;
|
|
23
|
+
subtitle?: string;
|
|
24
|
+
onsave?: (config: RateLimitPolicyConfig) => void | Promise<void>;
|
|
25
|
+
onresetCircuitBreaker?: () => void;
|
|
26
|
+
}
|
|
27
|
+
declare const RateLimitPolicyPanel: import("svelte").Component<Props, {}, "">;
|
|
28
|
+
type RateLimitPolicyPanel = ReturnType<typeof RateLimitPolicyPanel>;
|
|
29
|
+
export default RateLimitPolicyPanel;
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onDestroy, untrack, type Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
export interface ResizableSplitterProps {
|
|
5
|
+
direction?: 'horizontal' | 'vertical';
|
|
6
|
+
initialSizes?: [number, number];
|
|
7
|
+
minSizes?: [number, number];
|
|
8
|
+
maxSizes?: [number, number];
|
|
9
|
+
storageKey?: string;
|
|
10
|
+
collapsible?: boolean;
|
|
11
|
+
gutterSize?: number;
|
|
12
|
+
class?: string;
|
|
13
|
+
firstPane?: Snippet;
|
|
14
|
+
secondPane?: Snippet;
|
|
15
|
+
onResize?: (sizes: [number, number]) => void;
|
|
16
|
+
onCollapse?: (collapsedPane: 'first' | 'second' | null) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const {
|
|
20
|
+
direction = 'horizontal',
|
|
21
|
+
initialSizes = [50, 50],
|
|
22
|
+
minSizes = [15, 15],
|
|
23
|
+
maxSizes = [85, 85],
|
|
24
|
+
storageKey,
|
|
25
|
+
collapsible = true,
|
|
26
|
+
gutterSize = 8,
|
|
27
|
+
class: className = '',
|
|
28
|
+
firstPane,
|
|
29
|
+
secondPane,
|
|
30
|
+
onResize,
|
|
31
|
+
onCollapse,
|
|
32
|
+
}: ResizableSplitterProps = $props();
|
|
33
|
+
|
|
34
|
+
let containerEl = $state<HTMLDivElement | null>(null);
|
|
35
|
+
let sizes = $state<[number, number]>(untrack(() => normalize(initialSizes)));
|
|
36
|
+
let isDragging = $state(false);
|
|
37
|
+
let collapsedPane = $state<'first' | 'second' | null>(null);
|
|
38
|
+
let stopDragging = () => {};
|
|
39
|
+
let layoutConfiguration = '';
|
|
40
|
+
|
|
41
|
+
function bounds(): [number, number] {
|
|
42
|
+
const lower = Math.max(0, minSizes[0], 100 - maxSizes[1]);
|
|
43
|
+
const upper = Math.min(100, maxSizes[0], 100 - minSizes[1]);
|
|
44
|
+
return [lower, Math.max(lower, upper)];
|
|
45
|
+
}
|
|
46
|
+
function normalize(input: unknown): [number, number] {
|
|
47
|
+
const [lower, upper] = bounds();
|
|
48
|
+
function validPair(value: unknown): value is [number, number] {
|
|
49
|
+
return Array.isArray(value) && value.length === 2 &&
|
|
50
|
+
typeof value[0] === 'number' && Number.isFinite(value[0]) && value[0] >= 0 &&
|
|
51
|
+
typeof value[1] === 'number' && Number.isFinite(value[1]) && value[1] >= 0 &&
|
|
52
|
+
Number.isFinite(value[0] + value[1]) && value[0] + value[1] > 0;
|
|
53
|
+
}
|
|
54
|
+
const pair = validPair(input) ? input : validPair(initialSizes) ? initialSizes : [50, 50];
|
|
55
|
+
let first = (pair[0] ?? 50) / ((pair[0] ?? 50) + (pair[1] ?? 50)) * 100;
|
|
56
|
+
first = Number(Math.max(lower, Math.min(upper, first)).toFixed(2));
|
|
57
|
+
return [first, Number((100 - first).toFixed(2))];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
$effect(() => {
|
|
61
|
+
const settings = { direction, initialSizes, minSizes, maxSizes, storageKey };
|
|
62
|
+
const signature = JSON.stringify(settings);
|
|
63
|
+
if (signature === layoutConfiguration) return;
|
|
64
|
+
layoutConfiguration = signature;
|
|
65
|
+
untrack(() => {
|
|
66
|
+
// 配置切换时终止旧拖拽,避免把旧布局的移动写入新的存储键。
|
|
67
|
+
stopDragging();
|
|
68
|
+
let next: unknown = settings.initialSizes;
|
|
69
|
+
if (settings.storageKey && typeof localStorage !== 'undefined') {
|
|
70
|
+
try {
|
|
71
|
+
const saved = localStorage.getItem(`svadmin_splitter_${settings.storageKey}`);
|
|
72
|
+
if (saved) next = JSON.parse(saved);
|
|
73
|
+
} catch { /* 存储不可用时使用传入的初始比例。 */ }
|
|
74
|
+
}
|
|
75
|
+
sizes = normalize(next);
|
|
76
|
+
collapsedPane = null;
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
onDestroy(() => stopDragging());
|
|
80
|
+
|
|
81
|
+
function saveSizes(input: [number, number]) {
|
|
82
|
+
const [lower, upper] = bounds();
|
|
83
|
+
const first = Number(Math.max(lower, Math.min(upper, input[0])).toFixed(2));
|
|
84
|
+
sizes = [first, Number((100 - first).toFixed(2))];
|
|
85
|
+
onResize?.([...sizes]);
|
|
86
|
+
if (storageKey && typeof localStorage !== 'undefined') {
|
|
87
|
+
try { localStorage.setItem(`svadmin_splitter_${storageKey}`, JSON.stringify(sizes)); }
|
|
88
|
+
catch { /* 禁用浏览器存储不影响拖拽。 */ }
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function handlePointerDown(event: PointerEvent) {
|
|
92
|
+
if (event.button !== 0 || !containerEl || (event.target instanceof Element && event.target.closest('button'))) return;
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
stopDragging();
|
|
95
|
+
const horizontal = direction === 'horizontal';
|
|
96
|
+
const rect = containerEl.getBoundingClientRect();
|
|
97
|
+
const total = horizontal ? rect.width : rect.height;
|
|
98
|
+
if (total <= 0) return;
|
|
99
|
+
isDragging = true;
|
|
100
|
+
const start = horizontal ? event.clientX : event.clientY;
|
|
101
|
+
const first = sizes[0];
|
|
102
|
+
function move(next: PointerEvent) {
|
|
103
|
+
if (next.pointerId !== event.pointerId) return;
|
|
104
|
+
const position = horizontal ? next.clientX : next.clientY;
|
|
105
|
+
const changed = first + (position - start) / total * 100;
|
|
106
|
+
saveSizes([changed, 100 - changed]);
|
|
107
|
+
}
|
|
108
|
+
stopDragging = () => {
|
|
109
|
+
isDragging = false;
|
|
110
|
+
window.removeEventListener('pointermove', move);
|
|
111
|
+
window.removeEventListener('pointerup', stopDragging);
|
|
112
|
+
window.removeEventListener('pointercancel', stopDragging);
|
|
113
|
+
window.removeEventListener('blur', stopDragging);
|
|
114
|
+
};
|
|
115
|
+
window.addEventListener('pointermove', move);
|
|
116
|
+
window.addEventListener('pointerup', stopDragging);
|
|
117
|
+
window.addEventListener('pointercancel', stopDragging);
|
|
118
|
+
window.addEventListener('blur', stopDragging);
|
|
119
|
+
}
|
|
120
|
+
function handleDoubleClick() {
|
|
121
|
+
collapsedPane = null;
|
|
122
|
+
saveSizes(normalize([50, 50]));
|
|
123
|
+
onCollapse?.(null);
|
|
124
|
+
}
|
|
125
|
+
function toggleCollapse(pane: 'first' | 'second') {
|
|
126
|
+
if (!collapsible && collapsedPane !== pane) return;
|
|
127
|
+
stopDragging();
|
|
128
|
+
collapsedPane = collapsedPane === pane ? null : pane;
|
|
129
|
+
onCollapse?.(collapsedPane);
|
|
130
|
+
}
|
|
131
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
132
|
+
const previous = direction === 'horizontal' ? 'ArrowLeft' : 'ArrowUp';
|
|
133
|
+
const next = direction === 'horizontal' ? 'ArrowRight' : 'ArrowDown';
|
|
134
|
+
if (![previous, next, 'Home', 'End'].includes(event.key)) return;
|
|
135
|
+
event.preventDefault();
|
|
136
|
+
const [lower, upper] = bounds();
|
|
137
|
+
const first = event.key === 'Home' ? lower : event.key === 'End' ? upper :
|
|
138
|
+
Math.max(lower, Math.min(upper, sizes[0] + (event.key === previous ? -2 : 2)));
|
|
139
|
+
saveSizes([first, 100 - first]);
|
|
140
|
+
}
|
|
141
|
+
const isHorizontal = $derived(direction === 'horizontal');
|
|
142
|
+
</script>
|
|
143
|
+
|
|
144
|
+
<div
|
|
145
|
+
bind:this={containerEl}
|
|
146
|
+
class="resizable-splitter relative flex h-full w-full overflow-hidden {isHorizontal ? 'flex-row' : 'flex-col'} {isDragging ? 'select-none' : ''} {className}"
|
|
147
|
+
data-svadmin-component="ResizableSplitter"
|
|
148
|
+
>
|
|
149
|
+
<!-- First Pane -->
|
|
150
|
+
<div
|
|
151
|
+
class="relative min-h-0 min-w-0 overflow-auto transition-all duration-75 {collapsedPane === 'first' ? 'hidden' : ''}"
|
|
152
|
+
style:flex="{sizes[0]} 1 0%"
|
|
153
|
+
>
|
|
154
|
+
{#if firstPane}
|
|
155
|
+
{@render firstPane()}
|
|
156
|
+
{:else}
|
|
157
|
+
<div class="flex h-full w-full items-center justify-center p-4 text-xs text-muted-foreground">
|
|
158
|
+
面板 1 (First Pane)
|
|
159
|
+
</div>
|
|
160
|
+
{/if}
|
|
161
|
+
</div>
|
|
162
|
+
|
|
163
|
+
<!-- Splitter Gutter Divider -->
|
|
164
|
+
{#if collapsedPane === null}
|
|
165
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions (可调整的分隔线支持键盘和指针操作。) -->
|
|
166
|
+
<div
|
|
167
|
+
class="group relative z-10 flex shrink-0 items-center justify-center bg-border/60 transition-colors hover:bg-primary/30 active:bg-primary {isHorizontal ? 'cursor-col-resize h-full' : 'cursor-row-resize w-full'} {isDragging ? 'bg-primary' : ''}"
|
|
168
|
+
style="{isHorizontal ? `width: ${gutterSize}px` : `height: ${gutterSize}px`}; touch-action: none;"
|
|
169
|
+
role="separator"
|
|
170
|
+
tabindex="0"
|
|
171
|
+
aria-label="拖拽调整分栏大小"
|
|
172
|
+
aria-orientation={isHorizontal ? 'vertical' : 'horizontal'}
|
|
173
|
+
aria-valuenow={sizes[0]}
|
|
174
|
+
aria-valuemin={bounds()[0]}
|
|
175
|
+
aria-valuemax={bounds()[1]}
|
|
176
|
+
onpointerdown={handlePointerDown}
|
|
177
|
+
ondblclick={handleDoubleClick}
|
|
178
|
+
onkeydown={handleKeydown}
|
|
179
|
+
>
|
|
180
|
+
<!-- Center Grip Dots -->
|
|
181
|
+
<div class="pointer-events-none flex items-center justify-center opacity-60 group-hover:opacity-100 group-focus-within:opacity-100 {isHorizontal ? 'flex-col gap-1' : 'flex-row gap-1'}">
|
|
182
|
+
<span class="h-1 w-1 rounded-full bg-foreground/60"></span>
|
|
183
|
+
<span class="h-1 w-1 rounded-full bg-foreground/60"></span>
|
|
184
|
+
<span class="h-1 w-1 rounded-full bg-foreground/60"></span>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
<!-- Quick collapse helper triggers on hover -->
|
|
188
|
+
{#if collapsible}
|
|
189
|
+
<div class="absolute flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 {isHorizontal ? 'flex-col' : 'flex-row'}">
|
|
190
|
+
<button
|
|
191
|
+
type="button"
|
|
192
|
+
class="flex h-4 w-4 items-center justify-center rounded-full bg-card text-[9px] text-muted-foreground shadow-xs hover:bg-primary hover:text-primary-foreground"
|
|
193
|
+
title="折叠左/上方"
|
|
194
|
+
onclick={(e) => {
|
|
195
|
+
e.stopPropagation();
|
|
196
|
+
toggleCollapse('first');
|
|
197
|
+
}}
|
|
198
|
+
>
|
|
199
|
+
{isHorizontal ? '‹' : '▲'}
|
|
200
|
+
</button>
|
|
201
|
+
<button
|
|
202
|
+
type="button"
|
|
203
|
+
class="flex h-4 w-4 items-center justify-center rounded-full bg-card text-[9px] text-muted-foreground shadow-xs hover:bg-primary hover:text-primary-foreground"
|
|
204
|
+
title="折叠右/下方"
|
|
205
|
+
onclick={(e) => {
|
|
206
|
+
e.stopPropagation();
|
|
207
|
+
toggleCollapse('second');
|
|
208
|
+
}}
|
|
209
|
+
>
|
|
210
|
+
{isHorizontal ? '›' : '▼'}
|
|
211
|
+
</button>
|
|
212
|
+
</div>
|
|
213
|
+
{/if}
|
|
214
|
+
</div>
|
|
215
|
+
{:else}
|
|
216
|
+
<!-- Collapsed Restore Bar -->
|
|
217
|
+
<div
|
|
218
|
+
class="relative z-10 flex shrink-0 items-center justify-center border-border bg-muted/40 p-1 {isHorizontal ? 'h-full border-x' : 'w-full border-y'}"
|
|
219
|
+
>
|
|
220
|
+
<button
|
|
221
|
+
type="button"
|
|
222
|
+
class="inline-flex items-center gap-1 rounded-md border border-border bg-card px-2 py-1 text-xs font-medium text-foreground shadow-xs hover:bg-muted"
|
|
223
|
+
onclick={() => {
|
|
224
|
+
if (collapsedPane) toggleCollapse(collapsedPane);
|
|
225
|
+
}}
|
|
226
|
+
>
|
|
227
|
+
<span>恢复面板</span>
|
|
228
|
+
<span class="text-[10px] text-muted-foreground">({collapsedPane === 'first' ? '左/上' : '右/下'})</span>
|
|
229
|
+
</button>
|
|
230
|
+
</div>
|
|
231
|
+
{/if}
|
|
232
|
+
|
|
233
|
+
<!-- Second Pane -->
|
|
234
|
+
<div
|
|
235
|
+
class="relative min-h-0 min-w-0 overflow-auto transition-all duration-75 {collapsedPane === 'second' ? 'hidden' : ''}"
|
|
236
|
+
style:flex="{sizes[1]} 1 0%"
|
|
237
|
+
>
|
|
238
|
+
{#if secondPane}
|
|
239
|
+
{@render secondPane()}
|
|
240
|
+
{:else}
|
|
241
|
+
<div class="flex h-full w-full items-center justify-center p-4 text-xs text-muted-foreground">
|
|
242
|
+
面板 2 (Second Pane)
|
|
243
|
+
</div>
|
|
244
|
+
{/if}
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
export interface ResizableSplitterProps {
|
|
3
|
+
direction?: 'horizontal' | 'vertical';
|
|
4
|
+
initialSizes?: [number, number];
|
|
5
|
+
minSizes?: [number, number];
|
|
6
|
+
maxSizes?: [number, number];
|
|
7
|
+
storageKey?: string;
|
|
8
|
+
collapsible?: boolean;
|
|
9
|
+
gutterSize?: number;
|
|
10
|
+
class?: string;
|
|
11
|
+
firstPane?: Snippet;
|
|
12
|
+
secondPane?: Snippet;
|
|
13
|
+
onResize?: (sizes: [number, number]) => void;
|
|
14
|
+
onCollapse?: (collapsedPane: 'first' | 'second' | null) => void;
|
|
15
|
+
}
|
|
16
|
+
declare const ResizableSplitter: import("svelte").Component<ResizableSplitterProps, {}, "">;
|
|
17
|
+
type ResizableSplitter = ReturnType<typeof ResizableSplitter>;
|
|
18
|
+
export default ResizableSplitter;
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { untrack } from 'svelte';
|
|
3
|
+
import type {
|
|
4
|
+
ModerationCategory,
|
|
5
|
+
ModerationAction,
|
|
6
|
+
ModerationSeverity,
|
|
7
|
+
SensitiveWordItem,
|
|
8
|
+
} from './moderation-utils.js';
|
|
9
|
+
import { scanContent } from './moderation-utils.js';
|
|
10
|
+
|
|
11
|
+
export interface SensitiveWordAuditorProps {
|
|
12
|
+
words?: SensitiveWordItem[];
|
|
13
|
+
class?: string;
|
|
14
|
+
onSaveWords?: (words: SensitiveWordItem[]) => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
words: initialWords = [],
|
|
19
|
+
class: className = '',
|
|
20
|
+
onSaveWords,
|
|
21
|
+
}: SensitiveWordAuditorProps = $props();
|
|
22
|
+
|
|
23
|
+
// Internal reactive word dictionary
|
|
24
|
+
let wordList = $state<SensitiveWordItem[]>(untrack(() => initialWords.map(word => ({ ...word }))));
|
|
25
|
+
|
|
26
|
+
// Filters & search
|
|
27
|
+
let searchQuery = $state('');
|
|
28
|
+
let selectedCategory = $state<'ALL' | ModerationCategory>('ALL');
|
|
29
|
+
let selectedAction = $state<'ALL' | ModerationAction>('ALL');
|
|
30
|
+
|
|
31
|
+
// Interactive Test Sandbox State
|
|
32
|
+
let testInput = $state(
|
|
33
|
+
'尊敬的客户,本月理财产品承诺保本高收益,充值可享受高额返现,绝非博彩下注,详情联系专员。',
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const scanResult = $derived(scanContent(testInput, wordList));
|
|
37
|
+
|
|
38
|
+
// Add / Edit Modal state
|
|
39
|
+
let isAddOpen = $state(false);
|
|
40
|
+
let newWord = $state('');
|
|
41
|
+
let newCategory = $state<ModerationCategory>('spam');
|
|
42
|
+
let newAction = $state<ModerationAction>('mask');
|
|
43
|
+
let newSeverity = $state<ModerationSeverity>('medium');
|
|
44
|
+
let newReplacement = $state('***');
|
|
45
|
+
|
|
46
|
+
const filteredWords = $derived.by(() => {
|
|
47
|
+
return wordList.filter((item) => {
|
|
48
|
+
if (selectedCategory !== 'ALL' && item.category !== selectedCategory) return false;
|
|
49
|
+
if (selectedAction !== 'ALL' && item.action !== selectedAction) return false;
|
|
50
|
+
if (searchQuery.trim()) {
|
|
51
|
+
const q = searchQuery.toLowerCase();
|
|
52
|
+
if (!item.word.toLowerCase().includes(q)) return false;
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
function toggleWord(item: SensitiveWordItem) {
|
|
59
|
+
item.enabled = !item.enabled;
|
|
60
|
+
onSaveWords?.($state.snapshot(wordList));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function deleteWord(id: string) {
|
|
64
|
+
wordList = wordList.filter(w => w.id !== id);
|
|
65
|
+
onSaveWords?.($state.snapshot(wordList));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function handleAddWord() {
|
|
69
|
+
if (!newWord.trim()) return;
|
|
70
|
+
const item: SensitiveWordItem = {
|
|
71
|
+
id: `sw-${Date.now()}`,
|
|
72
|
+
word: newWord.trim(),
|
|
73
|
+
category: newCategory,
|
|
74
|
+
action: newAction,
|
|
75
|
+
severity: newSeverity,
|
|
76
|
+
...(newReplacement.trim() ? { replacement: newReplacement.trim() } : {}),
|
|
77
|
+
enabled: true,
|
|
78
|
+
};
|
|
79
|
+
wordList = [item, ...wordList];
|
|
80
|
+
onSaveWords?.($state.snapshot(wordList));
|
|
81
|
+
newWord = '';
|
|
82
|
+
isAddOpen = false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function getSeverityBadge(sev: ModerationSeverity) {
|
|
86
|
+
switch (sev) {
|
|
87
|
+
case 'critical':
|
|
88
|
+
return 'bg-destructive/15 text-destructive border-destructive/30';
|
|
89
|
+
case 'high':
|
|
90
|
+
return 'bg-warning/15 text-warning dark:text-warning border-warning/30';
|
|
91
|
+
case 'medium':
|
|
92
|
+
return 'bg-warning/15 text-warning dark:text-warning border-warning/30';
|
|
93
|
+
case 'low':
|
|
94
|
+
return 'bg-muted text-muted-foreground border-border';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function getActionBadge(act: ModerationAction) {
|
|
99
|
+
switch (act) {
|
|
100
|
+
case 'block':
|
|
101
|
+
return 'bg-destructive/10 text-destructive border-destructive/20';
|
|
102
|
+
case 'mask':
|
|
103
|
+
return 'bg-primary/10 text-primary border-primary/20';
|
|
104
|
+
case 'review':
|
|
105
|
+
return 'bg-warning/10 text-warning dark:text-warning border-warning/20';
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
<div
|
|
111
|
+
class="w-full flex flex-col gap-6 p-6 bg-background text-foreground rounded-xl border border-border shadow-sm {className}"
|
|
112
|
+
data-svadmin-component="SensitiveWordAuditor"
|
|
113
|
+
data-svadmin-resource="content_moderation"
|
|
114
|
+
>
|
|
115
|
+
<!-- Header -->
|
|
116
|
+
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4 pb-4 border-b border-border">
|
|
117
|
+
<div class="flex flex-col gap-1">
|
|
118
|
+
<div class="flex items-center gap-2">
|
|
119
|
+
<h2 class="text-xl font-bold tracking-tight text-foreground">敏感词合规审查与词库管理中心 (Auditor Studio)</h2>
|
|
120
|
+
<span class="text-xs px-2 py-0.5 rounded-full font-medium bg-primary/10 text-primary border border-primary/20">
|
|
121
|
+
Security & Compliance
|
|
122
|
+
</span>
|
|
123
|
+
</div>
|
|
124
|
+
<p class="text-sm text-muted-foreground">
|
|
125
|
+
等保 2.0 与内容安全合规必备:管理涉黄、涉政、广告欺诈违规词库,提供实时拦截、自动脱敏与人工复审策略。
|
|
126
|
+
</p>
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
<div class="flex items-center gap-2">
|
|
130
|
+
<button
|
|
131
|
+
type="button"
|
|
132
|
+
onclick={() => (isAddOpen = true)}
|
|
133
|
+
class="inline-flex items-center justify-center text-xs font-semibold px-4 py-2 rounded-lg bg-primary text-primary-foreground hover:bg-primary/90 transition-colors shadow-sm"
|
|
134
|
+
>
|
|
135
|
+
<svg class="w-3.5 h-3.5 mr-1.5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
136
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
|
|
137
|
+
</svg>
|
|
138
|
+
添加敏感词
|
|
139
|
+
</button>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
<!-- Live Content Moderation Sandbox -->
|
|
144
|
+
<div class="p-5 rounded-xl border border-border bg-card flex flex-col gap-4 shadow-sm">
|
|
145
|
+
<div class="flex items-center justify-between">
|
|
146
|
+
<div class="flex items-center gap-2">
|
|
147
|
+
<span class="text-sm font-bold text-foreground">实时内容合规检测沙箱</span>
|
|
148
|
+
<span class="text-[11px] text-muted-foreground">键入待检测文本实时识别命中违规词与处理决策</span>
|
|
149
|
+
</div>
|
|
150
|
+
{#if scanResult.hasViolation}
|
|
151
|
+
<span class="text-xs px-2.5 py-1 rounded-full font-semibold border {scanResult.blockRequired ? 'bg-destructive/15 text-destructive border-destructive/30' : 'bg-warning/15 text-warning dark:text-warning border-warning/30'}">
|
|
152
|
+
{scanResult.blockRequired ? '⚠️ 触发高危拦截规则' : '⚡ 建议人工复审 / 自动脱敏'}
|
|
153
|
+
</span>
|
|
154
|
+
{:else}
|
|
155
|
+
<span class="text-xs px-2.5 py-1 rounded-full font-semibold bg-success/15 text-success dark:text-success border border-success/30">
|
|
156
|
+
✓ 合规检测通过
|
|
157
|
+
</span>
|
|
158
|
+
{/if}
|
|
159
|
+
</div>
|
|
160
|
+
|
|
161
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 text-xs">
|
|
162
|
+
<!-- Input -->
|
|
163
|
+
<div class="flex flex-col gap-1.5">
|
|
164
|
+
<label for="test-content-input" class="font-semibold text-foreground">输入待审文本内容:</label>
|
|
165
|
+
<textarea
|
|
166
|
+
id="test-content-input"
|
|
167
|
+
rows="4"
|
|
168
|
+
bind:value={testInput}
|
|
169
|
+
class="w-full p-3 rounded-lg border border-border bg-background text-foreground focus:outline-none focus:ring-1 focus:ring-primary font-sans leading-relaxed"
|
|
170
|
+
placeholder="请输入测试文本..."
|
|
171
|
+
></textarea>
|
|
172
|
+
</div>
|
|
173
|
+
|
|
174
|
+
<!-- Result / Masked Preview -->
|
|
175
|
+
<div class="flex flex-col gap-1.5">
|
|
176
|
+
<div class="flex items-center justify-between">
|
|
177
|
+
<span class="font-semibold text-foreground">脱敏清洗与合规结果:</span>
|
|
178
|
+
<span class="text-[11px] text-muted-foreground font-mono">命中违规词: {scanResult.totalHits} 个</span>
|
|
179
|
+
</div>
|
|
180
|
+
<div class="flex-1 p-3 rounded-lg border border-border bg-muted/30 text-foreground leading-relaxed min-h-[96px] flex flex-col justify-between">
|
|
181
|
+
<div>{scanResult.maskedText}</div>
|
|
182
|
+
{#if scanResult.matches.length > 0}
|
|
183
|
+
<div class="flex items-center gap-1.5 flex-wrap pt-2 mt-2 border-t border-border/50">
|
|
184
|
+
<span class="text-muted-foreground font-medium text-[10px]">命中词条:</span>
|
|
185
|
+
{#each scanResult.matches as match, i (i)}
|
|
186
|
+
<span class="text-[10px] px-1.5 py-0.5 rounded border {getSeverityBadge(match.severity)}">
|
|
187
|
+
{match.word} ({match.action})
|
|
188
|
+
</span>
|
|
189
|
+
{/each}
|
|
190
|
+
</div>
|
|
191
|
+
{/if}
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
|
|
197
|
+
<!-- Filter Controls -->
|
|
198
|
+
<div class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3 text-xs">
|
|
199
|
+
<div class="relative flex-1 max-w-sm">
|
|
200
|
+
<input
|
|
201
|
+
type="text"
|
|
202
|
+
bind:value={searchQuery}
|
|
203
|
+
placeholder="搜索敏感词..."
|
|
204
|
+
class="w-full px-3 py-2 pl-8 rounded-lg border border-border bg-card text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary"
|
|
205
|
+
/>
|
|
206
|
+
<svg class="w-3.5 h-3.5 absolute left-2.5 top-2.5 text-muted-foreground" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
207
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
|
|
208
|
+
</svg>
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
<div class="flex items-center gap-2">
|
|
212
|
+
<select
|
|
213
|
+
bind:value={selectedCategory}
|
|
214
|
+
class="px-2.5 py-2 rounded-lg border border-border bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-primary"
|
|
215
|
+
>
|
|
216
|
+
<option value="ALL">全部分类</option>
|
|
217
|
+
<option value="spam">广告营销 / 欺诈</option>
|
|
218
|
+
<option value="violence">违法暴恐</option>
|
|
219
|
+
<option value="politics">涉政违规</option>
|
|
220
|
+
<option value="pornography">涉黄低俗</option>
|
|
221
|
+
<option value="custom">业务自定义</option>
|
|
222
|
+
</select>
|
|
223
|
+
|
|
224
|
+
<select
|
|
225
|
+
bind:value={selectedAction}
|
|
226
|
+
class="px-2.5 py-2 rounded-lg border border-border bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-primary"
|
|
227
|
+
>
|
|
228
|
+
<option value="ALL">全部处置策略</option>
|
|
229
|
+
<option value="block">直接拦截 (Block)</option>
|
|
230
|
+
<option value="mask">自动脱敏 (Mask)</option>
|
|
231
|
+
<option value="review">人工审核 (Review)</option>
|
|
232
|
+
</select>
|
|
233
|
+
</div>
|
|
234
|
+
</div>
|
|
235
|
+
|
|
236
|
+
<!-- Word List Table -->
|
|
237
|
+
<div class="rounded-xl border border-border bg-card overflow-hidden text-xs">
|
|
238
|
+
<table class="w-full border-collapse">
|
|
239
|
+
<thead>
|
|
240
|
+
<tr class="bg-muted/40 border-b border-border text-muted-foreground font-semibold">
|
|
241
|
+
<th class="p-3 text-left">词条内容</th>
|
|
242
|
+
<th class="p-3 text-left">违规分类</th>
|
|
243
|
+
<th class="p-3 text-left">风险严重度</th>
|
|
244
|
+
<th class="p-3 text-left">处置动作</th>
|
|
245
|
+
<th class="p-3 text-left">替换值</th>
|
|
246
|
+
<th class="p-3 text-center">状态</th>
|
|
247
|
+
<th class="p-3 text-right">操作</th>
|
|
248
|
+
</tr>
|
|
249
|
+
</thead>
|
|
250
|
+
<tbody>
|
|
251
|
+
{#if filteredWords.length === 0}
|
|
252
|
+
<tr>
|
|
253
|
+
<td colspan="7" class="p-8 text-center text-muted-foreground">没有找到匹配的敏感词</td>
|
|
254
|
+
</tr>
|
|
255
|
+
{:else}
|
|
256
|
+
{#each filteredWords as item (item.id)}
|
|
257
|
+
<tr class="border-b border-border/60 hover:bg-muted/20 transition-colors">
|
|
258
|
+
<td class="p-3 font-semibold text-foreground font-mono">{item.word}</td>
|
|
259
|
+
<td class="p-3 capitalize text-muted-foreground">{item.category}</td>
|
|
260
|
+
<td class="p-3">
|
|
261
|
+
<span class="px-2 py-0.5 rounded-full text-[11px] font-medium border {getSeverityBadge(item.severity)}">
|
|
262
|
+
{item.severity}
|
|
263
|
+
</span>
|
|
264
|
+
</td>
|
|
265
|
+
<td class="p-3">
|
|
266
|
+
<span class="px-2 py-0.5 rounded-full text-[11px] font-medium border {getActionBadge(item.action)}">
|
|
267
|
+
{item.action}
|
|
268
|
+
</span>
|
|
269
|
+
</td>
|
|
270
|
+
<td class="p-3 font-mono text-muted-foreground">{item.replacement || '-'}</td>
|
|
271
|
+
<td class="p-3 text-center">
|
|
272
|
+
<button
|
|
273
|
+
type="button"
|
|
274
|
+
onclick={() => toggleWord(item)}
|
|
275
|
+
class="text-[11px] px-2 py-0.5 rounded font-medium transition-colors {item.enabled ? 'bg-success/15 text-success dark:text-success' : 'bg-muted text-muted-foreground'}"
|
|
276
|
+
>
|
|
277
|
+
{item.enabled ? '启用中' : '已停用'}
|
|
278
|
+
</button>
|
|
279
|
+
</td>
|
|
280
|
+
<td class="p-3 text-right">
|
|
281
|
+
<button
|
|
282
|
+
type="button"
|
|
283
|
+
onclick={() => deleteWord(item.id)}
|
|
284
|
+
class="text-destructive hover:bg-destructive/10 px-2 py-1 rounded transition-colors"
|
|
285
|
+
>
|
|
286
|
+
删除
|
|
287
|
+
</button>
|
|
288
|
+
</td>
|
|
289
|
+
</tr>
|
|
290
|
+
{/each}
|
|
291
|
+
{/if}
|
|
292
|
+
</tbody>
|
|
293
|
+
</table>
|
|
294
|
+
</div>
|
|
295
|
+
|
|
296
|
+
<!-- Add Word Modal -->
|
|
297
|
+
{#if isAddOpen}
|
|
298
|
+
<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4">
|
|
299
|
+
<div class="w-full max-w-md rounded-xl bg-card border border-border p-6 shadow-xl flex flex-col gap-4 text-foreground text-xs">
|
|
300
|
+
<div class="flex items-center justify-between pb-2 border-b border-border">
|
|
301
|
+
<h3 class="font-bold text-sm text-foreground">添加敏感词条</h3>
|
|
302
|
+
<button type="button" onclick={() => (isAddOpen = false)} class="text-muted-foreground hover:text-foreground">✕</button>
|
|
303
|
+
</div>
|
|
304
|
+
|
|
305
|
+
<div class="flex flex-col gap-3">
|
|
306
|
+
<div class="flex flex-col gap-1">
|
|
307
|
+
<label for="new-word-input" class="font-semibold text-foreground">违规词条</label>
|
|
308
|
+
<input
|
|
309
|
+
id="new-word-input"
|
|
310
|
+
type="text"
|
|
311
|
+
bind:value={newWord}
|
|
312
|
+
placeholder="请输入词条,如:虚假宣传"
|
|
313
|
+
class="px-2.5 py-1.5 rounded border border-border bg-background text-foreground"
|
|
314
|
+
/>
|
|
315
|
+
</div>
|
|
316
|
+
|
|
317
|
+
<div class="grid grid-cols-2 gap-2">
|
|
318
|
+
<div class="flex flex-col gap-1">
|
|
319
|
+
<label for="new-category-select" class="font-semibold text-foreground">违规分类</label>
|
|
320
|
+
<select id="new-category-select" bind:value={newCategory} class="px-2 py-1.5 rounded border border-border bg-background text-foreground">
|
|
321
|
+
<option value="spam">广告营销 / 欺诈</option>
|
|
322
|
+
<option value="violence">违法暴恐</option>
|
|
323
|
+
<option value="politics">涉政违规</option>
|
|
324
|
+
<option value="pornography">涉黄低俗</option>
|
|
325
|
+
<option value="custom">业务自定义</option>
|
|
326
|
+
</select>
|
|
327
|
+
</div>
|
|
328
|
+
<div class="flex flex-col gap-1">
|
|
329
|
+
<label for="new-severity-select" class="font-semibold text-foreground">严重级别</label>
|
|
330
|
+
<select id="new-severity-select" bind:value={newSeverity} class="px-2 py-1.5 rounded border border-border bg-background text-foreground">
|
|
331
|
+
<option value="critical">严重 (Critical)</option>
|
|
332
|
+
<option value="high">高危 (High)</option>
|
|
333
|
+
<option value="medium">中等 (Medium)</option>
|
|
334
|
+
<option value="low">轻微 (Low)</option>
|
|
335
|
+
</select>
|
|
336
|
+
</div>
|
|
337
|
+
</div>
|
|
338
|
+
|
|
339
|
+
<div class="grid grid-cols-2 gap-2">
|
|
340
|
+
<div class="flex flex-col gap-1">
|
|
341
|
+
<label for="new-action-select" class="font-semibold text-foreground">处置动作</label>
|
|
342
|
+
<select id="new-action-select" bind:value={newAction} class="px-2 py-1.5 rounded border border-border bg-background text-foreground">
|
|
343
|
+
<option value="block">直接拦截 (Block)</option>
|
|
344
|
+
<option value="mask">自动脱敏 (Mask)</option>
|
|
345
|
+
<option value="review">人工审核 (Review)</option>
|
|
346
|
+
</select>
|
|
347
|
+
</div>
|
|
348
|
+
<div class="flex flex-col gap-1">
|
|
349
|
+
<label for="new-replacement-input" class="font-semibold text-foreground">替换值 (若脱敏)</label>
|
|
350
|
+
<input
|
|
351
|
+
id="new-replacement-input"
|
|
352
|
+
type="text"
|
|
353
|
+
bind:value={newReplacement}
|
|
354
|
+
placeholder="***"
|
|
355
|
+
class="px-2 py-1.5 rounded border border-border bg-background text-foreground font-mono"
|
|
356
|
+
/>
|
|
357
|
+
</div>
|
|
358
|
+
</div>
|
|
359
|
+
</div>
|
|
360
|
+
|
|
361
|
+
<div class="flex items-center justify-end gap-2 pt-3 border-t border-border">
|
|
362
|
+
<button type="button" onclick={() => (isAddOpen = false)} class="px-3 py-1.5 rounded border border-border bg-card">取消</button>
|
|
363
|
+
<button type="button" onclick={handleAddWord} class="px-3 py-1.5 rounded bg-primary text-primary-foreground font-semibold">保存</button>
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
</div>
|
|
367
|
+
{/if}
|
|
368
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SensitiveWordItem } from './moderation-utils.js';
|
|
2
|
+
export interface SensitiveWordAuditorProps {
|
|
3
|
+
words?: SensitiveWordItem[];
|
|
4
|
+
class?: string;
|
|
5
|
+
onSaveWords?: (words: SensitiveWordItem[]) => void;
|
|
6
|
+
}
|
|
7
|
+
declare const SensitiveWordAuditor: import("svelte").Component<SensitiveWordAuditorProps, {}, "">;
|
|
8
|
+
type SensitiveWordAuditor = ReturnType<typeof SensitiveWordAuditor>;
|
|
9
|
+
export default SensitiveWordAuditor;
|