sync update from LAN repo (source dhk-1 @ fc974e93)
This commit is contained in:
1 parent
a1fa13a238
commit
e2fea6a801
432 files changed
+68707
-2270
No files matched your search
@@ -67,7 +67,7 @@ const iconButtonClass = (isDark: boolean, isPaleLightTheme: boolean, isCustomThe
|
||||
? "text-slate-400 hover:bg-slate-800/50 hover:text-white"
|
||||
: isPaleLightTheme
|
||||
? "text-[var(--foreground)] hover:bg-white/55 hover:text-[var(--foreground)] active:bg-white/75"
|
||||
: "text-white hover:bg-[var(--brand-950)] active:bg-[#8a0618]",
|
||||
: "text-white hover:bg-[var(--brand-900)] active:bg-[var(--brand-950)]",
|
||||
);
|
||||
|
||||
type HeaderProps = {
|
||||
@@ -357,7 +357,7 @@ const Header = ({ collapsed }: HeaderProps) => {
|
||||
? "text-slate-200 hover:bg-slate-800/50"
|
||||
: isPaleLightTheme
|
||||
? "text-[var(--foreground)] hover:bg-white/55 active:bg-white/75"
|
||||
: "text-white hover:bg-[var(--brand-950)] active:bg-[#8a0618]",
|
||||
: "text-white hover:bg-[var(--brand-900)] active:bg-[var(--brand-950)]",
|
||||
)}
|
||||
>
|
||||
<div
|
||||
|
||||
@@ -144,6 +144,8 @@ export interface HtmlTemplateFieldInfo {
|
||||
extract: boolean;
|
||||
/** false = 布局分区(无独立数据键),抽取开关无意义。 */
|
||||
hasKey: boolean;
|
||||
/** true = 用户添加的自定义字段(可删除)。 */
|
||||
custom: boolean;
|
||||
}
|
||||
|
||||
/** 自定义模块(挂在指定页面底部的 AI 生成 HTML 片段,存于 manifest)。 */
|
||||
@@ -157,6 +159,8 @@ export interface HtmlTemplateCustomModule {
|
||||
export interface HtmlTemplatePageOption {
|
||||
key: string;
|
||||
label: string;
|
||||
/** true = 该页面(分类)已在模板导航整体隐藏。 */
|
||||
hidden: boolean;
|
||||
}
|
||||
|
||||
/** 字段目录 + 页面清单 + 自定义模块列表(「字段与模块」页签数据源)。 */
|
||||
@@ -169,11 +173,12 @@ export async function getHtmlTemplateFields(templateId: string): Promise<{
|
||||
method: "GET",
|
||||
});
|
||||
const data = await readJson<{
|
||||
fields?: (Omit<HtmlTemplateFieldInfo, "extract" | "hasKey"> & {
|
||||
fields?: (Omit<HtmlTemplateFieldInfo, "extract" | "hasKey" | "custom"> & {
|
||||
extract?: boolean | null;
|
||||
has_key?: boolean | null;
|
||||
custom?: boolean | null;
|
||||
})[] | null;
|
||||
pages?: HtmlTemplatePageOption[] | null;
|
||||
pages?: ({ key: string; label: string; hidden?: boolean | null } | null)[] | null;
|
||||
custom_modules?: HtmlTemplateCustomModule[] | null;
|
||||
}>(res, "get html template fields");
|
||||
return {
|
||||
@@ -182,8 +187,15 @@ export async function getHtmlTemplateFields(templateId: string): Promise<{
|
||||
extract: f.extract !== false,
|
||||
// 兼容旧缓存缺 has_key 的响应:缺失按有键处理(宁可多开不可全禁)。
|
||||
hasKey: f.has_key !== false,
|
||||
custom: !!f.custom,
|
||||
})),
|
||||
pages: data.pages ?? [],
|
||||
pages: (data.pages ?? [])
|
||||
.filter((p): p is { key: string; label: string; hidden?: boolean | null } => !!p)
|
||||
.map((p) => ({
|
||||
key: p.key,
|
||||
label: p.label,
|
||||
hidden: !!p.hidden,
|
||||
})),
|
||||
customModules: data.custom_modules ?? [],
|
||||
};
|
||||
}
|
||||
@@ -205,6 +217,52 @@ export async function updateHtmlTemplateFieldVisibility(
|
||||
return toMeta(await readJson<ServerMeta>(res, "update html template fields"));
|
||||
}
|
||||
|
||||
/** 更新页面清单(名称/隐藏标记;编号集合不可增删)。隐藏页面在产物导航整体下线。 */
|
||||
export async function updateHtmlTemplatePages(
|
||||
templateId: string,
|
||||
pages: { key: string; label: string; hidden: boolean }[],
|
||||
): Promise<HtmlTemplateMeta> {
|
||||
const res = await apiFetch(`${BASE()}/${encodeURIComponent(templateId)}/pages`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
pages: pages.map((p) => ({ 编号: p.key, 名称: p.label, 隐藏: p.hidden })),
|
||||
}),
|
||||
});
|
||||
return toMeta(await readJson<ServerMeta>(res, "update html template pages"));
|
||||
}
|
||||
|
||||
/** 向分类(数据分支)添加自定义字段:目录 + data.json 各条目同步补键。 */
|
||||
export async function addHtmlTemplateField(
|
||||
templateId: string,
|
||||
input: { label: string; branch: string; description?: string; defaultValue?: string },
|
||||
): Promise<HtmlTemplateMeta> {
|
||||
const res = await apiFetch(`${BASE()}/${encodeURIComponent(templateId)}/fields/add`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
label: input.label,
|
||||
branch: input.branch,
|
||||
description: input.description ?? "",
|
||||
default_value: input.defaultValue ?? "待补充",
|
||||
}),
|
||||
});
|
||||
return toMeta(await readJson<ServerMeta>(res, "add html template field"));
|
||||
}
|
||||
|
||||
/** 删除自定义字段:目录项与 data.json 各条目的键一并移除。 */
|
||||
export async function removeHtmlTemplateField(
|
||||
templateId: string,
|
||||
label: string,
|
||||
): Promise<HtmlTemplateMeta> {
|
||||
const res = await apiFetch(`${BASE()}/${encodeURIComponent(templateId)}/fields/remove`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ label }),
|
||||
});
|
||||
return toMeta(await readJson<ServerMeta>(res, "remove html template field"));
|
||||
}
|
||||
|
||||
/** 自定义模块列表整体替换(后端逐条消毒后入库)。 */
|
||||
export async function updateHtmlTemplateCustomModules(
|
||||
templateId: string,
|
||||
|
||||
@@ -14,6 +14,7 @@ export type { LlmWikiRetrievalMode } from "@/core/llmwiki/retrieval-debug";
|
||||
const API = () => `${getBackendBaseURL()}/api/llmwiki`;
|
||||
const PUBLIC_API = () => `${getBackendBaseURL()}/api/public/llmwiki`;
|
||||
const SETTINGS_API = () => `${getBackendBaseURL()}/api/system-settings/llmwiki`;
|
||||
const AUTO_SYNC_SETTINGS_API = () => `${SETTINGS_API()}/auto-sync`;
|
||||
|
||||
export type LlmWikiProvider = "legacy" | "weknora";
|
||||
export type LlmWikiScope = "personal" | "public" | "all";
|
||||
@@ -31,6 +32,12 @@ export interface LlmWikiSettings extends LlmWikiRuntime {
|
||||
effective_provider: LlmWikiProvider;
|
||||
}
|
||||
|
||||
export interface LocalWikiAutoSyncSettings {
|
||||
enabled: boolean;
|
||||
schedule: "hourly" | "daily";
|
||||
hour: number;
|
||||
}
|
||||
|
||||
export interface LlmWikiWikiInstructions {
|
||||
content_instructions?: string;
|
||||
extraction_instructions?: string;
|
||||
@@ -1279,6 +1286,26 @@ export async function getLlmWikiSettings(): Promise<LlmWikiSettings> {
|
||||
return readJson(await apiFetch(SETTINGS_API()), "读取知识服务连接配置");
|
||||
}
|
||||
|
||||
export async function getLocalWikiAutoSyncSettings(): Promise<LocalWikiAutoSyncSettings> {
|
||||
return readJson(
|
||||
await apiFetch(AUTO_SYNC_SETTINGS_API()),
|
||||
"读取知识库自动同步设置",
|
||||
);
|
||||
}
|
||||
|
||||
export async function saveLocalWikiAutoSyncSettings(
|
||||
input: LocalWikiAutoSyncSettings,
|
||||
): Promise<LocalWikiAutoSyncSettings> {
|
||||
return readJson(
|
||||
await apiFetch(AUTO_SYNC_SETTINGS_API(), {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(input),
|
||||
}),
|
||||
"保存知识库自动同步设置",
|
||||
);
|
||||
}
|
||||
|
||||
export async function saveLlmWikiSettings(input: {
|
||||
override_enabled: boolean;
|
||||
api_base_url: string;
|
||||
@@ -1314,6 +1341,7 @@ export async function testLlmWikiConnection(apiBaseUrl: string): Promise<void> {
|
||||
|
||||
const runtimeKey = ["llmwiki", "runtime"] as const;
|
||||
const settingsKey = ["llmwiki", "settings"] as const;
|
||||
const autoSyncSettingsKey = ["llmwiki", "auto-sync-settings"] as const;
|
||||
const knowledgeBasesKey = (userId: string | null, scope: LlmWikiScope) =>
|
||||
["llmwiki", "knowledge-bases", userId ?? "anonymous", scope] as const;
|
||||
|
||||
@@ -1609,6 +1637,15 @@ export function useLlmWikiSettings(enabled = true) {
|
||||
});
|
||||
}
|
||||
|
||||
export function useLocalWikiAutoSyncSettings(enabled = true) {
|
||||
const { userId } = useLiveAccount();
|
||||
return useQuery({
|
||||
queryKey: [...autoSyncSettingsKey, userId ?? "anonymous"],
|
||||
queryFn: getLocalWikiAutoSyncSettings,
|
||||
enabled,
|
||||
});
|
||||
}
|
||||
|
||||
export function useLlmWikiEmbeddingModels(enabled = true) {
|
||||
const { userId } = useLiveAccount();
|
||||
return useQuery({
|
||||
@@ -1763,3 +1800,15 @@ export function useLlmWikiSettingsActions() {
|
||||
test: useMutation({ mutationFn: testLlmWikiConnection }),
|
||||
};
|
||||
}
|
||||
|
||||
export function useLocalWikiAutoSyncSettingsActions() {
|
||||
const queryClient = useQueryClient();
|
||||
return {
|
||||
save: useMutation({
|
||||
mutationFn: saveLocalWikiAutoSyncSettings,
|
||||
onSuccess: async () => {
|
||||
await queryClient.invalidateQueries({ queryKey: autoSyncSettingsKey });
|
||||
},
|
||||
}),
|
||||
};
|
||||
}
|
||||
@@ -37,6 +37,7 @@ import {
|
||||
import { requestCrudService } from '@/service/request-axios-service';
|
||||
import { authStorageGet } from '@/core/auth/scoped-storage';
|
||||
import { copyTextToClipboard } from '@/core/clipboard';
|
||||
import { toast } from '@/core/ui/feedback';
|
||||
import { openKnowledgeSource, resolveWeKnoraSourceTarget, type WeKnoraSourceTarget } from '@/core/llmwiki/source-links';
|
||||
import { readRuntimeEnv } from '@/env';
|
||||
import { WeKnoraSourceDrawer } from '@/strategy-components/components/resource-management/llmwiki/WeKnoraSourceDrawer';
|
||||
@@ -1542,11 +1543,11 @@ const GeneralQA: React.FC<{
|
||||
};
|
||||
|
||||
const handleSaveRecord = () => {
|
||||
alert('问答记录已保存');
|
||||
toast.success('问答记录已保存');
|
||||
};
|
||||
|
||||
const handleCollect = () => {
|
||||
alert('已添加到收藏');
|
||||
toast.success('已添加到收藏');
|
||||
};
|
||||
|
||||
const handleKeyDown = (e) => {
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
CheckCircle,
|
||||
} from 'lucide-react';
|
||||
import { useTheme } from '../../../contexts/ThemeContext';
|
||||
import { toast } from '@/core/ui/feedback';
|
||||
import { ChatMessage, EmptyChatState, QAComposer, TypingIndicator } from './QACommon';
|
||||
|
||||
interface Agent {
|
||||
@@ -184,14 +185,14 @@ const AgentQA: React.FC = () => {
|
||||
* 保存问答记录
|
||||
*/
|
||||
const handleSaveRecord = () => {
|
||||
alert('问答记录已保存');
|
||||
toast.success('问答记录已保存');
|
||||
};
|
||||
|
||||
/**
|
||||
* 收藏当前对话
|
||||
*/
|
||||
const handleCollect = () => {
|
||||
alert('已添加到收藏');
|
||||
toast.success('已添加到收藏');
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React, { useState } from 'react';
|
||||
import { CheckCircle, ChevronLeft, ChevronRight, History, MessageCircle, Users } from 'lucide-react';
|
||||
import { useTheme } from '../../../contexts/ThemeContext';
|
||||
import { toast } from '@/core/ui/feedback';
|
||||
import { ChatMessage, EmptyChatState, QAComposer, TypingIndicator } from './QACommon';
|
||||
|
||||
interface CollaborativeQAProps {}
|
||||
@@ -170,8 +171,8 @@ const CollaborativeQA: React.FC<CollaborativeQAProps> = () => {
|
||||
onKeyDown={handleKeyDown}
|
||||
onSubmit={handleSend}
|
||||
onStop={handleStop}
|
||||
onSave={() => alert('问答记录已保存')}
|
||||
onCollect={() => alert('已添加到收藏')}
|
||||
onSave={() => toast.success('问答记录已保存')}
|
||||
onCollect={() => toast.success('已添加到收藏')}
|
||||
isLoading={isLoading}
|
||||
placeholder="输入协同研判主题或任务背景..."
|
||||
showUpload={false}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { useState, useRef, useEffect } from 'react';
|
||||
import { toast } from '@/core/ui/feedback';
|
||||
import {
|
||||
Send,
|
||||
Upload,
|
||||
@@ -613,15 +614,15 @@ const QA: React.FC<QAProps> = ({ initialMode }) => {
|
||||
};
|
||||
|
||||
const handleExportReport = () => {
|
||||
alert('报告导出功能开发中...');
|
||||
toast.info('报告导出功能开发中...');
|
||||
};
|
||||
|
||||
const handleSaveMultiAgentRecord = () => {
|
||||
alert('协同分析记录已保存');
|
||||
toast.success('协同分析记录已保存');
|
||||
};
|
||||
|
||||
const handleTransferToScene = () => {
|
||||
alert('转场景任务功能开发中...');
|
||||
toast.info('转场景任务功能开发中...');
|
||||
};
|
||||
|
||||
const handleMultiAgentFollowUp = (agentId: string) => {
|
||||
@@ -759,7 +760,7 @@ const QA: React.FC<QAProps> = ({ initialMode }) => {
|
||||
};
|
||||
|
||||
const handleSaveRecord = () => {
|
||||
alert('问答记录已保存');
|
||||
toast.success('问答记录已保存');
|
||||
};
|
||||
|
||||
// 新建问答 - 通用/智能体模式
|
||||
@@ -1306,7 +1307,7 @@ const QA: React.FC<QAProps> = ({ initialMode }) => {
|
||||
保存记录
|
||||
</button>
|
||||
<button
|
||||
onClick={() => alert('分析已结束')}
|
||||
onClick={() => toast.success('分析已结束')}
|
||||
className={`px-4 py-2 rounded-lg text-sm font-medium transition-all flex items-center gap-2 ${
|
||||
isDark ? 'bg-red-600/80 hover:bg-red-600 text-white' : 'bg-red-500 hover:bg-red-600 text-white'
|
||||
}`}
|
||||
|
||||
@@ -2,6 +2,7 @@ import React, { useState, useEffect, useMemo } from 'react';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import { useTheme } from '../../../contexts/ThemeContext';
|
||||
import { toast } from '@/core/ui/feedback';
|
||||
import {
|
||||
Edit2, Plus, Trash2, Check, X, ChevronDown, ChevronRight,
|
||||
Target, Users, Activity, BookOpen, Zap, AlertTriangle,
|
||||
@@ -641,7 +642,7 @@ export default function Template6BEditor() {
|
||||
|
||||
console.log('[Template6BEditor 保存结果]', result);
|
||||
console.log('[Template6BEditor 保存 JSON]', JSON.stringify(template, null, 2));
|
||||
window.alert(result.message + ' 详情已打印到控制台。');
|
||||
toast.info(result.message + ' 详情已打印到控制台。');
|
||||
if (valid) setDirty(false);
|
||||
};
|
||||
|
||||
@@ -767,7 +768,7 @@ export default function Template6BEditor() {
|
||||
}}
|
||||
onDelete={() => {
|
||||
if (template.agents.length <= 1) {
|
||||
window.alert('智能体最少必须保留 1 个');
|
||||
toast.warning('智能体最少必须保留 1 个');
|
||||
return;
|
||||
}
|
||||
update('agents', template.agents.filter((_, j) => j !== i));
|
||||
|
||||
@@ -2,6 +2,7 @@ import React, { useState, useEffect, useMemo } from 'react';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import { useTheme } from '../../../contexts/ThemeContext';
|
||||
import { toast } from '@/core/ui/feedback';
|
||||
import {
|
||||
Edit2, Plus, Trash2, Check, X, ChevronDown, ChevronRight,
|
||||
Target, Package, Globe, BookOpen, MessageSquare, Zap,
|
||||
@@ -479,7 +480,7 @@ function MultiSelectModal({
|
||||
const toggle = (value: string) => {
|
||||
const has = draft.includes(value);
|
||||
if (has && draft.length <= minKeep) {
|
||||
window.alert(`最少必须保留 ${minKeep} 个`);
|
||||
toast.warning(`最少必须保留 ${minKeep} 个`);
|
||||
return;
|
||||
}
|
||||
setDraft(prev => has ? prev.filter(v => v !== value) : [...prev, value]);
|
||||
@@ -519,7 +520,7 @@ function MultiSelectModal({
|
||||
<button
|
||||
onClick={() => {
|
||||
if (draft.length < minKeep) {
|
||||
window.alert(`最少必须保留 ${minKeep} 个`);
|
||||
toast.warning(`最少必须保留 ${minKeep} 个`);
|
||||
return;
|
||||
}
|
||||
onSave(draft);
|
||||
@@ -878,7 +879,7 @@ function AgentEditModal({
|
||||
|
||||
const removeRelevantField = (field: string) => {
|
||||
if (form.relevant_fields.length <= 1) {
|
||||
window.alert('关联字段最少必须保留 1 个');
|
||||
toast.warning('关联字段最少必须保留 1 个');
|
||||
return;
|
||||
}
|
||||
set('relevant_fields', form.relevant_fields.filter(x => x !== field));
|
||||
@@ -886,7 +887,7 @@ function AgentEditModal({
|
||||
|
||||
const removeExpertiseField = (field: string) => {
|
||||
if (expertiseFields.length <= 1) {
|
||||
window.alert('专业能力服务字段最少必须保留 1 个');
|
||||
toast.warning('专业能力服务字段最少必须保留 1 个');
|
||||
return;
|
||||
}
|
||||
setExpertiseFields(prev => prev.filter(x => x !== field));
|
||||
@@ -1131,7 +1132,7 @@ function FieldRequirementCard({
|
||||
const removeRequiredItem = (key: 'dependencies' | 'preferred_agents', value: string) => {
|
||||
const current = req[key];
|
||||
if (current.length <= 1) {
|
||||
window.alert(key === 'dependencies' ? '依赖字段最少必须保留 1 个' : '推荐智能体最少必须保留 1 个');
|
||||
toast.warning(key === 'dependencies' ? '依赖字段最少必须保留 1 个' : '推荐智能体最少必须保留 1 个');
|
||||
return;
|
||||
}
|
||||
setField(key, current.filter(x => x !== value));
|
||||
@@ -1283,7 +1284,7 @@ export default function TemplateEditor() {
|
||||
|
||||
console.log('[TemplateEditor 保存结果]', result);
|
||||
console.log('[TemplateEditor 保存 JSON]', JSON.stringify(template, null, 2));
|
||||
window.alert(result.message + ' 详情已打印到控制台。');
|
||||
toast.info(result.message + ' 详情已打印到控制台。');
|
||||
|
||||
if (valid) setDirty(false);
|
||||
};
|
||||
@@ -1420,7 +1421,7 @@ export default function TemplateEditor() {
|
||||
}}
|
||||
onDelete={() => {
|
||||
if (template.agents.length <= 1) {
|
||||
window.alert('智能体最少必须保留 1 个');
|
||||
toast.warning('智能体最少必须保留 1 个');
|
||||
return;
|
||||
}
|
||||
update('agents', template.agents.filter((_, j) => j !== i));
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { CircleAlert, CircleCheck, Loader2, RefreshCw } from "lucide-react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { toast } from "sonner";
|
||||
import { toast } from "@/core/ui/feedback";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
+8
-3
@@ -16,7 +16,7 @@ import {
|
||||
useParams,
|
||||
useSearchParams,
|
||||
} from "react-router-dom";
|
||||
import { toast } from "sonner";
|
||||
import { confirmAction, toast } from "@/core/ui/feedback";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
@@ -447,9 +447,14 @@ function CurrentWikiArticleActions({
|
||||
const remove = async () => {
|
||||
if (!slug) return;
|
||||
if (
|
||||
!window.confirm(
|
||||
!(await confirmAction(
|
||||
`确定删除文章「${detail.data?.title || slug}」吗?删除后不可恢复。`,
|
||||
)
|
||||
{
|
||||
title: "删除文章?",
|
||||
confirmText: "删除",
|
||||
danger: true,
|
||||
},
|
||||
))
|
||||
)
|
||||
return;
|
||||
try {
|
||||
|
||||
+97
-47
@@ -23,7 +23,7 @@ import {
|
||||
} from "lucide-react";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { toast } from "sonner";
|
||||
import { confirmAction, toast } from "@/core/ui/feedback";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -288,7 +288,11 @@ export function WeKnoraKnowledgeWorkspace() {
|
||||
};
|
||||
|
||||
const removeKnowledgeBase = async (item: LlmWikiKnowledgeBase) => {
|
||||
if (!window.confirm(`确定删除知识库“${item.name}”吗?知识服务中的文档和索引也会删除。`)) return;
|
||||
if (!(await confirmAction(`确定删除知识库“${item.name}”吗?知识服务中的文档和索引也会删除。`, {
|
||||
title: "删除知识库?",
|
||||
confirmText: "删除",
|
||||
danger: true,
|
||||
}))) return;
|
||||
try {
|
||||
await actions.remove.mutateAsync(item.id);
|
||||
toast.success("知识库已删除");
|
||||
@@ -308,11 +312,17 @@ export function WeKnoraKnowledgeWorkspace() {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex h-full min-h-0 flex-col bg-background">
|
||||
<div className="border-b bg-gradient-to-r from-primary/8 via-card to-card px-6 py-5">
|
||||
<div className="mx-auto flex max-w-[1500px] flex-wrap items-center justify-between gap-4">
|
||||
<div className="flex h-full min-h-0 flex-col bg-muted/40">
|
||||
<div className="relative overflow-hidden border-b border-border/60 bg-card px-6 py-5">
|
||||
{/* 顶部主题色渐变:自上而下淡出(跟随换肤) */}
|
||||
<div
|
||||
className="pointer-events-none absolute inset-x-0 top-0 h-28 bg-gradient-to-b from-primary/[0.09] via-primary/[0.03] to-transparent"
|
||||
aria-hidden
|
||||
/>
|
||||
<div className="relative mx-auto flex max-w-[1500px] flex-wrap items-center justify-between gap-4">
|
||||
<div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="h-4 w-[3px] rounded-full bg-primary" aria-hidden />
|
||||
<Database className="size-5 text-primary" />
|
||||
<h1 className="text-xl font-semibold">
|
||||
{pageDescription?.title || "知识库管理"}
|
||||
@@ -323,19 +333,19 @@ export function WeKnoraKnowledgeWorkspace() {
|
||||
{pageDescription?.description || "由知识服务负责解析与检索,用户、权限和发布范围由 cmzs 管理。"}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 rounded-full border bg-background/80 p-1 shadow-sm backdrop-blur">
|
||||
<div className="flex items-center gap-2 rounded-full bg-muted/40 p-1">
|
||||
{tab !== "settings" && (
|
||||
<Button variant="ghost" size="sm" className="rounded-full" onClick={() => navigate("/page/workspace/skills?tab=knowledge")}>
|
||||
<Sparkles className="mr-2 size-4" />从技能归纳
|
||||
<Sparkles className="mr-2.5 size-4" />从技能归纳
|
||||
</Button>
|
||||
)}
|
||||
{tab !== "settings" && (
|
||||
<Button variant="ghost" size="sm" className="rounded-full" onClick={() => void knowledge.refresh().catch((error) => toast.error(messageOf(error)))} disabled={knowledge.isFetching}>
|
||||
<RefreshCw className={`mr-2 size-4 ${knowledge.isFetching ? "animate-spin" : ""}`} />刷新
|
||||
<RefreshCw className={`mr-2.5 size-4 ${knowledge.isFetching ? "animate-spin" : ""}`} />刷新
|
||||
</Button>
|
||||
)}
|
||||
{tab === "personal" && <>
|
||||
<Button size="sm" className="rounded-full px-4 shadow-sm" onClick={() => setCreateDialogOpen(true)}><Plus className="mr-2 size-4" />新建知识库</Button>
|
||||
<Button size="sm" className="rounded-full px-4 shadow-sm" onClick={() => setCreateDialogOpen(true)}><Plus className="mr-2.5 size-4" />新建知识库</Button>
|
||||
</>}
|
||||
</div>
|
||||
</div>
|
||||
@@ -344,11 +354,11 @@ export function WeKnoraKnowledgeWorkspace() {
|
||||
<div className="min-h-0 flex-1 overflow-auto px-6 py-5">
|
||||
<div className="mx-auto max-w-[1500px]">
|
||||
<Tabs value={tab} onValueChange={(value) => setTab(value as WorkspaceTab)}>
|
||||
<div className="flex flex-wrap items-center justify-between gap-3 rounded-2xl border bg-card/80 p-3 shadow-sm">
|
||||
<div className="flex flex-wrap items-center justify-between gap-3 rounded-[5px] bg-card p-3 shadow-[0_2px_8px_rgba(15,23,42,0.06)]">
|
||||
<TabsList className="rounded-xl bg-muted/70">
|
||||
<TabsTrigger value="personal"><BookOpen className="mr-2 size-4" />我的知识库</TabsTrigger>
|
||||
<TabsTrigger value="public"><Globe2 className="mr-2 size-4" />公共 LLMWiki</TabsTrigger>
|
||||
{isAdmin && <TabsTrigger value="settings"><Settings2 className="mr-2 size-4" />连接配置</TabsTrigger>}
|
||||
<TabsTrigger value="personal"><BookOpen className="mr-2.5 size-4" />我的知识库</TabsTrigger>
|
||||
<TabsTrigger value="public"><Globe2 className="mr-2.5 size-4" />公共 LLMWiki</TabsTrigger>
|
||||
{isAdmin && <TabsTrigger value="settings"><Settings2 className="mr-2.5 size-4" />连接配置</TabsTrigger>}
|
||||
</TabsList>
|
||||
{tab !== "settings" && (
|
||||
<div className="flex w-full items-center gap-2 sm:w-auto">
|
||||
@@ -389,7 +399,7 @@ export function WeKnoraKnowledgeWorkspace() {
|
||||
</Select>
|
||||
)}
|
||||
{viewSwitchEnabled && <ViewModeToggle value={viewMode} onChange={setViewMode} className="shrink-0" />}
|
||||
<div className="flex min-w-0 flex-1 items-center gap-2 rounded-xl border bg-background/80 p-1 shadow-sm sm:w-auto">
|
||||
<div className="flex min-w-0 flex-1 items-center gap-2 rounded-[5px] bg-muted/30 p-1 sm:w-auto">
|
||||
<div className="relative min-w-0 flex-1 sm:w-80">
|
||||
<Search className="absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" />
|
||||
<Input value={searchText} onChange={(event) => setSearchText(event.target.value)} onKeyDown={(event) => event.key === "Enter" && void runSearch()} placeholder={tab === "public" ? "检索公共 Wiki 文档" : "检索我的 Wiki 文档"} className="border-0 bg-transparent pl-9 shadow-none focus-visible:ring-0" />
|
||||
@@ -406,7 +416,7 @@ export function WeKnoraKnowledgeWorkspace() {
|
||||
</Tabs>
|
||||
|
||||
{searchResponse && tab !== "settings" && (
|
||||
<Card className="mt-5 overflow-hidden border-emerald-200/70 bg-gradient-to-br from-emerald-50/70 via-card to-card shadow-sm dark:border-emerald-900/60 dark:from-emerald-950/20">
|
||||
<Card className="mt-5 overflow-hidden rounded-[5px] border-0 bg-gradient-to-br from-emerald-50/70 via-card to-card shadow-[0_2px_8px_rgba(15,23,42,0.06)] dark:from-emerald-950/20">
|
||||
<CardHeader className="border-b border-emerald-200/60 pb-4 dark:border-emerald-900/50">
|
||||
<div className="flex flex-wrap items-start justify-between gap-3">
|
||||
<div className="flex min-w-0 items-start gap-3">
|
||||
@@ -432,7 +442,7 @@ export function WeKnoraKnowledgeWorkspace() {
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3 p-4">
|
||||
{searchResponse.results.length === 0 ? (
|
||||
<div className="flex min-h-36 flex-col items-center justify-center rounded-xl border border-dashed bg-background/70 px-6 text-center">
|
||||
<div className="flex min-h-36 flex-col items-center justify-center rounded-[5px] border border-dashed border-border/60 bg-background/70 px-6 text-center">
|
||||
<BookOpenText className="mb-3 size-8 text-muted-foreground/60" />
|
||||
<div className="text-sm font-medium">已完成 Wiki 文档检索,暂未命中相关页面</div>
|
||||
<div className="mt-1 text-xs text-muted-foreground">可以缩短关键词或换一个主题后重试。</div>
|
||||
@@ -444,7 +454,7 @@ export function WeKnoraKnowledgeWorkspace() {
|
||||
<button
|
||||
type="button"
|
||||
key={`${result.knowledge_base_id}:${result.wiki_slug || result.id}`}
|
||||
className="group w-full rounded-xl border bg-background/90 p-4 text-left shadow-sm transition hover:-translate-y-0.5 hover:border-emerald-300 hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-500/40"
|
||||
className="group w-full rounded-[5px] bg-background/90 p-4 text-left shadow-[0_1px_3px_rgba(15,23,42,0.05)] transition hover:-translate-y-0.5 hover:shadow-[0_4px_14px_rgba(15,23,42,0.10)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-500/40"
|
||||
onClick={() => setSelectedSearchResult(result)}
|
||||
>
|
||||
<div className="flex items-start gap-3">
|
||||
@@ -570,7 +580,7 @@ function WikiConfigurationStatus({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={`rounded-xl border p-3 ${hasError ? "border-destructive/30 bg-destructive/5" : "bg-muted/25"}`}>
|
||||
<div className={`rounded-[5px] p-3 ${hasError ? "bg-destructive/5" : "bg-muted/25"}`}>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Badge variant="outline" className={badgeClass}>{label}</Badge>
|
||||
{revision != null && (
|
||||
@@ -634,13 +644,13 @@ function KnowledgeGrid({
|
||||
onDelete: (item: LlmWikiKnowledgeBase) => void;
|
||||
}) {
|
||||
if (loading) return <div className="flex h-64 items-center justify-center text-muted-foreground"><Loader2 className="mr-2 size-5 animate-spin" />正在读取知识库</div>;
|
||||
if (error) return <div className="rounded-lg border border-destructive/30 bg-destructive/5 p-6 text-sm text-destructive">{messageOf(error)}</div>;
|
||||
if (error) return <div className="rounded-[5px] bg-destructive/5 p-6 text-sm text-destructive">{messageOf(error)}</div>;
|
||||
const visibleRows = rows.filter(
|
||||
(item) => item.remote_status !== "missing" &&
|
||||
(!nameInitialFilter || knowledgeNameInitial(item.name) === nameInitialFilter),
|
||||
);
|
||||
if (!visibleRows.length) {
|
||||
return <div className="flex h-64 items-center justify-center rounded-xl border border-dashed text-sm text-muted-foreground">{nameInitialFilter ? `没有名称以 ${nameInitialFilter} 开头的知识库` : emptyText}</div>;
|
||||
return <div className="flex h-64 items-center justify-center rounded-[5px] border border-dashed border-border/60 text-sm text-muted-foreground">{nameInitialFilter ? `没有名称以 ${nameInitialFilter} 开头的知识库` : emptyText}</div>;
|
||||
}
|
||||
const sortedRows = [...visibleRows].sort((left, right) => compareKnowledgeBases(left, right, sort));
|
||||
const totalPages = Math.max(1, Math.ceil(sortedRows.length / pageSize));
|
||||
@@ -680,7 +690,7 @@ function KnowledgeGrid({
|
||||
<div>
|
||||
<div className="flex flex-col gap-3">
|
||||
{pageRows.map((item) => (
|
||||
<Item key={item.id} variant="outline" size="sm" className="w-full">
|
||||
<Item key={item.id} variant="outline" size="sm" className="w-full rounded-[5px] border-0 bg-card shadow-[0_2px_8px_rgba(15,23,42,0.06)] transition-shadow hover:shadow-[0_4px_14px_rgba(15,23,42,0.10)]">
|
||||
<ItemContent
|
||||
className="min-w-0 cursor-pointer"
|
||||
role="button"
|
||||
@@ -702,13 +712,33 @@ function KnowledgeGrid({
|
||||
</ItemTitle>
|
||||
<ItemDescription className="line-clamp-1">{item.description || "暂无描述"}</ItemDescription>
|
||||
</ItemContent>
|
||||
<ItemActions className="flex-wrap justify-end">
|
||||
<Button size="sm" variant="outline" className="rounded-full" onClick={() => onOpen(item)}><FileText className="mr-2 size-4" />查看详情</Button>
|
||||
<Button size="sm" variant="outline" className="rounded-full" onClick={() => onResearch(item)}><Microscope className="mr-2 size-4" />深度研究</Button>
|
||||
{onTest && <Button size="sm" variant="outline" className="rounded-full" onClick={() => onTest(item)}><Search className="mr-2 size-4" />检索测试</Button>}
|
||||
{item.can_write && !item.is_conversation_deposit && <Button size="sm" variant="outline" className="rounded-full" disabled={busy} onClick={() => onEdit(item)} aria-label={`编辑知识库 ${item.name}`}><Edit3 className="mr-2 size-4" />编辑</Button>}
|
||||
{item.is_owner && !item.is_conversation_deposit && <Button size="sm" variant="secondary" className="rounded-full" disabled={busy} onClick={() => void onPublish(item)}>{item.publication_status === "published" ? "取消公开" : "发布公共库"}</Button>}
|
||||
{item.can_write && !item.is_conversation_deposit && <Button size="icon" variant="ghost" className="size-8 shrink-0 rounded-full text-destructive hover:bg-destructive/10 hover:text-destructive" aria-label={`删除知识库 ${item.name}`} title="删除知识库" disabled={busy} onClick={() => void onDelete(item)}><Trash2 className="size-4" /></Button>}
|
||||
<ItemActions className="flex-wrap items-center justify-end gap-1">
|
||||
<Button size="sm" variant="ghost" className="h-8 gap-2.5 rounded-[5px] px-3 font-medium text-primary hover:bg-primary/10 hover:text-primary" onClick={() => onOpen(item)}>
|
||||
<FileText className="size-4" />查看详情
|
||||
</Button>
|
||||
<Button size="sm" variant="ghost" className="h-8 gap-2.5 rounded-[5px] px-2.5 text-muted-foreground hover:bg-muted hover:text-foreground" onClick={() => onResearch(item)}>
|
||||
<Microscope className="size-4" />深度研究
|
||||
</Button>
|
||||
{onTest && (
|
||||
<Button size="icon" variant="ghost" className="size-8 rounded-[5px] text-muted-foreground hover:bg-muted hover:text-foreground" title="检索测试" aria-label={`检索测试 ${item.name}`} onClick={() => onTest(item)}>
|
||||
<Search className="size-4" />
|
||||
</Button>
|
||||
)}
|
||||
{item.can_write && !item.is_conversation_deposit && (
|
||||
<Button size="icon" variant="ghost" className="size-8 rounded-[5px] text-muted-foreground hover:bg-muted hover:text-foreground" title="编辑" aria-label={`编辑知识库 ${item.name}`} disabled={busy} onClick={() => onEdit(item)}>
|
||||
<Edit3 className="size-4" />
|
||||
</Button>
|
||||
)}
|
||||
{item.is_owner && !item.is_conversation_deposit && (
|
||||
<Button size="icon" variant="ghost" className="size-8 rounded-[5px] text-muted-foreground hover:bg-muted hover:text-foreground" title={item.publication_status === "published" ? "取消公开" : "发布公共库"} aria-label={item.publication_status === "published" ? `取消公开 ${item.name}` : `发布知识库 ${item.name}`} disabled={busy} onClick={() => void onPublish(item)}>
|
||||
<Globe2 className="size-4" />
|
||||
</Button>
|
||||
)}
|
||||
{item.can_write && !item.is_conversation_deposit && (
|
||||
<Button size="icon" variant="ghost" className="size-8 rounded-[5px] text-destructive hover:bg-destructive/10 hover:text-destructive" aria-label={`删除知识库 ${item.name}`} title="删除知识库" disabled={busy} onClick={() => void onDelete(item)}>
|
||||
<Trash2 className="size-4" />
|
||||
</Button>
|
||||
)}
|
||||
</ItemActions>
|
||||
</Item>
|
||||
))}
|
||||
@@ -723,7 +753,7 @@ function KnowledgeGrid({
|
||||
{pageRows.map((item) => (
|
||||
<Card
|
||||
key={item.id}
|
||||
className="group overflow-hidden rounded-2xl border-border/70 bg-card/95 transition-all hover:-translate-y-0.5 hover:border-primary/30 hover:shadow-lg"
|
||||
className="group overflow-hidden rounded-[5px] border-0 bg-card shadow-[0_2px_8px_rgba(15,23,42,0.06)] transition-all hover:-translate-y-0.5 hover:shadow-[0_4px_14px_rgba(15,23,42,0.10)]"
|
||||
>
|
||||
<div className={`h-1 ${item.publication_status === "published" ? "bg-primary" : "bg-muted"}`} />
|
||||
<button type="button" className="w-full text-left outline-none transition-colors hover:bg-muted/25 focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2" onClick={() => onOpen(item)}>
|
||||
@@ -733,18 +763,38 @@ function KnowledgeGrid({
|
||||
<div className="flex shrink-0 flex-col items-end gap-1.5"><Badge variant={item.publication_status === "published" ? "default" : "secondary"}>{publicationLabels[item.publication_status] ?? "仅自己"}</Badge>{isWikiKnowledgeBase(item) && <Badge className="bg-violet-100 text-violet-700 hover:bg-violet-100 dark:bg-violet-950 dark:text-violet-300">Wiki</Badge>}<WikiConfigurationStatus knowledgeBase={item} /></div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<div className="px-6 pb-4"><div className="grid grid-cols-3 gap-2 rounded-xl border bg-muted/35 p-3 text-center text-xs"><div><div className="text-base font-semibold text-foreground">{item.knowledge_count}</div><span className="text-muted-foreground">文档</span></div><div><div className="text-base font-semibold text-foreground">{item.chunk_count}</div><span className="text-muted-foreground">分块</span></div><div><div className="text-base font-semibold text-foreground">{item.processing_count}</div><span className="text-muted-foreground">处理中</span></div></div></div>
|
||||
<div className="px-6 pb-4"><div className="grid grid-cols-3 gap-2 rounded-[5px] bg-muted/35 p-3 text-center text-xs"><div><div className="text-base font-semibold text-foreground">{item.knowledge_count}</div><span className="text-muted-foreground">文档</span></div><div><div className="text-base font-semibold text-foreground">{item.chunk_count}</div><span className="text-muted-foreground">分块</span></div><div><div className="text-base font-semibold text-foreground">{item.processing_count}</div><span className="text-muted-foreground">处理中</span></div></div></div>
|
||||
</button>
|
||||
<CardContent className="border-t bg-muted/20 px-6 py-4">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
||||
<Button size="sm" variant="outline" className="rounded-full" onClick={() => onOpen(item)}><FileText className="mr-2 size-4" />查看详情</Button>
|
||||
<Button size="sm" variant="outline" className="rounded-full" onClick={() => onResearch(item)}><Microscope className="mr-2 size-4" />深度研究</Button>
|
||||
{onTest && <Button size="sm" variant="outline" className="rounded-full" onClick={() => onTest(item)}><Search className="mr-2 size-4" />检索测试</Button>}
|
||||
{item.can_write && !item.is_conversation_deposit && <Button size="sm" variant="outline" className="rounded-full" disabled={busy} onClick={() => onEdit(item)} aria-label={`编辑知识库 ${item.name}`}><Edit3 className="mr-2 size-4" />编辑</Button>}
|
||||
{item.is_owner && !item.is_conversation_deposit && <Button size="sm" variant="secondary" className="rounded-full" disabled={busy} onClick={() => void onPublish(item)}>{item.publication_status === "published" ? "取消公开" : "发布公共库"}</Button>}
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-1">
|
||||
<Button size="sm" variant="ghost" className="h-8 gap-2.5 rounded-[5px] px-3 font-medium text-primary hover:bg-primary/10 hover:text-primary" onClick={() => onOpen(item)}>
|
||||
<FileText className="size-4" />查看详情
|
||||
</Button>
|
||||
<Button size="sm" variant="ghost" className="h-8 gap-2.5 rounded-[5px] px-2.5 text-muted-foreground hover:bg-muted hover:text-foreground" onClick={() => onResearch(item)}>
|
||||
<Microscope className="size-4" />深度研究
|
||||
</Button>
|
||||
{onTest && (
|
||||
<Button size="icon" variant="ghost" className="size-8 rounded-[5px] text-muted-foreground hover:bg-muted hover:text-foreground" title="检索测试" aria-label={`检索测试 ${item.name}`} onClick={() => onTest(item)}>
|
||||
<Search className="size-4" />
|
||||
</Button>
|
||||
)}
|
||||
{item.can_write && !item.is_conversation_deposit && (
|
||||
<Button size="icon" variant="ghost" className="size-8 rounded-[5px] text-muted-foreground hover:bg-muted hover:text-foreground" title="编辑" aria-label={`编辑知识库 ${item.name}`} disabled={busy} onClick={() => onEdit(item)}>
|
||||
<Edit3 className="size-4" />
|
||||
</Button>
|
||||
)}
|
||||
{item.is_owner && !item.is_conversation_deposit && (
|
||||
<Button size="icon" variant="ghost" className="size-8 rounded-[5px] text-muted-foreground hover:bg-muted hover:text-foreground" title={item.publication_status === "published" ? "取消公开" : "发布公共库"} aria-label={item.publication_status === "published" ? `取消公开 ${item.name}` : `发布知识库 ${item.name}`} disabled={busy} onClick={() => void onPublish(item)}>
|
||||
<Globe2 className="size-4" />
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{item.can_write && !item.is_conversation_deposit && <Button size="icon" variant="ghost" className="size-8 shrink-0 rounded-full text-destructive hover:bg-destructive/10 hover:text-destructive" aria-label={`删除知识库 ${item.name}`} title="删除知识库" disabled={busy} onClick={() => void onDelete(item)}><Trash2 className="size-4" /></Button>}
|
||||
{item.can_write && !item.is_conversation_deposit && (
|
||||
<Button size="icon" variant="ghost" className="size-8 shrink-0 rounded-[5px] text-destructive hover:bg-destructive/10 hover:text-destructive" aria-label={`删除知识库 ${item.name}`} title="删除知识库" disabled={busy} onClick={() => void onDelete(item)}>
|
||||
<Trash2 className="size-4" />
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -875,7 +925,7 @@ function EditKnowledgeDialog({
|
||||
<DialogFooter>
|
||||
<Button type="button" variant="outline" onClick={onClose} disabled={pending}>取消</Button>
|
||||
<Button type="submit" disabled={pending || !name.trim() || directoryTreeValidation.errors.length > 0 || instructionLengthInvalid}>
|
||||
{pending && <Loader2 className="mr-2 size-4 animate-spin" />}{pending ? "保存中" : "保存"}
|
||||
{pending && <Loader2 className="mr-2.5 size-4 animate-spin" />}{pending ? "保存中" : "保存"}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
@@ -971,7 +1021,7 @@ function CreateKnowledgeDialog({
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-medium" htmlFor="llmwiki-embedding-model">原文向量模型</label>
|
||||
{embeddingModels.isLoading ? (
|
||||
<div className="flex h-9 items-center rounded-md border px-3 text-sm text-muted-foreground"><Loader2 className="mr-2 size-4 animate-spin" />正在读取知识服务模型</div>
|
||||
<div className="flex h-9 items-center rounded-md border px-3 text-sm text-muted-foreground"><Loader2 className="mr-2.5 size-4 animate-spin" />正在读取知识服务模型</div>
|
||||
) : embeddingModels.isError ? (
|
||||
<div className="rounded-lg border border-destructive/30 bg-destructive/5 p-3 text-xs text-destructive">
|
||||
<p>模型读取失败:{messageOf(embeddingModels.error)}</p>
|
||||
@@ -1016,7 +1066,7 @@ function CreateKnowledgeDialog({
|
||||
},
|
||||
}))}
|
||||
>
|
||||
{pending && <Loader2 className="mr-2 size-4 animate-spin" />}{pending ? "创建中" : "创建"}
|
||||
{pending && <Loader2 className="mr-2.5 size-4 animate-spin" />}{pending ? "创建中" : "创建"}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
@@ -1357,7 +1407,7 @@ export function LocalEncoderSettingsCard() {
|
||||
<div className="flex flex-col gap-2 sm:flex-row">
|
||||
<Input id="local-encoder-path" value={modelPath} onChange={(event) => setModelPath(event.target.value)} placeholder="例如 /opt/deerflow/models/bge-m3" />
|
||||
<Button variant="outline" disabled={!modelPath.trim() || configure.isPending} onClick={() => configure.mutate()}>
|
||||
{configure.isPending && <Loader2 className="mr-2 size-4 animate-spin" />}保存目录
|
||||
{configure.isPending && <Loader2 className="mr-2.5 size-4 animate-spin" />}保存目录
|
||||
</Button>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">目录内需包含 <code>onnx/model.onnx</code>(推荐)或根目录 <code>model.onnx</code>。保存后会立即把 Wiki 镜像编码器切换为 local 并热重建,无需修改配置文件或重启服务。</p>
|
||||
@@ -1382,7 +1432,7 @@ export function LocalEncoderSettingsCard() {
|
||||
{files.length ? `已选择 ${files.length} 个文件,共 ${formatSize(selectedBytes)}` : "请选择完整 BGE-M3 目录。上传完成后会自动切换到 local;大文件会落到运行目录,不写入源码仓库。"}
|
||||
</p>
|
||||
<Button disabled={!files.length || upload.isPending} onClick={() => upload.mutate()}>
|
||||
{upload.isPending ? <Loader2 className="mr-2 size-4 animate-spin" /> : <Upload className="mr-2 size-4" />}
|
||||
{upload.isPending ? <Loader2 className="mr-2.5 size-4 animate-spin" /> : <Upload className="mr-2.5 size-4" />}
|
||||
{upload.isPending ? "正在上传,请勿关闭页面" : "上传并设为当前模型"}
|
||||
</Button>
|
||||
</div>
|
||||
@@ -1390,17 +1440,17 @@ export function LocalEncoderSettingsCard() {
|
||||
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button disabled={!usingLocal || !status?.model_files_ready || start.isPending || status?.state === "starting" || status?.state === "ready"} onClick={() => start.mutate()}>
|
||||
{(start.isPending || status?.state === "starting") && <Loader2 className="mr-2 size-4 animate-spin" />}
|
||||
{(start.isPending || status?.state === "starting") && <Loader2 className="mr-2.5 size-4 animate-spin" />}
|
||||
{!usingLocal ? "当前无需启动本地模型" : status?.state === "ready" ? "编码器已启动" : status?.state === "failed" ? "重新启动" : "一键启动编码器"}
|
||||
</Button>
|
||||
{localOverrideActive && (
|
||||
<Button variant="secondary" disabled={restoreConfigured.isPending} onClick={() => restoreConfigured.mutate()}>
|
||||
{restoreConfigured.isPending && <Loader2 className="mr-2 size-4 animate-spin" />}
|
||||
{restoreConfigured.isPending && <Loader2 className="mr-2.5 size-4 animate-spin" />}
|
||||
恢复 config.yaml 编码器
|
||||
</Button>
|
||||
)}
|
||||
<Button variant="ghost" disabled={encoder.isFetching} onClick={() => void encoder.refetch()}>
|
||||
<RefreshCw className={`mr-2 size-4 ${encoder.isFetching ? "animate-spin" : ""}`} />刷新状态
|
||||
<RefreshCw className={`mr-2.5 size-4 ${encoder.isFetching ? "animate-spin" : ""}`} />刷新状态
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
@@ -1432,8 +1482,8 @@ export function ConnectionSettings() {
|
||||
<div className="space-y-2"><label className="text-sm font-medium" htmlFor="weknora-web-url">知识服务管理地址(可选)</label><Input id="weknora-web-url" value={webUrl} onChange={(event) => setWebUrl(event.target.value)} placeholder="https://knowledge-admin.example.com" /></div>
|
||||
<div className="rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 text-xs text-muted-foreground">配置文件地址:{settings.data?.file_api_base_url || "未配置"}。页面只配置地址;免登录详情页所需的管理员账号/密码只从后端 config.yaml 或环境变量读取,不在前端保存。</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button variant="outline" disabled={!apiUrl.trim() || actions.test.isPending} onClick={async () => { try { await actions.test.mutateAsync(apiUrl.trim()); toast.success("知识服务连接正常"); } catch (error) { toast.error(messageOf(error)); } }}>{actions.test.isPending && <Loader2 className="mr-2 size-4 animate-spin" />}测试连接</Button>
|
||||
<Button disabled={actions.save.isPending} onClick={async () => { try { await actions.save.mutateAsync({ override_enabled: true, api_base_url: apiUrl.trim(), web_base_url: webUrl.trim() }); toast.success(apiUrl.trim() ? "已启用知识服务模式" : "已切换到原 LLMWiki 模式"); } catch (error) { toast.error(messageOf(error)); } }}>{actions.save.isPending && <Loader2 className="mr-2 size-4 animate-spin" />}保存页面配置</Button>
|
||||
<Button variant="outline" disabled={!apiUrl.trim() || actions.test.isPending} onClick={async () => { try { await actions.test.mutateAsync(apiUrl.trim()); toast.success("知识服务连接正常"); } catch (error) { toast.error(messageOf(error)); } }}>{actions.test.isPending && <Loader2 className="mr-2.5 size-4 animate-spin" />}测试连接</Button>
|
||||
<Button disabled={actions.save.isPending} onClick={async () => { try { await actions.save.mutateAsync({ override_enabled: true, api_base_url: apiUrl.trim(), web_base_url: webUrl.trim() }); toast.success(apiUrl.trim() ? "已启用知识服务模式" : "已切换到原 LLMWiki 模式"); } catch (error) { toast.error(messageOf(error)); } }}>{actions.save.isPending && <Loader2 className="mr-2.5 size-4 animate-spin" />}保存页面配置</Button>
|
||||
<Button variant="secondary" disabled={actions.reset.isPending} onClick={async () => { try { await actions.reset.mutateAsync(); toast.success("已恢复 config.yaml 配置"); } catch (error) { toast.error(messageOf(error)); } }}>恢复配置文件</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import {
|
||||
RefreshCw,
|
||||
} from "lucide-react";
|
||||
import { Navigate, useNavigate, useParams } from "react-router-dom";
|
||||
import { toast } from "sonner";
|
||||
import { toast } from "@/core/ui/feedback";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { ArrowLeft, BookOpenText, Braces, ExternalLink, Loader2, Search } from "lucide-react";
|
||||
import { useMemo, useState } from "react";
|
||||
import { Navigate, useNavigate, useParams } from "react-router-dom";
|
||||
import { toast } from "sonner";
|
||||
import { toast } from "@/core/ui/feedback";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import {
|
||||
} from "lucide-react";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { toast } from "sonner";
|
||||
import { toast } from "@/core/ui/feedback";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -1216,7 +1216,7 @@ export function WeKnoraSourceDrawer({
|
||||
}}
|
||||
linkClassName={(href) =>
|
||||
parseWeKnoraPreviewUrl(href)?.wikiSlug
|
||||
? "wiki-content-link font-medium text-[#be2323] decoration-[#be2323]/55 decoration-dashed hover:decoration-solid"
|
||||
? "wiki-content-link font-medium text-[#cf1322] decoration-[#cf1322]/55 decoration-dashed hover:decoration-solid"
|
||||
: undefined
|
||||
}
|
||||
onLinkClick={(event, href) => {
|
||||
|
||||
+6
-2
@@ -1,7 +1,7 @@
|
||||
import { ArrowLeft, ChevronDown, ChevronRight, Download, FilePlus2, FileText, Folder, Loader2, RefreshCw, Save, Search, Trash2 } from "lucide-react";
|
||||
import { type Dispatch, type SetStateAction, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { Navigate, useNavigate, useParams } from "react-router-dom";
|
||||
import { toast } from "sonner";
|
||||
import { confirmAction, toast } from "@/core/ui/feedback";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
@@ -604,7 +604,11 @@ export function WeKnoraWikiManagementPage() {
|
||||
|
||||
const remove = async () => {
|
||||
if (!canWrite || creating || !selectedSlug) return;
|
||||
if (!window.confirm(`确定删除文章「${draft.title || selectedSlug}」吗?删除后不可恢复。`)) return;
|
||||
if (!(await confirmAction(`确定删除文章「${draft.title || selectedSlug}」吗?删除后不可恢复。`, {
|
||||
title: "删除文章?",
|
||||
confirmText: "删除",
|
||||
danger: true,
|
||||
}))) return;
|
||||
try {
|
||||
await actions.removeWikiPage.mutateAsync({ id: noteId, slug: selectedSlug });
|
||||
toast.success("文章已删除");
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import {
|
||||
} from "lucide-react";
|
||||
import { type ReactNode, useEffect, useMemo, useState } from "react";
|
||||
import { Link, useLocation, useNavigate, useParams, useSearchParams } from "react-router-dom";
|
||||
import { toast } from "sonner";
|
||||
import { toast } from "@/core/ui/feedback";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import { userFacingKnowledgeMessage } from "@/lib/knowledge-message";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { Download, Loader2, Upload } from "lucide-react";
|
||||
import { useRef } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { toast } from "@/core/ui/feedback";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import {
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { toast } from "@/core/ui/feedback";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
|
||||
+4
-4
@@ -5,7 +5,7 @@ import { DateRangePicker, DateRangePickerProps, DateRangeValue, Loading } from '
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTheme } from '@/contexts/ThemeContext';
|
||||
import { requestCrudService } from '@/service/request-axios-service';
|
||||
import { toast } from 'sonner';
|
||||
import { toast } from "@/core/ui/feedback";
|
||||
import { KanbanColumn } from './KanbanColumn';
|
||||
import { TaskListItem } from './TaskManagement';
|
||||
import { listBusinessMappings } from '@/strategy-components/api/business-mapping';
|
||||
@@ -242,7 +242,7 @@ const SentimentAnalyzes: React.FC<TaskListPageProps> = ({ title, category, subCa
|
||||
|
||||
const metrics = [
|
||||
{ label: '全部任务', value: unanalyzedTotal + runningTotal + completedTotal, icon: Layers, fg: '#222222', chipBg: '#F5F5F5', chipFg: '#7F7F7F' },
|
||||
{ label: '未分析', value: unanalyzedTotal, icon: Inbox, fg: isLightBlue ? '#0062D9' : '#F5222D', chipBg: isLightBlue ? '#EAF4FF' : '#FEEDED', chipFg: isLightBlue ? '#0062D9' : '#F5222D' },
|
||||
{ label: '未分析', value: unanalyzedTotal, icon: Inbox, fg: isLightBlue ? '#0062D9' : '#CF1322', chipBg: isLightBlue ? '#EAF4FF' : '#FEEDED', chipFg: isLightBlue ? '#0062D9' : '#CF1322' },
|
||||
{ label: '分析中', value: runningTotal, icon: Loader, fg: isLightBlue ? '#0079FE' : '#1677FF', chipBg: isLightBlue ? '#F4F9FF' : '#EAF4FF', chipFg: isLightBlue ? '#0079FE' : '#1677FF' },
|
||||
{ label: '已完成', value: completedTotal, icon: CircleCheck, fg: '#52C41A', chipBg: '#EEFCF7', chipFg: '#189D72' },
|
||||
];
|
||||
@@ -297,7 +297,7 @@ const SentimentAnalyzes: React.FC<TaskListPageProps> = ({ title, category, subCa
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className={`inline-flex items-center gap-2 rounded-sm px-4 py-2 text-sm ${isDark ? 'bg-[rgba(77,141,255,0.16)] text-[#9CCBFF]' : isLightBlue ? 'bg-[#0062D9] text-white hover:bg-[#0079FE]' : 'bg-[#F5222D] text-white hover:bg-[#CF1322]'}`}
|
||||
className={`inline-flex items-center gap-2 rounded-sm px-4 py-2 text-sm ${isDark ? 'bg-[rgba(77,141,255,0.16)] text-[#9CCBFF]' : isLightBlue ? 'bg-[#0062D9] text-white hover:bg-[#0079FE]' : 'bg-[#CF1322] text-white hover:bg-[#BC0D1E]'}`}
|
||||
>
|
||||
<Plus className="h-4 w-4" />
|
||||
新建任务
|
||||
@@ -340,7 +340,7 @@ const SentimentAnalyzes: React.FC<TaskListPageProps> = ({ title, category, subCa
|
||||
<KanbanColumn
|
||||
title="未分析"
|
||||
count={unanalyzedTotal}
|
||||
color={isDark ? 'bg-[#7CC9FF]' : isLightBlue ? 'bg-[#0062D9]' : 'bg-[#F5222D]'}
|
||||
color={isDark ? 'bg-[#7CC9FF]' : isLightBlue ? 'bg-[#0062D9]' : 'bg-[#CF1322]'}
|
||||
tasks={unanalyzedList}
|
||||
taskType="unanalyzed"
|
||||
taskDataType="sentiment"
|
||||
|
||||
@@ -5,7 +5,7 @@ import dayjs from 'dayjs';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTheme } from '@/contexts/ThemeContext';
|
||||
import { requestCrudService } from '@/service/request-axios-service';
|
||||
import { toast } from 'sonner';
|
||||
import { toast } from "@/core/ui/feedback";
|
||||
import { KanbanColumn } from './KanbanColumn';
|
||||
import { TaskListItem } from './TaskManagement';
|
||||
import { listBusinessMappings } from '@/strategy-components/api/business-mapping';
|
||||
@@ -246,7 +246,7 @@ const TaskAnalyzes: React.FC<TaskListPageProps> = ({ title, category, subCategor
|
||||
|
||||
const metrics = [
|
||||
{ label: '全部任务', value: unanalyzedTotal + runningTotal + completedTotal, icon: Layers, fg: '#222222', chipBg: '#F5F5F5', chipFg: '#7F7F7F' },
|
||||
{ label: '未分析', value: unanalyzedTotal, icon: Inbox, fg: isLightBlue ? '#0062D9' : '#F5222D', chipBg: isLightBlue ? '#EAF4FF' : '#FEEDED', chipFg: isLightBlue ? '#0062D9' : '#F5222D' },
|
||||
{ label: '未分析', value: unanalyzedTotal, icon: Inbox, fg: isLightBlue ? '#0062D9' : '#CF1322', chipBg: isLightBlue ? '#EAF4FF' : '#FEEDED', chipFg: isLightBlue ? '#0062D9' : '#CF1322' },
|
||||
{ label: '分析中', value: runningTotal, icon: Loader, fg: isLightBlue ? '#0079FE' : '#1677FF', chipBg: isLightBlue ? '#F4F9FF' : '#EAF4FF', chipFg: isLightBlue ? '#0079FE' : '#1677FF' },
|
||||
{ label: '已完成', value: completedTotal, icon: CircleCheck, fg: '#52C41A', chipBg: '#EEFCF7', chipFg: '#189D72' },
|
||||
];
|
||||
@@ -294,7 +294,7 @@ const TaskAnalyzes: React.FC<TaskListPageProps> = ({ title, category, subCategor
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
className={`inline-flex shrink-0 items-center gap-2 whitespace-nowrap rounded-sm px-4 py-2 text-sm ${isDark ? 'bg-[rgba(77,141,255,0.16)] text-[#9CCBFF]' : isLightBlue ? 'bg-[#0062D9] text-white hover:bg-[#0079FE]' : 'bg-[#F5222D] text-white hover:bg-[#CF1322]'}`}
|
||||
className={`inline-flex shrink-0 items-center gap-2 whitespace-nowrap rounded-sm px-4 py-2 text-sm ${isDark ? 'bg-[rgba(77,141,255,0.16)] text-[#9CCBFF]' : isLightBlue ? 'bg-[#0062D9] text-white hover:bg-[#0079FE]' : 'bg-[#CF1322] text-white hover:bg-[#BC0D1E]'}`}
|
||||
>
|
||||
<Plus className="h-4 w-4" />
|
||||
新建任务
|
||||
@@ -336,7 +336,7 @@ const TaskAnalyzes: React.FC<TaskListPageProps> = ({ title, category, subCategor
|
||||
<KanbanColumn
|
||||
title="未分析"
|
||||
count={unanalyzedTotal}
|
||||
color={isDark ? 'bg-[#7CC9FF]' : isLightBlue ? 'bg-[#0062D9]' : 'bg-[#F5222D]'}
|
||||
color={isDark ? 'bg-[#7CC9FF]' : isLightBlue ? 'bg-[#0062D9]' : 'bg-[#CF1322]'}
|
||||
tasks={unanalyzedList}
|
||||
taskType="unanalyzed"
|
||||
pageIndexSearch={pageIndexChange}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Outlet, useLocation, useNavigate, useParams } from "react-router-dom";
|
||||
import { Loader2, MessageSquare, PlusSquare, Trash2 } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { toast } from "@/core/ui/feedback";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
Network,
|
||||
Workflow,
|
||||
} from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { toast } from "@/core/ui/feedback";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { ChevronDown, ChevronRight, Loader2, Maximize2 } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { toast } from "@/core/ui/feedback";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { CheckCircle2, Database, Loader2, TriangleAlert } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { toast } from "@/core/ui/feedback";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { loadArtifactContent } from "@/core/artifacts/loader";
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
} from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { toast } from "@/core/ui/feedback";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
|
||||
@@ -49,7 +49,7 @@ export type AppThemeColor = "red" | "green" | "blue" | "iceblue" | "lightyellow"
|
||||
/** 我方全部主题色(「应用管理」主题参数逐项配置目标值时遍历;dot 为配色小圆点)。 */
|
||||
export const APP_THEME_COLORS: { key: AppThemeColor; label: string; dot: string }[] = [
|
||||
{ key: "green", label: "绿色", dot: "#07C05F" },
|
||||
{ key: "red", label: "红色", dot: "#F5222D" },
|
||||
{ key: "red", label: "红色", dot: "#CF1322" },
|
||||
{ key: "blue", label: "蓝色", dot: "#1677FF" },
|
||||
{ key: "iceblue", label: "冰川蓝", dot: "#9BCEF1" },
|
||||
{ key: "lightyellow", label: "浅黄色", dot: "#F3FBD9" },
|
||||
|
||||
Reference in new issue
Block a user