refactor(env): 统一环境变量命名规范
This commit is contained in:
14
.env
14
.env
@@ -1,10 +1,12 @@
|
|||||||
|
VITE_BUILD_SOURCE_MAP=true
|
||||||
|
VITE_BUILD_MINIFY=true
|
||||||
|
VITE_CLOUDFLARE_SERVER_ENABLED=true
|
||||||
|
|
||||||
VITE_APP_TITLE=vue-ts-example-2025
|
VITE_APP_TITLE=vue-ts-example-2025
|
||||||
VITE_APP_BASE=/
|
VITE_APP_BASE=/
|
||||||
VITE_APP_BUILD_SOURCE_MAP=true
|
|
||||||
VITE_APP_BUILD_MINIFY=true
|
|
||||||
VITE_APP_BUILD_COMMIT=
|
VITE_APP_BUILD_COMMIT=
|
||||||
VITE_APP_BUILD_TIME=
|
VITE_APP_BUILD_TIME=
|
||||||
VITE_ENABLE_VUE_DEVTOOLS=true
|
VITE_APP_ENABLE_VUE_DEVTOOLS=true
|
||||||
VITE_MENU_SHOW_DEMOS=true
|
VITE_APP_MENU_SHOW_DEMOS=true
|
||||||
VITE_MENU_SHOW_ORDER=true
|
VITE_APP_MENU_SHOW_ORDER=true
|
||||||
VITE_CLOUDFLARE_SERVER_ENABLED=true
|
VITE_APP_ENABLE_ROUTER_LOG_GUARD=true
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export function useMetaLayoutsNMenuOptions({ menuInstRef }: { menuInstRef: Ref<M
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 根据环境变量判断是否显示 /demos 开头的路由
|
// 根据环境变量判断是否显示 /demos 开头的路由
|
||||||
if (import.meta.env.VITE_MENU_SHOW_DEMOS !== 'true' && route.path.startsWith('/demos')) {
|
if (import.meta.env.VITE_APP_MENU_SHOW_DEMOS !== 'true' && route.path.startsWith('/demos')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -114,7 +114,7 @@ export function useMetaLayoutsNMenuOptions({ menuInstRef }: { menuInstRef: Ref<M
|
|||||||
const routeName = route.name as string;
|
const routeName = route.name as string;
|
||||||
|
|
||||||
let text = te(routeName) ? t(routeName) : route.meta?.title || routeName;
|
let text = te(routeName) ? t(routeName) : route.meta?.title || routeName;
|
||||||
if (import.meta.env.VITE_MENU_SHOW_ORDER === 'true' && route.meta?.order) {
|
if (import.meta.env.VITE_APP_MENU_SHOW_ORDER === 'true' && route.meta?.order) {
|
||||||
const order = String(route.meta.order).padStart(orderMaxLength, '0');
|
const order = String(route.meta.order).padStart(orderMaxLength, '0');
|
||||||
text = `${order}. ${text}`;
|
text = `${order}. ${text}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export function install({ app }: { app: import('vue').App<Element> }) {
|
|||||||
{
|
{
|
||||||
// 警告:路由守卫的创建顺序会影响执行流程,请勿调整
|
// 警告:路由守卫的创建顺序会影响执行流程,请勿调整
|
||||||
createNProgressGuard(router);
|
createNProgressGuard(router);
|
||||||
createLogGuard(router);
|
if (import.meta.env.VITE_APP_ENABLE_ROUTER_LOG_GUARD === 'true') createLogGuard(router);
|
||||||
Object.assign(globalThis, { stack: createStackGuard(router) });
|
Object.assign(globalThis, { stack: createStackGuard(router) });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export function loadPlugin(configEnv: ConfigEnv): PluginOption {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (env.VITE_ENABLE_VUE_DEVTOOLS !== 'true') {
|
if (env.VITE_APP_ENABLE_VUE_DEVTOOLS !== 'true') {
|
||||||
consola.info('vue-devtools plugin disabled by env');
|
consola.info('vue-devtools plugin disabled by env');
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ export default defineConfig(async (configEnv) => {
|
|||||||
return {
|
return {
|
||||||
base: env.VITE_APP_BASE,
|
base: env.VITE_APP_BASE,
|
||||||
build: {
|
build: {
|
||||||
minify: env.VITE_APP_BUILD_MINIFY === 'true' ? undefined /* 即默认 */ : false, // 默认: 'terser'
|
minify: env.VITE_BUILD_MINIFY === 'true' ? undefined /* 即默认 */ : false, // 默认: 'terser'
|
||||||
sourcemap: env.VITE_APP_BUILD_SOURCE_MAP === 'true',
|
sourcemap: env.VITE_BUILD_SOURCE_MAP === 'true',
|
||||||
rollupOptions: viteConfigRollupOptions,
|
rollupOptions: viteConfigRollupOptions,
|
||||||
},
|
},
|
||||||
css: {
|
css: {
|
||||||
|
|||||||
15
worker-configuration.d.ts
vendored
15
worker-configuration.d.ts
vendored
@@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
// Generated by Wrangler by running `wrangler types` (hash: 84692d03acd392dfe81b48b26e3d156f)
|
// Generated by Wrangler by running `wrangler types` (hash: 038b66b18c316cb50fca417e244a37c5)
|
||||||
// Runtime types generated with workerd@1.20251008.0 2025-09-09
|
// Runtime types generated with workerd@1.20251008.0 2025-09-09
|
||||||
declare namespace Cloudflare {
|
declare namespace Cloudflare {
|
||||||
interface GlobalProps {
|
interface GlobalProps {
|
||||||
@@ -7,16 +7,17 @@ declare namespace Cloudflare {
|
|||||||
}
|
}
|
||||||
interface Env {
|
interface Env {
|
||||||
KV: KVNamespace;
|
KV: KVNamespace;
|
||||||
|
VITE_BUILD_SOURCE_MAP: string;
|
||||||
|
VITE_BUILD_MINIFY: string;
|
||||||
|
VITE_CLOUDFLARE_SERVER_ENABLED: string;
|
||||||
VITE_APP_TITLE: string;
|
VITE_APP_TITLE: string;
|
||||||
VITE_APP_BASE: string;
|
VITE_APP_BASE: string;
|
||||||
VITE_APP_BUILD_SOURCE_MAP: string;
|
|
||||||
VITE_APP_BUILD_MINIFY: string;
|
|
||||||
VITE_APP_BUILD_COMMIT: string;
|
VITE_APP_BUILD_COMMIT: string;
|
||||||
VITE_APP_BUILD_TIME: string;
|
VITE_APP_BUILD_TIME: string;
|
||||||
VITE_ENABLE_VUE_DEVTOOLS: string;
|
VITE_APP_ENABLE_VUE_DEVTOOLS: string;
|
||||||
VITE_MENU_SHOW_DEMOS: string;
|
VITE_APP_MENU_SHOW_DEMOS: string;
|
||||||
VITE_MENU_SHOW_ORDER: string;
|
VITE_APP_MENU_SHOW_ORDER: string;
|
||||||
VITE_CLOUDFLARE_SERVER_ENABLED: string;
|
VITE_APP_ENABLE_ROUTER_LOG_GUARD: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
interface Env extends Cloudflare.Env {}
|
interface Env extends Cloudflare.Env {}
|
||||||
|
|||||||
Reference in New Issue
Block a user