mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-03 13:44:47 +08:00
style: format style
This commit is contained in:
@@ -2,9 +2,9 @@ type ProxyItem = [string, string];
|
||||
|
||||
type ProxyList = ProxyItem[];
|
||||
|
||||
const regExps = (value: string,reg: string): string => {
|
||||
return value.replace(new RegExp(reg, 'g'), '');
|
||||
}
|
||||
const regExps = (value: string, reg: string): string => {
|
||||
return value.replace(new RegExp(reg, "g"), "");
|
||||
};
|
||||
|
||||
export function createProxy(list: ProxyList = []) {
|
||||
const ret: any = {};
|
||||
@@ -12,8 +12,8 @@ export function createProxy(list: ProxyList = []) {
|
||||
ret[prefix] = {
|
||||
target: target,
|
||||
changeOrigin: true,
|
||||
rewrite: (path:string) => regExps(path, prefix)
|
||||
rewrite: (path: string) => regExps(path, prefix)
|
||||
};
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as dotenv from 'dotenv';
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
export interface ViteEnv {
|
||||
VITE_PORT: number;
|
||||
@@ -11,25 +11,28 @@ export interface ViteEnv {
|
||||
export function loadEnv(): ViteEnv {
|
||||
const env = process.env.NODE_ENV;
|
||||
const ret: any = {};
|
||||
const envList = [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env', ,]
|
||||
envList.forEach((e) => {
|
||||
// eslint-disable-next-line no-sparse-arrays
|
||||
const envList = [`.env.${env}.local`, `.env.${env}`, ".env.local", ".env", ,];
|
||||
envList.forEach(e => {
|
||||
dotenv.config({
|
||||
path: e,
|
||||
path: e
|
||||
});
|
||||
});
|
||||
for (const envName of Object.keys(process.env)) {
|
||||
let realName = (process.env as any)[envName].replace(/\\n/g, '\n');
|
||||
realName = realName === 'true' ? true : realName === 'false' ? false : realName;
|
||||
if (envName === 'VITE_PORT') {
|
||||
let realName = (process.env as any)[envName].replace(/\\n/g, "\n");
|
||||
realName =
|
||||
realName === "true" ? true : realName === "false" ? false : realName;
|
||||
if (envName === "VITE_PORT") {
|
||||
realName = Number(realName);
|
||||
}
|
||||
if (envName === 'VITE_OPEN') {
|
||||
if (envName === "VITE_OPEN") {
|
||||
realName = Boolean(realName);
|
||||
}
|
||||
if (envName === 'VITE_PROXY') {
|
||||
if (envName === "VITE_PROXY") {
|
||||
try {
|
||||
realName = JSON.parse(realName);
|
||||
} catch (error) { }
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch (error) {}
|
||||
}
|
||||
ret[envName] = realName;
|
||||
process.env[envName] = realName;
|
||||
|
||||
Reference in New Issue
Block a user