work-agent 0.1.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/README.md +234 -0
- package/app/(admin)/approvals/page.tsx +16 -0
- package/app/(admin)/audit/page.tsx +18 -0
- package/app/(admin)/layout.tsx +47 -0
- package/app/(admin)/scheduled-tasks/page.tsx +17 -0
- package/app/(admin)/settings/page.tsx +46 -0
- package/app/(admin)/skills/[name]/page.tsx +378 -0
- package/app/(admin)/skills/page.tsx +406 -0
- package/app/(admin)/statistics/page.tsx +416 -0
- package/app/(admin)/tickets/[id]/page.tsx +348 -0
- package/app/(admin)/tickets/new/page.tsx +309 -0
- package/app/(admin)/tickets/page.tsx +27 -0
- package/app/api/audit/route.ts +30 -0
- package/app/api/auth/feishu/callback/route.ts +72 -0
- package/app/api/auth/feishu/login/route.ts +17 -0
- package/app/api/auth/feishu/sso/route.ts +78 -0
- package/app/api/auth/login/route.ts +85 -0
- package/app/api/auth/oauth/route.ts +168 -0
- package/app/api/config/providers/route.ts +105 -0
- package/app/api/config/route.ts +115 -0
- package/app/api/config/status/route.ts +56 -0
- package/app/api/config/test/route.ts +212 -0
- package/app/api/documents/[id]/route.ts +88 -0
- package/app/api/documents/route.ts +53 -0
- package/app/api/health/route.ts +32 -0
- package/app/api/knowledge/[id]/route.ts +152 -0
- package/app/api/knowledge/from-session/route.ts +27 -0
- package/app/api/knowledge/route.ts +100 -0
- package/app/api/market/knowledge/[id]/route.ts +92 -0
- package/app/api/market/knowledge/route.ts +130 -0
- package/app/api/marketplace/skills/[id]/approve/route.ts +68 -0
- package/app/api/marketplace/skills/[id]/certify/route.ts +54 -0
- package/app/api/marketplace/skills/[id]/install/route.ts +180 -0
- package/app/api/marketplace/skills/[id]/promote-to-system/route.ts +219 -0
- package/app/api/marketplace/skills/[id]/rate/route.ts +90 -0
- package/app/api/marketplace/skills/[id]/ratings/route.ts +55 -0
- package/app/api/marketplace/skills/[id]/reject/route.ts +68 -0
- package/app/api/marketplace/skills/[id]/route.ts +177 -0
- package/app/api/marketplace/skills/route.ts +235 -0
- package/app/api/memory/route.ts +40 -0
- package/app/api/my/files/[id]/route.ts +52 -0
- package/app/api/my/files/route.ts +230 -0
- package/app/api/my/knowledge/route.ts +36 -0
- package/app/api/pi-chat/route.ts +443 -0
- package/app/api/recommend/route.ts +38 -0
- package/app/api/scheduled-tasks/[id]/execute/route.ts +132 -0
- package/app/api/scheduled-tasks/[id]/route.ts +165 -0
- package/app/api/scheduled-tasks/[id]/toggle/route.ts +53 -0
- package/app/api/scheduled-tasks/route.ts +101 -0
- package/app/api/sessions/[id]/messages/route.ts +212 -0
- package/app/api/sessions/route.ts +101 -0
- package/app/api/share/file/[id]/route.ts +37 -0
- package/app/api/skills/[name]/execute/route.ts +121 -0
- package/app/api/skills/[name]/route.ts +167 -0
- package/app/api/skills/create/route.ts +65 -0
- package/app/api/skills/generate/route.ts +405 -0
- package/app/api/skills/installed/route.ts +151 -0
- package/app/api/skills/route.ts +174 -0
- package/app/api/skills/translate/route.ts +40 -0
- package/app/api/skills/user/[name]/route.ts +159 -0
- package/app/api/skills/user/route.ts +90 -0
- package/app/api/statistics/route.ts +94 -0
- package/app/api/task-executions/[id]/route.ts +34 -0
- package/app/api/task-executions/route.ts +29 -0
- package/app/api/tickets/[id]/approve/route.ts +129 -0
- package/app/api/tickets/[id]/execute/route.ts +201 -0
- package/app/api/tickets/[id]/route.ts +127 -0
- package/app/api/tickets/route.ts +103 -0
- package/app/api/user/skills/route.ts +175 -0
- package/app/api/users/route.ts +80 -0
- package/app/chat/page.tsx +5 -0
- package/app/globals.css +84 -0
- package/app/h5/layout.tsx +5 -0
- package/app/h5/mobile-approvals-page.tsx +167 -0
- package/app/h5/mobile-chat-page.tsx +951 -0
- package/app/h5/mobile-profile-page.tsx +147 -0
- package/app/h5/mobile-tickets-page.tsx +121 -0
- package/app/h5/page.tsx +23 -0
- package/app/h5/ticket-action-buttons.tsx +80 -0
- package/app/layout.tsx +26 -0
- package/app/login/page.tsx +318 -0
- package/app/market/knowledge/[id]/page.tsx +77 -0
- package/app/market/knowledge/page.tsx +358 -0
- package/app/market/layout.tsx +29 -0
- package/app/market/page.tsx +18 -0
- package/app/market/skills/page.tsx +397 -0
- package/app/my/files/page.tsx +511 -0
- package/app/my/knowledge/[id]/page.tsx +271 -0
- package/app/my/knowledge/new/page.tsx +234 -0
- package/app/my/knowledge/page.tsx +248 -0
- package/app/my/layout.tsx +32 -0
- package/app/my/memory/page.tsx +164 -0
- package/app/my/page.tsx +18 -0
- package/app/my/scheduled-tasks/[id]/edit/page.tsx +290 -0
- package/app/my/scheduled-tasks/[id]/executions/page.tsx +275 -0
- package/app/my/scheduled-tasks/[id]/page.tsx +284 -0
- package/app/my/scheduled-tasks/new/page.tsx +230 -0
- package/app/my/scheduled-tasks/page.tsx +27 -0
- package/app/my/skills/[name]/page.tsx +320 -0
- package/app/my/skills/new/page.tsx +394 -0
- package/app/my/skills/page.tsx +303 -0
- package/app/page.tsx +2288 -0
- package/app/share/[sessionId]/page.tsx +226 -0
- package/app/share/file/[id]/page.tsx +140 -0
- package/bin/README.md +63 -0
- package/bin/generate-api-system +300 -0
- package/bin/postinstall.js +95 -0
- package/bin/work-agent.js +173 -0
- package/components/ai-elements/agent.tsx +142 -0
- package/components/ai-elements/artifact.tsx +149 -0
- package/components/ai-elements/attachments.tsx +427 -0
- package/components/ai-elements/audio-player.tsx +232 -0
- package/components/ai-elements/canvas.tsx +26 -0
- package/components/ai-elements/chain-of-thought.tsx +223 -0
- package/components/ai-elements/checkpoint.tsx +72 -0
- package/components/ai-elements/code-block.tsx +555 -0
- package/components/ai-elements/commit.tsx +449 -0
- package/components/ai-elements/confirmation.tsx +173 -0
- package/components/ai-elements/connection.tsx +28 -0
- package/components/ai-elements/context.tsx +410 -0
- package/components/ai-elements/controls.tsx +19 -0
- package/components/ai-elements/conversation.tsx +167 -0
- package/components/ai-elements/edge.tsx +144 -0
- package/components/ai-elements/environment-variables.tsx +325 -0
- package/components/ai-elements/file-tree.tsx +298 -0
- package/components/ai-elements/image.tsx +25 -0
- package/components/ai-elements/inline-citation.tsx +294 -0
- package/components/ai-elements/jsx-preview.tsx +250 -0
- package/components/ai-elements/message.tsx +367 -0
- package/components/ai-elements/mic-selector.tsx +372 -0
- package/components/ai-elements/model-selector.tsx +214 -0
- package/components/ai-elements/node.tsx +72 -0
- package/components/ai-elements/open-in-chat.tsx +367 -0
- package/components/ai-elements/package-info.tsx +235 -0
- package/components/ai-elements/panel.tsx +16 -0
- package/components/ai-elements/persona.tsx +280 -0
- package/components/ai-elements/plan.tsx +144 -0
- package/components/ai-elements/prompt-input.tsx +1341 -0
- package/components/ai-elements/queue.tsx +275 -0
- package/components/ai-elements/reasoning.tsx +355 -0
- package/components/ai-elements/sandbox.tsx +133 -0
- package/components/ai-elements/schema-display.tsx +473 -0
- package/components/ai-elements/shimmer.tsx +78 -0
- package/components/ai-elements/snippet.tsx +141 -0
- package/components/ai-elements/sources.tsx +78 -0
- package/components/ai-elements/speech-input.tsx +324 -0
- package/components/ai-elements/stack-trace.tsx +531 -0
- package/components/ai-elements/suggestion.tsx +58 -0
- package/components/ai-elements/task.tsx +88 -0
- package/components/ai-elements/terminal.tsx +277 -0
- package/components/ai-elements/test-results.tsx +497 -0
- package/components/ai-elements/tool.tsx +174 -0
- package/components/ai-elements/toolbar.tsx +17 -0
- package/components/ai-elements/transcription.tsx +126 -0
- package/components/ai-elements/voice-selector.tsx +525 -0
- package/components/ai-elements/web-preview.tsx +282 -0
- package/components/audit-log-list.tsx +114 -0
- package/components/chat/EmptyPreviewState.tsx +12 -0
- package/components/chat/KnowledgePickerDialog.tsx +464 -0
- package/components/chat/KnowledgePreview.tsx +70 -0
- package/components/chat/KnowledgePreviewPanel.tsx +86 -0
- package/components/chat/MentionInput.tsx +309 -0
- package/components/chat/OrganizeDialog.tsx +258 -0
- package/components/chat/RecommendationBanner.tsx +94 -0
- package/components/chat/SaveToKnowledgeDialog.tsx +193 -0
- package/components/chat/SkillSelector.tsx +305 -0
- package/components/chat/SkillSwitcher.tsx +163 -0
- package/components/client-layout.tsx +15 -0
- package/components/knowledge/KnowledgeMetadataPanel.tsx +293 -0
- package/components/layout-wrapper.tsx +18 -0
- package/components/mobile-layout.tsx +62 -0
- package/components/scheduled-task-list.tsx +356 -0
- package/components/setup-guide.tsx +484 -0
- package/components/sub-nav.tsx +54 -0
- package/components/ticket-detail-content.tsx +383 -0
- package/components/ticket-list.tsx +366 -0
- package/components/top-nav.tsx +132 -0
- package/components/ui/accordion.tsx +58 -0
- package/components/ui/alert.tsx +59 -0
- package/components/ui/avatar.tsx +50 -0
- package/components/ui/badge.tsx +36 -0
- package/components/ui/button-group.tsx +83 -0
- package/components/ui/button.tsx +57 -0
- package/components/ui/card.tsx +91 -0
- package/components/ui/carousel.tsx +262 -0
- package/components/ui/collapsible.tsx +11 -0
- package/components/ui/command.tsx +153 -0
- package/components/ui/dialog.tsx +122 -0
- package/components/ui/dropdown-menu.tsx +200 -0
- package/components/ui/hover-card.tsx +29 -0
- package/components/ui/input-group.tsx +170 -0
- package/components/ui/input.tsx +22 -0
- package/components/ui/label.tsx +26 -0
- package/components/ui/popover.tsx +31 -0
- package/components/ui/progress.tsx +28 -0
- package/components/ui/scroll-area.tsx +48 -0
- package/components/ui/select.tsx +174 -0
- package/components/ui/separator.tsx +31 -0
- package/components/ui/spinner.tsx +16 -0
- package/components/ui/switch.tsx +29 -0
- package/components/ui/table.tsx +120 -0
- package/components/ui/tabs.tsx +55 -0
- package/components/ui/textarea.tsx +22 -0
- package/components/ui/tooltip.tsx +30 -0
- package/components/welcome-guide.tsx +182 -0
- package/components.json +24 -0
- package/lib/command-parser.ts +331 -0
- package/lib/dangerous-commands.ts +672 -0
- package/lib/db.ts +2250 -0
- package/lib/feishu-auth.ts +135 -0
- package/lib/file-storage.ts +306 -0
- package/lib/file-tool.ts +583 -0
- package/lib/knowledge-tool.ts +152 -0
- package/lib/knowledge-types.ts +66 -0
- package/lib/market-client.ts +313 -0
- package/lib/market-db.ts +736 -0
- package/lib/market-types.ts +51 -0
- package/lib/memory-tool.ts +211 -0
- package/lib/memory.ts +197 -0
- package/lib/pi-config.ts +436 -0
- package/lib/pi-session.ts +799 -0
- package/lib/pinyin.ts +13 -0
- package/lib/recommendation.ts +227 -0
- package/lib/risk-estimator.ts +350 -0
- package/lib/scheduled-task-tool.ts +184 -0
- package/lib/scheduler-init.ts +43 -0
- package/lib/scheduler.ts +416 -0
- package/lib/secure-bash-tool.ts +413 -0
- package/lib/skill-engine.ts +396 -0
- package/lib/skill-generator.ts +269 -0
- package/lib/skill-loader.ts +234 -0
- package/lib/skill-tool.ts +188 -0
- package/lib/skill-types.ts +82 -0
- package/lib/skills-init.ts +58 -0
- package/lib/ticket-tool.ts +246 -0
- package/lib/user-skill-types.ts +30 -0
- package/lib/user-skills.ts +362 -0
- package/lib/utils.ts +6 -0
- package/lib/workflow.ts +154 -0
- package/lib/zip-tool.ts +191 -0
- package/next.config.js +8 -0
- package/package.json +106 -0
- package/public/.gitkeep +1 -0
- package/public/icon.svg +1 -0
- package/tsconfig.json +42 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState, KeyboardEvent } from 'react';
|
|
4
|
+
import { X, Plus, Trash2, Save } from 'lucide-react';
|
|
5
|
+
import { Button } from '@/components/ui/button';
|
|
6
|
+
import { Input } from '@/components/ui/input';
|
|
7
|
+
import { Label } from '@/components/ui/label';
|
|
8
|
+
import {
|
|
9
|
+
Select,
|
|
10
|
+
SelectContent,
|
|
11
|
+
SelectItem,
|
|
12
|
+
SelectTrigger,
|
|
13
|
+
SelectValue,
|
|
14
|
+
} from '@/components/ui/select';
|
|
15
|
+
import { Switch } from '@/components/ui/switch';
|
|
16
|
+
import { Badge } from '@/components/ui/badge';
|
|
17
|
+
import {
|
|
18
|
+
Dialog,
|
|
19
|
+
DialogContent,
|
|
20
|
+
DialogDescription,
|
|
21
|
+
DialogHeader,
|
|
22
|
+
DialogTitle,
|
|
23
|
+
DialogTrigger,
|
|
24
|
+
} from '@/components/ui/dialog';
|
|
25
|
+
import type { KnowledgeType } from '@/lib/db';
|
|
26
|
+
import { KNOWLEDGE_TYPE_LABELS } from '@/lib/knowledge-types';
|
|
27
|
+
|
|
28
|
+
interface KnowledgeMetadataPanelProps {
|
|
29
|
+
title: string;
|
|
30
|
+
onTitleChange: (value: string) => void;
|
|
31
|
+
type: KnowledgeType;
|
|
32
|
+
onTypeChange: (value: KnowledgeType) => void;
|
|
33
|
+
category: string;
|
|
34
|
+
onCategoryChange: (value: string) => void;
|
|
35
|
+
tags: string[];
|
|
36
|
+
onTagsChange: (value: string[]) => void;
|
|
37
|
+
isActive: boolean;
|
|
38
|
+
onIsActiveChange: (value: boolean) => void;
|
|
39
|
+
categories: string[];
|
|
40
|
+
onSave: () => void;
|
|
41
|
+
onDelete?: () => void;
|
|
42
|
+
saving?: boolean;
|
|
43
|
+
showDelete?: boolean;
|
|
44
|
+
author?: string;
|
|
45
|
+
createdAt?: Date;
|
|
46
|
+
updatedAt?: Date;
|
|
47
|
+
sourceType?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function KnowledgeMetadataPanel({
|
|
51
|
+
title,
|
|
52
|
+
onTitleChange,
|
|
53
|
+
type,
|
|
54
|
+
onTypeChange,
|
|
55
|
+
category,
|
|
56
|
+
onCategoryChange,
|
|
57
|
+
tags,
|
|
58
|
+
onTagsChange,
|
|
59
|
+
isActive,
|
|
60
|
+
onIsActiveChange,
|
|
61
|
+
categories,
|
|
62
|
+
onSave,
|
|
63
|
+
onDelete,
|
|
64
|
+
saving,
|
|
65
|
+
showDelete = true,
|
|
66
|
+
author,
|
|
67
|
+
createdAt,
|
|
68
|
+
updatedAt,
|
|
69
|
+
sourceType,
|
|
70
|
+
}: KnowledgeMetadataPanelProps) {
|
|
71
|
+
const [tagInput, setTagInput] = useState('');
|
|
72
|
+
const [newCategoryInput, setNewCategoryInput] = useState('');
|
|
73
|
+
const [newCategoryDialogOpen, setNewCategoryDialogOpen] = useState(false);
|
|
74
|
+
|
|
75
|
+
const handleTagInputKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
|
|
76
|
+
if (e.key === 'Enter' || e.key === ',') {
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
addTag();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const addTag = () => {
|
|
83
|
+
const newTag = tagInput.trim().replace(',', '');
|
|
84
|
+
if (newTag && !tags.includes(newTag)) {
|
|
85
|
+
onTagsChange([...tags, newTag]);
|
|
86
|
+
}
|
|
87
|
+
setTagInput('');
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const removeTag = (tagToRemove: string) => {
|
|
91
|
+
onTagsChange(tags.filter(t => t !== tagToRemove));
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const handleAddNewCategory = () => {
|
|
95
|
+
if (newCategoryInput.trim()) {
|
|
96
|
+
onCategoryChange(newCategoryInput.trim());
|
|
97
|
+
setNewCategoryInput('');
|
|
98
|
+
setNewCategoryDialogOpen(false);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<div className="w-[300px] h-full bg-card border-l flex flex-col overflow-hidden">
|
|
104
|
+
<div className="p-4 border-b">
|
|
105
|
+
<h2 className="font-semibold text-lg">元数据</h2>
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
<div className="flex-1 overflow-y-auto p-4 space-y-5">
|
|
109
|
+
<div className="space-y-2">
|
|
110
|
+
<Label htmlFor="title" className="text-sm font-medium">
|
|
111
|
+
标题
|
|
112
|
+
</Label>
|
|
113
|
+
<Input
|
|
114
|
+
id="title"
|
|
115
|
+
type="text"
|
|
116
|
+
value={title}
|
|
117
|
+
onChange={(e) => onTitleChange(e.target.value)}
|
|
118
|
+
placeholder="知识标题..."
|
|
119
|
+
className="font-medium"
|
|
120
|
+
/>
|
|
121
|
+
</div>
|
|
122
|
+
|
|
123
|
+
<div className="space-y-2">
|
|
124
|
+
<Label htmlFor="type" className="text-sm font-medium">
|
|
125
|
+
类型
|
|
126
|
+
</Label>
|
|
127
|
+
<Select value={type} onValueChange={(v) => onTypeChange(v as KnowledgeType)}>
|
|
128
|
+
<SelectTrigger id="type">
|
|
129
|
+
<SelectValue placeholder="选择类型" />
|
|
130
|
+
</SelectTrigger>
|
|
131
|
+
<SelectContent>
|
|
132
|
+
{Object.entries(KNOWLEDGE_TYPE_LABELS).map(([value, label]) => (
|
|
133
|
+
<SelectItem key={value} value={value}>{label}</SelectItem>
|
|
134
|
+
))}
|
|
135
|
+
</SelectContent>
|
|
136
|
+
</Select>
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
<div className="space-y-2">
|
|
140
|
+
<Label htmlFor="category" className="text-sm font-medium">
|
|
141
|
+
分类
|
|
142
|
+
</Label>
|
|
143
|
+
<div className="flex gap-2">
|
|
144
|
+
<Select value={category} onValueChange={onCategoryChange}>
|
|
145
|
+
<SelectTrigger id="category" className="flex-1">
|
|
146
|
+
<SelectValue placeholder="选择分类" />
|
|
147
|
+
</SelectTrigger>
|
|
148
|
+
<SelectContent>
|
|
149
|
+
<SelectItem value="none">无分类</SelectItem>
|
|
150
|
+
{categories.map(cat => (
|
|
151
|
+
<SelectItem key={cat} value={cat}>{cat}</SelectItem>
|
|
152
|
+
))}
|
|
153
|
+
</SelectContent>
|
|
154
|
+
</Select>
|
|
155
|
+
<Dialog open={newCategoryDialogOpen} onOpenChange={setNewCategoryDialogOpen}>
|
|
156
|
+
<DialogTrigger asChild>
|
|
157
|
+
<Button variant="outline" size="icon" title="新建分类">
|
|
158
|
+
<Plus className="h-4 w-4" />
|
|
159
|
+
</Button>
|
|
160
|
+
</DialogTrigger>
|
|
161
|
+
<DialogContent>
|
|
162
|
+
<DialogHeader>
|
|
163
|
+
<DialogTitle>新建分类</DialogTitle>
|
|
164
|
+
<DialogDescription>
|
|
165
|
+
输入新的分类名称
|
|
166
|
+
</DialogDescription>
|
|
167
|
+
</DialogHeader>
|
|
168
|
+
<div className="py-4">
|
|
169
|
+
<Input
|
|
170
|
+
value={newCategoryInput}
|
|
171
|
+
onChange={(e) => setNewCategoryInput(e.target.value)}
|
|
172
|
+
placeholder="分类名称..."
|
|
173
|
+
onKeyDown={(e) => e.key === 'Enter' && handleAddNewCategory()}
|
|
174
|
+
/>
|
|
175
|
+
</div>
|
|
176
|
+
<div className="flex justify-end gap-2">
|
|
177
|
+
<Button variant="outline" onClick={() => setNewCategoryDialogOpen(false)}>
|
|
178
|
+
取消
|
|
179
|
+
</Button>
|
|
180
|
+
<Button onClick={handleAddNewCategory}>
|
|
181
|
+
创建
|
|
182
|
+
</Button>
|
|
183
|
+
</div>
|
|
184
|
+
</DialogContent>
|
|
185
|
+
</Dialog>
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
|
|
189
|
+
<div className="space-y-2">
|
|
190
|
+
<Label className="text-sm font-medium">标签</Label>
|
|
191
|
+
<div className="flex flex-wrap gap-1.5 min-h-[32px]">
|
|
192
|
+
{tags.map(tag => (
|
|
193
|
+
<Badge
|
|
194
|
+
key={tag}
|
|
195
|
+
variant="secondary"
|
|
196
|
+
className="gap-1 pr-1 pl-2"
|
|
197
|
+
>
|
|
198
|
+
{tag}
|
|
199
|
+
<button
|
|
200
|
+
onClick={() => removeTag(tag)}
|
|
201
|
+
className="hover:bg-muted rounded p-0.5"
|
|
202
|
+
>
|
|
203
|
+
<X className="h-3 w-3" />
|
|
204
|
+
</button>
|
|
205
|
+
</Badge>
|
|
206
|
+
))}
|
|
207
|
+
</div>
|
|
208
|
+
<Input
|
|
209
|
+
type="text"
|
|
210
|
+
value={tagInput}
|
|
211
|
+
onChange={(e) => setTagInput(e.target.value)}
|
|
212
|
+
onKeyDown={handleTagInputKeyDown}
|
|
213
|
+
onBlur={addTag}
|
|
214
|
+
placeholder="输入标签,回车添加..."
|
|
215
|
+
className="text-sm"
|
|
216
|
+
/>
|
|
217
|
+
</div>
|
|
218
|
+
|
|
219
|
+
<div className="space-y-3 pt-2">
|
|
220
|
+
<div className="flex items-center justify-between">
|
|
221
|
+
<Label htmlFor="isActive" className="text-sm font-medium cursor-pointer">
|
|
222
|
+
启用状态
|
|
223
|
+
</Label>
|
|
224
|
+
<Switch
|
|
225
|
+
id="isActive"
|
|
226
|
+
checked={isActive}
|
|
227
|
+
onCheckedChange={onIsActiveChange}
|
|
228
|
+
/>
|
|
229
|
+
</div>
|
|
230
|
+
<p className="text-xs text-muted-foreground">
|
|
231
|
+
{isActive ? '知识已启用,可被 AI 检索使用' : '知识已停用,暂不参与检索'}
|
|
232
|
+
</p>
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
{(author || createdAt || updatedAt || sourceType) && (
|
|
236
|
+
<div className="space-y-2 pt-2 border-t">
|
|
237
|
+
<p className="text-xs text-muted-foreground">
|
|
238
|
+
{author && <span>作者: {author}</span>}
|
|
239
|
+
</p>
|
|
240
|
+
<p className="text-xs text-muted-foreground">
|
|
241
|
+
{createdAt && <span>创建于: {new Date(createdAt).toLocaleString('zh-CN')}</span>}
|
|
242
|
+
</p>
|
|
243
|
+
<p className="text-xs text-muted-foreground">
|
|
244
|
+
{updatedAt && <span>更新于: {new Date(updatedAt).toLocaleString('zh-CN')}</span>}
|
|
245
|
+
</p>
|
|
246
|
+
{sourceType && (
|
|
247
|
+
<Badge variant="outline" className="text-xs">
|
|
248
|
+
{sourceType}
|
|
249
|
+
</Badge>
|
|
250
|
+
)}
|
|
251
|
+
</div>
|
|
252
|
+
)}
|
|
253
|
+
</div>
|
|
254
|
+
|
|
255
|
+
<div className="p-4 border-t space-y-2">
|
|
256
|
+
<Button
|
|
257
|
+
onClick={onSave}
|
|
258
|
+
disabled={saving || !title.trim()}
|
|
259
|
+
className="w-full"
|
|
260
|
+
>
|
|
261
|
+
<Save className="h-4 w-4 mr-2" />
|
|
262
|
+
{saving ? '保存中...' : '保存知识'}
|
|
263
|
+
</Button>
|
|
264
|
+
{showDelete && onDelete && (
|
|
265
|
+
<Dialog>
|
|
266
|
+
<DialogTrigger asChild>
|
|
267
|
+
<Button variant="outline" size="sm" className="w-full text-destructive hover:text-destructive">
|
|
268
|
+
<Trash2 className="h-4 w-4 mr-2" />
|
|
269
|
+
删除知识
|
|
270
|
+
</Button>
|
|
271
|
+
</DialogTrigger>
|
|
272
|
+
<DialogContent>
|
|
273
|
+
<DialogHeader>
|
|
274
|
+
<DialogTitle>确认删除</DialogTitle>
|
|
275
|
+
<DialogDescription>
|
|
276
|
+
确定要删除知识 "{title}" 吗?此操作无法撤销。
|
|
277
|
+
</DialogDescription>
|
|
278
|
+
</DialogHeader>
|
|
279
|
+
<div className="flex justify-end gap-2 mt-4">
|
|
280
|
+
<Button variant="outline" onClick={() => {}}>
|
|
281
|
+
取消
|
|
282
|
+
</Button>
|
|
283
|
+
<Button variant="destructive" onClick={onDelete}>
|
|
284
|
+
删除
|
|
285
|
+
</Button>
|
|
286
|
+
</div>
|
|
287
|
+
</DialogContent>
|
|
288
|
+
</Dialog>
|
|
289
|
+
)}
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
);
|
|
293
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { TopNav } from './top-nav';
|
|
4
|
+
|
|
5
|
+
interface LayoutWrapperProps {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function LayoutWrapper({ children }: LayoutWrapperProps) {
|
|
10
|
+
return (
|
|
11
|
+
<div className="flex flex-col h-screen">
|
|
12
|
+
<TopNav />
|
|
13
|
+
<main className="flex-1 overflow-auto">
|
|
14
|
+
{children}
|
|
15
|
+
</main>
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
import { MessageSquare, ClipboardList, User } from 'lucide-react';
|
|
5
|
+
import { cn } from '@/lib/utils';
|
|
6
|
+
|
|
7
|
+
type Tab = 'chat' | 'tickets' | 'approvals' | 'profile';
|
|
8
|
+
|
|
9
|
+
interface MobileLayoutProps {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
activeTab: Tab;
|
|
12
|
+
onTabChange: (tab: Tab) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function MobileLayout({ children, activeTab, onTabChange }: MobileLayoutProps) {
|
|
16
|
+
const [mounted, setMounted] = useState(false);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
setMounted(true);
|
|
20
|
+
}, []);
|
|
21
|
+
|
|
22
|
+
const tabs: { id: Tab; label: string; icon: React.ElementType }[] = [
|
|
23
|
+
{ id: 'chat', label: '对话', icon: MessageSquare },
|
|
24
|
+
{ id: 'tickets', label: '工单', icon: ClipboardList },
|
|
25
|
+
{ id: 'approvals', label: '审核', icon: ClipboardList },
|
|
26
|
+
{ id: 'profile', label: '我的', icon: User },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
if (!mounted) {
|
|
30
|
+
return <div className="h-screen bg-background" />;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div className="h-[100dvh] flex flex-col bg-background overflow-hidden">
|
|
35
|
+
{/* 主内容区 */}
|
|
36
|
+
<main className="flex-1 overflow-hidden flex flex-col">
|
|
37
|
+
{children}
|
|
38
|
+
</main>
|
|
39
|
+
|
|
40
|
+
{/* 底部导航栏 */}
|
|
41
|
+
<nav className="bg-card border-t flex-shrink-0 pb-safe">
|
|
42
|
+
<div className="flex">
|
|
43
|
+
{tabs.map((tab) => (
|
|
44
|
+
<button
|
|
45
|
+
key={tab.id}
|
|
46
|
+
onClick={() => onTabChange(tab.id)}
|
|
47
|
+
className={cn(
|
|
48
|
+
"flex-1 py-3 flex flex-col items-center gap-0.5 transition-colors",
|
|
49
|
+
activeTab === tab.id
|
|
50
|
+
? "text-primary"
|
|
51
|
+
: "text-muted-foreground"
|
|
52
|
+
)}
|
|
53
|
+
>
|
|
54
|
+
<tab.icon className="h-5 w-5" />
|
|
55
|
+
<span className="text-xs">{tab.label}</span>
|
|
56
|
+
</button>
|
|
57
|
+
))}
|
|
58
|
+
</div>
|
|
59
|
+
</nav>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
}
|