Merge branch 'PingChuan' into shiy-login

# Conflicts:
#	app/config/api-config.ts
fix: 1. 修复无法加载数据的问题:没有从入口页中进来会缺少数据。
2. 加强后端接口关于token的校验错误和权限校验错误的管理。

feat: 1. 对接后端的数据看板的接口。
2. 将系统设置单独抽出来作为管理员的固定一个入口。
This commit is contained in:
2025-11-22 15:57:22 +08:00
27 changed files with 1972 additions and 643 deletions
+56 -39
View File
@@ -11,6 +11,10 @@ interface ApiConfig {
documentUrl: string;
// 文档上传API URL
uploadUrl: string;
// Collabora Online 服务器地址
collaboraUrl: string;
// 应用基础URL(用于 WOPI 回调)
appUrl: string;
// OAuth2.0配置
oauth: {
// IDaaS服务器地址
@@ -33,26 +37,24 @@ const portConfigs: Record<string, Partial<ApiConfig>> = {
// 主要
// 梅州
'51703': {
// baseUrl: 'http://10.79.97.17:8000',
// documentUrl: 'http://10.79.97.17:8000/docauditai/',
// uploadUrl: 'http://10.79.97.17:8000/admin/documents',
baseUrl: 'http://172.16.0.55:8073',
documentUrl: 'http://172.16.0.55:8073/docauditai/',
uploadUrl: 'http://172.16.0.55:8073/admin/documents',
// baseUrl: 'http://nas.7bm.co:8073',
// documentUrl: 'http://nas.7bm.co:8073/docauditai/',
// uploadUrl: 'http://nas.7bm.co:8073/admin/documents',
baseUrl: 'http://127.0.0.1:8073',
documentUrl: 'http://127.0.0.1:8073/docauditai/',
uploadUrl: 'http://127.0.0.1:8073/admin/documents',
collaboraUrl: 'http://172.16.0.81:9980',
appUrl: 'http://10.79.97.17:51703',
oauth: {
redirectUri: 'http://10.79.97.17:51703/callback'
}
},
// 云浮
'51704': {
baseUrl: 'http://10.79.97.17:8001',
documentUrl: 'http://10.79.97.17:8001/docauditai/',
uploadUrl: 'http://10.79.97.17:8001/admin/documents',
collaboraUrl: 'http://10.79.97.17:9980',
appUrl: 'http://10.79.97.17:51704',
oauth: {
redirectUri: 'http://10.79.97.17:51704/callback'
}
@@ -63,6 +65,8 @@ const portConfigs: Record<string, Partial<ApiConfig>> = {
baseUrl: 'http://10.79.97.17:8002',
documentUrl: 'http://10.79.97.17:8002/docauditai/',
uploadUrl: 'http://10.79.97.17:8002/admin/documents',
collaboraUrl: 'http://10.79.97.17:9980',
appUrl: 'http://10.79.97.17:51705',
oauth: {
redirectUri: 'http://10.79.97.17:51705/callback'
}
@@ -73,6 +77,8 @@ const portConfigs: Record<string, Partial<ApiConfig>> = {
baseUrl: 'http://10.79.97.17:8003',
documentUrl: 'http://10.79.97.17:8003/docauditai/',
uploadUrl: 'http://10.79.97.17:8003/admin/documents',
collaboraUrl: 'http://10.79.97.17:9980',
appUrl: 'http://10.79.97.17:51706',
oauth: {
redirectUri: 'http://10.79.97.17:51706/callback'
}
@@ -84,6 +90,8 @@ const portConfigs: Record<string, Partial<ApiConfig>> = {
baseUrl: 'http://10.79.97.17:8004',
documentUrl: 'http://10.79.97.17:8004/docauditai/',
uploadUrl: 'http://10.79.97.17:8004/admin/documents',
collaboraUrl: 'http://10.79.97.17:9980',
appUrl: 'http://10.79.97.17:51707',
oauth: {
redirectUri: 'http://10.79.97.17:51707/callback'
}
@@ -93,7 +101,9 @@ const portConfigs: Record<string, Partial<ApiConfig>> = {
'51708': {
baseUrl: 'http://10.79.97.17:8005',
documentUrl: 'http://10.79.97.17:8005/docauditai/',
uploadUrl: 'http://10.79.97.17:8005/admin/documents'
uploadUrl: 'http://10.79.97.17:8005/admin/documents',
collaboraUrl: 'http://10.79.97.17:9980',
appUrl: 'http://10.79.97.17:51708'
},
};
@@ -102,12 +112,11 @@ const portConfigs: Record<string, Partial<ApiConfig>> = {
const configs: Record<string, ApiConfig> = {
// 开发环境
development: {
baseUrl: 'http://172.16.0.55:8073', // FastAPI后端(包含/dify代理)
documentUrl: 'http://172.16.0.55:8073/docauditai/',
uploadUrl: 'http://172.16.0.55:8073/admin/documents',
// baseUrl: 'http://nas.7bm.co:8073', // FastAPI后端(包含/dify代理)
// documentUrl: 'http://nas.7bm.co:8073/docauditai/',
// uploadUrl: 'http://nas.7bm.co:8073/admin/documents',
baseUrl: 'http://172.16.0.78:8073', // FastAPI后端(包含/dify代理)
documentUrl: 'http://172.16.0.78:8073/docauditai/',
uploadUrl: 'http://172.16.0.78:8073/admin/documents',
collaboraUrl: 'http://172.16.0.81:9980',
appUrl: 'http://172.16.0.78:51703',
oauth: {
serverUrl: 'http://10.79.112.85', // IDaaS服务器地址
clientId: 'none',
@@ -116,12 +125,14 @@ const configs: Record<string, ApiConfig> = {
appId: 'idaasoauth2' // 应用ID,用于登出
}
},
// 测试环境
testing: {
baseUrl: 'http://nas.7bm.co:8873', // FastAPI后端(包含/dify代理)
documentUrl: 'http://nas.7bm.co:8873/docauditai/',
uploadUrl: 'http://nas.7bm.co:8873/admin/documents',
collaboraUrl: 'http://10.79.97.17:9980',
appUrl: 'http://10.79.97.17:51703',
oauth: {
serverUrl: 'http://10.79.112.85', // IDaaS服务器地址
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
@@ -130,7 +141,7 @@ const configs: Record<string, ApiConfig> = {
appId: 'idaasoauth2' // 应用ID,用于登出
}
},
// 生产环境
production: {
baseUrl: 'http://10.79.97.17:8000', // FastAPI后端(包含/dify代理)
@@ -138,6 +149,8 @@ const configs: Record<string, ApiConfig> = {
documentUrl: 'http://10.76.244.156:9000/docauditai/',
// 文件上传
uploadUrl: 'http://10.79.97.17:8000/admin/documents',
collaboraUrl: 'http://10.79.97.17:9980',
appUrl: 'http://10.79.97.17:51703',
oauth: {
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
serverUrl: 'http://10.79.112.85', // IDaaS服务器地址(测试)
@@ -149,12 +162,14 @@ const configs: Record<string, ApiConfig> = {
appId: 'idaasoauth2' // 应用ID,用于登出
}
},
// 备用配置 (可以根据需要添加更多环境)
staging: {
baseUrl: 'http://172.16.0.119:9000/admin', // FastAPI后端(包含/dify代理)
documentUrl: 'http://nas.7bm.co:9000/docauditai/',
uploadUrl: 'http://172.16.0.119:8000/admin/documents/upload',
collaboraUrl: 'http://10.79.97.17:9980',
appUrl: 'http://172.16.0.119:3000',
oauth: {
serverUrl: 'http://10.79.112.85', // IDaaS服务器地址
clientId: 'none', // 需要替换为实际的Client ID
@@ -177,18 +192,18 @@ const getCurrentEnvironment = (): string => {
});
return nodeEnv || 'development';
}
// 客户端:优先使用NEXT_PUBLIC_前缀的环境变量
const nextPublicNodeEnv = process.env.NEXT_PUBLIC_NODE_ENV;
const nodeEnv = process.env.NODE_ENV;
const result = nextPublicNodeEnv || nodeEnv || 'development';
console.log('🔧 客户端环境检测:', {
NEXT_PUBLIC_NODE_ENV: nextPublicNodeEnv,
NODE_ENV: nodeEnv,
result: result
});
return result;
};
@@ -220,7 +235,7 @@ const getCurrentPort = (): string => {
if (typeof window !== 'undefined') {
windowPort = window.location.port || '';
}
// 在服务器端,优先使用运行时端口检测
if (typeof window === 'undefined') {
const runtimePort = getRuntimePort();
@@ -229,16 +244,16 @@ const getCurrentPort = (): string => {
return runtimePort;
}
}
// 优先使用环境变量中的端口配置
const nextPublicApiPortConfig = process.env.NEXT_PUBLIC_API_PORT_CONFIG;
const nextPublicPort = process.env.NEXT_PUBLIC_PORT;
const apiPortConfig = process.env.API_PORT_CONFIG;
const portEnv = process.env.PORT;
// 优先级:windowPort > NEXT_PUBLIC_API_PORT_CONFIG > NEXT_PUBLIC_PORT > API_PORT_CONFIG > PORT环境变量
const result = windowPort || nextPublicApiPortConfig || nextPublicPort || apiPortConfig || portEnv || '';
console.log('🔧 端口检测:', {
windowPort: windowPort,
NEXT_PUBLIC_API_PORT_CONFIG: nextPublicApiPortConfig,
@@ -247,7 +262,7 @@ const getCurrentPort = (): string => {
PORT: portEnv,
result: result
});
return result;
};
@@ -259,7 +274,7 @@ const getRuntimePort = (): string => {
if (typeof window !== 'undefined') {
return ''; // 客户端不执行此逻辑
}
// 尝试从进程参数中获取端口
const args = process.argv;
for (let i = 0; i < args.length; i++) {
@@ -270,7 +285,7 @@ const getRuntimePort = (): string => {
return args[i].split('=')[1];
}
}
// 从环境变量获取
return process.env.PORT || '';
};
@@ -282,17 +297,17 @@ const getRuntimePort = (): string => {
const getCurrentConfig = (): ApiConfig => {
const env = getCurrentEnvironment();
const port = getCurrentPort();
console.log('🔧 配置调试信息:', {
environment: env,
port: port,
hasPortConfig: !!(port && portConfigs[port]),
portConfig: port ? portConfigs[port] : null
});
// 获取基础配置
let defaultConfig = configs[env] || configs.development;
// 如果有端口特定配置,则合并配置
if (port && portConfigs[port]) {
console.log(`🔧 使用端口特定配置: ${port}`);
@@ -309,17 +324,17 @@ const getCurrentConfig = (): ApiConfig => {
} else {
console.log(`🔧 使用环境配置: ${env}`, defaultConfig);
}
// 只有在明确设置了环境变量的情况下才覆盖配置
const hasEnvOverrides = process.env.NEXT_PUBLIC_API_BASE_URL ||
process.env.NEXT_PUBLIC_DOCUMENT_URL ||
process.env.NEXT_PUBLIC_UPLOAD_URL;
const hasEnvOverrides = process.env.NEXT_PUBLIC_API_BASE_URL ||
process.env.NEXT_PUBLIC_DOCUMENT_URL ||
process.env.NEXT_PUBLIC_UPLOAD_URL;
if (hasEnvOverrides) {
console.log('🔧 检测到环境变量覆盖,使用环境变量配置');
return getConfigFromEnv(defaultConfig);
}
console.log('🔧 最终配置:', defaultConfig);
return defaultConfig;
};
@@ -332,6 +347,8 @@ export const {
baseUrl: API_BASE_URL,
documentUrl: DOCUMENT_URL,
uploadUrl: UPLOAD_URL,
collaboraUrl: COLLABORA_URL,
appUrl: APP_URL,
oauth: OAUTH_CONFIG
} = apiConfig;