fix:1. 优化角色权限管理的加载中样式。
2. root添加限制51707端口的路由访问,只允许访问交叉评查。 3. 开启省局端口限制的配置。
This commit is contained in:
+22
-15
@@ -34,12 +34,19 @@ import RouteChangeLoader from "~/components/ui/RouteChangeLoader";
|
||||
|
||||
|
||||
// 导入认证相关的服务器端功能(仅在服务器端使用)
|
||||
import {
|
||||
// getUserSession,
|
||||
import {
|
||||
// getUserSession,
|
||||
logout,
|
||||
type UserRole
|
||||
type UserRole
|
||||
} from "~/api/login/auth.server";
|
||||
|
||||
// 导入交叉评查专属模式配置
|
||||
import {
|
||||
CROSS_CHECKING_ONLY_MODE,
|
||||
CROSS_CHECKING_ONLY_PORT,
|
||||
getCurrentPort
|
||||
} from "~/config/api-config";
|
||||
|
||||
// 定义需要高级权限的路径
|
||||
// export const developerOnlyPaths = [
|
||||
// '/settings',
|
||||
@@ -289,20 +296,20 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
// 如果执行到这里,说明已通过认证或是公共路径
|
||||
}
|
||||
|
||||
// 检查51707端口访问控制
|
||||
const currentPort = process.env.PORT || process.env.API_PORT_CONFIG;
|
||||
const runtimePort = url.port || currentPort;
|
||||
const isPort51707 = currentPort === '51707' || runtimePort === '51707';
|
||||
// 检查交叉评查专属模式访问控制
|
||||
// 当 CROSS_CHECKING_ONLY_MODE=true 且端口为指定端口时,只允许访问 /cross-checking 相关路由
|
||||
const currentPort = getCurrentPort();
|
||||
const isCrossCheckingOnlyMode = CROSS_CHECKING_ONLY_MODE && currentPort === CROSS_CHECKING_ONLY_PORT;
|
||||
|
||||
if (isPort51707 && !isPublicPath) {
|
||||
// 51707端口(省局)只允许访问交叉评查相关路径和首页
|
||||
const allowedPaths = ['/', '/cross-checking','/chat-with-llm'];
|
||||
const isAllowedPath = allowedPaths.some(path => pathname === path) ||
|
||||
pathname.startsWith('/cross-checking/') ||
|
||||
pathname.startsWith('/chat-with-llm/');
|
||||
if (isCrossCheckingOnlyMode && !isPublicPath) {
|
||||
// 交叉评查专属模式:只允许访问首页和交叉评查相关路径
|
||||
const crossCheckingAllowedPaths = ['/', '/cross-checking'];
|
||||
const isCrossCheckingAllowedPath = crossCheckingAllowedPaths.some(path => pathname === path) ||
|
||||
pathname.startsWith('/cross-checking/');
|
||||
|
||||
if (!isAllowedPath) {
|
||||
return redirect("/cross-checking");
|
||||
if (!isCrossCheckingAllowedPath) {
|
||||
console.warn(`⚠️ [Root Loader] 交叉评查专属模式:拒绝访问 ${pathname}`);
|
||||
throw new Response("交叉评查专属模式下无权访问此页面", { status: 403 });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user