new
This commit is contained in:
189
config/config.ts
Normal file
189
config/config.ts
Normal file
@@ -0,0 +1,189 @@
|
||||
// Https://umijs.org/config/
|
||||
|
||||
import { join } from 'node:path';
|
||||
import { defineConfig } from '@umijs/max';
|
||||
import { utcInstance as dayjs } from '../src/utils/timeFormat';
|
||||
import defaultSettings from './defaultSettings';
|
||||
import proxy from './proxy';
|
||||
import { commonRoutes, roleRoutes } from './routes';
|
||||
|
||||
type ConfigType = ReturnType<typeof defineConfig>;
|
||||
|
||||
// Project custom environment
|
||||
const { REACT_APP_ENV = 'dev' } = process.env;
|
||||
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
|
||||
/**
|
||||
* @name Use public path
|
||||
* @description The path during deployment. If deployed in a non-root directory, this variable needs to be configured.
|
||||
* @doc https://umijs.org/docs/api/config#publicpath
|
||||
*/
|
||||
const PUBLIC_PATH: string = '/';
|
||||
|
||||
const config: ConfigType = defineConfig({
|
||||
/**
|
||||
* @name Enable hash mode
|
||||
* @description Include a hash suffix in build outputs. Commonly used for incremental deployments and to prevent browser caching.
|
||||
* @doc https://umijs.org/docs/api/config#hash
|
||||
*/
|
||||
hash: true,
|
||||
publicPath: PUBLIC_PATH,
|
||||
icons: {},
|
||||
|
||||
/**
|
||||
* @name Compatibility settings
|
||||
* @description Enabling IE11 may not be fully compatible; you need to check all dependencies you use
|
||||
* @doc https://umijs.org/docs/api/config#targets
|
||||
*/
|
||||
// targets: {
|
||||
// ie: 11,
|
||||
// },
|
||||
/**
|
||||
* @name Route configuration (files not imported in routes won't be compiled)
|
||||
* @description Only supports configuration keys: path, component, routes, redirect, wrappers, title
|
||||
* @doc https://umijs.org/docs/guides/routes
|
||||
*/
|
||||
// umi routes: https://umijs.org/docs/routing
|
||||
routes: [...commonRoutes, ...roleRoutes],
|
||||
/**
|
||||
* @name Theme configuration
|
||||
* @description Although called theme, this is actually just less variable settings
|
||||
* @doc antd theme settings https://ant.design/docs/react/customize-theme-cn
|
||||
* @doc umi theme config https://umijs.org/docs/api/config#theme
|
||||
*/
|
||||
// theme: { '@primary-color': '#1DA57A' }
|
||||
/**
|
||||
* @name Moment i18n configuration
|
||||
* @description If you don't require internationalization, enabling this can reduce the JS bundle size
|
||||
* @doc https://umijs.org/docs/api/config#ignoremomentlocale
|
||||
*/
|
||||
ignoreMomentLocale: true,
|
||||
|
||||
devtool: process.env.UMI_APP_SENTRY_DSN ? 'source-map' : false,
|
||||
/**
|
||||
* @name Proxy configuration
|
||||
* @description Allows your local server to proxy requests to your backend so you can access server data locally
|
||||
* @see Note: the proxy can only be used during local development and won't work after building for production.
|
||||
* @doc Proxy intro https://umijs.org/docs/guides/proxy
|
||||
* @doc Proxy config https://umijs.org/docs/api/config#proxy
|
||||
*/
|
||||
proxy: proxy[REACT_APP_ENV as keyof typeof proxy],
|
||||
|
||||
links: [
|
||||
{ rel: 'manifest', href: '/manifest.json' },
|
||||
{ rel: 'apple-touch-icon', href: '/logo.svg' },
|
||||
],
|
||||
// https: {},
|
||||
/**
|
||||
* @name Fast refresh configuration
|
||||
* @description A solid hot-reload feature that can preserve component state during updates
|
||||
*/
|
||||
fastRefresh: true,
|
||||
//============== The following are max plugin configurations ===============
|
||||
/**
|
||||
* @name 数据流插件
|
||||
* @@doc https://umijs.org/docs/max/data-flow
|
||||
*/
|
||||
model: {},
|
||||
/**
|
||||
* 一个全局的初始数据流,可以用它在插件之间共享数据
|
||||
* @description Can be used to store global data such as user info or global state. The global initial state is created at the very start of the Umi project.
|
||||
* @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
|
||||
*/
|
||||
title: 'RiskGuard',
|
||||
|
||||
layout: {
|
||||
locale: true,
|
||||
...defaultSettings,
|
||||
},
|
||||
/**
|
||||
* @name moment2dayjs plugin
|
||||
* @description Replace moment with dayjs across the project
|
||||
* @doc https://umijs.org/docs/max/moment2dayjs
|
||||
*/
|
||||
moment2dayjs: {
|
||||
preset: 'antd',
|
||||
plugins: ['duration'],
|
||||
},
|
||||
/**
|
||||
* @name Internationalization plugin
|
||||
* @doc https://umijs.org/docs/max/i18n
|
||||
*/
|
||||
locale: {
|
||||
default: 'en_US',
|
||||
baseNavigator: false,
|
||||
baseSeparator: '_',
|
||||
antd: true,
|
||||
},
|
||||
/**
|
||||
* @name antd plugin
|
||||
* @description Includes the babel import plugin by default
|
||||
* @doc https://umijs.org/docs/max/antd#antd
|
||||
*/
|
||||
antd: {
|
||||
configProvider: {
|
||||
theme: {
|
||||
cssVar: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
/**
|
||||
* @name Request configuration
|
||||
* @description Provides a unified network request and error handling solution based on axios and ahooks' useRequest.
|
||||
* @doc https://umijs.org/docs/max/request
|
||||
*/
|
||||
request: {},
|
||||
/**
|
||||
* @name Access plugin
|
||||
* @description Permission plugin based on initialState; initialState must be enabled first
|
||||
* @doc https://umijs.org/docs/max/access
|
||||
*/
|
||||
access: {},
|
||||
/**
|
||||
* @name Extra scripts in <head>
|
||||
* @description Configure additional scripts to inject into the <head>
|
||||
*/
|
||||
headScripts: [
|
||||
// Solve the problem of white screen when loading for the first time
|
||||
{ src: join(PUBLIC_PATH, 'scripts/loading.js'), async: true },
|
||||
],
|
||||
//================ pro plugin configurations =================
|
||||
presets: ['umi-presets-pro'],
|
||||
|
||||
targets: {
|
||||
firefox: 78,
|
||||
safari: 12,
|
||||
ios: 12,
|
||||
},
|
||||
mock: {
|
||||
include: ['mock/**/*', 'src/pages/**/_mock.ts'],
|
||||
},
|
||||
/**
|
||||
* @name Enable mako
|
||||
* @description Use mako for rapid development
|
||||
* @doc https://umijs.org/docs/api/config#mako
|
||||
*/
|
||||
mako: isDev ? false : {},
|
||||
helmet: false,
|
||||
// polyfill: false,
|
||||
mfsu: {
|
||||
esbuild: true,
|
||||
},
|
||||
codeSplitting: {
|
||||
jsStrategy: 'granularChunks',
|
||||
},
|
||||
define: {
|
||||
'process.env.UMI_APP_SENTRY_DSN': process.env.UMI_APP_SENTRY_DSN,
|
||||
'process.env.UMI_APP_SENTRY_RELEASE':
|
||||
process.env.UMI_APP_SENTRY_RELEASE ||
|
||||
dayjs().utc().format('YYYYMMDDHHmmss'),
|
||||
},
|
||||
});
|
||||
|
||||
export default config;
|
||||
24
config/defaultSettings.ts
Normal file
24
config/defaultSettings.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { ProLayoutProps } from '@ant-design/pro-components';
|
||||
|
||||
/**
|
||||
* @name
|
||||
*/
|
||||
const Settings: ProLayoutProps & {
|
||||
pwa?: boolean;
|
||||
logo?: string;
|
||||
} = {
|
||||
navTheme: 'light',
|
||||
colorPrimary: '#1890ff',
|
||||
layout: 'mix',
|
||||
contentWidth: 'Fluid',
|
||||
fixedHeader: false,
|
||||
fixSiderbar: true,
|
||||
footerRender: false,
|
||||
colorWeak: false,
|
||||
title: 'RiskGuard',
|
||||
pwa: false,
|
||||
logo: '/logo.svg',
|
||||
iconfontUrl: '',
|
||||
};
|
||||
|
||||
export default Settings;
|
||||
53
config/proxy.ts
Normal file
53
config/proxy.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* @name Proxy configuration
|
||||
* @see In the production environment, the proxy cannot take effect, so there is no configuration of the production environment
|
||||
* -------------------------------
|
||||
* The agent cannot take effect in the production environment
|
||||
* so there is no configuration of the production environment
|
||||
* For details, please see
|
||||
* https://pro.ant.design/docs/deploy
|
||||
*
|
||||
* @doc https://umijs.org/docs/guides/proxy
|
||||
*/
|
||||
export default {
|
||||
// If you need to customize the local development server, please uncomment and adjust as needed.
|
||||
dev: {
|
||||
'/api': {
|
||||
// The address to proxy
|
||||
// target: 'http://2333z061l7.51mypc.cn',
|
||||
target: 'http://172.20.177.121:8080',
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
'^/api': '',
|
||||
},
|
||||
// xfwd: true,
|
||||
onProxyRes: (proxyRes: any, req: { url: string | string[] }) => {
|
||||
// Tell the browser/proxy not to cache streaming data
|
||||
if (req.url?.includes('/sse')) {
|
||||
// Key setting: instruct the browser/proxy not to cache streamed data
|
||||
proxyRes.headers['Cache-Control'] = 'no-transform';
|
||||
|
||||
// For upstream proxies like Nginx, disable buffering (hard to verify effect; set as a precaution).
|
||||
proxyRes.headers['X-Accel-Buffering'] = 'no';
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
/**
|
||||
* @name Detailed proxy configuration
|
||||
* @doc https://github.com/chimurai/http-proxy-middleware
|
||||
*/
|
||||
test: {
|
||||
// localhost:8000/api/** -> https://preview.pro.ant.design/api/**
|
||||
'/api': {
|
||||
target: 'https://proapi.azurewebsites.net',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
pre: {
|
||||
'/api/': {
|
||||
target: 'your pre url',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
218
config/routes.ts
Normal file
218
config/routes.ts
Normal file
@@ -0,0 +1,218 @@
|
||||
/**
|
||||
* @name umi routing configuration
|
||||
* @description Only supports path, component, routes, redirect, wrappers, name, icon configuration
|
||||
* @param path path only supports two placeholder configurations. The first is in the form of dynamic parameter :id, and the second is the *wildcard character. The wildcard character can only appear at the end of the routing string.
|
||||
* @param component Configure the React component path used for rendering after location and path match. It can be an absolute path or a relative path. If it is a relative path, it will be searched starting from src/pages.
|
||||
* @param routes Configure sub-routes, usually used when you need to add layout components to multiple paths.
|
||||
* @param redirect Configure route jump
|
||||
* @param wrappers Configure the packaging component of the routing component. Through the packaging component, you can combine more functions into the current routing component. For example, it can be used for routing-level permission verification.
|
||||
* @param name Configure the title of the route. By default, the value of menu.xxxx in the internationalization file menu.ts is read. If the name is configured as login, the value of menu.login in menu.ts is read as the title.
|
||||
* @param icon Configure the icon of the route. For the value, refer to https://ant.design/components/icon-cn. Pay attention to removing the style suffix and capitalization. If you want to configure the icon to be <StepBackwardOutlined />, the value should be stepBackward or StepBackward. If you want to configure the icon to be <UserOutlined />, the value should be user or User.
|
||||
* @doc https://umijs.org/docs/guides/routes
|
||||
*/
|
||||
export const commonRoutes = [
|
||||
{
|
||||
path: '/login',
|
||||
layout: false,
|
||||
component: './login',
|
||||
// wrappers: ['@/wrappers/authRedirect'],
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
redirect: '/dashboard',
|
||||
},
|
||||
{
|
||||
path: '*',
|
||||
layout: false,
|
||||
component: './404',
|
||||
},
|
||||
];
|
||||
export const roleRoutes = [
|
||||
{
|
||||
path: '/dashboard',
|
||||
name: 'dashboard',
|
||||
icon: '📊',
|
||||
access: 'normalRouteFilter',
|
||||
meta: {
|
||||
permissions: ['dashboard:list'],
|
||||
},
|
||||
component: './dashboard',
|
||||
},
|
||||
{
|
||||
path: '/profile',
|
||||
name: 'profile',
|
||||
hideInMenu: true,
|
||||
component: './profile',
|
||||
},
|
||||
{
|
||||
path: '/rules',
|
||||
name: 'rules',
|
||||
icon: '⚙️',
|
||||
access: 'normalRouteFilter',
|
||||
meta: {
|
||||
permissions: ['rule:list'],
|
||||
},
|
||||
wrappers: ['@/wrappers/noBindDataSource'],
|
||||
component: './rules',
|
||||
routes: [
|
||||
{
|
||||
path: 'large-trade-lots',
|
||||
name: 'largeTradeLots',
|
||||
ruleType: '1',
|
||||
},
|
||||
{
|
||||
path: 'large-trade-usd',
|
||||
name: 'largeTradeUSD',
|
||||
ruleType: '2',
|
||||
},
|
||||
{
|
||||
path: 'liquidity-trade',
|
||||
name: 'liquidityTrade',
|
||||
ruleType: '3',
|
||||
},
|
||||
{
|
||||
path: 'scalping',
|
||||
name: 'scalping',
|
||||
ruleType: '4',
|
||||
},
|
||||
{
|
||||
path: 'exposure-alert',
|
||||
name: 'exposureAlert',
|
||||
ruleType: '5',
|
||||
},
|
||||
// {
|
||||
// path: 'pricing-volatility',
|
||||
// name: 'pricingVolatility',
|
||||
// ruleType: '6',
|
||||
// },
|
||||
{
|
||||
path: 'pricing',
|
||||
name: 'pricing',
|
||||
ruleType: '6',
|
||||
},
|
||||
{
|
||||
path: 'volatility',
|
||||
name: 'volatility',
|
||||
ruleType: '11',
|
||||
},
|
||||
{
|
||||
path: 'nop-limit',
|
||||
name: 'NOPLimit',
|
||||
ruleType: '7',
|
||||
},
|
||||
{
|
||||
path: 'watch-list',
|
||||
name: 'watchList',
|
||||
ruleType: '8',
|
||||
},
|
||||
{
|
||||
path: 'reverse-positions',
|
||||
name: 'reversePositions',
|
||||
ruleType: '9',
|
||||
},
|
||||
{
|
||||
path: 'deposit-withdrawal',
|
||||
name: 'depositWithdrawal',
|
||||
ruleType: '10',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/products',
|
||||
name: 'products',
|
||||
icon: '📦',
|
||||
access: 'normalRouteFilter',
|
||||
meta: {
|
||||
permissions: ['product:list'],
|
||||
},
|
||||
wrappers: ['@/wrappers/noBindDataSource'],
|
||||
component: './products/index',
|
||||
},
|
||||
{
|
||||
path: '/alert',
|
||||
name: 'alert',
|
||||
icon: '🔔',
|
||||
access: 'normalRouteFilter',
|
||||
meta: {
|
||||
permissions: ['alert:list'],
|
||||
},
|
||||
component: './alert/index',
|
||||
},
|
||||
{
|
||||
path: '/account',
|
||||
name: 'account',
|
||||
icon: '👥',
|
||||
access: 'normalRouteFilter',
|
||||
meta: {
|
||||
permissions: ['account:list'],
|
||||
},
|
||||
component: './account/index',
|
||||
},
|
||||
{
|
||||
path: '/company',
|
||||
name: 'company',
|
||||
icon: '🏢',
|
||||
access: 'normalRouteFilter',
|
||||
meta: {
|
||||
permissions: ['company:list'],
|
||||
},
|
||||
component: './company/index',
|
||||
},
|
||||
{
|
||||
path: '/data-source',
|
||||
name: 'dataSource',
|
||||
icon: '🔌',
|
||||
access: 'normalRouteFilter',
|
||||
meta: {
|
||||
permissions: ['data-source:list'],
|
||||
},
|
||||
component: './data-source/index',
|
||||
},
|
||||
{
|
||||
path: '/user',
|
||||
name: 'user',
|
||||
icon: '👤',
|
||||
access: 'normalRouteFilter',
|
||||
meta: {
|
||||
permissions: ['user:list'],
|
||||
},
|
||||
component: './user/index',
|
||||
},
|
||||
{
|
||||
path: '/role',
|
||||
name: 'role',
|
||||
icon: '🔐',
|
||||
access: 'normalRouteFilter',
|
||||
meta: {
|
||||
permissions: ['role:list'],
|
||||
},
|
||||
component: './role/index',
|
||||
},
|
||||
{
|
||||
path: '/config',
|
||||
name: 'config',
|
||||
icon: '🔧',
|
||||
access: 'normalRouteFilter',
|
||||
meta: {
|
||||
permissions: ['config:list'],
|
||||
},
|
||||
component: './config/index',
|
||||
},
|
||||
{
|
||||
path: '/email-services',
|
||||
name: 'emailServices',
|
||||
icon: '📧',
|
||||
access: 'isGlobalCompany',
|
||||
component: './email-services/index',
|
||||
},
|
||||
{
|
||||
path: '/oper-log',
|
||||
name: 'operLog',
|
||||
icon: '📜',
|
||||
access: 'normalRouteFilter',
|
||||
meta: {
|
||||
permissions: ['oper:log:list'],
|
||||
},
|
||||
component: './oper-log/index',
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user