更新: 删除 通过 .env 读入 ossurl 环境变量

This commit is contained in:
a12110 2026-04-12 17:00:33 +08:00
parent ba2aff52ef
commit b7b165c860
4 changed files with 2 additions and 12 deletions

1
.env
View File

@ -1 +0,0 @@
ossURL=

1
.gitignore vendored
View File

@ -17,6 +17,7 @@ _.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,6 +1,3 @@
import dotenv from "dotenv";
import path from "node:path";
// 判断是否为打包后的 Electron 环境
const isElectron = typeof process.versions?.electron !== "undefined";
let isPackaged = false;
@ -9,13 +6,6 @@ if (isElectron) {
isPackaged = app.isPackaged;
}
// 仅在非 Electron 环境加载 .env例如 Docker / Web 后端)
if (!isElectron) {
dotenv.config({
path: path.resolve(process.cwd(), ".env"),
});
}
//加载环境变量(打包环境默认使用 prod
const env = process.env.NODE_ENV;
if (!env) {

View File

@ -51,7 +51,7 @@ 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.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("/")}`;