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/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/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: '信息', + })} +