Merge branch '108' of https://github.com/HBAI-Ltd/Toonflow-app into 108
# Conflicts: # src/types/database.d.ts
This commit is contained in:
commit
b5fccf0ade
21
src/types/database.d.ts
vendored
21
src/types/database.d.ts
vendored
@ -1,18 +1,12 @@
|
|||||||
// @db-hash e24c7c99757472b92af11f26a2b2b8c7
|
// @db-hash f7bc2fdb80756d5536929eb47155578b
|
||||||
//该文件由脚本自动生成,请勿手动修改
|
//该文件由脚本自动生成,请勿手动修改
|
||||||
|
|
||||||
export interface _o_project_old_20260328 {
|
export interface _o_script_old_20260327 {
|
||||||
'artStyle'?: string | null;
|
'content'?: string | null;
|
||||||
'createTime'?: number | null;
|
'createTime'?: number | null;
|
||||||
'id'?: number | null;
|
'id'?: number;
|
||||||
'imageModel'?: string | null;
|
|
||||||
'intro'?: string | null;
|
|
||||||
'name'?: string | null;
|
'name'?: string | null;
|
||||||
'projectType'?: string | null;
|
'projectId'?: number | null;
|
||||||
'type'?: string | null;
|
|
||||||
'userId'?: number | null;
|
|
||||||
'videoModel'?: string | null;
|
|
||||||
'videoRatio'?: string | null;
|
|
||||||
}
|
}
|
||||||
export interface memories {
|
export interface memories {
|
||||||
'content': string;
|
'content': string;
|
||||||
@ -60,7 +54,6 @@ export interface o_assets {
|
|||||||
'name'?: string | null;
|
'name'?: string | null;
|
||||||
'projectId'?: number | null;
|
'projectId'?: number | null;
|
||||||
'prompt'?: string | null;
|
'prompt'?: string | null;
|
||||||
'promptState'?: string | null;
|
|
||||||
'remark'?: string | null;
|
'remark'?: string | null;
|
||||||
'scriptId'?: number | null;
|
'scriptId'?: number | null;
|
||||||
'startTime'?: number | null;
|
'startTime'?: number | null;
|
||||||
@ -180,7 +173,7 @@ export interface o_storyboard {
|
|||||||
'filePath'?: string | null;
|
'filePath'?: string | null;
|
||||||
'frameMode'?: string | null;
|
'frameMode'?: string | null;
|
||||||
'id'?: number;
|
'id'?: number;
|
||||||
'index'?: number | null;
|
'index'?: string | null;
|
||||||
'lines'?: string | null;
|
'lines'?: string | null;
|
||||||
'mode'?: string | null;
|
'mode'?: string | null;
|
||||||
'model'?: string | null;
|
'model'?: string | null;
|
||||||
@ -245,7 +238,7 @@ export interface o_videoConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface DB {
|
export interface DB {
|
||||||
"_o_project_old_20260328": _o_project_old_20260328;
|
"_o_script_old_20260327": _o_script_old_20260327;
|
||||||
"memories": memories;
|
"memories": memories;
|
||||||
"o_agentDeploy": o_agentDeploy;
|
"o_agentDeploy": o_agentDeploy;
|
||||||
"o_agentWorkData": o_agentWorkData;
|
"o_agentWorkData": o_agentWorkData;
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import vm from "@/utils/vm";
|
|||||||
import task from "@/utils/taskRecord";
|
import task from "@/utils/taskRecord";
|
||||||
import Ai from "@/utils/ai";
|
import Ai from "@/utils/ai";
|
||||||
import { getPrompts } from "@/utils/getPrompts";
|
import { getPrompts } from "@/utils/getPrompts";
|
||||||
|
import { getArtPrompt } from "@/utils/getArtPrompt";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
db,
|
db,
|
||||||
@ -22,4 +23,5 @@ export default {
|
|||||||
Ai,
|
Ai,
|
||||||
task,
|
task,
|
||||||
getPrompts,
|
getPrompts,
|
||||||
|
getArtPrompt,
|
||||||
};
|
};
|
||||||
|
|||||||
84
src/utils/getArtPrompt.ts
Normal file
84
src/utils/getArtPrompt.ts
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
import getPath from "./getPath";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 传入一个指定路径参数(风格名称),以及一个指定文件名,递归获取该文件并返回其内容
|
||||||
|
* @param styleName - 风格目录名,例如 "chinese_sweet_romance"
|
||||||
|
* @param fileName - 目标文件名(不含 .md 后缀),例如 "art_character"、"prefix"
|
||||||
|
* @returns 文件内容字符串,未找到时返回空字符串
|
||||||
|
*/
|
||||||
|
export function getArtPrompt(styleName: string, fileName: string): string {
|
||||||
|
const baseDir = getPath(["skills", "art_prompts", styleName]);
|
||||||
|
|
||||||
|
if (!fs.existsSync(baseDir)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
const target = fileName.endsWith(".md") ? fileName : `${fileName}.md`;
|
||||||
|
const found = findFileRecursive(baseDir, target);
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return fs.readFileSync(found, "utf-8");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 传入风格目录名,获取该风格下所有 .md 文件内容,按文件名映射返回
|
||||||
|
* @param styleName - 风格目录名,例如 "chinese_sweet_romance"
|
||||||
|
* @returns Record<文件名(不含后缀), 文件内容>
|
||||||
|
*/
|
||||||
|
export function getAllArtPrompts(styleName: string): Record<string, string> {
|
||||||
|
const baseDir = getPath(["skills", "art_prompts", styleName]);
|
||||||
|
|
||||||
|
if (!fs.existsSync(baseDir)) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const result: Record<string, string> = {};
|
||||||
|
collectMdFiles(baseDir, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归查找指定文件名的文件,返回第一个匹配的完整路径
|
||||||
|
*/
|
||||||
|
function findFileRecursive(dir: string, targetName: string): string | null {
|
||||||
|
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||||
|
|
||||||
|
for (const entry of entries) {
|
||||||
|
const fullPath = path.join(dir, entry.name);
|
||||||
|
|
||||||
|
if (entry.isFile() && entry.name === targetName) {
|
||||||
|
return fullPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.isDirectory()) {
|
||||||
|
const found = findFileRecursive(fullPath, targetName);
|
||||||
|
if (found) return found;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归收集目录下所有 .md 文件内容
|
||||||
|
*/
|
||||||
|
function collectMdFiles(dir: string, result: Record<string, string>): void {
|
||||||
|
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||||
|
|
||||||
|
for (const entry of entries) {
|
||||||
|
const fullPath = path.join(dir, entry.name);
|
||||||
|
|
||||||
|
if (entry.isFile() && entry.name.endsWith(".md")) {
|
||||||
|
const key = entry.name.replace(/\.md$/, "");
|
||||||
|
result[key] = fs.readFileSync(fullPath, "utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.isDirectory()) {
|
||||||
|
collectMdFiles(fullPath, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user