Commit 2abdbf78d8ca7ab7be4e8a308fc714cf098dd1d2

Authored by ww
1 parent da2f608d

feat: pull out environment variables to appapp.config.js

1 1 # Whether to open mock
2   -# VITE_USE_MOCK = true
  2 +# VITE_GLOB_USE_MOCK = true
3 3
4 4 # public path
5   -VITE_PUBLIC_PATH = /
  5 +VITE_GLOB_PUBLIC_PATH = /
6 6
7 7 # Cross-domain proxy, you can configure multiple
8 8 # Please note that no line breaks
... ... @@ -21,11 +21,11 @@ VITE_PROXY = [["/api","http://222.180.200.114:48080/api"],["/thingskit-drawio","
21 21 # 实时数据的ws地址
22 22 # VITE_WEB_SOCKET = ws://localhost:8080/api/ws/plugins/telemetry?token=
23 23 # VITE_WEB_SOCKET = ws://44.99.141.212:8080/api/ws/plugins/telemetry?token=
24   -VITE_WEB_SOCKET = ws://222.180.200.114:48080/api/ws/plugins/telemetry?token=
  24 +VITE_GLOB_WEB_SOCKET = ws://222.180.200.114:48080/api/ws/plugins/telemetry?token=
25 25 # VITE_WEB_SOCKET = ws://121.37.251.8:8080/api/ws/plugins/telemetry?token=
26 26
27 27 # Delete console
28   -VITE_DROP_CONSOLE = true
  28 +VITE_GLOB_DROP_CONSOLE = true
29 29
30 30 # Basic interface address SPA
31 31 VITE_GLOB_API_URL=/api
... ... @@ -40,10 +40,10 @@ VITE_GLOB_API_URL_PREFIX=/yt
40 40 VITE_GLOB_CONFIGURATION = /thingskit-drawio
41 41
42 42 # Content Security Policy
43   -VITE_CONTENT_SECURITY_POLICY = false
  43 +VITE_GLOB_CONTENT_SECURITY_POLICY = true
44 44
45 45 # Alarm Notify Polling Interval Time
46   -VITE_ALARM_NOTIFY_POLLING_INTERVAL_TIME = 500000
  46 +VITE_GLOB_ALARM_NOTIFY_POLLING_INTERVAL_TIME = 500000
47 47
48 48 # Alarm Notify Auto Close Time Unit is Second
49   -VITE_ALARM_NOTIFY_DURATION = 5
  49 +VITE_GLOB_ALARM_NOTIFY_DURATION = 5
... ...
1 1 # Whether to open mock
2   -VITE_USE_MOCK = false
  2 +VITE_GLOB_USE_MOCK = false
3 3
4 4 # public path
5   -VITE_PUBLIC_PATH = /
  5 +VITE_GLOB_PUBLIC_PATH = /
6 6
7 7 # Delete console
8   -VITE_DROP_CONSOLE = true
  8 +VITE_GLOB_DROP_CONSOLE = true
9 9
10 10 # Whether to enable gzip or brotli compression
11 11 # Optional: gzip | brotli | none
12 12 # If you need multiple forms, you can use `,` to separate
13   -VITE_BUILD_COMPRESS = 'gzip'
  13 +VITE_GLOB_BUILD_COMPRESS = 'gzip'
14 14
15 15 # Whether to delete origin files when using compress, default false
16   -VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false
  16 +VITE_GLOB_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false
17 17
18 18 # Basic interface address SPA
19 19 VITE_GLOB_API_URL=http://122.9.141.195:8080/api
... ... @@ -26,7 +26,7 @@ VITE_GLOB_UPLOAD_URL=http://122.9.141.195:8080/api/yt/oss/upload
26 26 VITE_GLOB_API_URL_PREFIX=/yt
27 27
28 28 # Whether to enable image compression
29   -VITE_USE_IMAGEMIN= false
  29 +VITE_GLOB_USE_IMAGEMIN= false
30 30
31 31 # use pwa
32 32 VITE_USE_PWA = false
... ... @@ -35,16 +35,16 @@ VITE_USE_PWA = false
35 35 VITE_LEGACY = true
36 36
37 37 # 实时数据的ws地址
38   -VITE_WEB_SOCKET = ws://122.9.141.195:8080/api/ws/plugins/telemetry?token=
  38 +VITE_GLOB_WEB_SOCKET = ws://122.9.141.195:8080/api/ws/plugins/telemetry?token=
39 39
40 40 #configuration
41 41 VITE_GLOB_CONFIGURATION = /thingskit-scada
42 42
43 43 # Content Security Policy
44   -VITE_CONTENT_SECURITY_POLICY = false
  44 +VITE_GLOB_CONTENT_SECURITY_POLICY = false
45 45
46 46 # Alarm Notify Polling Interval Time
47   -VITE_ALARM_NOTIFY_POLLING_INTERVAL_TIME = 60000
  47 +VITE_GLOB_ALARM_NOTIFY_POLLING_INTERVAL_TIME = 60000
48 48
49 49 # Alarm Notify Auto Close Time Unit is Second
50   -VITE_ALARM_NOTIFY_DURATION = 5
  50 +VITE_GLOB_ALARM_NOTIFY_DURATION = 5
... ...
... ... @@ -10,9 +10,11 @@ import pkg from '../../../package.json';
10 10 import { GLOB_CONFIG_FILE_NAME } from '../../constant';
11 11
12 12 export function configHtmlPlugin(env: ViteEnv, isBuild: boolean) {
13   - const { VITE_GLOB_APP_TITLE, VITE_PUBLIC_PATH, VITE_CONTENT_SECURITY_POLICY } = env;
  13 + const { VITE_GLOB_APP_TITLE, VITE_GLOB_PUBLIC_PATH, VITE_GLOB_CONTENT_SECURITY_POLICY } = env;
14 14
15   - const path = VITE_PUBLIC_PATH.endsWith('/') ? VITE_PUBLIC_PATH : `${VITE_PUBLIC_PATH}/`;
  15 + const path = VITE_GLOB_PUBLIC_PATH.endsWith('/')
  16 + ? VITE_GLOB_PUBLIC_PATH
  17 + : `${VITE_GLOB_PUBLIC_PATH}/`;
16 18
17 19 const getAppConfigSrc = () => {
18 20 return `${path || '/'}${GLOB_CONFIG_FILE_NAME}?v=${pkg.version}-${new Date().getTime()}`;
... ... @@ -24,7 +26,7 @@ export function configHtmlPlugin(env: ViteEnv, isBuild: boolean) {
24 26 // Inject data into ejs template
25 27 injectData: {
26 28 title: VITE_GLOB_APP_TITLE,
27   - contentSecurityPolicy: VITE_CONTENT_SECURITY_POLICY
  29 + contentSecurityPolicy: VITE_GLOB_CONTENT_SECURITY_POLICY
28 30 ? `<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />`
29 31 : '',
30 32 },
... ...
... ... @@ -19,11 +19,11 @@ import { configHmrPlugin } from './hmr';
19 19
20 20 export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
21 21 const {
22   - VITE_USE_IMAGEMIN,
23   - VITE_USE_MOCK,
  22 + VITE_GLOB_USE_IMAGEMIN,
  23 + VITE_GLOB_USE_MOCK,
24 24 VITE_LEGACY,
25   - VITE_BUILD_COMPRESS,
26   - VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE,
  25 + VITE_GLOB_BUILD_COMPRESS,
  26 + VITE_GLOB_BUILD_COMPRESS_DELETE_ORIGIN_FILE,
27 27 } = viteEnv;
28 28
29 29 const vitePlugins: (Plugin | Plugin[])[] = [
... ... @@ -49,7 +49,7 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
49 49 vitePlugins.push(configSvgIconsPlugin(isBuild));
50 50
51 51 // vite-plugin-mock
52   - VITE_USE_MOCK && vitePlugins.push(configMockPlugin(isBuild));
  52 + VITE_GLOB_USE_MOCK && vitePlugins.push(configMockPlugin(isBuild));
53 53
54 54 // vite-plugin-purge-icons
55 55 vitePlugins.push(purgeIcons());
... ... @@ -66,11 +66,11 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
66 66 // The following plugins only work in the production environment
67 67 if (isBuild) {
68 68 //vite-plugin-imagemin
69   - VITE_USE_IMAGEMIN && vitePlugins.push(configImageminPlugin());
  69 + VITE_GLOB_USE_IMAGEMIN && vitePlugins.push(configImageminPlugin());
70 70
71 71 // rollup-plugin-gzip
72 72 vitePlugins.push(
73   - configCompressPlugin(VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE)
  73 + configCompressPlugin(VITE_GLOB_BUILD_COMPRESS, VITE_GLOB_BUILD_COMPRESS_DELETE_ORIGIN_FILE)
74 74 );
75 75
76 76 // vite-plugin-pwa
... ...
... ... @@ -65,6 +65,7 @@
65 65 import { isNumber } from '/@/utils/is';
66 66 import { useLocale } from '/@/locales/useLocale';
67 67 import { useAppStore } from '/@/store/modules/app';
  68 + import { useGlobSetting } from '/@/hooks/setting';
68 69
69 70 const tinymceProps = {
70 71 options: {
... ... @@ -140,7 +141,8 @@
140 141
141 142 const initOptions = computed((): RawEditorSettings => {
142 143 const { height, options, toolbar, plugins } = props;
143   - const publicPath = import.meta.env.VITE_PUBLIC_PATH || '/';
  144 + useGlobSetting();
  145 + const publicPath = import.meta.env.VITE_GLOB_PUBLIC_PATH || '/';
144 146 return {
145 147 selector: `#${unref(tinymceId)}`,
146 148 height,
... ...
... ... @@ -10,6 +10,11 @@ export const useGlobSetting = (): Readonly<GlobConfig> => {
10 10 VITE_GLOB_APP_SHORT_NAME,
11 11 VITE_GLOB_API_URL_PREFIX,
12 12 VITE_GLOB_UPLOAD_URL,
  13 + VITE_GLOB_CONFIGURATION,
  14 + VITE_GLOB_WEB_SOCKET,
  15 + VITE_GLOB_CONTENT_SECURITY_POLICY,
  16 + VITE_GLOB_ALARM_NOTIFY_POLLING_INTERVAL_TIME,
  17 + VITE_GLOB_ALARM_NOTIFY_DURATION,
13 18 } = getAppEnvConfig();
14 19
15 20 if (!/[a-zA-Z\_]*/.test(VITE_GLOB_APP_SHORT_NAME)) {
... ... @@ -25,6 +30,11 @@ export const useGlobSetting = (): Readonly<GlobConfig> => {
25 30 shortName: VITE_GLOB_APP_SHORT_NAME,
26 31 urlPrefix: VITE_GLOB_API_URL_PREFIX,
27 32 uploadUrl: VITE_GLOB_UPLOAD_URL,
  33 + configurationPrefix: VITE_GLOB_CONFIGURATION,
  34 + socketUrl: VITE_GLOB_WEB_SOCKET,
  35 + securityPolicy: VITE_GLOB_CONTENT_SECURITY_POLICY,
  36 + alarmNotifyDuration: VITE_GLOB_ALARM_NOTIFY_DURATION,
  37 + alarmPollingInterval: VITE_GLOB_ALARM_NOTIFY_POLLING_INTERVAL_TIME,
28 38 };
29 39 return glob as Readonly<GlobConfig>;
30 40 };
... ...
  1 +import { useGlobSetting } from '../setting';
  2 +
  3 +let initialFlag = false;
  4 +export function useWebSecurityPolicy() {
  5 + if (window && window.document && window.document.documentElement) {
  6 + const { securityPolicy } = useGlobSetting();
  7 + if (securityPolicy === 'true' && !initialFlag) {
  8 + const meta = document.createElement('meta');
  9 + meta.setAttribute('http-equiv', 'Content-Security-Policy');
  10 + meta.setAttribute('content', 'upgrade-insecure-requests');
  11 + const container = document.querySelector('head');
  12 + container?.prepend(meta);
  13 + initialFlag = true;
  14 + }
  15 + }
  16 +}
... ...
... ... @@ -15,11 +15,14 @@ import { setupI18n } from '/@/locales/setupI18n';
15 15 import { registerGlobComp } from '/@/components/registerGlobComp';
16 16 import '/@/assets/iconfont/iconfont';
17 17 import { usePlatform } from './views/system/customize/hook/usePlatformInfo';
  18 +import { useWebSecurityPolicy } from './hooks/web/useWebSecurityPolicy';
18 19
19 20 if (import.meta.env.DEV) {
20 21 import('ant-design-vue/dist/antd.less');
21 22 }
22 23 async function bootstrap() {
  24 + useWebSecurityPolicy();
  25 +
23 26 const app = createApp(App);
24 27 // Configure store
25 28 setupStore(app);
... ...
... ... @@ -15,7 +15,7 @@ getRouteNames(basicRoutes);
15 15
16 16 // app router
17 17 export const router = createRouter({
18   - history: createWebHistory(import.meta.env.VITE_PUBLIC_PATH),
  18 + history: createWebHistory(import.meta.env.VITE_GLOB_PUBLIC_PATH),
19 19 routes: basicRoutes as unknown as RouteRecordRaw[],
20 20 strict: true,
21 21 scrollBehavior: () => ({ left: 0, top: 0 }),
... ...
... ... @@ -21,7 +21,6 @@ export function getAppEnvConfig() {
21 21 ? // Get the global configuration (the configuration will be extracted independently when packaging)
22 22 (import.meta.env as unknown as GlobEnvConfig)
23 23 : window[ENV_NAME as any]) as unknown as GlobEnvConfig;
24   -
25 24 const {
26 25 VITE_GLOB_APP_TITLE,
27 26 VITE_GLOB_API_URL,
... ... @@ -29,6 +28,10 @@ export function getAppEnvConfig() {
29 28 VITE_GLOB_API_URL_PREFIX,
30 29 VITE_GLOB_UPLOAD_URL,
31 30 VITE_GLOB_CONFIGURATION,
  31 + VITE_GLOB_WEB_SOCKET,
  32 + VITE_GLOB_CONTENT_SECURITY_POLICY,
  33 + VITE_GLOB_ALARM_NOTIFY_POLLING_INTERVAL_TIME,
  34 + VITE_GLOB_ALARM_NOTIFY_DURATION,
32 35 } = ENV;
33 36
34 37 if (!/^[a-zA-Z\_]*$/.test(VITE_GLOB_APP_SHORT_NAME)) {
... ... @@ -44,6 +47,10 @@ export function getAppEnvConfig() {
44 47 VITE_GLOB_API_URL_PREFIX,
45 48 VITE_GLOB_UPLOAD_URL,
46 49 VITE_GLOB_CONFIGURATION,
  50 + VITE_GLOB_WEB_SOCKET,
  51 + VITE_GLOB_CONTENT_SECURITY_POLICY,
  52 + VITE_GLOB_ALARM_NOTIFY_POLLING_INTERVAL_TIME,
  53 + VITE_GLOB_ALARM_NOTIFY_DURATION,
47 54 };
48 55 }
49 56
... ...
... ... @@ -7,6 +7,7 @@ import { alarmLevel } from '/@/views/device/list/config/detail.config';
7 7 import { RoleEnum } from '/@/enums/roleEnum';
8 8 import { usePermission } from '/@/hooks/web/usePermission';
9 9 import { useUserStore } from '/@/store/modules/user';
  10 +import { useGlobSetting } from '/@/hooks/setting';
10 11
11 12 interface UseAlarmNotifyParams {
12 13 alarmNotifyStatus?: AlarmStatus;
... ... @@ -20,10 +21,11 @@ export enum AlarmPermissionKey {
20 21 }
21 22
22 23 export function useAlarmNotify(params: UseAlarmNotifyParams = {}) {
  24 + const { alarmNotifyDuration, alarmPollingInterval } = useGlobSetting();
23 25 const {
24 26 alarmNotifyStatus = AlarmStatus.ACTIVE_UN_ACK,
25   - interval = import.meta.env.VITE_ALARM_NOTIFY_POLLING_INTERVAL_TIME || 60000,
26   - duration = import.meta.env.VITE_ALARM_NOTIFY_DURATION || 5,
  27 + interval = Number(alarmPollingInterval) || 60000,
  28 + duration = Number(alarmNotifyDuration) || 5,
27 29 color = 'orange',
28 30 } = params;
29 31 const alarmNotifyStatusMean = AlarmStatusMean[alarmNotifyStatus];
... ...
... ... @@ -84,10 +84,11 @@
84 84 deleteConfigurationCenter,
85 85 } from '/@/api/configuration/center/configurationCenter';
86 86 import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
87   - import { getAppEnvConfig, isDevMode } from '/@/utils/env';
  87 + import { isDevMode } from '/@/utils/env';
88 88 import { Authority } from '/@/components/Authority';
89 89 import { Popconfirm } from 'ant-design-vue';
90 90 import { Tag } from 'ant-design-vue';
  91 + import { useGlobSetting } from '/@/hooks/setting';
91 92 export default defineComponent({
92 93 components: {
93 94 PageWrapper,
... ... @@ -100,7 +101,7 @@
100 101 Tag,
101 102 },
102 103 setup() {
103   - const { VITE_GLOB_CONFIGURATION } = getAppEnvConfig();
  104 + const { configurationPrefix } = useGlobSetting();
104 105 const isDev = isDevMode();
105 106 const searchInfo = reactive<Recordable>({});
106 107 const { organizationIdTreeRef, resetFn } = useResetOrganizationTree(searchInfo);
... ... @@ -165,14 +166,14 @@
165 166
166 167 const handlePreview = (record: Recordable | null) => {
167 168 window.open(
168   - `${VITE_GLOB_CONFIGURATION}/${isDev ? '?dev=1&' : '?'}configurationId=${
  169 + `${configurationPrefix}/${isDev ? '?dev=1&' : '?'}configurationId=${
169 170 record!.id
170 171 }&lightbox=1`
171 172 );
172 173 };
173 174 const handleDesign = (record: Recordable | null) => {
174 175 window.open(
175   - `${VITE_GLOB_CONFIGURATION}/${isDev ? '?dev=1&' : '?'}configurationId=${record!.id}`
  176 + `${configurationPrefix}/${isDev ? '?dev=1&' : '?'}configurationId=${record!.id}`
176 177 );
177 178 };
178 179
... ...
... ... @@ -28,6 +28,7 @@
28 28 import configurationSrc from '/@/assets/icons/configuration.svg';
29 29 import { cloneDeep } from 'lodash';
30 30 import { usePermission } from '/@/hooks/web/usePermission';
  31 + import { useGlobSetting } from '/@/hooks/setting';
31 32
32 33 const listColumn = ref(5);
33 34
... ... @@ -110,23 +111,19 @@
110 111 }
111 112 };
112 113
113   - const { VITE_GLOB_CONFIGURATION } = import.meta.env;
  114 + const { configurationPrefix } = useGlobSetting();
114 115 const isDev = isDevMode();
115 116
116 117 const { hasPermission } = usePermission();
117 118 const handlePreview = (record: ConfigurationCenterItemsModal) => {
118 119 if (!hasPermission('api:yt:configuration:center:get_configuration_info:get')) return;
119 120 window.open(
120   - `${VITE_GLOB_CONFIGURATION}/${isDev ? '?dev=1&' : '?'}configurationId=${
121   - record!.id
122   - }&lightbox=1`
  121 + `${configurationPrefix}/${isDev ? '?dev=1&' : '?'}configurationId=${record!.id}&lightbox=1`
123 122 );
124 123 };
125 124
126 125 const handleDesign = (record: ConfigurationCenterItemsModal) => {
127   - window.open(
128   - `${VITE_GLOB_CONFIGURATION}/${isDev ? '?dev=1&' : '?'}configurationId=${record!.id}`
129   - );
  126 + window.open(`${configurationPrefix}/${isDev ? '?dev=1&' : '?'}configurationId=${record!.id}`);
130 127 };
131 128
132 129 const { createSyncConfirm } = useSyncConfirm();
... ...
... ... @@ -113,6 +113,7 @@
113 113 import CustomerAlarmMessage from './CustomerAlarmMessage.vue';
114 114 import { useDate } from '../hooks/useDate';
115 115 import { getTrendData } from '/@/api/dashboard';
  116 + import { useGlobSetting } from '/@/hooks/setting';
116 117
117 118 defineExpose({
118 119 isAdmin,
... ... @@ -145,8 +146,9 @@
145 146
146 147 // web Socket
147 148 const token: string = getAuthCache(JWT_TOKEN_KEY);
  149 + const { socketUrl } = useGlobSetting();
148 150 const state = reactive({
149   - server: `${import.meta.env.VITE_WEB_SOCKET}${token}`,
  151 + server: `${socketUrl}${token}`,
150 152 alarmList: new Array<[number, string]>(),
151 153 alarmItem: new Array<[number, string]>(),
152 154 dataPointList: new Array<[number, string]>(),
... ...
... ... @@ -19,6 +19,7 @@
19 19 import { Specs, StructJSON } from '/@/api/device/model/modelOfMatterModel';
20 20 import { isArray, isObject } from '/@/utils/is';
21 21 import { DataTypeEnum } from '/@/components/Form/src/externalCompns/components/StructForm/config';
  22 + import { useGlobSetting } from '/@/hooks/setting';
22 23
23 24 interface ReceiveMessage {
24 25 data: {
... ... @@ -42,9 +43,9 @@
42 43 };
43 44
44 45 const token = getAuthCache(JWT_TOKEN_KEY);
45   -
  46 + const { socketUrl } = useGlobSetting();
46 47 const socketInfo = reactive({
47   - origin: `${import.meta.env.VITE_WEB_SOCKET}${token}`,
  48 + origin: `${socketUrl}${token}`,
48 49 attr: undefined as string | undefined,
49 50 originData: [] as DataSource[],
50 51 dataSource: [] as DataSource[],
... ...
... ... @@ -12,6 +12,7 @@
12 12 import { getAuthCache } from '/@/utils/auth';
13 13 import { useMessage } from '/@/hooks/web/useMessage';
14 14 import type { socketDataType } from '../../types';
  15 + import { useGlobSetting } from '/@/hooks/setting';
15 16 export default defineComponent({
16 17 name: 'RealTimeData',
17 18 components: {
... ... @@ -25,8 +26,9 @@
25 26 },
26 27 setup(props) {
27 28 const token: string = getAuthCache(JWT_TOKEN_KEY);
  29 + const { socketUrl } = useGlobSetting();
28 30 const state = reactive({
29   - server: `${import.meta.env.VITE_WEB_SOCKET}${token}`,
  31 + server: `${socketUrl}${token}`,
30 32 sendValue: JSON.stringify({
31 33 attrSubCmds: [],
32 34 tsSubCmds: [
... ...
... ... @@ -2,6 +2,7 @@ import { useWebSocket } from '@vueuse/core';
2 2 import { Ref, unref } from 'vue';
3 3 import { DataBoardLayoutInfo } from '../types/type';
4 4 import { JWT_TOKEN_KEY } from '/@/enums/cacheEnum';
  5 +import { useGlobSetting } from '/@/hooks/setting';
5 6 import { getAuthCache } from '/@/utils/auth';
6 7 import { isNullAndUnDef } from '/@/utils/is';
7 8
... ... @@ -57,8 +58,10 @@ export function useSocketConnect(dataSourceRef: Ref<DataBoardLayoutInfo[]>) {
57 58
58 59 const waitSendQueue: string[] = [];
59 60
  61 + const { socketUrl } = useGlobSetting();
  62 +
60 63 const config = {
61   - server: `${import.meta.env.VITE_WEB_SOCKET}${token}`,
  64 + server: `${socketUrl}${token}`,
62 65 };
63 66
64 67 // const getNeedUpdateValueById = (componentId: string, deviceId: string) => {};
... ...
... ... @@ -146,6 +146,16 @@ export interface GlobConfig {
146 146 urlPrefix?: string;
147 147 // Project abbreviation
148 148 shortName: string;
  149 + // configuration center proxy prefix
  150 + configurationPrefix: string;
  151 + // socket url
  152 + socketUrl: string;
  153 + // alarm notify alarm duration
  154 + alarmNotifyDuration: string;
  155 + // alarm notify polling interval
  156 + alarmPollingInterval: string;
  157 + // upgrade your http policy to https
  158 + securityPolicy: string;
149 159 }
150 160 export interface GlobEnvConfig {
151 161 // Site title
... ... @@ -158,6 +168,14 @@ export interface GlobEnvConfig {
158 168 VITE_GLOB_APP_SHORT_NAME: string;
159 169 // Upload url
160 170 VITE_GLOB_UPLOAD_URL?: string;
161   - //configuration
  171 + // configuration
162 172 VITE_GLOB_CONFIGURATION: string;
  173 + // socket
  174 + VITE_GLOB_WEB_SOCKET: string;
  175 + // force transform http to https
  176 + VITE_GLOB_CONTENT_SECURITY_POLICY: string;
  177 + // notify polling interval time
  178 + VITE_GLOB_ALARM_NOTIFY_POLLING_INTERVAL_TIME: string;
  179 + // notify duration
  180 + VITE_GLOB_ALARM_NOTIFY_DURATION: string;
163 181 }
... ...
... ... @@ -58,22 +58,22 @@ declare global {
58 58
59 59 declare interface ViteEnv {
60 60 VITE_PORT: number;
61   - VITE_USE_MOCK: boolean;
  61 + VITE_GLOB_USE_MOCK: boolean;
62 62 VITE_USE_PWA: boolean;
63   - VITE_PUBLIC_PATH: string;
  63 + VITE_GLOB_PUBLIC_PATH: string;
64 64 VITE_PROXY: [string, string][];
65 65 VITE_GLOB_APP_TITLE: string;
66 66 VITE_GLOB_APP_SHORT_NAME: string;
67 67 VITE_USE_CDN: boolean;
68   - VITE_DROP_CONSOLE: boolean;
69   - VITE_BUILD_COMPRESS: 'gzip' | 'brotli' | 'none';
70   - VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE: boolean;
  68 + VITE_GLOB_DROP_CONSOLE: boolean;
  69 + VITE_GLOB_BUILD_COMPRESS: 'gzip' | 'brotli' | 'none';
  70 + VITE_GLOB_BUILD_COMPRESS_DELETE_ORIGIN_FILE: boolean;
71 71 VITE_LEGACY: boolean;
72   - VITE_USE_IMAGEMIN: boolean;
  72 + VITE_GLOB_USE_IMAGEMIN: boolean;
73 73 VITE_GENERATE_UI: string;
74   - VITE_CONTENT_SECURITY_POLICY: boolean;
75   - VITE_ALARM_NOTIFY_POLLING_INTERVAL_TIME: number;
76   - VITE_ALARM_NOTIFY_DURATION: number;
  74 + VITE_GLOB_CONTENT_SECURITY_POLICY: boolean;
  75 + VITE_GLOB_ALARM_NOTIFY_POLLING_INTERVAL_TIME: number;
  76 + VITE_GLOB_ALARM_NOTIFY_DURATION: number;
77 77 }
78 78
79 79 declare function parseInt(s: string | number, radix?: number): number;
... ...
... ... @@ -30,12 +30,12 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
30 30 // The boolean type read by loadEnv is a string. This function can be converted to boolean type
31 31 const viteEnv = wrapperEnv(env);
32 32
33   - const { VITE_PORT, VITE_PUBLIC_PATH, VITE_PROXY, VITE_DROP_CONSOLE } = viteEnv;
  33 + const { VITE_PORT, VITE_GLOB_PUBLIC_PATH, VITE_PROXY, VITE_GLOB_DROP_CONSOLE } = viteEnv;
34 34
35 35 const isBuild = command === 'build';
36 36
37 37 return {
38   - base: VITE_PUBLIC_PATH,
  38 + base: VITE_GLOB_PUBLIC_PATH,
39 39 root,
40 40 resolve: {
41 41 alias: [
... ... @@ -70,7 +70,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
70 70 compress: {
71 71 keep_infinity: true,
72 72 // Used to delete console in production environment
73   - drop_console: VITE_DROP_CONSOLE,
  73 + drop_console: VITE_GLOB_DROP_CONSOLE,
74 74 },
75 75 },
76 76 // Turning off brotliSize display can slightly reduce packaging time
... ...