给所有请求都加上jwt,隐藏生成jwt的secret(放到.env中),隐藏app-secret(放在pm2运行配置文件中,后续直接读取环境配置即可)
This commit is contained in:
@@ -27,12 +27,13 @@ interface DocumentListModalProps {
|
||||
total?: number;
|
||||
onPageChange?: (page: number) => void;
|
||||
onPageSizeChange?: (size: number) => void;
|
||||
frontendJWT?: string; // 新增JWT参数
|
||||
}
|
||||
|
||||
export function DocumentListModal({
|
||||
isOpen,
|
||||
onClose,
|
||||
title,
|
||||
export function DocumentListModal({
|
||||
isOpen,
|
||||
onClose,
|
||||
title,
|
||||
files,
|
||||
onViewFile,
|
||||
loading = false,
|
||||
@@ -41,7 +42,8 @@ export function DocumentListModal({
|
||||
pageSize = 10,
|
||||
total = 0,
|
||||
onPageChange,
|
||||
onPageSizeChange
|
||||
onPageSizeChange,
|
||||
frontendJWT
|
||||
}: DocumentListModalProps) {
|
||||
// 查看按钮防抖
|
||||
const [isnavigating,setIsnavigating] = useState(false)
|
||||
@@ -58,9 +60,8 @@ export function DocumentListModal({
|
||||
// 检查audit_status是否为0,如果是则更新为2
|
||||
if (auditStatus === 0 || auditStatus === null) {
|
||||
try {
|
||||
// TODO: 不需要传递userId,直接使用fileId找到对应文档,然后更新文档状态
|
||||
// 更新文档状态
|
||||
const updatedFile = await updateDocumentAuditStatus(fileId, 2);
|
||||
// 更新文档状态,传递JWT
|
||||
const updatedFile = await updateDocumentAuditStatus(fileId, 2, frontendJWT);
|
||||
console.log('更新后的文档状态:', updatedFile);
|
||||
} catch (error) {
|
||||
console.error('更新文件审核状态时出错:', error);
|
||||
@@ -68,7 +69,7 @@ export function DocumentListModal({
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 如果有自定义的查看处理函数,则调用它
|
||||
if (onViewFile) {
|
||||
setIsnavigating(true)
|
||||
|
||||
@@ -410,7 +410,7 @@ export function FilePreview({ fileContent, activeReviewPointResultId, targetPage
|
||||
}}
|
||||
>
|
||||
<Document
|
||||
file={DOCUMENT_URL+real_path}
|
||||
file={`/api/pdf-proxy?path=${encodeURIComponent(real_path)}`}
|
||||
onLoadSuccess={onDocumentLoadSuccess}
|
||||
onLoadError={(error) => {
|
||||
console.error("PDF加载错误:", error);
|
||||
|
||||
@@ -18,6 +18,7 @@ const REVIEW_TYPE_TO_APP: Record<string, AppModule> = {
|
||||
interface LayoutProps {
|
||||
children: React.ReactNode;
|
||||
userRole?: UserRole;
|
||||
frontendJWT?: string;
|
||||
}
|
||||
|
||||
// 添加一个接口表示路由handle可能包含的属性
|
||||
@@ -32,7 +33,7 @@ interface Match {
|
||||
data: unknown;
|
||||
}
|
||||
|
||||
export function Layout({ children, userRole = 'developer' }: LayoutProps) {
|
||||
export function Layout({ children, userRole = 'developer' as UserRole, frontendJWT = '' }: LayoutProps) {
|
||||
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
|
||||
const [selectedApp, setSelectedApp] = useState<AppModule>('');
|
||||
const matches = useMatches() as Match[];
|
||||
@@ -108,6 +109,7 @@ export function Layout({ children, userRole = 'developer' }: LayoutProps) {
|
||||
onToggle={toggleSidebar}
|
||||
userRole={userRole}
|
||||
selectedApp={selectedApp}
|
||||
frontendJWT={frontendJWT}
|
||||
/>
|
||||
|
||||
<div className={`main-content ${sidebarCollapsed ? 'sidebar-collapsed' : ''}`}>
|
||||
|
||||
@@ -7,6 +7,7 @@ interface SidebarProps {
|
||||
onToggle: () => void;
|
||||
collapsed: boolean;
|
||||
userRole: UserRole;
|
||||
frontendJWT?: string;
|
||||
selectedApp?: string; // 添加所选应用模块参数
|
||||
}
|
||||
|
||||
@@ -31,7 +32,7 @@ const APP_ICON_MAP: Record<string, string> = {
|
||||
'model': '/images/icon_assistant.png'
|
||||
};
|
||||
|
||||
export function Sidebar({ onToggle, collapsed, userRole, selectedApp = '' }: SidebarProps) {
|
||||
export function Sidebar({ onToggle, collapsed, userRole, frontendJWT = '', selectedApp = '' }: SidebarProps) {
|
||||
const location = useLocation();
|
||||
const [expandedMenus, setExpandedMenus] = useState<Record<string, boolean>>({});
|
||||
const [currentApp, setCurrentApp] = useState<string>(''); // 初始设置为空字符串而不是selectedApp
|
||||
@@ -47,7 +48,7 @@ export function Sidebar({ onToggle, collapsed, userRole, selectedApp = '' }: Sid
|
||||
try {
|
||||
console.log('userRole', userRole);
|
||||
const roleKey = mapUserRoleToRoleKey(userRole);
|
||||
const result = await getUserRoutesByRole(roleKey);
|
||||
const result = await getUserRoutesByRole(roleKey, frontendJWT);
|
||||
|
||||
if (result.success && result.data) {
|
||||
setMenuItems(result.data);
|
||||
@@ -253,7 +254,7 @@ export function Sidebar({ onToggle, collapsed, userRole, selectedApp = '' }: Sid
|
||||
// })
|
||||
|
||||
return (
|
||||
<div className={`sidebar ${collapsed ? 'collapsed' : ''}`}>
|
||||
<div className={`sidebar ${collapsed ? 'collapsed' : ''} flex flex-col`}>
|
||||
<div className="py-6 px-4 border-b border-gray-100 flex justify-between items-center">
|
||||
<div className="flex items-center"
|
||||
onClick={() => {
|
||||
@@ -300,7 +301,7 @@ export function Sidebar({ onToggle, collapsed, userRole, selectedApp = '' }: Sid
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="py-4 px-[10px]">
|
||||
<div className="py-4 px-[10px] flex-1 overflow-y-auto sidebar-scroll-area">
|
||||
{isLoading || isLoadingRoutes ? (
|
||||
// 加载中状态显示,保留菜单布局结构
|
||||
<div className="py-2">
|
||||
@@ -382,6 +383,19 @@ export function Sidebar({ onToggle, collapsed, userRole, selectedApp = '' }: Sid
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 操作手册下载按钮 */}
|
||||
<div className="mt-auto px-4 py-1 border-t border-gray-100">
|
||||
<a
|
||||
href="/智慧法务平台操作手册.pdf"
|
||||
download="智慧法务平台操作手册.pdf"
|
||||
className={`flex items-center ${collapsed ? 'justify-center' : ''} text-gray-600 hover:text-green-700 transition-colors duration-200`}
|
||||
title="下载操作手册"
|
||||
>
|
||||
<i className={`ri-question-line ${collapsed ? 'text-base' : 'text-base mr-3'}`}></i>
|
||||
{!collapsed && <span className="text-base">操作手册</span>}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -414,7 +414,7 @@ export function FilePreview({ fileContent, activeReviewPointResultId, targetPage
|
||||
}}
|
||||
>
|
||||
<Document
|
||||
file={DOCUMENT_URL+real_path}
|
||||
file={`/api/pdf-proxy?path=${encodeURIComponent(real_path)}`}
|
||||
onLoadSuccess={onDocumentLoadSuccess}
|
||||
onLoadError={(error) => {
|
||||
console.error("PDF加载错误:", error);
|
||||
|
||||
@@ -9,7 +9,7 @@ import { Modal } from '~/components/ui/Modal';
|
||||
import { UploadArea, type UploadAreaRef } from '~/components/ui/UploadArea';
|
||||
import { Button } from '~/components/ui/Button';
|
||||
import { toastService } from '~/components/ui/Toast';
|
||||
import { DOCUMENT_URL } from "~/api/axios-client";
|
||||
// import { DOCUMENT_URL } from "~/api/axios-client";
|
||||
import { uploadFileToBinary, uploadDocumentToServer } from '~/api/files/files-upload';
|
||||
|
||||
interface ReviewTabsProps {
|
||||
@@ -61,7 +61,8 @@ export function ReviewTabs({ activeTab, onTabChange, children, fileInfo, onConfi
|
||||
// 下载原文件
|
||||
const handleDownloadFile = async () => {
|
||||
try {
|
||||
const downloadUrl = `${DOCUMENT_URL}${fileInfo.path}`;
|
||||
// 使用 PDF 代理路由获取文件,自动添加 JWT 认证
|
||||
const downloadUrl = `/api/pdf-proxy?path=${encodeURIComponent(fileInfo.path || '')}`;
|
||||
|
||||
// 使用fetch获取文件内容
|
||||
const response = await fetch(downloadUrl);
|
||||
|
||||
Reference in New Issue
Block a user