修复系统概览数据不准确的查询。修复交叉评查意见列表的数量查询。优化全局消息提示的层级。优化提交意见进行局部更新。

This commit is contained in:
2025-07-25 09:49:36 +08:00
parent 3dab54d551
commit ccd5cdf71e
29 changed files with 2444 additions and 1035 deletions
+155 -49
View File
@@ -32,14 +32,16 @@ interface ApiConfig {
const configs: Record<string, ApiConfig> = {
// 开发环境
development: {
// baseUrl: '/api', // 改为相对路径,让nginx处理
baseUrl: 'http://172.16.0.55:8008',
// baseUrl: 'http://172.16.0.81:3000',
// baseUrl: 'http://nas.7bm.co:3000',
// documentUrl: 'http://172.16.0.81:9000/docauditai/',
documentUrl: 'http://172.16.0.55:8008/docauditai/',
// documentUrl: '/api/docauditai/',
// uploadUrl: '/api/admin/documents', // 改为相对路径
uploadUrl: 'http://172.16.0.55:8008/admin/documents',
// uploadUrl: 'http://172.16.0.58:8008/admin/documents',
// uploadUrl: 'http://172.16.0.58:8008/admin/documents',
oauth: {
serverUrl: 'http://10.79.112.85', // IDaaS服务器地址
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
@@ -103,35 +105,50 @@ const getClientConfigs = (env: string): Record<string, Partial<ApiConfig>> => {
// 开发环境 - 本地nginx代理配置
return {
'client-a': {
baseUrl: 'http://localhost:8001',
uploadUrl: 'http://localhost:8001/admin/documents',
baseUrl: '/api', // 改为相对路径,让nginx处理
uploadUrl: '/api/admin/documents', // 改为相对路径
documentUrl: '/api/docauditai/',
oauth: {
serverUrl: 'http://10.79.112.85',
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb',
redirectUri: 'http://localhost:8001/callback',
redirectUri: 'http://172.16.0.34:5174/callback',
appId: 'idaasoauth2'
}
},
'client-b': {
baseUrl: 'http://localhost:8002',
uploadUrl: 'http://localhost:8002/admin/documents',
baseUrl: '/api', // 改为相对路径,让nginx处理
uploadUrl: '/api/admin/documents', // 改为相对路径
documentUrl: '/api/docauditai/',
oauth: {
serverUrl: 'http://10.79.112.85',
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb',
redirectUri: 'http://localhost:8002/callback',
redirectUri: 'http://172.16.0.34:5175/callback',
appId: 'idaasoauth2'
}
},
'client-c': {
baseUrl: 'http://localhost:8003',
uploadUrl: 'http://localhost:8003/admin/documents',
baseUrl: '/api', // 改为相对路径,让nginx处理
uploadUrl: '/api/admin/documents', // 改为相对路径
documentUrl: '/api/docauditai/',
oauth: {
serverUrl: 'http://10.79.112.85',
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb',
redirectUri: 'http://localhost:8003/callback',
redirectUri: 'http://172.16.0.34:5176/callback',
appId: 'idaasoauth2'
}
},
'client-d': {
baseUrl: '/api', // 改为相对路径,让nginx处理
uploadUrl: '/api/admin/documents', // 改为相对路径
documentUrl: '/api/docauditai/',
oauth: {
serverUrl: 'http://10.79.112.85',
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb',
redirectUri: 'http://172.16.0.34:5177/callback',
appId: 'idaasoauth2'
}
}
@@ -139,36 +156,51 @@ const getClientConfigs = (env: string): Record<string, Partial<ApiConfig>> => {
} else {
// 生产环境 - 服务器配置
return {
'client-a': {
baseUrl: 'http://10.79.97.17:51701',
uploadUrl: 'http://10.79.97.17:51701/admin/documents',
oauth: {
serverUrl: 'http://10.79.112.85',
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb',
redirectUri: 'http://10.79.97.17:51701/callback',
appId: 'idaasoauth2'
}
},
'client-b': {
baseUrl: 'http://10.79.97.17:51702',
uploadUrl: 'http://10.79.97.17:51702/admin/documents',
oauth: {
serverUrl: 'http://10.79.112.85',
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb',
redirectUri: 'http://10.79.97.17:51702/callback',
appId: 'idaasoauth2'
}
},
'client-c': {
'provincial': {
baseUrl: 'http://10.79.97.17:51704',
uploadUrl: 'http://10.79.97.17:51704/admin/documents',
documentUrl: 'http://10.76.244.156:9000/docauditai/',
oauth: {
serverUrl: 'http://10.79.112.85',
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb',
redirectUri: 'http://10.79.97.17:51704/callback',
redirectUri: 'http://10.79.97.17/callback',
appId: 'idaasoauth2'
}
},
'meizhou': {
baseUrl: 'http://10.79.97.17:51705',
uploadUrl: 'http://10.79.97.17:51705/admin/documents',
documentUrl: 'http://10.76.244.156:9000/docauditai/',
oauth: {
serverUrl: 'http://10.79.112.85',
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb',
redirectUri: 'http://10.79.97.17/callback',
appId: 'idaasoauth2'
}
},
'jieyang': {
baseUrl: 'http://10.79.97.17:51706',
uploadUrl: 'http://10.79.97.17:51706/admin/documents',
documentUrl: 'http://10.76.244.156:9000/docauditai/',
oauth: {
serverUrl: 'http://10.79.112.85',
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb',
redirectUri: 'http://10.79.97.17/callback',
appId: 'idaasoauth2'
}
},
'yunfu': {
baseUrl: 'http://10.79.97.17:51707',
uploadUrl: 'http://10.79.97.17:51707/admin/documents',
documentUrl: 'http://10.76.244.156:9000/docauditai/',
oauth: {
serverUrl: 'http://10.79.112.85',
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb',
redirectUri: 'http://10.79.97.17/callback',
appId: 'idaasoauth2'
}
}
@@ -182,8 +214,46 @@ const getCurrentEnvironment = (): string => {
return process.env.NEXT_PUBLIC_API_ENV || process.env.NODE_ENV || 'development';
};
// 获取客户端ID
const getClientId = (): string => {
// 获取客户端ID - 支持从请求头动态获取
const getClientId = (request?: Request): string => {
// SSR: 通过请求头的 host 判断
if (request && typeof window === 'undefined') {
// 1. 优先 X-Client-ID
const clientIdFromHeader = request.headers.get('X-Client-ID');
if (clientIdFromHeader) return clientIdFromHeader;
// 2. 通过 host 端口判断
const host = request.headers.get('host'); // 例如 172.24.238.60:5177
if (host) {
const port = host.split(':')[1];
const portToClient: Record<string, string> = {
'5174': 'client-a',
'5175': 'client-b',
'5176': 'client-c',
'5177': 'client-d'
};
if (port && portToClient[port]) {
return portToClient[port];
}
}
}
// 浏览器端
if (typeof window !== 'undefined') {
const port = window.location.port;
const portToClient: Record<string, string> = {
'5174': 'client-a',
'5175': 'client-b',
'5176': 'client-c',
'5177': 'client-d'
};
if (port && portToClient[port]) {
console.log(`🎯 浏览器端检测到客户端ID: ${portToClient[port]} (端口: ${port})`);
return portToClient[port];
}
}
// 回退到环境变量
return process.env.CLIENT_ID || process.env.NEXT_PUBLIC_CLIENT_ID || 'main';
};
@@ -204,9 +274,9 @@ const getConfigFromEnv = (defaultConfig: ApiConfig): ApiConfig => {
};
// 获取当前配置 - 支持客户端特定配置
const getCurrentConfig = (): ApiConfig => {
const getCurrentConfig = (request?: Request): ApiConfig => {
const env = getCurrentEnvironment();
const clientId = getClientId();
const clientId = getClientId(request);
const defaultConfig = configs[env] || configs.development;
// 获取当前环境的客户端特定配置
@@ -234,16 +304,52 @@ const getCurrentConfig = (): ApiConfig => {
return finalConfig;
};
// 导出当前环境的配置
// 导出当前环境的配置(静态,用于兼容性)
export const apiConfig = getCurrentConfig();
// 导出具体的配置项,方便使用
export const {
baseUrl: API_BASE_URL,
documentUrl: DOCUMENT_URL,
uploadUrl: UPLOAD_URL,
oauth: OAUTH_CONFIG
} = apiConfig;
// 导出动态配置获取函数(支持从请求头获取客户端ID)
export const getApiConfig = (request?: Request): ApiConfig => {
return getCurrentConfig(request);
};
// 导出具体的配置项,方便使用(现在是真正动态的)
// 使用getter函数实现动态获取,避免ES模块中exports未定义的问题
export const API_BASE_URL = {
get value() {
return getCurrentConfig().baseUrl;
}
};
export const DOCUMENT_URL = {
get value() {
return getCurrentConfig().documentUrl;
}
};
export const UPLOAD_URL = {
get value() {
return getCurrentConfig().uploadUrl;
}
};
export const OAUTH_CONFIG = {
get value() {
return getCurrentConfig().oauth;
}
};
// 动态获取配置项的函数
export const getApiBaseUrl = (request?: Request): string => {
return getApiConfig(request).baseUrl;
};
export const getUploadUrl = (request?: Request): string => {
return getApiConfig(request).uploadUrl;
};
export const getOAuthConfig = (request?: Request) => {
return getApiConfig(request).oauth;
};
// 导出所有配置,供调试使用
export { configs };