This commit is contained in:
ditiqi 2025-02-21 16:11:17 +08:00
commit 2769bac7f8
21 changed files with 195 additions and 194 deletions

View File

@ -21,7 +21,7 @@ export abstract class RowModelService {
// 添加更多需要引号的关键词
]);
protected logger = new Logger(this.tableName);
protected constructor(protected tableName: string) {}
protected constructor(protected tableName: string) { }
protected async getRowDto(row: any, staff?: UserProfile): Promise<any> {
return row;
}
@ -52,7 +52,7 @@ export abstract class RowModelService {
]);
SQL = await this.getRowsSqlWrapper(SQL, request, staff);
this.logger.debug('getrows', SQL);
// this.logger.debug('getrows', SQL);
const results: any[] = (await db?.$queryRawUnsafe(SQL)) || [];

View File

@ -21,7 +21,6 @@ export class GenDevService {
deptStaffRecord: Record<string, Staff[]> = {};
terms: Record<TaxonomySlug, Term[]> = {
[TaxonomySlug.CATEGORY]: [],
[TaxonomySlug.UNIT]: [],
[TaxonomySlug.TAG]: [],
[TaxonomySlug.LEVEL]: [],
};
@ -36,7 +35,7 @@ export class GenDevService {
private readonly departmentService: DepartmentService,
private readonly staffService: StaffService,
private readonly termService: TermService,
) {}
) { }
async genDataEvent() {
EventBus.emit('genDataEvent', { type: 'start' });
try {
@ -62,7 +61,7 @@ export class GenDevService {
const domains = this.depts.filter((item) => item.isDomain);
for (const domain of domains) {
await this.createTerms(domain, TaxonomySlug.CATEGORY, depth, count);
await this.createTerms(domain, TaxonomySlug.UNIT, depth, count);
// await this.createTerms(domain, TaxonomySlug.UNIT, depth, count);
}
}
const termCount = await db.term.count();

View File

@ -1,7 +1,5 @@
VITE_APP_TUS_URL=http://localhost:8080
VITE_APP_API_URL=http://localhost:3000
VITE_APP_SERVER_IP=192.168.252.239
VITE_APP_SERVER_PORT=3000
VITE_APP_UPLOAD_PORT=80
VITE_APP_FILE_PORT=80
VITE_APP_VERSION=0.3.0
VITE_APP_APP_NAME=MOOC

View File

@ -14,7 +14,6 @@ import { Toaster } from 'react-hot-toast';
dayjs.locale("zh-cn");
function App() {
return (
<>
<AuthProvider>

View File

@ -1,11 +1,41 @@
/**
* -
* 功能: 捕获React Router路由层级错误并展示可视化错误信息
* :
* -
* -
* -
*/
import { useRouteError } from "react-router-dom";
/**
*
* @核心功能
* @设计模式 UI展示
* @使用示例 React Router的RouterProvider中配置errorElement={<ErrorPage/>}
*/
export default function ErrorPage() {
// 使用React Router提供的Hook获取路由错误对象
// 类型定义为any以兼容React Router不同版本的类型差异
const error: any = useRouteError();
return <div className=" flex justify-center items-center pt-64 ">
<div className=" flex flex-col gap-4">
<div className=" text-xl font-bold text-primary">?...</div>
<div className=" text-tertiary" >{error?.statusText || error?.message}</div>
return (
// 主容器: 基于Flex的垂直水平双居中布局
// pt-64: 顶部留白实现视觉层次结构
<div className="flex justify-center items-center pt-64">
{/* 内容区块: 采用纵向弹性布局控制内部元素间距 */}
<div className="flex flex-col gap-4">
{/* 主标题: 强调性文字样式配置 */}
<div className="text-xl font-bold text-primary">
?...
</div>
{/* 错误详情: 动态渲染错误信息,实现优雅降级策略 */}
{/* 使用可选链操作符防止未定义错误,信息优先级: statusText > message */}
<div className="text-tertiary">
{error?.statusText || error?.message}
</div>
</div>
</div>
)
}

View File

@ -5,6 +5,7 @@ import CourseList from "./components/CourseList";
import { api } from "@nice/client";
import { LectureType, PostType } from "@nice/common";
export default function CoursesPage() {
const [currentPage, setCurrentPage] = useState(1);
const [selectedCategory, setSelectedCategory] = useState("");

View File

@ -2,6 +2,7 @@ import HeroSection from './components/HeroSection';
import CategorySection from './components/CategorySection';
import CoursesSection from './components/CoursesSection';
import FeaturedTeachersSection from './components/FeaturedTeachersSection';
import { TusUploader } from '@web/src/components/common/uploader/TusUploader';
const HomePage = () => {
const mockCourses = [
{
@ -105,6 +106,7 @@ const HomePage = () => {
return (
<div className="min-h-screen">
<HeroSection />
<TusUploader></TusUploader>
<CoursesSection
title="推荐课程"
description="最受欢迎的精品课程,助你快速成长"

View File

@ -2,5 +2,5 @@ import MindEditor from "@web/src/components/common/editor/MindEditor";
// import MindElixir, { MindElixirInstance } from "mind-elixir";
import { useEffect, useRef } from "react";
export default function PathsPage() {
// return <MindEditor></MindEditor>
return <MindEditor></MindEditor>
}

View File

@ -1,27 +1,26 @@
// import { MindElixirInstance } from "packages/mind-elixir-core/dist/types";
import { MindElixirInstance } from "mind-elixir";
import { useRef, useEffect } from "react";
// import MindElixir from "mind-elixir";
import MindElixir from "mind-elixir";
export default function MindEditor() {
// const me = useRef<MindElixirInstance>();
// useEffect(() => {
// const instance = new MindElixir({
// el: "#map",
// direction: MindElixir.SIDE,
// draggable: true, // default true
// contextMenu: true, // default true
// toolBar: true, // default true
// nodeMenu: true, // default true
// keypress: true, // default true
// });
// // instance.install(NodeMenu);
// instance.init(MindElixir.new("新主题"));
// me.current = instance;
// }, []);
// return (
// <div>
// <div>1</div>
// <div id="map" style={{ width: "100%" }} />
// </div>
// );
const me = useRef<MindElixirInstance>();
useEffect(() => {
const instance = new MindElixir({
el: "#map",
direction: MindElixir.SIDE,
draggable: true, // default true
contextMenu: true, // default true
toolBar: true, // default true
nodeMenu: true, // default true
keypress: true // default true
});
// instance.install(NodeMenu);
instance.init(MindElixir.new("新主题"));
me.current = instance;
}, []);
return <div >
<div id="map" style={{ width: "100%" }} />
</div>
}

View File

@ -5,12 +5,8 @@ import {
DeleteOutlined,
} from "@ant-design/icons";
import { Upload, Progress, Button } from "antd";
import type { UploadFile } from "antd";
import { useTusUpload } from "@web/src/hooks/useTusUpload";
import toast from "react-hot-toast";
import { getCompressedImageUrl } from "@nice/utils";
import { api } from "@nice/client";
export interface TusUploaderProps {
value?: string[];
onChange?: (value: string[]) => void;
@ -30,16 +26,7 @@ export const TusUploader = ({
onChange,
multiple = true,
}: TusUploaderProps) => {
const { data: files } = api.resource.findMany.useQuery({
where: {
fileId: { in: value },
},
select: {
id: true,
fileId: true,
title: true,
},
});
const { handleFileUpload, uploadProgress } = useTusUpload();
const [uploadingFiles, setUploadingFiles] = useState<UploadingFile[]>([]);
const [completedFiles, setCompletedFiles] = useState<UploadingFile[]>(
@ -74,6 +61,7 @@ export const TusUploader = ({
const handleBeforeUpload = useCallback(
(file: File) => {
const fileKey = `${file.name}-${Date.now()}`;
setUploadingFiles((prev) => [
@ -151,7 +139,7 @@ export const TusUploader = ({
name="files"
multiple={multiple}
showUploadList={false}
style={{ background: "transparent", borderStyle: "none" }}
beforeUpload={handleBeforeUpload}>
<p className="ant-upload-drag-icon">
<UploadOutlined />

View File

@ -33,15 +33,9 @@ import {
useSortable,
verticalListSortingStrategy,
} from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
import QuillEditor from "@web/src/components/common/editor/quill/QuillEditor";
import { TusUploader } from "@web/src/components/common/uploader/TusUploader";
import { Lecture, LectureType, PostType } from "@nice/common";
import { useCourseEditor } from "../../context/CourseEditorContext";
import { usePost } from "@nice/client";
import toast from "react-hot-toast";
import { CourseContentFormHeader } from "./CourseContentFormHeader";
import { CourseSectionEmpty } from "./CourseSectionEmpty";
import { LectureData, SectionData } from "./interface";
import { SortableLecture } from "./SortableLecture";

View File

@ -17,31 +17,12 @@ import {
} from "antd";
import React, { useCallback, useEffect, useState } from "react";
import {
DndContext,
closestCenter,
KeyboardSensor,
PointerSensor,
useSensor,
useSensors,
DragEndEvent,
} from "@dnd-kit/core";
import { api, emitDataChange } from "@nice/client";
import {
arrayMove,
SortableContext,
sortableKeyboardCoordinates,
useSortable,
verticalListSortingStrategy,
} from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
import QuillEditor from "@web/src/components/common/editor/quill/QuillEditor";
import { TusUploader } from "@web/src/components/common/uploader/TusUploader";
import { Lecture, LectureType, PostType } from "@nice/common";
import { useCourseEditor } from "../../context/CourseEditorContext";
import { usePost } from "@nice/client";
import toast from "react-hot-toast";
import { CourseContentFormHeader } from "./CourseContentFormHeader";
import { CourseSectionEmpty } from "./CourseSectionEmpty";
import { LectureData, SectionData } from "./interface";
interface SortableSectionProps {
courseId?: string;

View File

@ -2,7 +2,7 @@ export const env: {
APP_NAME: string;
SERVER_IP: string;
VERSION: string;
UPLOAD_PORT: string;
FILE_PORT: string;
SERVER_PORT: string;
} = {
APP_NAME: import.meta.env.PROD
@ -11,9 +11,9 @@ export const env: {
SERVER_IP: import.meta.env.PROD
? (window as any).env.VITE_APP_SERVER_IP
: import.meta.env.VITE_APP_SERVER_IP,
UPLOAD_PORT: import.meta.env.PROD
? (window as any).env.VITE_APP_UPLOAD_PORT
: import.meta.env.VITE_APP_UPLOAD_PORT,
FILE_PORT: import.meta.env.PROD
? (window as any).env.VITE_APP_FILE_PORT
: import.meta.env.VITE_APP_FILE_PORT,
SERVER_PORT: import.meta.env.PROD
? (window as any).env.VITE_APP_SERVER_PORT
: import.meta.env.VITE_APP_SERVER_PORT,

View File

@ -2,11 +2,6 @@ import { useState } from "react";
import * as tus from "tus-js-client";
import { env } from "../env";
import { getCompressedImageUrl } from "@nice/utils";
// useTusUpload.ts
interface UploadProgress {
fileId: string;
progress: number;
}
interface UploadResult {
compressedUrl: string;
@ -35,8 +30,7 @@ export function useTusUpload() {
if (uploadIndex === -1 || uploadIndex + 4 >= parts.length) {
throw new Error("Invalid upload URL format");
}
const resUrl = `http://${env.SERVER_IP}:${env.UPLOAD_PORT}/uploads/${parts.slice(uploadIndex + 1, uploadIndex + 6).join("/")}`;
const resUrl = `http://${env.SERVER_IP}:${env.FILE_PORT}/uploads/${parts.slice(uploadIndex + 1, uploadIndex + 6).join("/")}`;
return resUrl;
};
const handleFileUpload = async (
@ -45,11 +39,13 @@ export function useTusUpload() {
onError: (error: Error) => void,
fileKey: string // 添加文件唯一标识
) => {
// console.log()
setIsUploading(true);
setUploadProgress((prev) => ({ ...prev, [fileKey]: 0 }));
setUploadError(null);
try {
console.log(`http://${env.SERVER_IP}:${env.SERVER_PORT}/upload`);
const upload = new tus.Upload(file, {
endpoint: `http://${env.SERVER_IP}:${env.SERVER_PORT}/upload`,
retryDelays: [0, 1000, 3000, 5000],
@ -96,6 +92,7 @@ export function useTusUpload() {
onError: (error) => {
setIsUploading(false);
setUploadError(error.message);
console.log(error);
onError(error);
},
});

View File

@ -129,3 +129,4 @@
height: 600px;
width: 100%;
}

View File

@ -3,13 +3,9 @@ import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App.js";
import "./index.css";
import { ModuleRegistry } from "@ag-grid-community/core";
import { LicenseManager } from "@ag-grid-enterprise/core";
import { ClientSideRowModelModule } from "@ag-grid-community/client-side-row-model";
ModuleRegistry.registerModules([ClientSideRowModelModule]);
LicenseManager.setLicenseKey(

View File

@ -5,7 +5,8 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "pnpm run --parallel dev"
"dev": "pnpm run --parallel dev",
"db:clear": "pnpm --filter common run db:clear"
},
"keywords": [],
"author": "insiinc",

View File

@ -45,6 +45,7 @@ model Term {
depts Department[] @relation("department_term")
hasChildren Boolean? @default(false) @map("has_children")
posts Post[] @relation("post_term")
@@index([name]) // 对name字段建立索引以加快基于name的查找速度
@@index([parentId]) // 对parentId字段建立索引以加快基于parentId的查找速度
@@map("term")
@ -222,6 +223,7 @@ model Post {
watchableStaffs Staff[] @relation("post_watch_staff") // 可观看的员工列表,关联 Staff 模型
watchableDepts Department[] @relation("post_watch_dept") // 可观看的部门列表,关联 Department 模型
meta Json? // 封面url 视频url objectives具体的学习目标 rating评分Int
// 索引
@@index([type, domainId])
@@index([authorId, type])
@ -302,8 +304,6 @@ model Visit {
@@map("visit")
}
model Enrollment {
id String @id @default(cuid()) @map("id")
status String @map("status")
@ -404,3 +404,19 @@ model NodeEdge {
@@index([targetId])
@@map("node_edge")
}
model Animal {
id String @id @default(cuid())
name String
age Int
gender Boolean
personId String?
person Person? @relation(fields: [personId], references: [id])
}
model Person {
id String @id @default(cuid())
name String
age Int
gender Boolean
animals Animal[]
}

View File

@ -15,7 +15,6 @@ export enum LectureType {
}
export enum TaxonomySlug {
CATEGORY = "category",
UNIT = "unit",
TAG = "tag",
LEVEL = "level",
}

View File

@ -12,7 +12,7 @@ importers:
dependencies:
'@nestjs/bullmq':
specifier: ^10.2.0
version: 10.2.3(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.15)(@nestjs/websockets@10.4.15)(reflect-metadata@0.2.2)(rxjs@7.8.1))(bullmq@5.34.8)
version: 10.2.3(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15)(bullmq@5.34.8)
'@nestjs/common':
specifier: ^10.3.10
version: 10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1)
@ -33,7 +33,7 @@ importers:
version: 10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/websockets@10.4.15)(rxjs@7.8.1)
'@nestjs/schedule':
specifier: ^4.1.0
version: 4.1.2(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.15)(@nestjs/websockets@10.4.15)(reflect-metadata@0.2.2)(rxjs@7.8.1))
version: 4.1.2(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15)
'@nestjs/websockets':
specifier: ^10.3.10
version: 10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15)(@nestjs/platform-socket.io@10.4.15)(reflect-metadata@0.2.2)(rxjs@7.8.1)
@ -148,7 +148,7 @@ importers:
version: 10.2.3(chokidar@3.6.0)(typescript@5.7.2)
'@nestjs/testing':
specifier: ^10.0.0
version: 10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.15)(@nestjs/websockets@10.4.15)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15))
version: 10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15)(@nestjs/platform-express@10.4.15)
'@types/exceljs':
specifier: ^1.3.0
version: 1.3.2
@ -673,7 +673,7 @@ importers:
specifier: ^5.62.0
version: 5.62.0(eslint@8.57.1)(typescript@5.7.2)
'@viselect/vanilla':
specifier: ^3.5.1
specifier: ^3.9.0
version: 3.9.0
eslint:
specifier: ^8.57.0
@ -9665,15 +9665,15 @@ snapshots:
'@msgpackr-extract/msgpackr-extract-win32-x64@3.0.3':
optional: true
'@nestjs/bull-shared@10.2.3(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.15)(@nestjs/websockets@10.4.15)(reflect-metadata@0.2.2)(rxjs@7.8.1))':
'@nestjs/bull-shared@10.2.3(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15)':
dependencies:
'@nestjs/common': 10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1)
'@nestjs/core': 10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.15)(@nestjs/websockets@10.4.15)(reflect-metadata@0.2.2)(rxjs@7.8.1)
tslib: 2.8.1
'@nestjs/bullmq@10.2.3(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.15)(@nestjs/websockets@10.4.15)(reflect-metadata@0.2.2)(rxjs@7.8.1))(bullmq@5.34.8)':
'@nestjs/bullmq@10.2.3(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15)(bullmq@5.34.8)':
dependencies:
'@nestjs/bull-shared': 10.2.3(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.15)(@nestjs/websockets@10.4.15)(reflect-metadata@0.2.2)(rxjs@7.8.1))
'@nestjs/bull-shared': 10.2.3(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15)
'@nestjs/common': 10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1)
'@nestjs/core': 10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.15)(@nestjs/websockets@10.4.15)(reflect-metadata@0.2.2)(rxjs@7.8.1)
bullmq: 5.34.8
@ -9770,7 +9770,7 @@ snapshots:
- supports-color
- utf-8-validate
'@nestjs/schedule@4.1.2(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.15)(@nestjs/websockets@10.4.15)(reflect-metadata@0.2.2)(rxjs@7.8.1))':
'@nestjs/schedule@4.1.2(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15)':
dependencies:
'@nestjs/common': 10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1)
'@nestjs/core': 10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.15)(@nestjs/websockets@10.4.15)(reflect-metadata@0.2.2)(rxjs@7.8.1)
@ -9788,7 +9788,7 @@ snapshots:
transitivePeerDependencies:
- chokidar
'@nestjs/testing@10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.15)(@nestjs/websockets@10.4.15)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15))':
'@nestjs/testing@10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.15)(@nestjs/platform-express@10.4.15)':
dependencies:
'@nestjs/common': 10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1)
'@nestjs/core': 10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.15)(@nestjs/websockets@10.4.15)(reflect-metadata@0.2.2)(rxjs@7.8.1)