From 0ca9a3971069e189f647410663a30599d4534dd3 Mon Sep 17 00:00:00 2001 From: jiangzhixiong <710328466@qq.com> Date: Mon, 6 May 2024 17:44:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(all):=20=E4=BF=AE=E6=94=B9=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.prod.ts | 11 +++++++++++ config/config.ts | 3 ++- global.d.ts | 4 ++++ package.json | 2 ++ src/app.ts | 22 ++++++++++++++-------- 5 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 config/config.prod.ts diff --git a/config/config.prod.ts b/config/config.prod.ts new file mode 100644 index 0000000..fed0ba4 --- /dev/null +++ b/config/config.prod.ts @@ -0,0 +1,11 @@ +import { defineConfig } from '@umijs/max'; + +export default defineConfig({ + define: { + APP_ENV: 'production', + CABINET_HOST: '/cabinet/', + VIDEO_HOST: '/video/', + ALGORITHM_HOST: '/algorithm/', + MATERIAL_HOST: '/material/', + }, +}); diff --git a/config/config.ts b/config/config.ts index 11acdd4..f8c9515 100644 --- a/config/config.ts +++ b/config/config.ts @@ -18,6 +18,7 @@ export default defineConfig({ routes, npmClient: 'pnpm', define: { - APP_ENV: process.env.NODE_ENV || 'production', + APP_ENV: process.env.NODE_ENV || 'development', + COMMON_URL: 'http://10.0.0.204:30058', // 基建服务 }, }); diff --git a/global.d.ts b/global.d.ts index d68a63e..2db7b8b 100644 --- a/global.d.ts +++ b/global.d.ts @@ -1 +1,5 @@ declare const APP_ENV: string; +declare const COMMON_URL: string; +declare const VIDEO_HOST: string; +declare const ALGORITHM_HOST: string; +declare const MATERIAL_HOST: string; diff --git a/package.json b/package.json index e800b81..a643b2c 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,8 @@ "@ant-design/pro-components": "^2.6.49", "@umijs/max": "^4.1.1", "@zhst/func": "^0.8.1", + "@zhst/request": "^0.12.1", + "@zhst/slave": "^0.7.1", "antd": "^5.14.1", "cross-env": "^7.0.3" }, diff --git a/src/app.ts b/src/app.ts index c409ed9..26e122d 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,4 +1,4 @@ -import doRequest from '@/utils/request'; +import { reqConfig } from '@zhst/request'; import useFatherAction from './actions'; // 运行时配置 @@ -17,14 +17,16 @@ export const useQiankunStateForSlave = useFatherAction; const hostname = location.hostname; +console.log('APP_ENV', APP_ENV); + export const qiankun = { apps: [ { name: 'cabinet', // 盒子管理 entry: APP_ENV === 'production' - ? `//${hostname}:30068/cabinet/` - : '//localhost:30068/', + ? `//${hostname}:30058/cabinet/` + : '//localhost:30088/', props: {}, singular: false, credentials: true, @@ -33,8 +35,8 @@ export const qiankun = { name: 'video', // AI 智能分析仓 entry: APP_ENV === 'production' - ? `//${hostname}:30088/video/` - : '//localhost:30088/', + ? `//${hostname}:30058/video/` + : '//localhost:30068/', singular: false, credentials: true, }, @@ -42,7 +44,7 @@ export const qiankun = { name: 'algorithm', // AI 算法分析 entry: APP_ENV === 'production' - ? `//${hostname}:30078/algorithm/` + ? `//${hostname}:30058/algorithm/` : '//localhost:30078/', singular: false, credentials: true, @@ -51,7 +53,7 @@ export const qiankun = { name: 'material', // 物料库 entry: APP_ENV === 'production' - ? `//${hostname}:30098/material/` + ? `//${hostname}:30058/material/` : '//localhost:30098/', singular: false, credentials: true, @@ -65,4 +67,8 @@ export const qiankun = { }, }; -export const request = doRequest; +// @ts-ignore +export const request = reqConfig({ + baseURL: COMMON_URL, + showMsg: true, +}); From be7a154b03181a716dc5116d67ed919d30ed18bd Mon Sep 17 00:00:00 2001 From: jiangzhixiong <710328466@qq.com> Date: Wed, 8 May 2024 13:56:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat(app.ts):=20=E5=85=BC=E5=AE=B980?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/app.ts b/src/app.ts index 26e122d..5d0ce4b 100644 --- a/src/app.ts +++ b/src/app.ts @@ -15,9 +15,10 @@ export async function getInitialState(): Promise<{ // 给子应用暴露的方法 export const useQiankunStateForSlave = useFatherAction; -const hostname = location.hostname; - -console.log('APP_ENV', APP_ENV); +/** + * 单端口模式 - 兼容 80 端口 + */ +const hostname = location.port ? `${location.hostname}:${location.port}` : location.hostname export const qiankun = { apps: [ @@ -25,7 +26,7 @@ export const qiankun = { name: 'cabinet', // 盒子管理 entry: APP_ENV === 'production' - ? `//${hostname}:30058/cabinet/` + ? `//${hostname}/cabinet/` : '//localhost:30088/', props: {}, singular: false, @@ -35,7 +36,7 @@ export const qiankun = { name: 'video', // AI 智能分析仓 entry: APP_ENV === 'production' - ? `//${hostname}:30058/video/` + ? `//${hostname}/video/` : '//localhost:30068/', singular: false, credentials: true, @@ -44,7 +45,7 @@ export const qiankun = { name: 'algorithm', // AI 算法分析 entry: APP_ENV === 'production' - ? `//${hostname}:30058/algorithm/` + ? `//${hostname}/algorithm/` : '//localhost:30078/', singular: false, credentials: true, @@ -53,7 +54,7 @@ export const qiankun = { name: 'material', // 物料库 entry: APP_ENV === 'production' - ? `//${hostname}:30058/material/` + ? `//${hostname}/material/` : '//localhost:30098/', singular: false, credentials: true,