- Implement PermissionGuard component for route-level permission enforcement - Add tree-based permission checkbox group in role management popup - Gate SSE connection, unread count fetch, and rule edit actions on user permissions - Add skip401Refresh option and auto token refresh on 401 response - Improve alert table with fixed columns, explicit widths, and text ellipsis - Add i18n entries for permission guide and rule menu descriptions (en/zh) - Add expo-api nginx proxy configuration - Add .claude to .gitignore Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
192 lines
5.7 KiB
TypeScript
192 lines
5.7 KiB
TypeScript
// 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: {
|
|
loading: '@/loading',
|
|
},
|
|
/**
|
|
* @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;
|