diff --git a/react-ui/.eslintrc.js b/react-ui/.eslintrc.js index ad3e7590..564a28d2 100644 --- a/react-ui/.eslintrc.js +++ b/react-ui/.eslintrc.js @@ -5,6 +5,6 @@ module.exports = { REACT_APP_ENV: true, }, rules: { - "@typescript-eslint/no-use-before-define": "off" - } + '@typescript-eslint/no-use-before-define': 'off', + }, }; diff --git a/react-ui/config/defaultSettings.ts b/react-ui/config/defaultSettings.ts index 91930d6e..b4430310 100644 --- a/react-ui/config/defaultSettings.ts +++ b/react-ui/config/defaultSettings.ts @@ -9,7 +9,7 @@ const Settings: ProLayoutProps & { } = { navTheme: 'light', // 拂晓蓝 - colorPrimary: '#1890ff', + colorPrimary: '#1664ff', layout: 'mix', contentWidth: 'Fluid', fixedHeader: false, @@ -19,7 +19,7 @@ const Settings: ProLayoutProps & { title: '复杂智能软件', pwa: true, logo: '/assets/images/left-top-logo.png', - iconfontUrl: '', + iconfontUrl: '', token: { // 参见ts声明,demo 见文档,通过token 修改样式 //https://procomponents.ant.design/components/layout#%E9%80%9A%E8%BF%87-token-%E4%BF%AE%E6%94%B9%E6%A0%B7%E5%BC%8F diff --git a/react-ui/package.json b/react-ui/package.json index 0a55edde..a3ad6812 100644 --- a/react-ui/package.json +++ b/react-ui/package.json @@ -4,19 +4,10 @@ "private": true, "description": "An out-of-box UI solution for enterprise applications", "scripts": { - "dev": "npm run start:dev", + "analyze": "cross-env ANALYZE=1 max build", "build": "max build", "deploy": "npm run build && npm run gh-pages", - "preview": "npm run build && max preview --port 8000", - "serve": "umi-serve", - "start": "cross-env UMI_ENV=dev max dev", - "start:dev": "cross-env REACT_APP_ENV=dev MOCK=none UMI_ENV=dev max dev", - "start:no-mock": "cross-env MOCK=none UMI_ENV=dev max dev", - "start:pre": "cross-env REACT_APP_ENV=pre UMI_ENV=dev max dev", - "start:test": "cross-env REACT_APP_ENV=test MOCK=none UMI_ENV=dev max dev", - "test": "jest", - "test:coverage": "npm run jest -- --coverage", - "test:update": "npm run jest -- -u", + "dev": "npm run start:dev", "docker-hub:build": "docker build -f Dockerfile.hub -t ant-design-pro ./", "docker-prod:build": "docker-compose -f ./docker/docker-compose.yml build", "docker-prod:dev": "docker-compose -f ./docker/docker-compose.yml up", @@ -24,7 +15,6 @@ "docker:dev": "docker-compose -f ./docker/docker-compose.dev.yml up", "docker:push": "npm run docker-hub:build && npm run docker:tag && docker push antdesign/ant-design-pro", "docker:tag": "docker tag ant-design-pro antdesign/ant-design-pro", - "analyze": "cross-env ANALYZE=1 max build", "gh-pages": "gh-pages -d dist", "i18n-remove": "pro i18n-remove --locale=zh-CN --write", "postinstall": "max setup", @@ -38,8 +28,18 @@ "openapi": "max openapi", "prepare": "cd .. && husky install", "prettier": "prettier -c --write \"**/**.{js,jsx,tsx,ts,less,md,json}\"", - "tsc": "tsc --noEmit", - "record": "cross-env NODE_ENV=development REACT_APP_ENV=test max record --scene=login" + "preview": "npm run build && max preview --port 8000", + "record": "cross-env NODE_ENV=development REACT_APP_ENV=test max record --scene=login", + "serve": "umi-serve", + "start": "cross-env UMI_ENV=dev max dev", + "start:dev": "cross-env REACT_APP_ENV=dev MOCK=none UMI_ENV=dev max dev", + "start:no-mock": "cross-env MOCK=none UMI_ENV=dev max dev", + "start:pre": "cross-env REACT_APP_ENV=pre UMI_ENV=dev max dev", + "start:test": "cross-env REACT_APP_ENV=test MOCK=none UMI_ENV=dev max dev", + "test": "jest", + "test:coverage": "npm run jest -- --coverage", + "test:update": "npm run jest -- -u", + "tsc": "tsc --noEmit" }, "lint-staged": { "**/*.{js,jsx,ts,tsx}": "npm run lint-staged:js", diff --git a/react-ui/src/app.tsx b/react-ui/src/app.tsx index 07fa0094..ee86b5cd 100644 --- a/react-ui/src/app.tsx +++ b/react-ui/src/app.tsx @@ -2,7 +2,6 @@ import RightContent from '@/components/RightContent'; import type { Settings as LayoutSettings } from '@ant-design/pro-components'; import type { RunTimeLayoutConfig } from '@umijs/max'; import { history } from '@umijs/max'; -import axios from 'axios'; import defaultSettings from '../config/defaultSettings'; import '../public/fonts/font.css'; import { getAccessToken } from './access'; @@ -17,8 +16,7 @@ import { setRemoteMenu, } from './services/session'; export { requestConfig as request } from './requestConfig'; -axios.defaults.baseUrl = 'http://172.20.32.150:8082'; -const isDev = process.env.NODE_ENV === 'development'; +// const isDev = process.env.NODE_ENV === 'development'; /** * @see https://umijs.org/zh-CN/plugins/plugin-initial-state @@ -34,10 +32,9 @@ export async function getInitialState(): Promise<{ const response = await getUserInfo({ skipErrorHandler: true, }); - if (response.user.avatar === '') { - response.user.avatar = - 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png'; - } + response.user.avatar = + response.user.avatar || + 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png'; return { ...response.user, permissions: response.permissions, @@ -66,7 +63,7 @@ export async function getInitialState(): Promise<{ } // ProLayout 支持的api https://procomponents.ant.design/components/layout -export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => { +export const layout: RunTimeLayoutConfig = ({ initialState }) => { return { rightContentRender: () => , waterMarkProps: { @@ -155,26 +152,26 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) = }; }; -export async function onRouteChange({ clientRoutes, location }) { +export async function onRouteChange({ clientRoutes, location }: any) { const menus = getRemoteMenu(); - // console.log('onRouteChange', clientRoutes, location, menus); + console.log('onRouteChange', clientRoutes, location, menus); if (menus === null && location.pathname !== PageEnum.LOGIN) { console.log('refresh'); history.go(0); } } -// export function patchRoutes({ routes, routeComponents }) { -// console.log('patchRoutes', routes, routeComponents); -// } +export function patchRoutes({ routes, routeComponents }: any) { + console.log('patchRoutes', routes, routeComponents); +} -export async function patchClientRoutes({ routes }) { - // console.log('patchClientRoutes', routes); +export async function patchClientRoutes({ routes }: any) { + console.log('patchClientRoutes', routes); patchRouteWithRemoteMenus(routes); } export function render(oldRender: () => void) { - // console.log('render get routers', oldRender) + console.log('render get routers', oldRender); const token = getAccessToken(); if (!token || token?.length === 0) { oldRender(); diff --git a/react-ui/src/components/DictTag/index.tsx b/react-ui/src/components/DictTag/index.tsx index 2b2a7910..cd5bce07 100644 --- a/react-ui/src/components/DictTag/index.tsx +++ b/react-ui/src/components/DictTag/index.tsx @@ -1,7 +1,7 @@ -import React from 'react'; -import { Tag } from 'antd'; import { ProSchemaValueEnumType } from '@ant-design/pro-components'; +import { Tag } from 'antd'; import { DefaultOptionType } from 'antd/es/select'; +import React from 'react'; /* * * @@ -11,105 +11,101 @@ import { DefaultOptionType } from 'antd/es/select'; * */ export interface DictValueEnumType extends ProSchemaValueEnumType { - id?: string | number; - key?: string | number; - value: string | number; - label: string; - listClass?: string; + id?: string | number; + key?: string | number; + value: string | number; + label: string; + listClass?: string; } export interface DictOptionType extends DefaultOptionType { - id?: string | number; - key?: string | number; - text: string; - listClass?: string; + id?: string | number; + key?: string | number; + text: string; + listClass?: string; } - export type DictValueEnumObj = Record; export type DictTagProps = { - key?: string; - value?: string | number; - enums?: DictValueEnumObj; - options?: DictOptionType[]; + key?: string; + value?: string | number; + enums?: DictValueEnumObj; + options?: DictOptionType[]; }; const DictTag: React.FC = (props) => { - function getDictColor(type?: string) { - switch (type) { - case 'primary': - return 'blue'; - case 'success': - return 'success'; - case 'info': - return 'green'; - case 'warning': - return 'warning'; - case 'danger': - return 'error'; - case 'default': - default: - return 'default'; - } + function getDictColor(type?: string) { + switch (type) { + case 'primary': + return 'blue'; + case 'success': + return 'success'; + case 'info': + return 'green'; + case 'warning': + return 'warning'; + case 'danger': + return 'error'; + case 'default': + default: + return 'default'; } + } - function getDictLabelByValue(value: string | number | undefined): string { - if (value === undefined) { - return ''; - } - if (props.enums) { - const item = props.enums[value]; - return item.label; - } - if (props.options) { - if (!Array.isArray(props.options)) { - console.log('DictTag options is no array!') - return ''; - } - for (const item of props.options) { - if (item.value === value) { - return item.text; - } - } + function getDictLabelByValue(value: string | number | undefined): string { + if (value === undefined) { + return ''; + } + if (props.enums) { + const item = props.enums[value]; + return item.label; + } + if (props.options) { + if (!Array.isArray(props.options)) { + console.log('DictTag options is no array!'); + return ''; + } + for (const item of props.options) { + if (item.value === value) { + return item.text; } - return String(props.value); + } } + return String(props.value); + } - function getDictListClassByValue(value: string | number | undefined): string { - if (value === undefined) { - return 'default'; - } - if (props.enums) { - const item = props.enums[value]; - return item.listClass || 'default'; - } - if (props.options) { - if (!Array.isArray(props.options)) { - console.log('DictTag options is no array!') - return 'default'; - } - for (const item of props.options) { - if (item.value === value) { - return item.listClass || 'default'; - } - } + function getDictListClassByValue(value: string | number | undefined): string { + if (value === undefined) { + return 'default'; + } + if (props.enums) { + const item = props.enums[value]; + return item.listClass || 'default'; + } + if (props.options) { + if (!Array.isArray(props.options)) { + console.log('DictTag options is no array!'); + return 'default'; + } + for (const item of props.options) { + if (item.value === value) { + return item.listClass || 'default'; } - return String(props.value); + } } + return String(props.value); + } - const getTagColor = () => { - return getDictColor(getDictListClassByValue(props.value).toLowerCase()); - }; - - const getTagText = (): string => { - return getDictLabelByValue(props.value); - }; + const getTagColor = () => { + return getDictColor(getDictListClassByValue(props.value).toLowerCase()); + }; - return ( - {getTagText()} - ) -} + const getTagText = (): string => { + return getDictLabelByValue(props.value); + }; + return {getTagText()}; +}; -export default DictTag; \ No newline at end of file +export default DictTag; diff --git a/react-ui/src/components/HeaderDropdown/index.tsx b/react-ui/src/components/HeaderDropdown/index.tsx index 8474be51..ae560fd2 100644 --- a/react-ui/src/components/HeaderDropdown/index.tsx +++ b/react-ui/src/components/HeaderDropdown/index.tsx @@ -1,8 +1,8 @@ +import { useEmotionCss } from '@ant-design/use-emotion-css'; import { Dropdown } from 'antd'; import type { DropDownProps } from 'antd/es/dropdown'; -import React from 'react'; -import { useEmotionCss } from '@ant-design/use-emotion-css'; import classNames from 'classnames'; +import React from 'react'; export type HeaderDropdownProps = { overlayClassName?: string; diff --git a/react-ui/src/components/IconSelector/Category.tsx b/react-ui/src/components/IconSelector/Category.tsx index dd0e93f7..5f683276 100644 --- a/react-ui/src/components/IconSelector/Category.tsx +++ b/react-ui/src/components/IconSelector/Category.tsx @@ -1,8 +1,8 @@ +import { useIntl } from '@umijs/max'; import * as React from 'react'; import CopyableIcon from './CopyableIcon'; -import type { ThemeType } from './index'; import type { CategoriesKeys } from './fields'; -import { useIntl } from '@umijs/max'; +import type { ThemeType } from './index'; import styles from './style.less'; interface CategoryProps { @@ -13,8 +13,7 @@ interface CategoryProps { onSelect: (type: string, name: string) => any; } -const Category: React.FC = props => { - +const Category: React.FC = (props) => { const { icons, title, newIcons, theme } = props; const intl = useIntl(); const [justCopied, setJustCopied] = React.useState(null); @@ -40,12 +39,14 @@ const Category: React.FC = props => { return (
-

{intl.formatMessage({ - id: `app.docs.components.icon.category.${title}`, - defaultMessage: '信息', - })}

+

+ {intl.formatMessage({ + id: `app.docs.components.icon.category.${title}`, + defaultMessage: '信息', + })} +