更新: 增强ossUrl返回健壮性

This commit is contained in:
a12110 2026-04-10 23:27:33 +08:00
parent 7486c419f1
commit 6e825f6c8a
5 changed files with 12 additions and 36 deletions

1
.env Normal file
View File

@ -0,0 +1 @@
ossURL=

1
.gitignore vendored
View File

@ -17,7 +17,6 @@ _.log
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local

View File

@ -1,3 +1,11 @@
import dotenv from "dotenv";
import path from "node:path";
dotenv.config({
path: path.resolve(process.cwd(), ".env"),
});
// 判断是否为打包后的 Electron 环境
const isElectron = typeof process.versions?.electron !== "undefined";
let isPackaged = false;

View File

@ -1,37 +1,6 @@
// @db-hash 6cd709d9bdfe00c4dc87961a8ebba149
// @db-hash 3296433eb24314b094ac5d3839c049c5
//该文件由脚本自动生成,请勿手动修改
export interface _o_project_old_20260404 {
'artStyle'?: string | null;
'createTime'?: number | null;
'directorManual'?: string | null;
'id'?: number | null;
'imageModel'?: string | null;
'imageQuality'?: string | null;
'intro'?: string | null;
'mode'?: string | null;
'name'?: string | null;
'projectType'?: string | null;
'type'?: string | null;
'userId'?: number | null;
'videoModel'?: string | null;
'videoRatio'?: string | null;
}
export interface _o_prompt_old_20260406 {
'data'?: string | null;
'id'?: number;
'name'?: string | null;
'type'?: string | null;
'useData'?: string | null;
}
export interface _o_prompt_old_20260406_1 {
'data'?: string | null;
'id'?: number;
'name'?: string | null;
'TEXT'?: any | null;
'type'?: string | null;
'useData'?: string | null;
}
export interface memories {
'content': string;
'createTime': number;
@ -263,9 +232,6 @@ export interface o_videoTrack {
}
export interface DB {
"_o_project_old_20260404": _o_project_old_20260404;
"_o_prompt_old_20260406": _o_prompt_old_20260406;
"_o_prompt_old_20260406_1": _o_prompt_old_20260406_1;
"memories": memories;
"o_agentDeploy": o_agentDeploy;
"o_agentWorkData": o_agentWorkData;

View File

@ -51,6 +51,8 @@ class OSS {
const safePath = normalizeUserPath(userRelPath);
// URL 始终使用 /,所以这里需要将系统分隔符转回 /
let url = `/${prefix}/`;
if (!process.env.ossURL || process.env.ossURL != "") url = process.env.ossURL + `/${prefix}/`;
// if (process.env.NODE_ENV == "dev") url = `http://localhost:10588/${prefix}/`;
if (isEletron()) url = `http://localhost:${process.env.PORT}/${prefix}/`;
return `${url}${safePath.split(path.sep).join("/")}`;
}