修复白屏问题

This commit is contained in:
ACT丶流星雨 2026-02-10 21:26:18 +08:00
parent da37cb44ae
commit 034b362d06
5 changed files with 29 additions and 11 deletions

View File

@ -18,6 +18,7 @@ files:
- "!**/*.d.ts"
- "!src/**/*"
- "!scripts/**/*.ts"
- "!scripts/*.ts"
asar: true

View File

@ -18,7 +18,11 @@ function createMainWindow(): void {
}
app.whenReady().then(async () => {
createMainWindow();
await startServe();
try {
await startServe();
} catch (err) {
console.error("[服务启动失败]:", err);
}
});
app.on("window-all-closed", () => {

View File

@ -7,13 +7,28 @@ const defaultEnvValues: Record<string, string> = {
prod: `NODE_ENV=prod\nPORT=60000\nOSSURL=http://127.0.0.1:60000/`,
};
//加载环境变量
const env = process.env.NODE_ENV ?? "dev";
// 判断是否为打包后的 Electron 环境
const isElectron = typeof process.versions?.electron !== "undefined";
let isPackaged = false;
if (isElectron) {
const { app } = require("electron");
isPackaged = app.isPackaged;
}
//加载环境变量(打包环境默认使用 prod
const env = process.env.NODE_ENV ?? (isPackaged ? "prod" : "dev");
if (!env) {
console.log("[环境变量为空]");
process.exit(1);
} else {
const envDir = path.resolve("env");
// Electron 打包环境使用 userData 目录,开发环境使用项目根目录
let envDir: string;
if (isElectron) {
const { app } = require("electron");
envDir = path.join(app.getPath("userData"), "env");
} else {
envDir = path.resolve("env");
}
const envFilePath = path.join(envDir, `.env.${env}`);
// 自动创建 env 目录和文件(.gitignore 可能忽略了这些文件)

View File

@ -29,7 +29,7 @@ export default async (knex: Knex): Promise<void> => {
await addColumn("t_video", "aiConfigId", "integer");
await addColumn("t_config", "modelType", "text");
await addColumn("t_videoConfig", "audioEnabled", "integer");
await addColumn("t_videoConfig", "errorReason", "text");
await addColumn("t_video", "errorReason", "text");
//更正字段
await alterColumnType("t_config", "modelType", "text");

View File

@ -1,8 +1,7 @@
// @db-hash 5a1cbe86324cb073c1931fc53c56725f
// @db-hash 5a633f2d45df5d971905dd32c0ac9880
//该文件由脚本自动生成,请勿手动修改
export interface _t_video_old_20260210 {
'aiConfigId'?: number | null;
export interface _t_video_old_20260131 {
'configId'?: number | null;
'filePath'?: string | null;
'firstFrame'?: string | null;
@ -53,6 +52,7 @@ export interface t_config {
'manufacturer'?: string | null;
'model'?: string | null;
'modelType'?: string | null;
'name'?: string | null;
'type'?: string | null;
'userId'?: number | null;
}
@ -139,7 +139,6 @@ export interface t_user {
export interface t_video {
'aiConfigId'?: number | null;
'configId'?: number | null;
'errorReason'?: string | null;
'filePath'?: string | null;
'firstFrame'?: string | null;
'id'?: number;
@ -152,7 +151,6 @@ export interface t_video {
'time'?: number | null;
}
export interface t_videoConfig {
'aiConfigId'?: number | null;
'audioEnabled'?: number | null;
'createTime'?: number | null;
'duration'?: number | null;
@ -172,7 +170,7 @@ export interface t_videoConfig {
}
export interface DB {
"_t_video_old_20260210": _t_video_old_20260210;
"_t_video_old_20260131": _t_video_old_20260131;
"t_aiModelMap": t_aiModelMap;
"t_assets": t_assets;
"t_chatHistory": t_chatHistory;