feat:替换 Dify 为自建 RAG去实现

1、修复了若干无权限时的失败提示语
2、新增了一个生成后续建议问题的功能
3、重构了知识问答部分的权限管理模块
4、修复了若干渲染不恰当的样式渲染
This commit is contained in:
PingChuan
2026-04-10 16:20:32 +08:00
parent f525707358
commit 5bee9288b9
31 changed files with 407 additions and 304 deletions
+12 -6
View File
@@ -13,6 +13,7 @@ import { Button, Dropdown, Input, Layout, Menu, Modal, Tooltip, message, theme,
import { forwardRef, useImperativeHandle, useMemo, useState } from 'react';
import type { ChatApp } from '~/api/dify-chat-apps/types';
import type { ConversationItem } from '~/api/dify-chat';
import { usePermission } from '~/hooks/usePermission';
import { deleteConversation, renameConversation } from '~/api/dify-chat';
import '../../styles/components/chat-with-llm/sidebar.css';
@@ -32,6 +33,8 @@ interface ChatSidebarProps {
currentChatApp: ChatApp | null;
onChatAppChange: (appId: string) => void;
onConversationRenamed?: (conversationId: string, newName: string) => void;
/** 会话列表权限被拒绝时,隐藏重命名/删除按钮 */
conversationReadOnly?: boolean;
}
// 暴露给父组件的方法接口
@@ -55,7 +58,10 @@ const ChatSidebar = forwardRef<ChatSidebarRef, ChatSidebarProps>(({
onNewConversation,
onConversationDeleted,
onConversationRenamed,
conversationReadOnly = false,
}, ref) => {
const { hasPermission } = usePermission();
const canDeleteConversation = hasPermission('dify:conversation:delete');
const [searchValue, setSearchValue] = useState('');
const [renameModalVisible, setRenameModalVisible] = useState(false);
const [deleteModalVisible, setDeleteModalVisible] = useState(false);
@@ -208,24 +214,24 @@ const ChatSidebar = forwardRef<ChatSidebarRef, ChatSidebarProps>(({
<span className="truncate flex-1" title={conv.name}>
{conv.name}
</span>
{!collapsed && (
{!collapsed && (!conversationReadOnly || canDeleteConversation) && (
<Dropdown
menu={{
items: [
{
...(!conversationReadOnly ? [{
key: 'rename',
icon: <EditOutlined />,
label: '重命名',
onClick: () => handleRename(conv),
},
{
}] : []),
...(canDeleteConversation ? [{
key: 'delete',
icon: <DeleteOutlined />,
label: '删除',
danger: true,
onClick: () => handleDeleteClick(conv),
},
],
}] : []),
].filter(Boolean),
}}
trigger={['click']}
placement="bottomRight"