Skip to content
This repository was archived by the owner on Nov 28, 2024. It is now read-only.

Commit 47074e3

Browse files
author
齐下无贰
committed
fix '@' & update storage
1 parent 0239d7d commit 47074e3

4 files changed

Lines changed: 63 additions & 12 deletions

File tree

react-app/craco.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ module.exports = {
4444
// stream: false,
4545
// crypto: false,
4646
},
47+
extensions: [".js", ".jsx", ".json", ".ts", ".tsx"],
48+
// https://blog.csdn.net/peter_hzq/article/details/120656880
49+
alias: {
50+
"@": path.resolve(__dirname, "src"),
51+
},
52+
// modules: [webpackPaths.srcPath, "node_modules"],
4753
},
4854
}),
4955
},
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const path = require("path");
2+
import fs from "fs";
3+
import { FileCardProps } from "@/components/FileCard";
4+
5+
const savePath = ".";
6+
7+
async function FileLocalStorage(fileProps: FileCardProps) {
8+
// fileProps = {
9+
// type: "review",
10+
// filetype: ext,
11+
// filename: trueFilename,
12+
// filesize: filesize,
13+
// uploadProgress: 1,
14+
// done: true,
15+
// mentioned: [],
16+
// mentionables: [],
17+
// overview: overview,
18+
// grade: review,
19+
// };
20+
21+
return function (payload: FormData, fileProps: FileCardProps) {
22+
const targetFolder = path.join(savePath, "/FileStorage");
23+
if (!fs.existsSync(targetFolder)) {
24+
fs.mkdirSync(targetFolder);
25+
}
26+
27+
// 2023-10-15T07:53:42.423Z
28+
const timestamp = new Date().toISOString();
29+
30+
const file = payload.get("file");
31+
const newPath = path.join(
32+
targetFolder,
33+
`${timestamp}_${fileProps.filename}.${fileProps.filetype}`
34+
);
35+
// 存储文件
36+
};
37+
}
38+
39+
export { FileLocalStorage };

react-app/src/api/db/prisma/schema.prisma

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,24 @@ model Session {
5050
model ReviewStorage {
5151
id Int @id @unique @default(autoincrement())
5252
53-
// TODO
54-
profile_id String @default("")
53+
profile_id String @default("")
5554
RequestMessage String?
5655
RequestUser String
57-
mentioned String @default("")
56+
mentioned String @default("")
57+
file FileStorage @relation(fields: [fileStorageHash], references: [hash])
5858
59-
hash String?
60-
filePath String?
61-
filename String?
62-
filesize Int?
63-
filetype String?
59+
deleted Boolean @default(false)
60+
createdAt DateTime @default(now())
61+
updatedAt DateTime @updatedAt
62+
fileStorageHash String
63+
}
6464

65-
deleted Boolean @default(false)
66-
createdAt DateTime @default(now())
67-
updatedAt DateTime @updatedAt
65+
model FileStorage {
66+
hash String @id @unique
67+
file Bytes
68+
filePath String?
69+
filename String?
70+
filesize Int?
71+
filetype String?
72+
ReviewStorage ReviewStorage[]
6873
}

react-app/src/api/review.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export const GetFileReview = async (payload: FormData, onProgressUpdate: (p: Axi
1616
const config: AxiosRequestConfig = {
1717
onUploadProgress: onProgressUpdate
1818
}
19-
return await api.post('/api/file/review', payload, config)
19+
// return await api.post('/api/file/review', payload, config)
20+
return await api.post('/api/file/rating', payload, config)
2021
}
2122

2223
export const GetOpenAIConnectionTest = async () => {

0 commit comments

Comments
 (0)