文档列表documents添加用户id的限制,添加通过统一认证之后数据库中用户数据的添加和角色的添加,添加Sidebar菜单通过数据库请求获取

This commit is contained in:
2025-07-20 21:49:40 +08:00
parent e4ce41cebe
commit d8f3d98c70
17 changed files with 1630 additions and 199 deletions
+10
View File
@@ -35,6 +35,11 @@ export const meta: MetaFunction = () => {
// 数据加载器
export const loader = async ({ request }: LoaderFunctionArgs) => {
// 获取用户会话信息
const { getUserSession } = await import("~/api/login/auth.server");
const { userInfo } = await getUserSession(request);
console.log(userInfo);
// 获取URL查询参数,只保留必要的分页参数
const url = new URL(request.url);
const page = parseInt(url.searchParams.get("page") || "1", 10);
@@ -55,6 +60,7 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
page,
pageSize,
documentTypeOptions,
userInfo, // 传递用户信息到客户端
initialLoad: true // 标记这是初始加载
});
};
@@ -195,6 +201,9 @@ export default function DocumentsIndex() {
loadingBarService.show();
try {
// 从loader data中获取用户ID
const userId = loaderData.userInfo?.user_id?.toString();
// 构建搜索参数
const searchParams = {
name: search || undefined,
@@ -205,6 +214,7 @@ export default function DocumentsIndex() {
dateFrom: dateFrom || undefined,
dateTo: dateTo || undefined,
reviewType: storedReviewType || undefined,
userId: userId, // 添加用户ID筛选
page: currentPage,
pageSize
};