config.ts
// https://umijs.org/config/
import { defineConfig } from '@umijs/max';
import { join } from 'path';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
import routes from './routes';
const { REACT_APP_ENV = 'dev' } = process.env;
export default defineConfig({
define: {
// API_URL: 'http://192.168.1.91:8080'
// API_URL: 'http://10.90.27.66:8888/api',
API_URL: 'http://10.90.22.79:8888/api',
// API_URL: 'http://10.5.16.35:8081',
// API_URL: 'http://112.124.50.186:8080',
WS_URL :`ws://10.90.27.66:8888/api/player`,
// WS_URL :`ws://10.90.22.53:8000/api/player`,
ICE_SERVERS :{
"iceServers": [
{
urls:"stun:10.90.27.66:3478"
},
{
urls: ["turn:10.90.27.66:3478"],
username: "kurento",
credential: "kurento"
}
]
}
},
headScripts: [
{ src: '/js/adapter.min.js'},
{ src: "/js/webrtcstreamer.js"},
],
keepalive: [/./],
tabsLayout: {},
/**
* @name 开启 hash 模式
* @description 让 build 之后的产物包含 hash 后缀。通常用于增量发布和避免浏览器加载缓存。
* @doc https://umijs.org/docs/api/config#hash
*/
hash: true,
/**
* @name 兼容性设置
* @description 设置 ie11 不一定完美兼容,需要检查自己使用的所有依赖
* @doc https://umijs.org/docs/api/config#targets
*/
// targets: {
// ie: 11,
// },
/**
* @name 路由的配置,不在路由中引入的文件不会编译
* @description 只支持 path,component,routes,redirect,wrappers,title 的配置
* @doc https://umijs.org/docs/guides/routes
*/
// umi routes: https://umijs.org/docs/routing
routes,
/**
* @name 主题的配置
* @description 虽然叫主题,但是其实只是 less 的变量设置
* @doc antd的主题设置 https://ant.design/docs/react/customize-theme-cn
* @doc umi 的theme 配置 https://umijs.org/docs/api/config#theme
*/
theme: {
// 如果不想要 configProvide 动态设置主题需要把这个设置为 default
// 只有设置为 variable, 才能使用 configProvide 动态设置主色调
'root-entry-name': 'variable',
},
/**
* @name moment 的国际化配置
* @description 如果对国际化没有要求,打开之后能减少js的包大小
* @doc https://umijs.org/docs/api/config#ignoremomentlocale
*/
ignoreMomentLocale: true,
/**
* @name 代理配置
* @description 可以让你的本地服务器代理到你的服务器上,这样你就可以访问服务器的数据了
* @see 要注意以下 代理只能在本地开发时使用,build 之后就无法使用了。
* @doc 代理介绍 https://umijs.org/docs/guides/proxy
* @doc 代理配置 https://umijs.org/docs/api/config#proxy
*/
proxy: proxy[REACT_APP_ENV as keyof typeof proxy],
/**
* @name 快速热更新配置
* @description 一个不错的热更新组件,更新时可以保留 state
*/
fastRefresh: true,
//============== 以下都是max的插件配置 ===============
/**
* @name 数据流插件
* @@doc https://umijs.org/docs/max/data-flow
*/
model: {},
/**
* 一个全局的初始数据流,可以用它在插件之间共享数据
* @description 可以用来存放一些全局的数据,比如用户信息,或者一些全局的状态,全局初始状态在整个 Umi 项目的最开始创建。
* @doc https://umijs.org/docs/max/data-flow#%E5%85%A8%E5%B1%80%E5%88%9D%E5%A7%8B%E7%8A%B6%E6%80%81
*/
initialState: {},
/**
* @name layout 插件
* @doc https://umijs.org/docs/max/layout-menu
*/
layout: {
locale: true,
...defaultSettings,
},
/**
* @name 国际化插件
* @doc https://umijs.org/docs/max/i18n
*/
locale: {
// default zh-CN
default: 'zh-CN',
antd: true,
// default true, when it is true, will use `navigator.language` overwrite default
baseNavigator: true,
},
/**
* @name antd 插件
* @description 内置了 babel import 插件
* @doc https://umijs.org/docs/max/antd#antd
*/
antd: {},
/**
* @name 网络请求配置
* @description 它基于 axios 和 ahooks 的 useRequest 提供了一套统一的网络请求和错误处理方案。
* @doc https://umijs.org/docs/max/request
*/
request: {},
/**
* @name 权限插件
* @description 基于 initialState 的权限插件,必须先打开 initialState
* @doc https://umijs.org/docs/max/access
*/
access: {},
//================ pro 插件配置 =================
presets: ['umi-presets-pro'],
/**
* @name openAPI 插件的配置
* @description 基于 openapi 的规范生成serve 和mock,能减少很多样板代码
* @doc https://pro.ant.design/zh-cn/docs/openapi/
*/
openAPI: [
{
requestLibPath: "import { request } from '@umijs/max'",
// 或者使用在线的版本
// schemaPath: "https://gw.alipayobjects.com/os/antfincdn/M%24jrzTTYJN/oneapi.json"
schemaPath: join(__dirname, 'oneapi.json'),
mock: false,
},
{
requestLibPath: "import { request } from '@umijs/max'",
schemaPath: 'https://gw.alipayobjects.com/os/antfincdn/CA1dOm%2631B/openapi.json',
projectName: 'swagger',
},
],
// mfsu: {
// strategy: 'normal',
// },
requestRecord: {},
});
defaultSettings.ts
import { Settings as LayoutSettings } from '@ant-design/pro-components';
/**
* @name
*/
const Settings: LayoutSettings & {
pwa?: boolean;
logo?: string;
} = {
navTheme: 'light',
// 拂晓蓝
colorPrimary: '#1890ff',
layout: 'mix',
contentWidth: 'Fluid',
fixedHeader: false,
fixSiderbar: true,
colorWeak: false,
title: '',
pwa: false,
logo: '/loms.png',
iconfontUrl: '',
};
export default Settings;
routes.ts
/**
* @name umi 的路由配置
* @description 只支持 path,component,routes,redirect,wrappers,name,icon 的配置
* @param path path 只支持两种占位符配置,第一种是动态参数 :id 的形式,第二种是 * 通配符,通配符只能出现路由字符串的最后。
* @param component 配置 location 和 path 匹配后用于渲染的 React 组件路径。可以是绝对路径,也可以是相对路径,如果是相对路径,会从 src/pages 开始找起。
* @param routes 配置子路由,通常在需要为多个路径增加 layout 组件时使用。
* @param redirect 配置路由跳转
* @param wrappers 配置路由组件的包装组件,通过包装组件可以为当前的路由组件组合进更多的功能。 比如,可以用于路由级别的权限校验
* @param name 配置路由的标题,默认读取国际化文件 menu.ts 中 menu.xxxx 的值,如配置 name 为 login,则读取 menu.ts 中 menu.login 的取值作为标题
* @param icon 配置路由的图标,取值参考 https://ant.design/components/icon-cn, 注意去除风格后缀和大小写,如想要配置图标为 <StepBackwardOutlined /> 则取值应为 stepBackward 或 StepBackward,如想要配置图标为 <UserOutlined /> 则取值应为 user 或者 User
* @doc https://umijs.org/docs/guides/routes
*/
export default [
{
path: '/user',
layout: false,
routes: [
{
name: 'login',
path: '/user/login',
component: './User/Login',
},
{
name: 'register',
path: '/user/register',
component: './User/register',
},
{
component: './404',
},
],
},
{
path: '/welcome',
name: 'welcome',
icon: 'smile',
component: './DashBoard',
},
{
path: '/team',
name: 'team',
icon: 'UserOutlined',
routes: [
{
path: '/team/manage',
name: 'manage',
icon: 'UserOutlined',
component: './TeamManage',
},
{
path: '/team/person',
name: 'person',
icon: 'UserOutlined',
component: './TeamManage/PersonManage',
},
{
path: '/team/personDetail/:uniqueKey',
name: 'personDetail',
icon: 'UserOutlined',
hideInMenu: true,
component: './TeamManage/PersonManage/Detail',
},
{
path: '/team/schedule',
name: 'schedule',
icon: 'UserOutlined',
component: './TeamManage/ExperimentalSchedule',
},
],
},
{
path: '/project',
name: 'project',
icon: 'AppstoreOutlined',
component: './Project',
},
{
path: '/task',
name: 'task',
icon: 'ExperimentOutlined',
routes: [
{
path: '/task/experiment',
name: 'experiment',
component: './Experiment',
icon: 'ExperimentOutlined',
},
{ path: '/task/run', name: 'run', component: './Run', icon: 'DesktopOutlined' },
],
},
{
path: '/experiment',
routes: [
{
path: '/experiment/design',
icon: 'ExperimentOutlined',
component: './Experiment/design',
},
{
path: '/experiment/detail',
icon: 'ExperimentOutlined',
component: './Experiment/design/disabledIndex',
},
],
},
{
path: '/run',
icon: 'ReconciliationOutlined',
routes: [
{
path: '/run/design',
icon: 'ExperimentOutlined',
component: './Run/design',
},
{
path: '/run/detail',
icon: 'ExperimentOutlined',
component: './Run/design/disabledIndex',
},
],
},
{
path: '/device',
name: 'device',
icon: 'FundProjectionScreenOutlined',
routes: [
{
path: '/device',
icon: 'FundProjectionScreenOutlined',
component: './DeviceManage',
},
{
path: '/device/detail/:uniqueKey', // 设备详情页面
icon: 'FundProjectionScreenOutlined',
component: './DeviceManage/DeviceList',
},
],
},
{
path: '/board',
name: "board",
component: './Board',
layout: false,
},
{
path: '/board',
name: 'board',
icon: 'FundProjectionScreenOutlined',
redirect: "/board"
},
{
path: '/building',
name: 'building',
component: './Building',
layout: false,
},
{
path: '/building',
name: 'building',
icon: 'FundProjectionScreenOutlined',
redirect: "/building"
},
{
path: '/consumable',
name: 'consumable',
icon: 'ReconciliationOutlined',
component: './ConsumableManagement',
},
// {
// path: '/camera',
// name: 'camera',
// icon: 'FundProjectionScreenOutlined',
// routes: [
// {
// path: '/camera',
// icon: 'FundProjectionScreenOutlined',
// component: './Camera',
// }
// ],
// },
{
path: '/storage',
name: 'storage',
icon: 'FundProjectionScreenOutlined',
routes: [
{
path: '/storage',
icon: 'FundProjectionScreenOutlined',
component: './StorageManage',
}
],
},
{
path: '/sample',
name: 'sample',
icon: 'TagsOutlined',
component: './Sample/List',
},
{
path: '/runWorksheet',
name: 'runWorksheet',
icon: 'ReconciliationOutlined',
component: './WorkSheet/run/List',
},
{
path: '/runSample',
name: 'runSample',
icon: 'ContainerOutlined',
component: './RunSample',
},
{
path: '/instrument',
name: 'instrument',
icon: 'FundProjectionScreenOutlined',
component: './Instrument',
},
{
path: '/template',
name: 'template',
icon: 'MacCommandOutlined',
component: './Template',
},
{
path: '/client',
name: 'client',
icon: 'TeamOutlined',
component: './Client/List',
},
{
path: '/system',
name: 'system',
icon: 'SettingOutlined',
component: './System/settings',
},
{
path: '/',
redirect: '/board',
layout: false,
},
{
path: '*',
layout: false,
component: './404',
},
];