完善版本号获取,为热更新做准备
This commit is contained in:
parent
696f0f6115
commit
70e56f2fac
@ -19,6 +19,8 @@ if (!fs.existsSync(envFile)) {
|
|||||||
console.log(`📄 已自动创建环境变量文件: ${envFile}`);
|
console.log(`📄 已自动创建环境变量文件: ${envFile}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const pkg = JSON.parse(fs.readFileSync(path.resolve("package.json"), "utf8"));
|
||||||
|
|
||||||
const external = [
|
const external = [
|
||||||
"electron",
|
"electron",
|
||||||
"@huggingface/transformers",
|
"@huggingface/transformers",
|
||||||
@ -51,6 +53,9 @@ const appBuildConfig: esbuild.BuildOptions = {
|
|||||||
},
|
},
|
||||||
sourcemap: false,
|
sourcemap: false,
|
||||||
external,
|
external,
|
||||||
|
define: {
|
||||||
|
__APP_VERSION__: JSON.stringify(pkg.version),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Electron 主进程打包配置
|
// Electron 主进程打包配置
|
||||||
@ -69,6 +74,9 @@ const mainBuildConfig: esbuild.BuildOptions = {
|
|||||||
},
|
},
|
||||||
sourcemap: false,
|
sourcemap: false,
|
||||||
external,
|
external,
|
||||||
|
define: {
|
||||||
|
__APP_VERSION__: JSON.stringify(pkg.version),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|||||||
@ -40,7 +40,6 @@ export async function decisionAI(ctx: AgentContext) {
|
|||||||
resTool.systemMessage("决策层AI 接管聊天");
|
resTool.systemMessage("决策层AI 接管聊天");
|
||||||
|
|
||||||
const memory = new Memory("scriptAgent", isolationKey);
|
const memory = new Memory("scriptAgent", isolationKey);
|
||||||
console.log("%c Line:43 🥟 isolationKey", "background:#4fff4B", isolationKey);
|
|
||||||
await memory.add("user", text);
|
await memory.add("user", text);
|
||||||
const [skill, mem] = await Promise.all([useSkill("script_agent_decision.md"), memory.get(text)]);
|
const [skill, mem] = await Promise.all([useSkill("script_agent_decision.md"), memory.get(text)]);
|
||||||
|
|
||||||
@ -59,7 +58,6 @@ export async function decisionAI(ctx: AgentContext) {
|
|||||||
].join("\n");
|
].join("\n");
|
||||||
|
|
||||||
const prefixSystem = `${projectInfo}\n\n## 章节ID映射表\n${novelData.map((i: any) => `- ${i.id}: 第${i.index}章`).join("\n")}\n\n`;
|
const prefixSystem = `${projectInfo}\n\n## 章节ID映射表\n${novelData.map((i: any) => `- ${i.id}: 第${i.index}章`).join("\n")}\n\n`;
|
||||||
console.log("%c Line:57 🍧 prefixSystem", "background:#ea7e5c", prefixSystem);
|
|
||||||
|
|
||||||
const { textStream } = await u.Ai.Text("scriptAgent").stream({
|
const { textStream } = await u.Ai.Text("scriptAgent").stream({
|
||||||
system: prefixSystem + systemPrompt,
|
system: prefixSystem + systemPrompt,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// @routes-hash fd1b3ec2552be041f1b6e9582eb842b6
|
// @routes-hash adf6a50cb14a1d93aea2983d0364e6a3
|
||||||
import { Express } from "express";
|
import { Express } from "express";
|
||||||
|
|
||||||
import route1 from "./routes/agents/clearMemory";
|
import route1 from "./routes/agents/clearMemory";
|
||||||
@ -38,7 +38,7 @@ import route34 from "./routes/novel/getNovelEventState";
|
|||||||
import route35 from "./routes/novel/getNovelIndex";
|
import route35 from "./routes/novel/getNovelIndex";
|
||||||
import route36 from "./routes/novel/updateNovel";
|
import route36 from "./routes/novel/updateNovel";
|
||||||
import route37 from "./routes/other/deleteAllData";
|
import route37 from "./routes/other/deleteAllData";
|
||||||
import route38 from "./routes/other/getCaptcha";
|
import route38 from "./routes/other/getVersion";
|
||||||
import route39 from "./routes/production/assets/getAssetsData";
|
import route39 from "./routes/production/assets/getAssetsData";
|
||||||
import route40 from "./routes/production/editImage/generateFlowImage";
|
import route40 from "./routes/production/editImage/generateFlowImage";
|
||||||
import route41 from "./routes/production/editImage/getImageFlow";
|
import route41 from "./routes/production/editImage/getImageFlow";
|
||||||
@ -135,7 +135,7 @@ export default async (app: Express) => {
|
|||||||
app.use("/api/novel/getNovelIndex", route35);
|
app.use("/api/novel/getNovelIndex", route35);
|
||||||
app.use("/api/novel/updateNovel", route36);
|
app.use("/api/novel/updateNovel", route36);
|
||||||
app.use("/api/other/deleteAllData", route37);
|
app.use("/api/other/deleteAllData", route37);
|
||||||
app.use("/api/other/getCaptcha", route38);
|
app.use("/api/other/getVersion", route38);
|
||||||
app.use("/api/production/assets/getAssetsData", route39);
|
app.use("/api/production/assets/getAssetsData", route39);
|
||||||
app.use("/api/production/editImage/generateFlowImage", route40);
|
app.use("/api/production/editImage/generateFlowImage", route40);
|
||||||
app.use("/api/production/editImage/getImageFlow", route41);
|
app.use("/api/production/editImage/getImageFlow", route41);
|
||||||
|
|||||||
@ -1,13 +0,0 @@
|
|||||||
import express from "express";
|
|
||||||
import { success } from "@/lib/responseFormat";
|
|
||||||
import { md5 } from "js-md5";
|
|
||||||
const router = express.Router();
|
|
||||||
|
|
||||||
// 获取验证码
|
|
||||||
export default router.get("/", async (req, res) => {
|
|
||||||
const data: any = { svg: "<svg></svg>", captcha: md5("123") };
|
|
||||||
if (req.app.get("env") === "dev") {
|
|
||||||
data.key = 2;
|
|
||||||
}
|
|
||||||
res.status(200).send(success(data));
|
|
||||||
});
|
|
||||||
22
src/routes/other/getVersion.ts
Normal file
22
src/routes/other/getVersion.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import express from "express";
|
||||||
|
import { success } from "@/lib/responseFormat";
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
|
declare const __APP_VERSION__: string | undefined;
|
||||||
|
|
||||||
|
const APP_VERSION: string = (() => {
|
||||||
|
if (typeof __APP_VERSION__ !== "undefined") {
|
||||||
|
return __APP_VERSION__;
|
||||||
|
}
|
||||||
|
// 开发环境回退:从 package.json 读取
|
||||||
|
const pkgPath = path.resolve(process.cwd(), "package.json");
|
||||||
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
||||||
|
return pkg.version;
|
||||||
|
})();
|
||||||
|
|
||||||
|
export default router.get("/", async (req, res) => {
|
||||||
|
res.status(200).send(success(APP_VERSION));
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user