(
@@ -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}>
@@ -177,10 +165,10 @@ export const TusUploader = ({
file.status === "done"
? 100
: Math.round(
- uploadProgress?.[
- file.fileKey!
- ] || 0
- )
+ uploadProgress?.[
+ file.fileKey!
+ ] || 0
+ )
}
status={
file.status === "error"
diff --git a/apps/web/src/components/models/course/editor/form/CourseContentForm/LectureList.tsx b/apps/web/src/components/models/course/editor/form/CourseContentForm/LectureList.tsx
index 0ef99e7..8395c94 100644
--- a/apps/web/src/components/models/course/editor/form/CourseContentForm/LectureList.tsx
+++ b/apps/web/src/components/models/course/editor/form/CourseContentForm/LectureList.tsx
@@ -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";
diff --git a/apps/web/src/env.ts b/apps/web/src/env.ts
index 30278b3..956a74b 100755
--- a/apps/web/src/env.ts
+++ b/apps/web/src/env.ts
@@ -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,
diff --git a/apps/web/src/hooks/useTusUpload.ts b/apps/web/src/hooks/useTusUpload.ts
index 8c855fa..0b99a1d 100644
--- a/apps/web/src/hooks/useTusUpload.ts
+++ b/apps/web/src/hooks/useTusUpload.ts
@@ -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,9 +30,7 @@ export function useTusUpload() {
if (uploadIndex === -1 || uploadIndex + 4 >= parts.length) {
throw new Error("Invalid upload URL format");
}
- console.log(env.UPLOAD_PORT);
- 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 (
@@ -46,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],
@@ -97,6 +92,7 @@ export function useTusUpload() {
onError: (error) => {
setIsUploading(false);
setUploadError(error.message);
+ console.log(error)
onError(error);
},
});
diff --git a/package.json b/package.json
index 40e6ac1..8a85a11 100644
--- a/package.json
+++ b/package.json
@@ -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",
diff --git a/packages/common/prisma/schema.prisma b/packages/common/prisma/schema.prisma
index 061c73e..01bb99e 100644
--- a/packages/common/prisma/schema.prisma
+++ b/packages/common/prisma/schema.prisma
@@ -413,7 +413,6 @@ model Animal {
personId String?
person Person? @relation(fields: [personId], references: [id])
}
-
model Person {
id String @id @default(cuid())
name String