2026-04-04 18:54:17 +08:00

16 lines
481 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 判断是否为打包后的 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;
if (!env) {
if (isElectron) process.env.NODE_ENV = "prod";
else process.env.NODE_ENV = "dev";
console.log(`[环境变量:${process.env.NODE_ENV}]`);
}