diff --git a/apps/web/src/components/models/course/editor/context/CourseEditorContext.tsx b/apps/web/src/components/models/course/editor/context/CourseEditorContext.tsx
index 6b61854..0c8becc 100755
--- a/apps/web/src/components/models/course/editor/context/CourseEditorContext.tsx
+++ b/apps/web/src/components/models/course/editor/context/CourseEditorContext.tsx
@@ -1,6 +1,7 @@
import { createContext, useContext, ReactNode, useEffect } from "react";
import { Form, FormInstance, message } from "antd";
import {
+ courseDetailSelect,
CourseDto,
CourseMeta,
CourseStatus,
@@ -48,9 +49,7 @@ export function CourseFormProvider({
const { data: course }: { data: CourseDto } = api.post.findFirst.useQuery(
{
where: { id: editId },
- include: {
- terms: true,
- },
+ select: courseDetailSelect,
},
{ enabled: Boolean(editId) }
);
@@ -65,10 +64,12 @@ export function CourseFormProvider({
useEffect(() => {
if (course) {
+ const deptIds = (course?.depts || [])?.map((dept) => dept.id);
const formData = {
title: course.title,
subTitle: course.subTitle,
content: course.content,
+ deptIds: deptIds,
meta: {
thumbnail: course?.meta?.thumbnail,
},
@@ -91,7 +92,10 @@ export function CourseFormProvider({
const formattedValues = {
...values,
meta: {
- thumbnail: values?.meta?.thumbnail,
+ ...((course?.meta as CourseMeta) || {}),
+ ...(values?.meta?.thumbnail !== undefined && {
+ thumbnail: values?.meta?.thumbnail,
+ }),
},
terms: {
connect: termIds.map((id) => ({ id })), // 转换成 connect 格式
@@ -106,12 +110,9 @@ export function CourseFormProvider({
});
delete formattedValues.sections;
delete formattedValues.deptIds;
- if (course) {
- formattedValues.meta = {
- ...(course?.meta as CourseMeta),
- thumbnail: values?.meta?.thumbnail,
- };
- }
+
+ console.log(course.meta);
+ console.log(formattedValues?.meta);
try {
if (editId) {
const result = await update.mutateAsync({
diff --git a/apps/web/src/components/models/course/editor/form/CourseContentForm/SortableSection.tsx b/apps/web/src/components/models/course/editor/form/CourseContentForm/SortableSection.tsx
index aea9b29..bf6af5b 100755
--- a/apps/web/src/components/models/course/editor/form/CourseContentForm/SortableSection.tsx
+++ b/apps/web/src/components/models/course/editor/form/CourseContentForm/SortableSection.tsx
@@ -69,6 +69,9 @@ export const SortableSection: React.FC
= ({
});
} else {
result = await update.mutateAsync({
+ where: {
+ id: field?.id,
+ },
data: {
title: values?.title,
},
diff --git a/apps/web/src/components/models/course/editor/layout/CourseEditorHeader.tsx b/apps/web/src/components/models/course/editor/layout/CourseEditorHeader.tsx
index 8c23fa7..a3197f8 100755
--- a/apps/web/src/components/models/course/editor/layout/CourseEditorHeader.tsx
+++ b/apps/web/src/components/models/course/editor/layout/CourseEditorHeader.tsx
@@ -4,6 +4,7 @@ import { useEffect } from "react";
import { useNavigate } from "react-router-dom";
import { CourseStatus, CourseStatusLabel } from "@nice/common";
import { useCourseEditor } from "../context/CourseEditorContext";
+import { useAuth } from "@web/src/providers/auth-provider";
const { Title } = Typography;
@@ -16,6 +17,8 @@ const courseStatusVariant: Record = {
export default function CourseEditorHeader() {
const navigate = useNavigate();
+ const { user, hasSomePermissions } = useAuth();
+
const { onSubmit, course, form } = useCourseEditor();
const handleSave = () => {
@@ -34,7 +37,13 @@ export default function CourseEditorHeader() {
}
- onClick={() => navigate(-1)}
+ onClick={() => {
+ if (course?.id) {
+ navigate(`/course/${course?.id}/detail`);
+ } else {
+ navigate("/");
+ }
+ }}
type="text"
/>
diff --git a/apps/web/src/routes/index.tsx b/apps/web/src/routes/index.tsx
index 7592489..9a60fd1 100755
--- a/apps/web/src/routes/index.tsx
+++ b/apps/web/src/routes/index.tsx
@@ -63,16 +63,6 @@ export const routes: CustomRouteObject[] = [
path: "courses",
element: ,
},
-
- {
- path: "profiles",
- },
-
- // // 课程预览页面
- // {
- // path: "coursePreview/:id?",
- // element: ,
- // },
],
},
{
@@ -103,12 +93,6 @@ export const routes: CustomRouteObject[] = [
),
},
- // {
- // path: "setting",
- // element: (
- //
- // ),
- // },
],
},
{
diff --git a/config/nginx/conf.d/web.conf b/config/nginx/conf.d/web.conf
index 67302b8..e0ac769 100755
--- a/config/nginx/conf.d/web.conf
+++ b/config/nginx/conf.d/web.conf
@@ -100,7 +100,7 @@ server {
# 仅供内部使用
internal;
# 代理到认证服务
- proxy_pass http://host.docker.internal:3000/auth/file;
+ proxy_pass http://host.docker.internal:/auth/file;
# 请求优化:不传递请求体
proxy_pass_request_body off;
diff --git a/packages/common/src/enum.ts b/packages/common/src/enum.ts
index 6264c9b..1bcd87c 100755
--- a/packages/common/src/enum.ts
+++ b/packages/common/src/enum.ts
@@ -8,6 +8,7 @@ export enum PostType {
COURSE = "couse",
SECTION = "section",
LECTURE = "lecture",
+ PATH = "path",
}
export enum LectureType {
VIDEO = "video",
@@ -100,7 +101,7 @@ export enum RolePerms {
}
export enum AppConfigSlug {
BASE_SETTING = "base_setting",
-
+
}
// 资源类型的枚举,定义了不同类型的资源,以字符串值表示
export enum ResourceType {
diff --git a/packages/mind-elixir-core b/packages/mind-elixir-core
deleted file mode 160000
index b911b4b..0000000
--- a/packages/mind-elixir-core
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit b911b4ba7629da9d6c622abe241fd25299baf1a5