修复视觉手册
This commit is contained in:
parent
2f0a064363
commit
76efd4fdf5
@ -1,3 +1,10 @@
|
|||||||
|
123
|
||||||
|
1212121212的王师傅水电费第三方水电费
|
||||||
|
1212121212
|
||||||
|
1212121212
|
||||||
|
121212
|
||||||
|
# # name121212第三方士大夫士大夫水电费第三方
|
||||||
|
# name121212
|
||||||
name
|
name
|
||||||
123123水电费水电费水电费水电费水电费
|
123123水电费水电费水电费水电费水电费
|
||||||
12312312312
|
12312312312
|
||||||
|
|||||||
@ -33,10 +33,6 @@ export default router.post(
|
|||||||
filePath: ending,
|
filePath: ending,
|
||||||
type: "clip",
|
type: "clip",
|
||||||
});
|
});
|
||||||
// 查询o_videoConfig表,拿到已选中的videoId
|
|
||||||
const configRows = await u.db("o_videoConfig").select("videoId");
|
|
||||||
const selectedIds = new Set(configRows.map((row) => row.videoId));
|
|
||||||
|
|
||||||
// 查询o_video表
|
// 查询o_video表
|
||||||
const videoRows = await u.db("o_video").where("state", "生成成功").andWhere("projectId", projectId).select("*");
|
const videoRows = await u.db("o_video").where("state", "生成成功").andWhere("projectId", projectId).select("*");
|
||||||
// 处理并返回结果
|
// 处理并返回结果
|
||||||
@ -44,8 +40,7 @@ export default router.post(
|
|||||||
videoRows.map(async (row) => ({
|
videoRows.map(async (row) => ({
|
||||||
id: row.id,
|
id: row.id,
|
||||||
filePath: row.filePath ? await u.oss.getFileUrl(row.filePath) : "",
|
filePath: row.filePath ? await u.oss.getFileUrl(row.filePath) : "",
|
||||||
selected: selectedIds.has(row.id),
|
videoTrackId: row.videoTrackId,
|
||||||
videoParametersId: row.videoParametersId,
|
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -89,8 +89,6 @@ export default router.post(
|
|||||||
scene: { promptKey: "scene-polish", itemType: "scenes", label: "场景图", nameLabel: "场景", visualManual: "art_scene" },
|
scene: { promptKey: "scene-polish", itemType: "scenes", label: "场景图", nameLabel: "场景", visualManual: "art_scene" },
|
||||||
tool: { promptKey: "tool-polish", itemType: "props", label: "道具图", nameLabel: "道具", visualManual: "art_prop" },
|
tool: { promptKey: "tool-polish", itemType: "props", label: "道具图", nameLabel: "道具", visualManual: "art_prop" },
|
||||||
};
|
};
|
||||||
const novelData = (await u.db("o_novel").whereIn("chapterIndex", [1]).select("*")) as NovelChapter[];
|
|
||||||
const novelText = mergeNovelText(novelData);
|
|
||||||
// 批量更新所有 item 状态为生成中
|
// 批量更新所有 item 状态为生成中
|
||||||
const assetsIds = items.map((item: { assetsId: number }) => item.assetsId);
|
const assetsIds = items.map((item: { assetsId: number }) => item.assetsId);
|
||||||
await u.db("o_assets").whereIn("id", assetsIds).update({ promptState: "生成中" });
|
await u.db("o_assets").whereIn("id", assetsIds).update({ promptState: "生成中" });
|
||||||
|
|||||||
@ -13,6 +13,7 @@ export default router.post(
|
|||||||
validateFields({
|
validateFields({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
images: z.array(z.string()),
|
images: z.array(z.string()),
|
||||||
|
stylePath: z.string(),
|
||||||
data: z.array(
|
data: z.array(
|
||||||
z.object({
|
z.object({
|
||||||
label: z.string(),
|
label: z.string(),
|
||||||
@ -23,18 +24,19 @@ export default router.post(
|
|||||||
}),
|
}),
|
||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { name, images, data } = req.body as {
|
const { name, images, data, stylePath } = req.body as {
|
||||||
name: string;
|
name: string;
|
||||||
images: string[];
|
images: string[];
|
||||||
data: { label: string; value: string; data: string }[];
|
data: { label: string; value: string; data: string }[];
|
||||||
|
stylePath: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (/^\d+$/.test(name)) {
|
if (/^\d+$/.test(stylePath)) {
|
||||||
res.status(400).send(error("名称不能为纯数字"));
|
res.status(400).send(error("文件名称不能为纯数字"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const mainPath = u.getPath(["skills", "art_prompts", name]);
|
const mainPath = u.getPath(["skills", "art_prompts", stylePath]);
|
||||||
if (fs.existsSync(mainPath)) {
|
if (fs.existsSync(mainPath)) {
|
||||||
return res.status(400).send(error("请勿填写重复名称的视觉手册"));
|
return res.status(400).send(error("请勿填写重复名称的视觉手册"));
|
||||||
}
|
}
|
||||||
@ -74,7 +76,7 @@ export default router.post(
|
|||||||
}
|
}
|
||||||
fs.writeFileSync(filePath, item.data, "utf-8");
|
fs.writeFileSync(filePath, item.data, "utf-8");
|
||||||
}
|
}
|
||||||
const ossImagesDir = u.getPath(["oss", name]);
|
const ossImagesDir = u.getPath(["oss", stylePath]);
|
||||||
|
|
||||||
let existingFiles: string[] = [];
|
let existingFiles: string[] = [];
|
||||||
try {
|
try {
|
||||||
@ -86,12 +88,12 @@ export default router.post(
|
|||||||
|
|
||||||
for (const file of existingFiles) {
|
for (const file of existingFiles) {
|
||||||
if (!retainedFileNames.has(file)) {
|
if (!retainedFileNames.has(file)) {
|
||||||
await u.oss.deleteFile(`${name}/${file}`);
|
await u.oss.deleteFile(`${stylePath}/${file}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const item of images) {
|
for (const item of images) {
|
||||||
if (!item.startsWith("http")) await u.oss.writeFile(`${name}/${u.uuid()}.jpg`, item);
|
if (!item.startsWith("http")) await u.oss.writeFile(`${stylePath}/${u.uuid()}.jpg`, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status(200).send(success());
|
res.status(200).send(success());
|
||||||
|
|||||||
@ -15,6 +15,7 @@ export default router.post(
|
|||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { name } = req.body as { name: string };
|
const { name } = req.body as { name: string };
|
||||||
|
console.log("%c Line:18 🍓 name", "background:#2eafb0", name);
|
||||||
|
|
||||||
// 安全校验:不允许包含路径分隔符、纯数字,防止越级删除或误删项目目录
|
// 安全校验:不允许包含路径分隔符、纯数字,防止越级删除或误删项目目录
|
||||||
if (name.includes("/") || name.includes("\\") || name === "." || name === ".." || /^\d+$/.test(name)) {
|
if (name.includes("/") || name.includes("\\") || name === "." || name === ".." || /^\d+$/.test(name)) {
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export default router.post(
|
|||||||
"/",
|
"/",
|
||||||
validateFields({
|
validateFields({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
title: z.string(),
|
stylePath: z.string(),
|
||||||
images: z.array(z.string()),
|
images: z.array(z.string()),
|
||||||
data: z.array(
|
data: z.array(
|
||||||
z.object({
|
z.object({
|
||||||
@ -24,19 +24,19 @@ export default router.post(
|
|||||||
}),
|
}),
|
||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { name, title, images, data } = req.body as {
|
const { name, stylePath, images, data } = req.body as {
|
||||||
name: string;
|
name: string;
|
||||||
title: string;
|
stylePath: string;
|
||||||
images: string[];
|
images: string[];
|
||||||
data: { label: string; value: string; data: string }[];
|
data: { label: string; value: string; data: string }[];
|
||||||
};
|
};
|
||||||
|
|
||||||
if (/^\d+$/.test(name)) {
|
if (/^\d+$/.test(stylePath)) {
|
||||||
res.status(400).send(error("名称不能为纯数字"));
|
res.status(400).send(error("名称不能为纯数字"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const mainPath = u.getPath(["skills", "art_prompts", name]);
|
const mainPath = u.getPath(["skills", "art_prompts", stylePath]);
|
||||||
if (!fs.existsSync(mainPath)) {
|
if (!fs.existsSync(mainPath)) {
|
||||||
return res.status(400).send(error("视觉手册不存在"));
|
return res.status(400).send(error("视觉手册不存在"));
|
||||||
}
|
}
|
||||||
@ -74,10 +74,10 @@ export default router.post(
|
|||||||
if (!fs.existsSync(fileDir)) {
|
if (!fs.existsSync(fileDir)) {
|
||||||
fs.mkdirSync(fileDir, { recursive: true });
|
fs.mkdirSync(fileDir, { recursive: true });
|
||||||
}
|
}
|
||||||
const content = item.value === "README" ? `# ${title}\n${item.data}` : item.data;
|
const content = item.value === "README" ? `${name}\n${item.data}` : item.data;
|
||||||
fs.writeFileSync(filePath, content, "utf-8");
|
fs.writeFileSync(filePath, content, "utf-8");
|
||||||
}
|
}
|
||||||
const ossImagesDir = u.getPath(["oss", name]);
|
const ossImagesDir = u.getPath(["oss", stylePath]);
|
||||||
|
|
||||||
let existingFiles: string[] = [];
|
let existingFiles: string[] = [];
|
||||||
try {
|
try {
|
||||||
@ -89,12 +89,12 @@ export default router.post(
|
|||||||
|
|
||||||
for (const file of existingFiles) {
|
for (const file of existingFiles) {
|
||||||
if (!retainedFileNames.has(file)) {
|
if (!retainedFileNames.has(file)) {
|
||||||
await u.oss.deleteFile(`${name}/${file}`);
|
await u.oss.deleteFile(`${stylePath}/${file}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const item of images) {
|
for (const item of images) {
|
||||||
if (!item.startsWith("http")) await u.oss.writeFile(`${name}/${u.uuid()}.jpg`, item);
|
if (!item.startsWith("http")) await u.oss.writeFile(`${stylePath}/${u.uuid()}.jpg`, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status(200).send(success());
|
res.status(200).send(success());
|
||||||
|
|||||||
@ -65,7 +65,6 @@ export default router.post("/", async (req, res) => {
|
|||||||
const readmePath = path.join(styleDir, "README.md");
|
const readmePath = path.join(styleDir, "README.md");
|
||||||
const readmeContent = fs.readFileSync(readmePath, "utf-8");
|
const readmeContent = fs.readFileSync(readmePath, "utf-8");
|
||||||
const firstLine = readmeContent.split("\n")[0].replace(/--/g, "");
|
const firstLine = readmeContent.split("\n")[0].replace(/--/g, "");
|
||||||
const stylePath = path.join("askills", "art_prompts", styleName);
|
|
||||||
const data = DATA_MAP.map(({ label, value, subDir }) => {
|
const data = DATA_MAP.map(({ label, value, subDir }) => {
|
||||||
let mdPath: string;
|
let mdPath: string;
|
||||||
if (subDir) {
|
if (subDir) {
|
||||||
@ -83,7 +82,7 @@ export default router.post("/", async (req, res) => {
|
|||||||
return {
|
return {
|
||||||
name: firstLine,
|
name: firstLine,
|
||||||
image: images,
|
image: images,
|
||||||
stylePath,
|
stylePath: styleName,
|
||||||
data,
|
data,
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
|||||||
19
src/types/database.d.ts
vendored
19
src/types/database.d.ts
vendored
@ -1,6 +1,20 @@
|
|||||||
// @db-hash c2029b55b7dcdcf64788dafc34799fea
|
// @db-hash b1210691844e077e9df7dc16c802ce5a
|
||||||
//该文件由脚本自动生成,请勿手动修改
|
//该文件由脚本自动生成,请勿手动修改
|
||||||
|
|
||||||
|
export interface _o_project_old_20260331 {
|
||||||
|
'artStyle'?: string | null;
|
||||||
|
'createTime'?: number | null;
|
||||||
|
'id'?: number | null;
|
||||||
|
'imageModel'?: string | null;
|
||||||
|
'imageQuality'?: string | null;
|
||||||
|
'intro'?: string | null;
|
||||||
|
'name'?: string | null;
|
||||||
|
'projectType'?: string | null;
|
||||||
|
'type'?: string | null;
|
||||||
|
'userId'?: number | null;
|
||||||
|
'videoModel'?: string | null;
|
||||||
|
'videoRatio'?: string | null;
|
||||||
|
}
|
||||||
export interface memories {
|
export interface memories {
|
||||||
'content': string;
|
'content': string;
|
||||||
'createTime': number;
|
'createTime': number;
|
||||||
@ -73,7 +87,6 @@ export interface o_image {
|
|||||||
'filePath'?: string | null;
|
'filePath'?: string | null;
|
||||||
'id'?: number;
|
'id'?: number;
|
||||||
'model'?: string | null;
|
'model'?: string | null;
|
||||||
'reason'?: string | null;
|
|
||||||
'resolution'?: string | null;
|
'resolution'?: string | null;
|
||||||
'state'?: string | null;
|
'state'?: string | null;
|
||||||
'type'?: string | null;
|
'type'?: string | null;
|
||||||
@ -168,7 +181,6 @@ export interface o_storyboard {
|
|||||||
'duration'?: string | null;
|
'duration'?: string | null;
|
||||||
'filePath'?: string | null;
|
'filePath'?: string | null;
|
||||||
'frameMode'?: string | null;
|
'frameMode'?: string | null;
|
||||||
'group'?: string | null;
|
|
||||||
'id'?: number;
|
'id'?: number;
|
||||||
'index'?: number | null;
|
'index'?: number | null;
|
||||||
'lines'?: string | null;
|
'lines'?: string | null;
|
||||||
@ -229,6 +241,7 @@ export interface o_videoTrack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface DB {
|
export interface DB {
|
||||||
|
"_o_project_old_20260331": _o_project_old_20260331;
|
||||||
"memories": memories;
|
"memories": memories;
|
||||||
"o_agentDeploy": o_agentDeploy;
|
"o_agentDeploy": o_agentDeploy;
|
||||||
"o_agentWorkData": o_agentWorkData;
|
"o_agentWorkData": o_agentWorkData;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user