Merge branch 'jzx/upgrade-onePort-20240423' into 'develop'

feat(app.ts): 兼容80端口

See merge request web-project/aircraft-carrier-fleet!14
This commit is contained in:
江志雄 2024-05-08 14:04:30 +08:00
commit a6da074b84
5 changed files with 35 additions and 10 deletions

11
config/config.prod.ts Normal file
View File

@ -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/',
},
});

View File

@ -18,6 +18,7 @@ export default defineConfig({
routes, routes,
npmClient: 'pnpm', npmClient: 'pnpm',
define: { define: {
APP_ENV: process.env.NODE_ENV || 'production', APP_ENV: process.env.NODE_ENV || 'development',
COMMON_URL: 'http://10.0.0.204:30058', // 基建服务
}, },
}); });

4
global.d.ts vendored
View File

@ -1 +1,5 @@
declare const APP_ENV: string; 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;

View File

@ -18,6 +18,8 @@
"@ant-design/pro-components": "^2.6.49", "@ant-design/pro-components": "^2.6.49",
"@umijs/max": "^4.1.1", "@umijs/max": "^4.1.1",
"@zhst/func": "^0.8.1", "@zhst/func": "^0.8.1",
"@zhst/request": "^0.12.1",
"@zhst/slave": "^0.7.1",
"antd": "^5.14.1", "antd": "^5.14.1",
"cross-env": "^7.0.3" "cross-env": "^7.0.3"
}, },

View File

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