From 2c2bc8614c8ea0ce386369eb4924da1e6aa052d1 Mon Sep 17 00:00:00 2001
From: husq <931347610@qq.com>
Date: Wed, 27 Sep 2023 09:35:57 +0800
Subject: [PATCH] 添加环境配置区分
---
src/components/GMap.vue | 3 +
env/.env.stag | 15 +------
src/env.d.ts | 8 +++
env/.env.production | 6 +-
env/.env | 6 +--
src/main.ts | 2
src/api/http/request.ts | 4 +-
vite.config.ts | 2
env/.env.dev | 3 +
src/api/http/config.ts | 9 ++--
tsconfig.json | 9 ++--
src/websocket/util/config.ts | 3 -
package.json | 5 ++
13 files changed, 37 insertions(+), 38 deletions(-)
diff --git a/env/.env b/env/.env
index edbd2bd..87c4fea 100644
--- a/env/.env
+++ b/env/.env
@@ -1,4 +1,2 @@
-VITE_APP_ENVIRONMENT=DEV
-VITE_APP_APIGATEWAY_BACKEND_HOST=''
-VITE_HTTP = 'http://172.16.13.129:8100'
-VITE_CESIUM_TOKEN = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJhMjdmNGUxZC02YzY3LTQyZWUtOTNmYy1hNTI0MDRkZDY2ZmEiLCJpZCI6MTYxODgyLCJpYXQiOjE2OTI3NTQyNDV9.Pm7xTwPmKowPzFgJ0TsIKOtthigq86BLJX4c8M97Hhw'
\ No newline at end of file
+VITE_API_URL = 'http://192.168.1.198:6789'
+VITE_WS_API_URL = 'ws://192.168.1.198:6789/api/v1/ws'
\ No newline at end of file
diff --git a/env/.env.dev b/env/.env.dev
new file mode 100644
index 0000000..f352086
--- /dev/null
+++ b/env/.env.dev
@@ -0,0 +1,3 @@
+VITE_API_URL = 'http://192.168.1.198:6789'
+VITE_WS_API_URL = 'ws://192.168.1.198:6789/api/v1/ws'
+VITE_APP_ENVIRONMENT=DEV
\ No newline at end of file
diff --git a/env/.env.production b/env/.env.production
index 22c939b..21a0ed8 100644
--- a/env/.env.production
+++ b/env/.env.production
@@ -1,4 +1,4 @@
-VITE_APP_ENVIRONMENT=production
+VITE_APP_ENVIRONMENT=PROD
VITE_APP_APIGATEWAY_BACKEND_HOST=''
-VITE_HTTP = 'http://172.16.13.129:8100'
-VITE_CESIUM_TOKEN = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJhMjdmNGUxZC02YzY3LTQyZWUtOTNmYy1hNTI0MDRkZDY2ZmEiLCJpZCI6MTYxODgyLCJpYXQiOjE2OTI3NTQyNDV9.Pm7xTwPmKowPzFgJ0TsIKOtthigq86BLJX4c8M97Hhw'
\ No newline at end of file
+VITE_API_URL = 'https://dev.jxpskj.com:36789'
+VITE_WS_API_URL = 'wss://dev.jxpskj.com:36789/api/v1/ws'
diff --git a/env/.env.stag b/env/.env.stag
index 8aa5141..c6b010b 100644
--- a/env/.env.stag
+++ b/env/.env.stag
@@ -1,14 +1,3 @@
-###
- # @Author: husq 931347610@qq.com
- # @Date: 2023-08-22 09:55:39
- # @LastEditors: husq 931347610@qq.com
- # @LastEditTime: 2023-08-30 17:56:53
- # @FilePath: \Cloud-API-Demo-Web\env\.env.stag
- # @Description:
- #
- # Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
-###
VITE_APP_ENVIRONMENT=STAG
-VITE_APP_APIGATEWAY_BACKEND_HOST=''
-VITE_HTTP = 'http://172.16.13.129:8100'
-VITE_CESIUM_TOKEN = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJhMjdmNGUxZC02YzY3LTQyZWUtOTNmYy1hNTI0MDRkZDY2ZmEiLCJpZCI6MTYxODgyLCJpYXQiOjE2OTI3NTQyNDV9.Pm7xTwPmKowPzFgJ0TsIKOtthigq86BLJX4c8M97Hhw'
\ No newline at end of file
+VITE_API_URL = 'http://192.168.1.198:6789'
+VITE_WS_API_URL = 'ws://192.168.1.198:6789/api/v1/ws'
\ No newline at end of file
diff --git a/package.json b/package.json
index 7f7c374..0a87c23 100644
--- a/package.json
+++ b/package.json
@@ -3,8 +3,11 @@
"version": "0.0.1",
"scripts": {
"serve": "vite",
+ "serve:dev": "vite --mode dev",
+ "serve:production": "vite --mode production",
"build:test": "vite build --mode stag",
- "build": "vite build",
+ "build:production": "vite build --mode production",
+ "build:dev": "vite build --mode dev",
"preview": "vite preview",
"lint": "eslint --fix"
},
diff --git a/src/api/http/config.ts b/src/api/http/config.ts
index 56b0d3d..d88c538 100644
--- a/src/api/http/config.ts
+++ b/src/api/http/config.ts
@@ -4,17 +4,16 @@
appId: '136971', // You need to go to the development website to apply.
appKey: '3e56cb20958060caeb1071cdb32400e', // You need to go to the development website to apply.
appLicense: 'eS2rczbPpEUZZkOuek7hB1fugv3TE0RdKyEU319A2cxmVKs7Bc11RadcPcHnQJjBq/Peja5R6bp2IILCypa2lskCUGXkXHmqxdPIVTyMQpkZtjM+eXLut/VHPdXVZOvYxKFMVel6jfEyd4rWL9jBI1N34rCvwSgad6T49mRC8R0=', // You need to go to the development website to apply
-
// http
// http://172.16.13.64:8100
// baseURL: 'http://192.168.1.133:6789', // This url must end with "/". Example: 'http://192.168.1.1:6789/'
- // baseURL: 'http://192.168.1.198:6789', // This url must end with "/". Example: 'http://192.168.1.1:6789/'
- baseURL: 'https://dev.jxpskj.com:36789', // This url must end with "/". Example: 'http://192.168.1.1:6789/'
+ // baseURL: 'http://192.168.1.133:6789', // This url must end with "/". Example: 'http://192.168.1.1:6789/'
+ baseURL: 'http://192.168.1.198:6789', // This url must end with "/". Example: 'http://192.168.1.1:6789/'
// ws: 'ws//127.0.0.1:6789/api/v1/ws',
// ws://192.168.1.198:1883/
- // websocketURL: 'ws://192.168.1.198:6789/api/v1/ws', // Example: 'ws://192.168.1.198:6789/api/v1/ws'
+ websocketURL: 'ws://192.168.1.198:6789/api/v1/ws', // Example: 'ws://192.168.1.198:6789/api/v1/ws'
// websocketURL: 'ws://192.168.1.133:6789/api/v1/ws', // Example: 'ws://192.168.1.198:6789/api/v1/ws'
- websocketURL: 'wss://dev.jxpskj.com:36789/api/v1/ws', // Example: 'ws://192.168.1.198:6789/api/v1/ws'
+ // websocketURL: 'wss://dev.jxpskj.com:36789/api/v1/ws', // Example: 'ws://192.168.1.198:6789/api/v1/ws'
// livestreaming
// RTMP Note: This IP is the address of the streaming server. If you want to see livestream on web page, you need to convert the RTMP stream to WebRTC stream.
diff --git a/src/api/http/request.ts b/src/api/http/request.ts
index 44ca4e8..5d9c1f6 100644
--- a/src/api/http/request.ts
+++ b/src/api/http/request.ts
@@ -10,7 +10,7 @@
function getAuthToken () {
return localStorage.getItem(ELocalStorageKey.Token)
}
-
+console.log(import.meta.env.VITE_API_URL, 'request.ts')
const instance = axios.create({
// withCredentials: true,
headers: {
@@ -22,7 +22,7 @@
instance.interceptors.request.use(
config => {
config.headers[ELocalStorageKey.Token] = localStorage.getItem(ELocalStorageKey.Token)
- config.baseURL = CURRENT_CONFIG.baseURL
+ config.baseURL = import.meta.env.VITE_API_URL
// config.headers[REQUEST_ID] = uuidv4()
// config.baseURL = CURRENT_CONFIG.baseURL
return config
diff --git a/src/components/GMap.vue b/src/components/GMap.vue
index 8c8a784..8d32862 100644
--- a/src/components/GMap.vue
+++ b/src/components/GMap.vue
@@ -169,7 +169,8 @@
</div>
</div>
<!-- 机场OSD -->
- <div class="osd-panel fz12" v-if="osdVisible.visible && osdVisible.is_dock">
+ <!-- && osdVisible.is_dock -->
+ <div class="osd-panel fz12" v-if="osdVisible.visible">
<div class="fz16 pl5 pr5 flex-align-center flex-row flex-justify-between"
style="border-bottom: 1px solid #515151; height: 10%;">
<span>{{ osdVisible.gateway_callsign }}</span>
diff --git a/src/env.d.ts b/src/env.d.ts
index e19346d..e5fad7e 100644
--- a/src/env.d.ts
+++ b/src/env.d.ts
@@ -1,9 +1,15 @@
// Environment variable definition
// https://cn.vitejs.dev/guide/env-and-mode.html#env-files
-
+/// <reference types="vite/client" />
interface ImportMetaEnv {
VITE_APP_ENVIRONMENT: 'DEV' | 'STAG' | 'UAT' | 'PROD',
// api gateway
VITE_APP_APIGATEWAY_BACKEND_HOST: string
+ VITE_API_URL: string
+ VITE_WS_API_URL: string
// More environment variables...
}
+
+interface ImportMeta {
+ readonly env: ImportMetaEnv
+}
diff --git a/src/main.ts b/src/main.ts
index f0da572..bfc8303 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -2,7 +2,7 @@
* @Author: husq 931347610@qq.com
* @Date: 2023-09-13 18:21:07
* @LastEditors: husq 931347610@qq.com
- * @LastEditTime: 2023-09-25 15:54:31
+ * @LastEditTime: 2023-09-26 17:11:02
* @FilePath: \Cloud-API-Demo-Web\src\main.ts
* @Description:
*
diff --git a/src/websocket/util/config.ts b/src/websocket/util/config.ts
index 5d01148..a8ab912 100644
--- a/src/websocket/util/config.ts
+++ b/src/websocket/util/config.ts
@@ -2,11 +2,10 @@
import { CURRENT_CONFIG } from '/@/api/http/config'
const user = localStorage.getItem('user_info')
-
export function getWebsocketUrl () {
const token: string = localStorage.getItem(ELocalStorageKey.Token) || '' as string
// const url = CURRENT_CONFIG.websocketURL
- const url = CURRENT_CONFIG.websocketURL + '?x-auth-token=' + encodeURI(token)
+ const url = import.meta.env.VITE_WS_API_URL + '?x-auth-token=' + encodeURI(token)
return url
}
diff --git a/tsconfig.json b/tsconfig.json
index bdbeccb..53ce92b 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -12,7 +12,7 @@
"types": ["vite/client"],
"lib": [
"esnext",
- "dom"
+ "dom",
],
"paths": {
"/@/*": [
@@ -24,8 +24,9 @@
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
- "src/**/*.vue"
-, "src/vendors/coordtransform.js",
-"types/auto-imports.d.ts"
+ "src/**/*.vue",
+ "src/vendors/coordtransform.js",
+ "types/auto-imports.d.ts",
+ "src/env.d.ts"
]
}
\ No newline at end of file
diff --git a/vite.config.ts b/vite.config.ts
index 76ae186..1eef1cd 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -86,7 +86,7 @@
},
}
},
- base: '/',
+ base: './',
build: {
target: ['es2015'], // 最低支持 es2015
sourcemap: true
--
Gitblit v1.9.3