feat: 初步完成评查详情页面的work文档和pdf文档的加载的页面三栏设计的重构。
This commit is contained in:
+10
-5
@@ -139,16 +139,21 @@ function isDynamicIdSegment(segment: string): boolean {
|
||||
* @returns true 表示允许访问,false 表示拒绝访问
|
||||
*/
|
||||
function isPathAllowed(pathname: string, allowedPaths: string[]): boolean {
|
||||
// 1. 精确匹配
|
||||
if (allowedPaths.includes(pathname)) {
|
||||
// --- 开发测试 START:reviewsTest 复用 reviews 的权限(测试完后 git checkout app/root.tsx 还原)---
|
||||
const testPath = pathname.replace(/^\/reviewsTest/, '/reviews');
|
||||
const checkPath = testPath !== pathname ? testPath : pathname;
|
||||
// --- 开发测试 END ---
|
||||
|
||||
// 1. 精确匹配(原版用 pathname,测试期间用 checkPath)
|
||||
if (allowedPaths.includes(checkPath)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 2. 动态路由匹配(只允许看起来像ID的子路径)
|
||||
for (const allowedPath of allowedPaths) {
|
||||
if (pathname.startsWith(allowedPath + '/')) {
|
||||
if (checkPath.startsWith(allowedPath + '/')) {
|
||||
// 提取子路径部分(例如:'/documents/123' -> '123')
|
||||
const subPath = pathname.substring(allowedPath.length + 1);
|
||||
const subPath = checkPath.substring(allowedPath.length + 1);
|
||||
|
||||
// 支持多级嵌套路由(例如:/documents/123/edit)
|
||||
const segments = subPath.split('/');
|
||||
@@ -166,7 +171,7 @@ function isPathAllowed(pathname: string, allowedPaths: string[]): boolean {
|
||||
}
|
||||
|
||||
// 3. 根路径特殊处理(仅根路径 '/' 对所有已登录用户开放)
|
||||
if (pathname === '/') {
|
||||
if (checkPath === '/') {
|
||||
return true; // 根路径重定向到首页,始终允许
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user