From a11fbf83525bb741bc47b1752718f0bca07ffd0b Mon Sep 17 00:00:00 2001 From: songjianet <1778651752@qq.com> Date: Thu, 27 Jan 2022 17:54:46 +0800 Subject: [PATCH] [Feature][UI Next] Change how env is used. (#8221) --- dolphinscheduler-ui-next/.env.development | 2 +- dolphinscheduler-ui-next/.env.production | 2 +- dolphinscheduler-ui-next/src/layouts/content/index.tsx | 7 +++++-- .../src/layouts/content/use-dataList.ts | 8 ++------ dolphinscheduler-ui-next/src/service/service.ts | 5 ++++- .../src/views/projects/workflow/relation/index.tsx | 4 ++-- dolphinscheduler-ui-next/vite.config.ts | 10 +++++++++- 7 files changed, 24 insertions(+), 14 deletions(-) diff --git a/dolphinscheduler-ui-next/.env.development b/dolphinscheduler-ui-next/.env.development index b667c39809..db4722f352 100644 --- a/dolphinscheduler-ui-next/.env.development +++ b/dolphinscheduler-ui-next/.env.development @@ -15,4 +15,4 @@ NODE_ENV = development -VITE_APP_WEB_URL = '' +VITE_APP_DEV_WEB_URL = '' diff --git a/dolphinscheduler-ui-next/.env.production b/dolphinscheduler-ui-next/.env.production index 35599c8a2d..d974189303 100644 --- a/dolphinscheduler-ui-next/.env.production +++ b/dolphinscheduler-ui-next/.env.production @@ -15,4 +15,4 @@ NODE_ENV = production -VITE_APP_WEB_URL = '' +VITE_APP_PROD_WEB_URL = '' diff --git a/dolphinscheduler-ui-next/src/layouts/content/index.tsx b/dolphinscheduler-ui-next/src/layouts/content/index.tsx index eafc6f02cb..35ff9664c9 100644 --- a/dolphinscheduler-ui-next/src/layouts/content/index.tsx +++ b/dolphinscheduler-ui-next/src/layouts/content/index.tsx @@ -64,7 +64,7 @@ const Content = defineComponent({ state.isShowSide = menuStore.getShowSideStatus sideKey.value = route.matched[1]?.path }, - {immediate: true} + { immediate: true } ) const getSideMenu = (state: any) => { @@ -101,7 +101,10 @@ const Content = defineComponent({ {this.isShowSide && ( - + )} diff --git a/dolphinscheduler-ui-next/src/layouts/content/use-dataList.ts b/dolphinscheduler-ui-next/src/layouts/content/use-dataList.ts index 5ffb96f5e3..e018e6213c 100644 --- a/dolphinscheduler-ui-next/src/layouts/content/use-dataList.ts +++ b/dolphinscheduler-ui-next/src/layouts/content/use-dataList.ts @@ -266,15 +266,11 @@ export function useDataList() { const changeHeaderMenuOptions = (state: any) => { state.headerMenuOptions = state.menuOptions.map( - (item: { - label: string - key: string - icon: any - }) => { + (item: { label: string; key: string; icon: any }) => { return { label: item.label, key: item.key, - icon: item.icon, + icon: item.icon } } ) diff --git a/dolphinscheduler-ui-next/src/service/service.ts b/dolphinscheduler-ui-next/src/service/service.ts index a854f709c5..c71fbd868c 100644 --- a/dolphinscheduler-ui-next/src/service/service.ts +++ b/dolphinscheduler-ui-next/src/service/service.ts @@ -23,7 +23,10 @@ import { useUserStore } from '@/store/user/user' const userStore = useUserStore() const baseRequestConfig: AxiosRequestConfig = { - baseURL: import.meta.env.VITE_APP_WEB_URL + '/dolphinscheduler', + baseURL: + import.meta.env.MODE === 'development' + ? '/dolphinscheduler' + : import.meta.env.VITE_APP_PROD_WEB_URL + '/dolphinscheduler', timeout: 10000, transformRequest: (params) => { if (_.isPlainObject(params)) { diff --git a/dolphinscheduler-ui-next/src/views/projects/workflow/relation/index.tsx b/dolphinscheduler-ui-next/src/views/projects/workflow/relation/index.tsx index 076848054d..8baa303ea8 100644 --- a/dolphinscheduler-ui-next/src/views/projects/workflow/relation/index.tsx +++ b/dolphinscheduler-ui-next/src/views/projects/workflow/relation/index.tsx @@ -18,8 +18,8 @@ import { defineComponent, onMounted, toRefs, watch } from 'vue' import { useI18n } from 'vue-i18n' import { useRoute } from 'vue-router' -import {NSelect, NButton, NIcon, NSpace, NTooltip} from 'naive-ui' -import {ReloadOutlined, EyeOutlined, EditOutlined} from '@vicons/antd' +import { NSelect, NButton, NIcon, NSpace, NTooltip } from 'naive-ui' +import { ReloadOutlined, EyeOutlined, EditOutlined } from '@vicons/antd' import { useRelation } from './use-relation' import Card from '@/components/card' import Graph from './components/Graph' diff --git a/dolphinscheduler-ui-next/vite.config.ts b/dolphinscheduler-ui-next/vite.config.ts index 8e82cce227..019618e75b 100644 --- a/dolphinscheduler-ui-next/vite.config.ts +++ b/dolphinscheduler-ui-next/vite.config.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { defineConfig } from 'vite' +import { defineConfig, loadEnv } from 'vite' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' import viteCompression from 'vite-plugin-compression' @@ -49,5 +49,13 @@ export default defineConfig({ // resolve vue-i18n warning: You are running the esm-bundler build of vue-i18n. 'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js' } + }, + server: { + proxy: { + '/dolphinscheduler': { + target: loadEnv('development', './').VITE_APP_DEV_WEB_URL, + changeOrigin: true + } + } } })