完善版本号获取,为热更新做准备

This commit is contained in:
ACT丶流星雨 2026-03-26 16:25:25 +08:00
parent 696f0f6115
commit 70e56f2fac
5 changed files with 33 additions and 18 deletions

View File

@ -19,6 +19,8 @@ if (!fs.existsSync(envFile)) {
console.log(`📄 已自动创建环境变量文件: ${envFile}`);
}
const pkg = JSON.parse(fs.readFileSync(path.resolve("package.json"), "utf8"));
const external = [
"electron",
"@huggingface/transformers",
@ -51,6 +53,9 @@ const appBuildConfig: esbuild.BuildOptions = {
},
sourcemap: false,
external,
define: {
__APP_VERSION__: JSON.stringify(pkg.version),
},
};
// Electron 主进程打包配置
@ -69,6 +74,9 @@ const mainBuildConfig: esbuild.BuildOptions = {
},
sourcemap: false,
external,
define: {
__APP_VERSION__: JSON.stringify(pkg.version),
},
};
(async () => {

View File

@ -40,7 +40,6 @@ export async function decisionAI(ctx: AgentContext) {
resTool.systemMessage("决策层AI 接管聊天");
const memory = new Memory("scriptAgent", isolationKey);
console.log("%c Line:43 🥟 isolationKey", "background:#4fff4B", isolationKey);
await memory.add("user", 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");
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({
system: prefixSystem + systemPrompt,

View File

@ -1,4 +1,4 @@
// @routes-hash fd1b3ec2552be041f1b6e9582eb842b6
// @routes-hash adf6a50cb14a1d93aea2983d0364e6a3
import { Express } from "express";
import route1 from "./routes/agents/clearMemory";
@ -38,7 +38,7 @@ import route34 from "./routes/novel/getNovelEventState";
import route35 from "./routes/novel/getNovelIndex";
import route36 from "./routes/novel/updateNovel";
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 route40 from "./routes/production/editImage/generateFlowImage";
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/updateNovel", route36);
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/editImage/generateFlowImage", route40);
app.use("/api/production/editImage/getImageFlow", route41);

View File

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

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