Merge remote-tracking branch 'origin/Wren' into PingChuan

This commit is contained in:
PingChuan
2025-11-25 10:56:57 +08:00
35 changed files with 7412 additions and 1085 deletions
+31 -8
View File
@@ -90,12 +90,16 @@ export function Sidebar({ onToggle, collapsed, userRole, frontendJWT = '' }: Sid
fetchUserRoutes();
}, [userRole, frontendJWT, navigate]);
// 从 sessionStorage 读取当前选中的模块名称和图片路径
// 🔑 检查是否处于系统设置模式
const [isSettingsMode, setIsSettingsMode] = useState<boolean>(false);
// 从 sessionStorage 读取当前选中的模块名称和图片路径,以及系统设置模式标志
useEffect(() => {
if (typeof window !== 'undefined') {
try {
const moduleName = sessionStorage.getItem('selectedModuleName');
const modulePicPath = sessionStorage.getItem('selectedModulePicPath');
const settingsMode = sessionStorage.getItem('settingsMode');
if (moduleName) {
setSelectedModuleName(moduleName);
@@ -106,6 +110,14 @@ export function Sidebar({ onToggle, collapsed, userRole, frontendJWT = '' }: Sid
setSelectedModulePicPath(modulePicPath);
console.log('🖼️ [Sidebar] 模块图片路径:', modulePicPath);
}
// 🔑 检查是否处于系统设置模式
if (settingsMode === 'true') {
setIsSettingsMode(true);
console.log('⚙️ [Sidebar] 进入系统设置模式');
} else {
setIsSettingsMode(false);
}
} catch (error) {
console.error('❌ [Sidebar] 读取 sessionStorage 失败:', error);
}
@@ -154,19 +166,30 @@ export function Sidebar({ onToggle, collapsed, userRole, frontendJWT = '' }: Sid
// console.log('子菜单点击:', child.title, '路径:', child.path);
};
const isPort51707 = typeof window !== 'undefined' && window.location.port === '51707'
// const isPort51707 = typeof window !== 'undefined' && window.location.port === '51707'
// 处理菜单项:清理子菜单结构
const processedMenuItems: MenuItem[] = menuItems.filter(item =>{
// console.log('菜单项:', item.title, 'Icon:', item.icon)
// 如果是省局访问
if(isPort51707){
if (selectedModuleName === '智慧法务大模型'){
return item.path && item.path.startsWith('/chat-with-llm')
}
return item.path && item.path.startsWith('/cross-checking')
// 🔑 优先检查:如果处于系统设置模式,只显示 /settings 及其子路由
if (isSettingsMode) {
return item.path === '/settings' || item.path?.startsWith('/settings/');
}
// 🔑 重要:非系统设置模式下,隐藏所有 /settings 相关菜单
if (item.path === '/settings' || item.path?.startsWith('/settings/')) {
return false;
}
// 如果是省局访问
// if(isPort51707){
// if (selectedModuleName === '智慧法务大模型'){
// return item.path && item.path.startsWith('/chat-with-llm')
// }
// return item.path && item.path.startsWith('/cross-checking')
// }
// 🔑 如果选择了"智慧法务大模型",只显示 /chat-with-llm 相关菜单
if (selectedModuleName === '智慧法务大模型') {
return item.path === '/chat-with-llm' || item.path?.startsWith('/chat-with-llm/');
+4
View File
@@ -8,6 +8,10 @@ import { DOCUMENT_URL } from '~/api/axios-client';
import { CollaboraViewer, type CollaboraViewerHandle } from '~/components/collabora/CollaboraViewer';
import { requestPageInfo } from '~/components/collabora/lib/pageInfo';
// 导入react-pdf的CSS样式(文本层和注释层必需)
import 'react-pdf/dist/esm/Page/TextLayer.css';
import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
// 设置worker路径为public目录下的worker文件
// 使用已经下载的兼容版本 (pdfjs-dist v2.12.313)
// 2025/09/28 使用新版本的pdfjs-dist v4.8.69
+8 -7
View File
@@ -140,28 +140,26 @@ export function BasicInfo({ onChange, initialData, evaluationPointGroups = [], r
// 处理条款号输入框失去焦点
const handleLawArticlesBlur = () => {
if (!lawArticlesText) return;
// 将输入的文本转换为数组
const articles = lawArticlesText
.split(',')
.map(article => article.trim())
.filter(article => article !== '');
// 创建一个新的引用法律对象,保留现有字段
const referencesLaws = {
...(formData.references_laws || {}),
articles: articles.length > 0 ? articles : []
articles: articles // ✅ 清空时会是空数组
};
// 更新表单数据
const newData = {
...formData,
references_laws: referencesLaws
};
setFormData(newData);
if (onChange) {
onChange(newData);
}
@@ -171,6 +169,9 @@ export function BasicInfo({ onChange, initialData, evaluationPointGroups = [], r
useEffect(() => {
if (formData.references_laws?.articles && formData.references_laws.articles.length > 0) {
setLawArticlesText(formData.references_laws.articles.join(','));
} else {
// ✅ 当 articles 为空时,也清空输入框
setLawArticlesText('');
}
}, [formData.references_laws?.articles]);
+7 -4
View File
@@ -31,20 +31,23 @@ export function Table<T extends Record<string, any>>({
className = '',
onRow,
}: TableProps<T>) {
// 防御性检查:确保 dataSource 始终是数组
const safeDataSource = dataSource || [];
const getRowKey = (record: T, index: number): string => {
if (typeof rowKey === 'function') {
return rowKey(record);
}
return String(record[rowKey]);
};
return (
<div className={`ant-table-wrapper ${className} ${loading ? 'ant-table-loading' : ''}`}>
<table className={`ant-table ${bordered ? 'ant-table-bordered' : ''}`}>
<thead>
<tr>
{columns.map((column, index) => (
<th
<th
key={column.key || column.dataIndex?.toString() || index}
className={column.className}
style={{
@@ -58,8 +61,8 @@ export function Table<T extends Record<string, any>>({
</tr>
</thead>
<tbody>
{dataSource.length > 0 ? (
dataSource.map((record, index) => (
{safeDataSource.length > 0 ? (
safeDataSource.map((record, index) => (
<tr
key={getRowKey(record, index)}
{...(onRow ? onRow(record, index) : {})}