feat(filelib): 老师端左栏导航:回收站 + 最近打开(ADR-0031)

- 回收站:listBin(祖先全活跃的已删顶点;管理员/直连 MANAGE 可见)、
  restore(与 D15 对称只清本节点,落审计)、purge(仅管理员,pathIds 枚举
  子树按深度降序分批硬删,绕过 self-FK RESTRICT)
- 最近打开:FileLibRecentVisit 表(filePath='' 兜底 PG 唯一索引),客户端
  成功打开后上报(VIEW 门禁,upsert 刷新),列表 20 条,D8/D15 可见性过滤
- 前端:/app 左栏(文件库/最近打开/回收站);RecentView/BinView;
  GridLibraryView 埋点 + navTarget 跳转(breadcrumb 建栈,role 已捎带)
- 测试:filelib-nav 集成 4 例;全套 79 例绿
This commit is contained in:
ymy
2026-07-31 13:27:04 +08:00
parent 04fa383286
commit d072e9ec1e
17 changed files with 998 additions and 17 deletions
@@ -0,0 +1,65 @@
-- DropIndex
DROP INDEX "ProjectSearchDocument_normalizedBreadcrumb_trgm_idx";
-- DropIndex
DROP INDEX "ProjectSearchDocument_normalizedCode_trgm_idx";
-- DropIndex
DROP INDEX "ProjectSearchDocument_normalizedName_trgm_idx";
-- DropIndex
DROP INDEX "ProjectSearchDocument_normalizedSearchText_trgm_idx";
-- DropIndex
DROP INDEX "Team_archivedAt_idx";
-- AlterTable
ALTER TABLE "ExternalDirectoryConnection" ALTER COLUMN "updatedAt" DROP DEFAULT;
-- AlterTable
ALTER TABLE "Organization" ALTER COLUMN "updatedAt" DROP DEFAULT;
-- AlterTable
ALTER TABLE "ProjectSearchDocument" ALTER COLUMN "updatedAt" DROP DEFAULT;
-- CreateTable
CREATE TABLE "FileLibRecentVisit" (
"id" TEXT NOT NULL,
"organizationId" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"nodeId" TEXT NOT NULL,
"filePath" TEXT NOT NULL DEFAULT '',
"openedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "FileLibRecentVisit_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "FileLibRecentVisit_organizationId_userId_openedAt_idx" ON "FileLibRecentVisit"("organizationId", "userId", "openedAt");
-- CreateIndex
CREATE UNIQUE INDEX "FileLibRecentVisit_organizationId_userId_nodeId_filePath_key" ON "FileLibRecentVisit"("organizationId", "userId", "nodeId", "filePath");
-- RenameForeignKey
ALTER TABLE "OrganizationFeishuApplicationConnection" RENAME CONSTRAINT "OrganizationFeishuApplicationConnection_activeSecretVersionId_f" TO "OrganizationFeishuApplicationConnection_activeSecretVersio_fkey";
-- RenameIndex
ALTER INDEX "ExternalPrincipalMembership_principalType_principalId_revokedAt" RENAME TO "ExternalPrincipalMembership_principalType_principalId_revok_idx";
-- RenameIndex
ALTER INDEX "ExternalPrincipalMembership_userId_principalType_principalId_co" RENAME TO "ExternalPrincipalMembership_userId_principalType_principalI_key";
-- RenameIndex
ALTER INDEX "OrganizationAgentRoleSkill_organizationId_agentRoleId_sortOrder" RENAME TO "OrganizationAgentRoleSkill_organizationId_agentRoleId_sortO_idx";
-- RenameIndex
ALTER INDEX "OrganizationCapabilityConnection_organizationId_capabilityId_ke" RENAME TO "OrganizationCapabilityConnection_organizationId_capabilityI_key";
-- RenameIndex
ALTER INDEX "OrganizationFeishuApplicationConnection_activeSecretVersionId_k" RENAME TO "OrganizationFeishuApplicationConnection_activeSecretVersion_key";
-- RenameIndex
ALTER INDEX "OrganizationFeishuApplicationConnection_appIdentityFingerprint_" RENAME TO "OrganizationFeishuApplicationConnection_appIdentityFingerpr_key";
-- RenameIndex
ALTER INDEX "TeamExternalBinding_teamId_principalType_principalId_revokedAt_" RENAME TO "TeamExternalBinding_teamId_principalType_principalId_revoke_key";
+15
View File
@@ -1110,3 +1110,18 @@ model FileLibExportJob {
@@index([organizationId, status])
}
/// ADR-0031:最近打开。客户端在成功打开后上报;filePath="" 表示节点本身
/// (文件夹/项目),非空表示项目内文件预览(PG 唯一索引视 NULL 互不相同,
/// 故用空串而非 null)。名称读取时 join FileLibNode 实时取,不做冗余。
model FileLibRecentVisit {
id String @id @default(cuid())
organizationId String
userId String
nodeId String
filePath String @default("")
openedAt DateTime
@@unique([organizationId, userId, nodeId, filePath])
@@index([organizationId, userId, openedAt])
}