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..5d0ce4b 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'; // 运行时配置 @@ -15,7 +15,10 @@ export async function getInitialState(): Promise<{ // 给子应用暴露的方法 export const useQiankunStateForSlave = useFatherAction; -const hostname = location.hostname; +/** + * 单端口模式 - 兼容 80 端口 + */ +const hostname = location.port ? `${location.hostname}:${location.port}` : location.hostname export const qiankun = { apps: [ @@ -23,8 +26,8 @@ export const qiankun = { name: 'cabinet', // 盒子管理 entry: APP_ENV === 'production' - ? `//${hostname}:30068/cabinet/` - : '//localhost:30068/', + ? `//${hostname}/cabinet/` + : '//localhost:30088/', props: {}, singular: false, credentials: true, @@ -33,8 +36,8 @@ export const qiankun = { name: 'video', // AI 智能分析仓 entry: APP_ENV === 'production' - ? `//${hostname}:30088/video/` - : '//localhost:30088/', + ? `//${hostname}/video/` + : '//localhost:30068/', singular: false, credentials: true, }, @@ -42,7 +45,7 @@ export const qiankun = { name: 'algorithm', // AI 算法分析 entry: APP_ENV === 'production' - ? `//${hostname}:30078/algorithm/` + ? `//${hostname}/algorithm/` : '//localhost:30078/', singular: false, credentials: true, @@ -51,7 +54,7 @@ export const qiankun = { name: 'material', // 物料库 entry: APP_ENV === 'production' - ? `//${hostname}:30098/material/` + ? `//${hostname}/material/` : '//localhost:30098/', singular: false, credentials: true, @@ -65,4 +68,8 @@ export const qiankun = { }, }; -export const request = doRequest; +// @ts-ignore +export const request = reqConfig({ + baseURL: COMMON_URL, + showMsg: true, +});