diff --git a/app/components/reviews/ReviewTabs.tsx b/app/components/reviews/ReviewTabs.tsx index ebd6a79..8b2caa7 100644 --- a/app/components/reviews/ReviewTabs.tsx +++ b/app/components/reviews/ReviewTabs.tsx @@ -24,9 +24,10 @@ interface ReviewTabsProps { type?: string; }; onConfirmResults: () => void; + jwtToken?: string | null; } -export function ReviewTabs({ activeTab, onTabChange, children, fileInfo, onConfirmResults }: ReviewTabsProps) { +export function ReviewTabs({ activeTab, onTabChange, children, fileInfo, onConfirmResults, jwtToken }: ReviewTabsProps) { const [isNavigating, setIsNavigating] = useState(false); const [isReuploadModalOpen, setIsReuploadModalOpen] = useState(false); const [selectedTemplateFiles, setSelectedTemplateFiles] = useState([]); @@ -185,7 +186,8 @@ export function ReviewTabs({ activeTab, onTabChange, children, fileInfo, onConfi null, //remark 备注 false, //is_test_document 是否为测试文档:false fileInfo.id, //document_id 主文档id - true //is_reupload 是否为重新上传:true + true, //is_reupload 是否为重新上传:true + jwtToken || undefined, //jwtToken ); // console.log('重新上传合同模板',uploadResult); @@ -396,4 +398,4 @@ export function ReviewTabs({ activeTab, onTabChange, children, fileInfo, onConfi ); -} \ No newline at end of file +} \ No newline at end of file diff --git a/app/routes/reviews.tsx b/app/routes/reviews.tsx index 3357f55..6f1a23b 100644 --- a/app/routes/reviews.tsx +++ b/app/routes/reviews.tsx @@ -183,6 +183,10 @@ export async function loader({ request }: LoaderFunctionArgs) { return Response.json({ result: false, message: '文件ID不能为空' }); } + // 获取用户会话信息 + const { getUserSession } = await import("~/api/login/auth.server"); + const { userInfo, frontendJWT } = await getUserSession(request); + // 获取评查点数据,传递request对象 const reviewData = await getReviewPoints(id, request); @@ -202,7 +206,9 @@ export async function loader({ request }: LoaderFunctionArgs) { reviewPoints: reviewData.data, reviewInfo: reviewData.reviewInfo, statistics: reviewData.stats, - comparison_document: reviewData.comparison_document + comparison_document: reviewData.comparison_document, + userInfo, + frontendJWT }); } else { console.error("返回的评查数据格式不正确",JSON.stringify(reviewData,null,2)); @@ -287,7 +293,7 @@ export default function ReviewDetails() { const navigate = useNavigate(); const loaderData = useLoaderData(); const fetcher = useFetcher(); - const { document, reviewPoints, statistics, reviewInfo, comparison_document } = loaderData; + const { document, reviewPoints, statistics, reviewInfo, comparison_document, frontendJWT } = loaderData; const [isLoading, setIsLoading] = useState(false); // 已经通过loader加载了数据,不需要再显示加载状态 const [activeTab, setActiveTab] = useState('preview'); // 'preview', 'analysis', 'fileinfo' const [reviewData, setReviewData] = useState(null); @@ -699,6 +705,7 @@ export default function ReviewDetails() { type: document?.type }} onConfirmResults={handleConfirmResults} + jwtToken={frontendJWT} > {/* 评查结果选项卡内容 */} {activeTab === 'preview' && ( diff --git a/app/routes/test.client-config.tsx b/app/routes/test.client-config.tsx deleted file mode 100644 index 86172d7..0000000 --- a/app/routes/test.client-config.tsx +++ /dev/null @@ -1,249 +0,0 @@ -/** - * 客户端配置测试页面 - * 用于验证Nginx代理和客户端ID检测是否正常工作 - */ -import { json, type LoaderFunctionArgs } from "@remix-run/node"; -import { useLoaderData } from "@remix-run/react"; -import { getApiConfig } from "~/config/api-config"; -import { detectClientFromRequest, getRequestDebugInfo } from "~/utils/client-detection"; - -/** - * 服务器端loader函数 - 获取配置和调试信息 - */ -export async function loader({ request }: LoaderFunctionArgs) { - // 获取客户端配置 - const config = getApiConfig(request); - - // 获取客户端检测信息 - const detectedClientId = detectClientFromRequest(request); - - // 获取调试信息 - const debugInfo = getRequestDebugInfo(request); - - // 获取当前URL信息 - const url = new URL(request.url); - - return json({ - config, - detectedClientId, - debugInfo, - serverInfo: { - url: url.href, - host: url.host, - port: url.port, - pathname: url.pathname - }, - timestamp: new Date().toISOString() - }); -} - -/** - * 客户端配置测试页面组件 - */ -export default function ClientConfigTest() { - const data = useLoaderData(); - - // 浏览器端检测客户端ID - const browserClientId = typeof window !== 'undefined' ? (() => { - const port = window.location.port; - const portToClient: Record = { - '5174': 'client-a', - '5175': 'client-b', - '5176': 'client-c', - '5177': 'client-d' - }; - return port && portToClient[port] ? portToClient[port] : 'unknown'; - })() : 'server-side'; - - const browserPort = typeof window !== 'undefined' ? window.location.port : 'server-side'; - - return ( -
-
-
-

- 🧪 客户端配置测试页面 -

- - {/* 基本信息 */} -
-
-

📍 访问信息

-
-
当前URL: {data.serverInfo.url}
-
主机: {data.serverInfo.host}
-
端口: {data.serverInfo.port || '默认端口'}
-
路径: {data.serverInfo.pathname}
-
浏览器端口: {browserPort}
-
-
- -
-

🎯 客户端检测

-
-
服务器端检测: - - {data.detectedClientId} - -
-
浏览器端检测: - - {browserClientId} - -
-
-
-
- - {/* Nginx请求头信息 */} -
-

🔍 Nginx请求头信息

-
-
-
- X-Client-ID: - - {data.debugInfo.clientId || '未检测到'} - -
-
- X-Original-Port: - - {data.debugInfo.originalPort || '未检测到'} - -
-
- X-Forwarded-Port: - - {data.debugInfo.forwardedPort || '未设置'} - -
-
- X-Real-IP: - - {data.debugInfo.realIp || '未设置'} - -
-
-
-
- - {/* 当前配置信息 */} -
-

⚙️ 当前API配置

-
-
-
Base URL: {data.config.baseUrl}
-
Upload URL: {data.config.uploadUrl}
-
Document URL: {data.config.documentUrl}
-
OAuth Server: {data.config.oauth.serverUrl}
-
OAuth Redirect: {data.config.oauth.redirectUri}
-
OAuth Client ID: {data.config.oauth.clientId.substring(0, 20)}...
-
-
-
- - {/* 状态检查 */} -
-

✅ 状态检查

-
-
-
- - {data.debugInfo.clientId ? '✅ Nginx X-Client-ID 传递正常' : '❌ Nginx X-Client-ID 未传递'} - -
- -
-
- - {data.detectedClientId !== 'main' ? '✅ 服务器端客户端检测成功' : '⚠️ 服务器端使用默认配置'} - -
- -
-
- - {browserClientId !== 'unknown' ? '✅ 浏览器端客户端检测成功' : '⚠️ 浏览器端使用默认配置'} - -
- -
-
- - {data.config.baseUrl.includes(data.detectedClientId.replace('client-', '517')) ? '✅ 配置匹配正确' : '⚠️ 配置可能不匹配'} - -
-
-
- - {/* 调试信息 */} -
-

🔧 完整调试信息

-
- - 点击查看详细信息 - -
-                {JSON.stringify({
-                  serverData: data,
-                  browserInfo: {
-                    clientId: browserClientId,
-                    port: browserPort,
-                    userAgent: typeof window !== 'undefined' ? navigator.userAgent : 'server-side'
-                  }
-                }, null, 2)}
-              
-
-
- - {/* 测试链接 */} -
-

🔗 其他客户端测试链接

-
- {[ - { port: '5174', client: 'client-a', name: '客户端A' }, - { port: '5175', client: 'client-b', name: '客户端B' }, - { port: '5176', client: 'client-c', name: '客户端C' }, - { port: '5177', client: 'client-d', name: '客户端D' } - ].map(({ port, client, name }) => ( - - {name}
- :{port} -
- ))} -
-
- -
- 最后更新: {data.timestamp} -
-
-
-
- ); -} \ No newline at end of file diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs index ecff7ba..fcd95b4 100644 --- a/ecosystem.config.cjs +++ b/ecosystem.config.cjs @@ -9,7 +9,8 @@ module.exports = { script: 'node', args: [ '-r', 'dotenv/config', - './node_modules/.bin/remix-serve', + // './node_modules/.bin/remix-serve', + './node_modules/@remix-run/serve/dist/cli.js', './build/server/index.js' ], instances: 1, @@ -38,7 +39,8 @@ module.exports = { script: 'node', args: [ '-r', 'dotenv/config', - './node_modules/.bin/remix-serve', + // './node_modules/.bin/remix-serve', + './node_modules/@remix-run/serve/dist/cli.js', './build/server/index.js' ], instances: 1, @@ -68,7 +70,8 @@ module.exports = { script: 'node', args: [ '-r', 'dotenv/config', - './node_modules/.bin/remix-serve', + // './node_modules/.bin/remix-serve', + './node_modules/@remix-run/serve/dist/cli.js', './build/server/index.js' ], instances: 1, @@ -98,7 +101,8 @@ module.exports = { script: 'node', args: [ '-r', 'dotenv/config', - './node_modules/.bin/remix-serve', + // './node_modules/.bin/remix-serve', + './node_modules/@remix-run/serve/dist/cli.js', './build/server/index.js' ], instances: 1, @@ -128,7 +132,8 @@ module.exports = { script: 'node', args: [ '-r', 'dotenv/config', - './node_modules/.bin/remix-serve', + //'./node_modules/.bin/remix-serve', + './node_modules/@remix-run/serve/dist/cli.js', './build/server/index.js' ], instances: 1, @@ -158,7 +163,8 @@ module.exports = { script: 'node', args: [ '-r', 'dotenv/config', - './node_modules/.bin/remix-serve', + //'./node_modules/.bin/remix-serve', + './node_modules/@remix-run/serve/dist/cli.js', './build/server/index.js' ], instances: 1,