From 57c6a02c135c1224e9de2766e412eedd4cd18d58 Mon Sep 17 00:00:00 2001 From: p-honggang.li <p-honggang.li@pcitc.com> Date: 星期五, 29 八月 2025 14:01:59 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/utils/env.ts | 65 ++++++++++++++++++++++++++++++++ 1 files changed, 65 insertions(+), 0 deletions(-) diff --git a/src/utils/env.ts b/src/utils/env.ts new file mode 100644 index 0000000..258ff87 --- /dev/null +++ b/src/utils/env.ts @@ -0,0 +1,65 @@ +/** + * 鐜閰嶇疆绠$悊 + */ + +// 鐜绫诲瀷鏋氫妇 +export enum Environment { + DEVELOPMENT = 'development', + PRODUCTION = 'production', + TEST = 'test' +} + +// 鑾峰彇褰撳墠鐜 +export const getCurrentEnvironment = (): Environment => { + const mode = import.meta.env.MODE + if (mode === 'development') return Environment.DEVELOPMENT + if (mode === 'production') return Environment.PRODUCTION + if (mode === 'test') return Environment.TEST + return Environment.DEVELOPMENT // 榛樿寮�鍙戠幆澧� +} + +// 鏄惁涓哄紑鍙戠幆澧� +export const isDevelopment = (): boolean => { + return import.meta.env.DEV +} + +// 鏄惁涓虹敓浜х幆澧� +export const isProduction = (): boolean => { + return import.meta.env.PROD +} + +// 鏄惁涓烘祴璇曠幆澧� +export const isTest = (): boolean => { + return import.meta.env.MODE === 'test' +} + +// 鑿滃崟鏄剧ず閰嶇疆 +export const getMenuConfig = () => { + return { + // 寮�鍙戠幆澧冩樉绀烘墍鏈夎彍鍗� + showLeftMenu: isDevelopment(), + showTopMenu: isDevelopment(), + showHeader: isDevelopment(), + showFooter: isDevelopment(), + // 鐢熶骇鐜鍙樉绀洪〉闈㈠唴瀹� + showPageContent: true + } +} + +// 甯冨眬鏍峰紡閰嶇疆 +export const getLayoutConfig = () => { + const isDev = isDevelopment() + return { + // 涓诲鍣ㄩ珮搴� + mainContainerHeight: isDev ? 'calc(95vh - 90px)' : '100vh', + // 鏄惁鏄剧ず渚ц竟鏍� + showSidebar: isDev, + // 鏄惁鏄剧ず椤堕儴瀵艰埅 + showTopNav: isDev, + // 鏄惁鏄剧ず澶撮儴 + showHeader: isDev, + // 鏄惁鏄剧ず搴曢儴鐗堟潈淇℃伅 + showFooter: isDev + } +} + -- Gitblit v1.8.0