diff --git a/.env b/.env deleted file mode 100644 index 4ea20d2..0000000 --- a/.env +++ /dev/null @@ -1 +0,0 @@ -ossURL= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1575956..f5aa258 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/src/env.ts b/src/env.ts index 09af65c..db8f322 100644 --- a/src/env.ts +++ b/src/env.ts @@ -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) { diff --git a/src/utils/oss.ts b/src/utils/oss.ts index d53dbfd..e95ed21 100644 --- a/src/utils/oss.ts +++ b/src/utils/oss.ts @@ -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("/")}`;