修复白屏问题
This commit is contained in:
parent
da37cb44ae
commit
034b362d06
@ -18,6 +18,7 @@ files:
|
|||||||
- "!**/*.d.ts"
|
- "!**/*.d.ts"
|
||||||
- "!src/**/*"
|
- "!src/**/*"
|
||||||
- "!scripts/**/*.ts"
|
- "!scripts/**/*.ts"
|
||||||
|
- "!scripts/*.ts"
|
||||||
|
|
||||||
asar: true
|
asar: true
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,11 @@ function createMainWindow(): void {
|
|||||||
}
|
}
|
||||||
app.whenReady().then(async () => {
|
app.whenReady().then(async () => {
|
||||||
createMainWindow();
|
createMainWindow();
|
||||||
await startServe();
|
try {
|
||||||
|
await startServe();
|
||||||
|
} catch (err) {
|
||||||
|
console.error("[服务启动失败]:", err);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on("window-all-closed", () => {
|
app.on("window-all-closed", () => {
|
||||||
|
|||||||
21
src/env.ts
21
src/env.ts
@ -7,13 +7,28 @@ const defaultEnvValues: Record<string, string> = {
|
|||||||
prod: `NODE_ENV=prod\nPORT=60000\nOSSURL=http://127.0.0.1:60000/`,
|
prod: `NODE_ENV=prod\nPORT=60000\nOSSURL=http://127.0.0.1:60000/`,
|
||||||
};
|
};
|
||||||
|
|
||||||
//加载环境变量
|
// 判断是否为打包后的 Electron 环境
|
||||||
const env = process.env.NODE_ENV ?? "dev";
|
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) {
|
if (!env) {
|
||||||
console.log("[环境变量为空]");
|
console.log("[环境变量为空]");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
} else {
|
} 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}`);
|
const envFilePath = path.join(envDir, `.env.${env}`);
|
||||||
|
|
||||||
// 自动创建 env 目录和文件(.gitignore 可能忽略了这些文件)
|
// 自动创建 env 目录和文件(.gitignore 可能忽略了这些文件)
|
||||||
|
|||||||
@ -29,7 +29,7 @@ export default async (knex: Knex): Promise<void> => {
|
|||||||
await addColumn("t_video", "aiConfigId", "integer");
|
await addColumn("t_video", "aiConfigId", "integer");
|
||||||
await addColumn("t_config", "modelType", "text");
|
await addColumn("t_config", "modelType", "text");
|
||||||
await addColumn("t_videoConfig", "audioEnabled", "integer");
|
await addColumn("t_videoConfig", "audioEnabled", "integer");
|
||||||
await addColumn("t_videoConfig", "errorReason", "text");
|
await addColumn("t_video", "errorReason", "text");
|
||||||
|
|
||||||
//更正字段
|
//更正字段
|
||||||
await alterColumnType("t_config", "modelType", "text");
|
await alterColumnType("t_config", "modelType", "text");
|
||||||
|
|||||||
10
src/types/database.d.ts
vendored
10
src/types/database.d.ts
vendored
@ -1,8 +1,7 @@
|
|||||||
// @db-hash 5a1cbe86324cb073c1931fc53c56725f
|
// @db-hash 5a633f2d45df5d971905dd32c0ac9880
|
||||||
//该文件由脚本自动生成,请勿手动修改
|
//该文件由脚本自动生成,请勿手动修改
|
||||||
|
|
||||||
export interface _t_video_old_20260210 {
|
export interface _t_video_old_20260131 {
|
||||||
'aiConfigId'?: number | null;
|
|
||||||
'configId'?: number | null;
|
'configId'?: number | null;
|
||||||
'filePath'?: string | null;
|
'filePath'?: string | null;
|
||||||
'firstFrame'?: string | null;
|
'firstFrame'?: string | null;
|
||||||
@ -53,6 +52,7 @@ export interface t_config {
|
|||||||
'manufacturer'?: string | null;
|
'manufacturer'?: string | null;
|
||||||
'model'?: string | null;
|
'model'?: string | null;
|
||||||
'modelType'?: string | null;
|
'modelType'?: string | null;
|
||||||
|
'name'?: string | null;
|
||||||
'type'?: string | null;
|
'type'?: string | null;
|
||||||
'userId'?: number | null;
|
'userId'?: number | null;
|
||||||
}
|
}
|
||||||
@ -139,7 +139,6 @@ export interface t_user {
|
|||||||
export interface t_video {
|
export interface t_video {
|
||||||
'aiConfigId'?: number | null;
|
'aiConfigId'?: number | null;
|
||||||
'configId'?: number | null;
|
'configId'?: number | null;
|
||||||
'errorReason'?: string | null;
|
|
||||||
'filePath'?: string | null;
|
'filePath'?: string | null;
|
||||||
'firstFrame'?: string | null;
|
'firstFrame'?: string | null;
|
||||||
'id'?: number;
|
'id'?: number;
|
||||||
@ -152,7 +151,6 @@ export interface t_video {
|
|||||||
'time'?: number | null;
|
'time'?: number | null;
|
||||||
}
|
}
|
||||||
export interface t_videoConfig {
|
export interface t_videoConfig {
|
||||||
'aiConfigId'?: number | null;
|
|
||||||
'audioEnabled'?: number | null;
|
'audioEnabled'?: number | null;
|
||||||
'createTime'?: number | null;
|
'createTime'?: number | null;
|
||||||
'duration'?: number | null;
|
'duration'?: number | null;
|
||||||
@ -172,7 +170,7 @@ export interface t_videoConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface DB {
|
export interface DB {
|
||||||
"_t_video_old_20260210": _t_video_old_20260210;
|
"_t_video_old_20260131": _t_video_old_20260131;
|
||||||
"t_aiModelMap": t_aiModelMap;
|
"t_aiModelMap": t_aiModelMap;
|
||||||
"t_assets": t_assets;
|
"t_assets": t_assets;
|
||||||
"t_chatHistory": t_chatHistory;
|
"t_chatHistory": t_chatHistory;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user