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 HomePage from "../app/main/home/page";
|
||||||
import { CourseDetailPage } from "../app/main/course/detail/page";
|
import { CourseDetailPage } from "../app/main/course/detail/page";
|
||||||
import { CourseBasicForm } from "../components/models/course/editor/form/CourseBasicForm";
|
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 { CourseGoalForm } from "../components/models/course/editor/form/CourseGoalForm";
|
||||||
import CourseSettingForm from "../components/models/course/editor/form/CourseSettingForm";
|
import CourseSettingForm from "../components/models/course/editor/form/CourseSettingForm";
|
||||||
import CourseEditorLayout from "../components/models/course/editor/layout/CourseEditorLayout";
|
import CourseEditorLayout from "../components/models/course/editor/layout/CourseEditorLayout";
|
||||||
import { MainLayout } from "../app/main/layout/MainLayout";
|
import { MainLayout } from "../app/main/layout/MainLayout";
|
||||||
import CoursesPage from "../app/main/courses/page";
|
import CoursesPage from "../app/main/courses/page";
|
||||||
|
import { adminRoute } from "./admin-route";
|
||||||
|
|
||||||
interface CustomIndexRouteObject extends IndexRouteObject {
|
interface CustomIndexRouteObject extends IndexRouteObject {
|
||||||
name?: string;
|
name?: string;
|
||||||
|
@ -64,13 +65,13 @@ export const routes: CustomRouteObject[] = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "courses",
|
path: "courses",
|
||||||
element: <CoursesPage></CoursesPage>
|
element: <CoursesPage></CoursesPage>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "my-courses"
|
path: "my-courses",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "profiles"
|
path: "profiles",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "courses",
|
path: "courses",
|
||||||
|
@ -101,23 +102,28 @@ export const routes: CustomRouteObject[] = [
|
||||||
{
|
{
|
||||||
path: ":id?/editor",
|
path: ":id?/editor",
|
||||||
element: <CourseEditorLayout></CourseEditorLayout>,
|
element: <CourseEditorLayout></CourseEditorLayout>,
|
||||||
children: [{
|
children: [
|
||||||
|
{
|
||||||
index: true,
|
index: true,
|
||||||
element: <CourseBasicForm></CourseBasicForm>
|
element: <CourseBasicForm></CourseBasicForm>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'goal',
|
path: "goal",
|
||||||
element: <CourseGoalForm></CourseGoalForm>
|
element: <CourseGoalForm></CourseGoalForm>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'content',
|
path: "content",
|
||||||
element: <CourseContentForm></CourseContentForm>
|
element: (
|
||||||
|
<CourseContentForm></CourseContentForm>
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'setting',
|
path: "setting",
|
||||||
element: <CourseSettingForm></CourseSettingForm>
|
element: (
|
||||||
}
|
<CourseSettingForm></CourseSettingForm>
|
||||||
]
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ":id?/detail", // 使用 ? 表示 id 参数是可选的
|
path: ":id?/detail", // 使用 ? 表示 id 参数是可选的
|
||||||
|
@ -125,115 +131,7 @@ export const routes: CustomRouteObject[] = [
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
adminRoute,
|
||||||
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>;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { useQueryClient } from "@tanstack/react-query";
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
import { getQueryKey } from "@trpc/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 { api } from "../trpc";
|
||||||
import { findQueryData, getCacheDataFromQuery } from "../utils";
|
import { findQueryData, getCacheDataFromQuery } from "../utils";
|
||||||
import { CrudOperation, emitDataChange } from "../../event";
|
import { CrudOperation, emitDataChange } from "../../event";
|
||||||
|
@ -10,34 +10,45 @@ export function useDepartment() {
|
||||||
const create = api.department.create.useMutation({
|
const create = api.department.create.useMutation({
|
||||||
onSuccess: (result) => {
|
onSuccess: (result) => {
|
||||||
queryClient.invalidateQueries({ queryKey });
|
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({
|
const update = api.department.update.useMutation({
|
||||||
onSuccess: (result) => {
|
onSuccess: (result) => {
|
||||||
|
|
||||||
queryClient.invalidateQueries({ queryKey });
|
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({
|
const softDeleteByIds = api.department.softDeleteByIds.useMutation({
|
||||||
onSuccess: (result) => {
|
onSuccess: (result) => {
|
||||||
queryClient.invalidateQueries({ queryKey });
|
queryClient.invalidateQueries({ queryKey });
|
||||||
emitDataChange(ObjectType.DEPARTMENT, result as any, CrudOperation.DELETED)
|
emitDataChange(
|
||||||
|
ObjectType.DEPARTMENT,
|
||||||
|
result as any,
|
||||||
|
CrudOperation.DELETED
|
||||||
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const buildTree = (
|
const buildTree = (
|
||||||
data: DepartmentDto[],
|
data: DepartmentDto[],
|
||||||
parentId: string | null = null
|
parentId: string | null = null
|
||||||
): DataNode[] => {
|
): TreeDataNode[] => {
|
||||||
return data
|
return data
|
||||||
.filter((department) => department.parentId === parentId)
|
.filter((department) => department.parentId === parentId)
|
||||||
.sort((a, b) => a.order - b.order)
|
.sort((a, b) => a.order - b.order)
|
||||||
.map((department) => {
|
.map((department) => {
|
||||||
const node: DataNode = {
|
const node: TreeDataNode = {
|
||||||
title: department.name,
|
title: department.name,
|
||||||
key: department.id,
|
key: department.id,
|
||||||
value: department.id,
|
value: department.id,
|
||||||
|
@ -58,6 +69,6 @@ export function useDepartment() {
|
||||||
update,
|
update,
|
||||||
create,
|
create,
|
||||||
// getTreeData,
|
// getTreeData,
|
||||||
getDept
|
getDept,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { getQueryKey } from "@trpc/react-query";
|
import { getQueryKey } from "@trpc/react-query";
|
||||||
import { useQueryClient } from "@tanstack/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 { api } from "../trpc";
|
||||||
import { findQueryData } from "../utils";
|
import { findQueryData } from "../utils";
|
||||||
import { CrudOperation, emitDataChange } from "../../event";
|
import { CrudOperation, emitDataChange } from "../../event";
|
||||||
|
@ -37,12 +37,12 @@ export function useTerm() {
|
||||||
const buildTree = (
|
const buildTree = (
|
||||||
data: TermDto[],
|
data: TermDto[],
|
||||||
parentId: string | null = null
|
parentId: string | null = null
|
||||||
): DataNode[] => {
|
): TreeDataNode[] => {
|
||||||
return data
|
return data
|
||||||
.filter((term) => term.parentId === parentId)
|
.filter((term) => term.parentId === parentId)
|
||||||
.sort((a, b) => a.order - b.order)
|
.sort((a, b) => a.order - b.order)
|
||||||
.map((term) => {
|
.map((term) => {
|
||||||
const node: DataNode = {
|
const node: TreeDataNode = {
|
||||||
title: term.name,
|
title: term.name,
|
||||||
key: term.id,
|
key: term.id,
|
||||||
value: term.id,
|
value: term.id,
|
||||||
|
|
|
@ -59,10 +59,10 @@ export const InitTaxonomies: { name: string; slug: string }[] = [
|
||||||
name: "难度等级",
|
name: "难度等级",
|
||||||
slug: TaxonomySlug.LEVEL,
|
slug: TaxonomySlug.LEVEL,
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
name: "研判单元",
|
// name: "研判单元",
|
||||||
slug: TaxonomySlug.UNIT,
|
// slug: TaxonomySlug.UNIT,
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
name: "标签",
|
name: "标签",
|
||||||
slug: TaxonomySlug.TAG,
|
slug: TaxonomySlug.TAG,
|
||||||
|
|
|
@ -10,8 +10,8 @@ export enum PostType {
|
||||||
SECTION = "section",
|
SECTION = "section",
|
||||||
}
|
}
|
||||||
export enum LectureType {
|
export enum LectureType {
|
||||||
VIDEO = 'video',
|
VIDEO = "video",
|
||||||
ARTICLE ='article'
|
ARTICLE = "article",
|
||||||
}
|
}
|
||||||
export enum TaxonomySlug {
|
export enum TaxonomySlug {
|
||||||
CATEGORY = "category",
|
CATEGORY = "category",
|
||||||
|
|
Loading…
Reference in New Issue