feat:替换 Dify 为自建 RAG去实现
1、修复了若干无权限时的失败提示语 2、新增了一个生成后续建议问题的功能 3、重构了知识问答部分的权限管理模块 4、修复了若干渲染不恰当的样式渲染
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
EyeOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { useDocumentDetail } from '~/hooks/dify-dataset-manager/document-detail';
|
||||
import { usePermission } from '~/hooks/usePermission';
|
||||
import type { DocumentDetailProps } from '~/types/dify-dataset-manager/document-detail';
|
||||
import { INDEXING_STATUS_CONFIG } from '~/types/dify-dataset-manager/document-detail';
|
||||
|
||||
@@ -26,6 +27,7 @@ import { INDEXING_STATUS_CONFIG } from '~/types/dify-dataset-manager/document-de
|
||||
export default function DocumentDetail({
|
||||
datasetId,
|
||||
document,
|
||||
canEditDataset = true,
|
||||
}: DocumentDetailProps) {
|
||||
const {
|
||||
settings,
|
||||
@@ -41,6 +43,10 @@ export default function DocumentDetail({
|
||||
handleSaveAndProcess,
|
||||
} = useDocumentDetail(datasetId, document);
|
||||
|
||||
const { hasPermission } = usePermission();
|
||||
const canManageDoc = hasPermission('dify:document:manage') && canEditDataset;
|
||||
const readOnly = !canManageDoc || isProcessing;
|
||||
|
||||
if (!document) {
|
||||
return (
|
||||
<div className="document-detail-empty">
|
||||
@@ -83,7 +89,7 @@ export default function DocumentDetail({
|
||||
value={settings.separator}
|
||||
onChange={(e) => updateSettings('separator', e.target.value)}
|
||||
placeholder="\n\n"
|
||||
disabled={isProcessing}
|
||||
disabled={readOnly}
|
||||
className="setting-input"
|
||||
/>
|
||||
</div>
|
||||
@@ -102,7 +108,7 @@ export default function DocumentDetail({
|
||||
onChange={(value) => updateSettings('maxTokens', value || 500)}
|
||||
min={100}
|
||||
max={4000}
|
||||
disabled={isProcessing}
|
||||
disabled={readOnly}
|
||||
className="setting-input-number"
|
||||
/>
|
||||
<span className="input-suffix">characters</span>
|
||||
@@ -123,7 +129,7 @@ export default function DocumentDetail({
|
||||
onChange={(value) => updateSettings('chunkOverlap', value || 50)}
|
||||
min={0}
|
||||
max={500}
|
||||
disabled={isProcessing}
|
||||
disabled={readOnly}
|
||||
className="setting-input-number"
|
||||
/>
|
||||
<span className="input-suffix">characters</span>
|
||||
@@ -141,7 +147,7 @@ export default function DocumentDetail({
|
||||
<Checkbox
|
||||
checked={settings.removeExtraSpaces}
|
||||
onChange={(e) => updateSettings('removeExtraSpaces', e.target.checked)}
|
||||
disabled={isProcessing}
|
||||
disabled={readOnly}
|
||||
>
|
||||
替换掉连续的空格、换行符和制表符
|
||||
</Checkbox>
|
||||
@@ -149,7 +155,7 @@ export default function DocumentDetail({
|
||||
<Checkbox
|
||||
checked={settings.removeUrlsEmails}
|
||||
onChange={(e) => updateSettings('removeUrlsEmails', e.target.checked)}
|
||||
disabled={isProcessing}
|
||||
disabled={readOnly}
|
||||
>
|
||||
删除所有 URL 和电子邮件地址
|
||||
</Checkbox>
|
||||
@@ -163,16 +169,16 @@ export default function DocumentDetail({
|
||||
<h3 className="section-title">索引方式</h3>
|
||||
<div className="index-options">
|
||||
<div
|
||||
className={`index-option ${settings.indexingTechnique === 'high_quality' ? 'active' : ''} ${isProcessing ? 'disabled' : ''}`}
|
||||
onClick={() => !isProcessing && updateSettings('indexingTechnique', 'high_quality')}
|
||||
className={`index-option ${settings.indexingTechnique === 'high_quality' ? 'active' : ''} ${readOnly ? 'disabled' : ''}`}
|
||||
onClick={() => !readOnly && updateSettings('indexingTechnique', 'high_quality')}
|
||||
>
|
||||
<span className="option-radio"></span>
|
||||
<span className="option-label">高质量</span>
|
||||
<span className="option-badge recommended">推荐</span>
|
||||
</div>
|
||||
<div
|
||||
className={`index-option ${settings.indexingTechnique === 'economy' ? 'active' : ''} ${isProcessing ? 'disabled' : ''}`}
|
||||
onClick={() => !isProcessing && updateSettings('indexingTechnique', 'economy')}
|
||||
className={`index-option ${settings.indexingTechnique === 'economy' ? 'active' : ''} ${readOnly ? 'disabled' : ''}`}
|
||||
onClick={() => !readOnly && updateSettings('indexingTechnique', 'economy')}
|
||||
>
|
||||
<span className="option-radio"></span>
|
||||
<span className="option-label">经济</span>
|
||||
@@ -190,29 +196,33 @@ export default function DocumentDetail({
|
||||
>
|
||||
预览块
|
||||
</Button>
|
||||
<Button
|
||||
icon={<ReloadOutlined />}
|
||||
onClick={handleReset}
|
||||
disabled={isProcessing}
|
||||
>
|
||||
重置
|
||||
</Button>
|
||||
{canManageDoc && (
|
||||
<Button
|
||||
icon={<ReloadOutlined />}
|
||||
onClick={handleReset}
|
||||
disabled={isProcessing}
|
||||
>
|
||||
重置
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
|
||||
{/* 保存并处理按钮 */}
|
||||
<div className="save-actions">
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={handleSaveAndProcess}
|
||||
loading={saving}
|
||||
disabled={isProcessing}
|
||||
block
|
||||
>
|
||||
{isProcessing ? '处理中...' : '保存并处理'}
|
||||
</Button>
|
||||
</div>
|
||||
{canManageDoc && (
|
||||
<div className="save-actions">
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={handleSaveAndProcess}
|
||||
loading={saving}
|
||||
disabled={isProcessing}
|
||||
block
|
||||
>
|
||||
{isProcessing ? '处理中...' : '保存并处理'}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 右侧预览区域 */}
|
||||
|
||||
Reference in New Issue
Block a user