完全移除模块级权限系统,迁移至接口级权限

后端:
- 删除 StudyRolePermission 模型和 project_permissions API 文件
- 重写 project_permissions.py core,移除所有模块级权限函数
- 重写 permission_cache.py,移除模块级权限缓存逻辑
- 新增权限模板功能(PermissionTemplate 模型、API、服务层)
- 新增 permission_templates 数据库迁移
- 迁移 8 个模块(attachments、audit_logs、dashboard、faqs、
  faq_categories、fees_attachments、knowledge_notes、
  material_equipments、overview、subject_histories、subject_pds)
  至接口级权限检查
- 删除所有模块级权限相关测试文件,新增权限模板测试

前端:
- 删除 ProjectPermissions.vue 和 ProjectPermissionsModule.vue
- 重写 projectRoutePermissions.ts,改为基于接口级权限格式
- 更新 store/study.ts、router/index.ts、AuditLogs.vue、Projects.vue
  中的权限 API 调用,从 fetchProjectRolePermissions 改为
  fetchApiEndpointPermissions
- 清理 types/api.ts 中的旧模块级权限类型定义
- 新增 PermissionTemplateSelector.vue 组件
- 更新权限管理页面,移除模块级权限 tab

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Cheng Zhou
2026-05-15 09:07:43 +08:00
parent 3b1bdc2070
commit 20ce6bccef
55 changed files with 1971 additions and 3030 deletions
@@ -1,4 +1,4 @@
import { describe, it, expect, beforeEach, vi } from "vitest";
import { describe, it, expect, beforeEach } from "vitest";
import { mount } from "@vue/test-utils";
import ApiPermissions from "@/views/admin/ApiPermissions.vue";
import { createPinia, setActivePinia } from "pinia";
@@ -12,7 +12,6 @@ describe("ApiPermissions.vue", () => {
const wrapper = mount(ApiPermissions, {
global: {
stubs: {
ProjectPermissionsModule: true,
ApiEndpointPermissions: true,
PermissionMonitoring: true,
},
@@ -23,11 +22,10 @@ describe("ApiPermissions.vue", () => {
expect(wrapper.find(".permission-title h2").text()).toBe("权限管理");
});
it("renders three tabs", () => {
it("renders tabs", () => {
const wrapper = mount(ApiPermissions, {
global: {
stubs: {
ProjectPermissionsModule: true,
ApiEndpointPermissions: true,
PermissionMonitoring: true,
},
@@ -35,14 +33,13 @@ describe("ApiPermissions.vue", () => {
});
const tabs = wrapper.findAll(".el-tabs__nav-item");
expect(tabs.length).toBeGreaterThanOrEqual(3);
expect(tabs.length).toBeGreaterThanOrEqual(2);
});
it("has save button disabled when not dirty", () => {
const wrapper = mount(ApiPermissions, {
global: {
stubs: {
ProjectPermissionsModule: true,
ApiEndpointPermissions: true,
PermissionMonitoring: true,
},