diff --git a/apps/web/src/routes/index.tsx b/apps/web/src/routes/index.tsx index f55410b..03a60fb 100755 --- a/apps/web/src/routes/index.tsx +++ b/apps/web/src/routes/index.tsx @@ -18,12 +18,13 @@ import InstructorCoursesPage from "../app/main/courses/instructor/page"; import HomePage from "../app/main/home/page"; import { CourseDetailPage } from "../app/main/course/detail/page"; import { CourseBasicForm } from "../components/models/course/editor/form/CourseBasicForm"; -import CourseContentForm from "../components/models/course/editor/form/CourseContentForm"; +import CourseContentForm from "../components/models/course/editor/form/CourseContentForm/CourseContentForm"; import { CourseGoalForm } from "../components/models/course/editor/form/CourseGoalForm"; import CourseSettingForm from "../components/models/course/editor/form/CourseSettingForm"; import CourseEditorLayout from "../components/models/course/editor/layout/CourseEditorLayout"; import { MainLayout } from "../app/main/layout/MainLayout"; import CoursesPage from "../app/main/courses/page"; +import { adminRoute } from "./admin-route"; interface CustomIndexRouteObject extends IndexRouteObject { name?: string; @@ -64,13 +65,13 @@ export const routes: CustomRouteObject[] = [ }, { path: "courses", - element: + element: , }, { - path: "my-courses" + path: "my-courses", }, { - path: "profiles" + path: "profiles", }, { path: "courses", @@ -101,23 +102,28 @@ export const routes: CustomRouteObject[] = [ { path: ":id?/editor", element: , - children: [{ - index: true, - element: - }, - { - path: 'goal', - element: - }, - { - path: 'content', - element: - }, - { - path: 'setting', - element: - } - ] + children: [ + { + index: true, + element: , + }, + { + path: "goal", + element: , + }, + { + path: "content", + element: ( + + ), + }, + { + path: "setting", + element: ( + + ), + }, + ], }, { path: ":id?/detail", // 使用 ? 表示 id 参数是可选的 @@ -125,115 +131,7 @@ export const routes: CustomRouteObject[] = [ }, ], }, - { - path: "admin", - children: [ - { - path: "base-setting", - element: ( - - - - ), - handle: { - crumb() { - return ( - - 基本设置 - - ); - }, - }, - }, - { - path: "department", - breadcrumb: "单位管理", - element: ( - - - - ), - handle: { - crumb() { - return ( - - 组织架构 - - ); - }, - }, - }, - { - path: "staff", - element: ( - - - - ), - handle: { - crumb() { - return ( - 用户管理 - ); - }, - }, - }, - { - path: "term", - breadcrumb: "分类配置", - element: ( - - - - ), - handle: { - crumb() { - return 分类配置; - }, - }, - }, - { - path: "role", - breadcrumb: "角色管理", - element: ( - - - - ), - handle: { - crumb() { - return 角色管理; - }, - }, - }, - ], - }, + adminRoute, ], }, { diff --git a/packages/client/src/api/hooks/useDepartment.ts b/packages/client/src/api/hooks/useDepartment.ts index d12928b..9f0ab68 100755 --- a/packages/client/src/api/hooks/useDepartment.ts +++ b/packages/client/src/api/hooks/useDepartment.ts @@ -1,6 +1,6 @@ import { useQueryClient } from "@tanstack/react-query"; import { getQueryKey } from "@trpc/react-query"; -import { DataNode, DepartmentDto, ObjectType } from "@nice/common"; +import { DataNode, DepartmentDto, ObjectType, TreeDataNode } from "@nice/common"; import { api } from "../trpc"; import { findQueryData, getCacheDataFromQuery } from "../utils"; import { CrudOperation, emitDataChange } from "../../event"; @@ -10,34 +10,45 @@ export function useDepartment() { const create = api.department.create.useMutation({ onSuccess: (result) => { queryClient.invalidateQueries({ queryKey }); - emitDataChange(ObjectType.DEPARTMENT, result as any, CrudOperation.CREATED) + emitDataChange( + ObjectType.DEPARTMENT, + result as any, + CrudOperation.CREATED + ); }, }); const update = api.department.update.useMutation({ onSuccess: (result) => { - queryClient.invalidateQueries({ queryKey }); - emitDataChange(ObjectType.DEPARTMENT, result as any, CrudOperation.UPDATED) + emitDataChange( + ObjectType.DEPARTMENT, + result as any, + CrudOperation.UPDATED + ); }, }); const softDeleteByIds = api.department.softDeleteByIds.useMutation({ onSuccess: (result) => { queryClient.invalidateQueries({ queryKey }); - emitDataChange(ObjectType.DEPARTMENT, result as any, CrudOperation.DELETED) + emitDataChange( + ObjectType.DEPARTMENT, + result as any, + CrudOperation.DELETED + ); }, }); const buildTree = ( data: DepartmentDto[], parentId: string | null = null - ): DataNode[] => { + ): TreeDataNode[] => { return data .filter((department) => department.parentId === parentId) .sort((a, b) => a.order - b.order) .map((department) => { - const node: DataNode = { + const node: TreeDataNode = { title: department.name, key: department.id, value: department.id, @@ -58,6 +69,6 @@ export function useDepartment() { update, create, // getTreeData, - getDept + getDept, }; } diff --git a/packages/client/src/api/hooks/useTerm.ts b/packages/client/src/api/hooks/useTerm.ts index b32447c..542d437 100755 --- a/packages/client/src/api/hooks/useTerm.ts +++ b/packages/client/src/api/hooks/useTerm.ts @@ -1,6 +1,6 @@ import { getQueryKey } from "@trpc/react-query"; import { useQueryClient } from "@tanstack/react-query"; -import { DataNode, ObjectType, TermDto } from "@nice/common"; +import { DataNode, ObjectType, TermDto, TreeDataNode } from "@nice/common"; import { api } from "../trpc"; import { findQueryData } from "../utils"; import { CrudOperation, emitDataChange } from "../../event"; @@ -37,12 +37,12 @@ export function useTerm() { const buildTree = ( data: TermDto[], parentId: string | null = null - ): DataNode[] => { + ): TreeDataNode[] => { return data .filter((term) => term.parentId === parentId) .sort((a, b) => a.order - b.order) .map((term) => { - const node: DataNode = { + const node: TreeDataNode = { title: term.name, key: term.id, value: term.id, diff --git a/packages/common/src/constants.ts b/packages/common/src/constants.ts index 577731d..675ad6d 100755 --- a/packages/common/src/constants.ts +++ b/packages/common/src/constants.ts @@ -59,10 +59,10 @@ export const InitTaxonomies: { name: string; slug: string }[] = [ name: "难度等级", slug: TaxonomySlug.LEVEL, }, - { - name: "研判单元", - slug: TaxonomySlug.UNIT, - }, + // { + // name: "研判单元", + // slug: TaxonomySlug.UNIT, + // }, { name: "标签", slug: TaxonomySlug.TAG, diff --git a/packages/common/src/enum.ts b/packages/common/src/enum.ts index f21181b..c642ca9 100755 --- a/packages/common/src/enum.ts +++ b/packages/common/src/enum.ts @@ -9,9 +9,9 @@ export enum PostType { LECTURE = "lecture", SECTION = "section", } -export enum LectureType{ - VIDEO = 'video', - ARTICLE ='article' +export enum LectureType { + VIDEO = "video", + ARTICLE = "article", } export enum TaxonomySlug { CATEGORY = "category",