add
This commit is contained in:
parent
f363117c1d
commit
c740898a44
|
@ -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: <CoursesPage></CoursesPage>
|
||||
element: <CoursesPage></CoursesPage>,
|
||||
},
|
||||
{
|
||||
path: "my-courses"
|
||||
path: "my-courses",
|
||||
},
|
||||
{
|
||||
path: "profiles"
|
||||
path: "profiles",
|
||||
},
|
||||
{
|
||||
path: "courses",
|
||||
|
@ -101,23 +102,28 @@ export const routes: CustomRouteObject[] = [
|
|||
{
|
||||
path: ":id?/editor",
|
||||
element: <CourseEditorLayout></CourseEditorLayout>,
|
||||
children: [{
|
||||
children: [
|
||||
{
|
||||
index: true,
|
||||
element: <CourseBasicForm></CourseBasicForm>
|
||||
element: <CourseBasicForm></CourseBasicForm>,
|
||||
},
|
||||
{
|
||||
path: 'goal',
|
||||
element: <CourseGoalForm></CourseGoalForm>
|
||||
path: "goal",
|
||||
element: <CourseGoalForm></CourseGoalForm>,
|
||||
},
|
||||
{
|
||||
path: 'content',
|
||||
element: <CourseContentForm></CourseContentForm>
|
||||
path: "content",
|
||||
element: (
|
||||
<CourseContentForm></CourseContentForm>
|
||||
),
|
||||
},
|
||||
{
|
||||
path: 'setting',
|
||||
element: <CourseSettingForm></CourseSettingForm>
|
||||
}
|
||||
]
|
||||
path: "setting",
|
||||
element: (
|
||||
<CourseSettingForm></CourseSettingForm>
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: ":id?/detail", // 使用 ? 表示 id 参数是可选的
|
||||
|
@ -125,115 +131,7 @@ export const routes: CustomRouteObject[] = [
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "admin",
|
||||
children: [
|
||||
{
|
||||
path: "base-setting",
|
||||
element: (
|
||||
<WithAuth
|
||||
options={{
|
||||
orPermissions: [
|
||||
RolePerms.MANAGE_BASE_SETTING,
|
||||
],
|
||||
}}>
|
||||
<BaseSettingPage></BaseSettingPage>
|
||||
</WithAuth>
|
||||
),
|
||||
handle: {
|
||||
crumb() {
|
||||
return (
|
||||
<Link to={"/admin/base-setting"}>
|
||||
基本设置
|
||||
</Link>
|
||||
);
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "department",
|
||||
breadcrumb: "单位管理",
|
||||
element: (
|
||||
<WithAuth
|
||||
options={{
|
||||
orPermissions: [RolePerms.MANAGE_ANY_DEPT],
|
||||
}}>
|
||||
<DepartmentAdminPage></DepartmentAdminPage>
|
||||
</WithAuth>
|
||||
),
|
||||
handle: {
|
||||
crumb() {
|
||||
return (
|
||||
<Link to={"/admin/department"}>
|
||||
组织架构
|
||||
</Link>
|
||||
);
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "staff",
|
||||
element: (
|
||||
<WithAuth
|
||||
options={{
|
||||
orPermissions: [
|
||||
RolePerms.MANAGE_ANY_STAFF,
|
||||
RolePerms.MANAGE_DOM_STAFF,
|
||||
],
|
||||
}}>
|
||||
<StaffAdminPage></StaffAdminPage>
|
||||
</WithAuth>
|
||||
),
|
||||
handle: {
|
||||
crumb() {
|
||||
return (
|
||||
<Link to={"/admin/staff"}>用户管理</Link>
|
||||
);
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "term",
|
||||
breadcrumb: "分类配置",
|
||||
element: (
|
||||
<WithAuth
|
||||
options={{
|
||||
orPermissions: [
|
||||
RolePerms.MANAGE_ANY_TERM,
|
||||
// RolePerms.MANAGE_DOM_TERM
|
||||
],
|
||||
}}>
|
||||
<TermAdminPage></TermAdminPage>
|
||||
</WithAuth>
|
||||
),
|
||||
handle: {
|
||||
crumb() {
|
||||
return <Link to={"/admin/term"}>分类配置</Link>;
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "role",
|
||||
breadcrumb: "角色管理",
|
||||
element: (
|
||||
<WithAuth
|
||||
options={{
|
||||
orPermissions: [
|
||||
RolePerms.MANAGE_ANY_ROLE,
|
||||
RolePerms.MANAGE_DOM_ROLE,
|
||||
],
|
||||
}}>
|
||||
<RoleAdminPage></RoleAdminPage>
|
||||
</WithAuth>
|
||||
),
|
||||
handle: {
|
||||
crumb() {
|
||||
return <Link to={"/admin/role"}>角色管理</Link>;
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
adminRoute,
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -10,8 +10,8 @@ export enum PostType {
|
|||
SECTION = "section",
|
||||
}
|
||||
export enum LectureType {
|
||||
VIDEO = 'video',
|
||||
ARTICLE ='article'
|
||||
VIDEO = "video",
|
||||
ARTICLE = "article",
|
||||
}
|
||||
export enum TaxonomySlug {
|
||||
CATEGORY = "category",
|
||||
|
|
Loading…
Reference in New Issue