# Conflicts:
#	src/types/database.d.ts
This commit is contained in:
小帅 2026-03-29 20:49:44 +08:00
commit b5fccf0ade
3 changed files with 93 additions and 14 deletions

View File

@ -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;

View File

@ -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
View 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);
}
}
}