| @@ -16,7 +16,7 @@ const config: StorybookConfig = { | |||
| name: '@storybook/react-webpack5', | |||
| options: {}, | |||
| }, | |||
| staticDirs: ['../public'], | |||
| staticDirs: ['../public', { from: '../docs', to: '/docs' }], | |||
| docs: { | |||
| defaultName: 'Documentation', | |||
| }, | |||
| @@ -1,133 +1 @@ | |||
| Language : 🇺🇸 | [🇨🇳](./README.zh-CN.md) | [🇷🇺](./README.ru-RU.md) | [🇹🇷](./README.tr-TR.md) | [🇯🇵](./README.ja-JP.md) | [🇫🇷](./README.fr-FR.md) | [🇵🇹](./README.pt-BR.md) | [🇸🇦](./README.ar-DZ.md) | |||
| <h1 align="center">Ant Design Pro</h1> | |||
| <div align="center"> | |||
| An out-of-box UI solution for enterprise applications as a React boilerplate. | |||
| [](https://dev.azure.com/ant-design/ant-design-pro/_build/latest?definitionId=1?branchName=master)   | |||
| [](https://gitter.im/ant-design/pro-english?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [](https://gitter.im/ant-design/ant-design-pro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [](http://umijs.org/)  | |||
|  | |||
| </div> | |||
| - Preview: http://preview.pro.ant.design | |||
| - Home Page: http://pro.ant.design | |||
| - Documentation: http://pro.ant.design/docs/getting-started | |||
| - ChangeLog: http://pro.ant.design/docs/changelog | |||
| - FAQ: http://pro.ant.design/docs/faq | |||
| - Mirror Site in China: http://ant-design-pro.gitee.io | |||
| ## 5.0 is out! 🎉🎉🎉 | |||
| [Ant Design Pro 5.0.0](https://github.com/ant-design/ant-design-pro/issues/8656) | |||
| ## Translation Recruitment :loudspeaker: | |||
| We need your help: https://github.com/ant-design/ant-design-pro/issues/120 | |||
| ## Features | |||
| - :bulb: **TypeScript**: A language for application-scale JavaScript | |||
| - :scroll: **Blocks**: Build page with block template | |||
| - :gem: **Neat Design**: Follow [Ant Design specification](http://ant.design/) | |||
| - :triangular_ruler: **Common Templates**: Typical templates for enterprise applications | |||
| - :rocket: **State of The Art Development**: Newest development stack of React/umi/dva/antd | |||
| - :iphone: **Responsive**: Designed for variable screen sizes | |||
| - :art: **Theming**: Customizable theme with simple config | |||
| - :globe_with_meridians: **International**: Built-in i18n solution | |||
| - :gear: **Best Practices**: Solid workflow to make your code healthy | |||
| - :1234: **Mock development**: Easy to use mock development solution | |||
| - :white_check_mark: **UI Test**: Fly safely with unit and e2e tests | |||
| ## Templates | |||
| ``` | |||
| - Dashboard | |||
| - Analytic | |||
| - Monitor | |||
| - Workspace | |||
| - Form | |||
| - Basic Form | |||
| - Step Form | |||
| - Advanced From | |||
| - List | |||
| - Standard Table | |||
| - Standard List | |||
| - Card List | |||
| - Search List (Project/Applications/Article) | |||
| - Profile | |||
| - Simple Profile | |||
| - Advanced Profile | |||
| - Account | |||
| - Account Center | |||
| - Account Settings | |||
| - Result | |||
| - Success | |||
| - Failed | |||
| - Exception | |||
| - 403 | |||
| - 404 | |||
| - 500 | |||
| - User | |||
| - Login | |||
| - Register | |||
| - Register Result | |||
| ``` | |||
| ## Usage | |||
| ### Use bash | |||
| We provide pro-cli to quickly initialize scaffolding. | |||
| ```bash | |||
| # use npm | |||
| npm i @ant-design/pro-cli -g | |||
| pro create myapp | |||
| ``` | |||
| select umi version | |||
| ```shell | |||
| 🐂 Use umi@4 or umi@3 ? (Use arrow keys) | |||
| ❯ umi@4 | |||
| umi@3 | |||
| ``` | |||
| > If the umi@4 version is selected, full blocks are not yet supported. | |||
| If you choose umi@3, you can also choose the pro template. Pro is the basic template, which only provides the basic content of the framework operation. Complete contains all blocks, which is not suitable for secondary development as a basic template. | |||
| ```shell | |||
| ? 🚀 Full or a simple scaffold? (Use arrow keys) | |||
| ❯ simple | |||
| complete | |||
| ``` | |||
| Install dependencies: | |||
| ```shell | |||
| $ cd myapp && tyarn | |||
| // or | |||
| $ cd myapp && npm install | |||
| ``` | |||
| ## Browsers support | |||
| Modern browsers. | |||
| | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Opera | | |||
| | --- | --- | --- | --- | --- | | |||
| | Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | | |||
| ## Contributing | |||
| Any type of contribution is welcome, here are some examples of how you may contribute to this project: | |||
| - Use Ant Design Pro in your daily work. | |||
| - Submit [issues](http://github.com/ant-design/ant-design-pro/issues) to report bugs or ask questions. | |||
| - Propose [pull requests](http://github.com/ant-design/ant-design-pro/pulls) to improve our code. | |||
| # Documentation | |||
| @@ -1,8 +1,8 @@ | |||
| { | |||
| "name": "ant-design-pro", | |||
| "version": "6.0.0", | |||
| "name": "cl-model", | |||
| "version": "1.0.0", | |||
| "private": true, | |||
| "description": "An out-of-box UI solution for enterprise applications", | |||
| "description": "", | |||
| "scripts": { | |||
| "analyze": "cross-env ANALYZE=1 max build", | |||
| "build": "max build", | |||
| @@ -16,6 +16,7 @@ | |||
| "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", | |||
| "docs": "typedoc --entryPointStrategy expand --entryPoints 'src/utils' --skipErrorChecking --out docs", | |||
| "gh-pages": "gh-pages -d dist", | |||
| "i18n-remove": "pro i18n-remove --locale=zh-CN --write", | |||
| "postinstall": "max setup", | |||
| @@ -132,6 +133,7 @@ | |||
| "swagger-ui-dist": "^4.18.2", | |||
| "ts-loader": "~9.5.2", | |||
| "ts-node": "^10.9.1", | |||
| "typedoc": "~0.28.1", | |||
| "typescript": "^5.0.4", | |||
| "umi-presets-pro": "^2.0.0" | |||
| }, | |||
| @@ -0,0 +1,5 @@ | |||
| import { Meta } from '@storybook/blocks'; | |||
| <Meta title="Documentation/Utils" /> | |||
| <a href="/docs/index.html" target='_blank'>工具栏文档</a> | |||
| @@ -7,7 +7,10 @@ | |||
| import { PageEnum } from '@/enums/pagesEnums'; | |||
| import G6 from '@antv/g6'; | |||
| // 生成 8 位随机数 | |||
| /** | |||
| * 生成 8 位随机数 | |||
| * @returns 8 位随机数 | |||
| */ | |||
| export function s8() { | |||
| return (((1 + Math.random()) * 0x100000000) | 0).toString(16).substring(1); | |||
| } | |||
| @@ -20,7 +23,12 @@ export function getNameByCode(list: any[], code: any) { | |||
| return name; | |||
| } | |||
| // 解析 json 字符串 | |||
| /** | |||
| * 完全解析 json 字符串,不会抛异常 | |||
| * | |||
| * @param text - the string to be parsed | |||
| * @returns the parsed JSON object if the string is a valid JSON text, null otherwise | |||
| */ | |||
| export function parseJsonText(text?: string | null): any | null { | |||
| if (text === undefined || text === null || text === '') { | |||
| return null; | |||
| @@ -32,8 +40,17 @@ export function parseJsonText(text?: string | null): any | null { | |||
| } | |||
| } | |||
| // 判断是否为一般对象 | |||
| function isPlainObject(value: any) { | |||
| /** | |||
| * Checks if a given value is a plain object. | |||
| * | |||
| * A plain object is an object that is created using the Object constructor. | |||
| * It does not have any special properties or methods that are not part of the | |||
| * standard Object prototype. | |||
| * | |||
| * @param {any} value - The value to be checked. | |||
| * @returns {boolean} true if the value is a plain object, false otherwise. | |||
| */ | |||
| function isPlainObject(value: any): boolean { | |||
| if (value === null || typeof value !== 'object') return false; | |||
| let proto = Object.getPrototypeOf(value); | |||
| while (proto !== null) { | |||
| @@ -43,7 +60,14 @@ function isPlainObject(value: any) { | |||
| return true; | |||
| } | |||
| // underscore to camelCase | |||
| /** | |||
| * Converts all property names in an object from underscore notation to camelCase. | |||
| * | |||
| * If the object is not a plain object, it is returned as is. | |||
| * | |||
| * @param obj - The object whose property names need to be converted. | |||
| * @returns The object with all property names converted to camelCase. | |||
| */ | |||
| export function underscoreToCamelCase(obj: Record<string, any>) { | |||
| if (!isPlainObject(obj)) { | |||
| return obj; | |||
| @@ -66,7 +90,14 @@ export function underscoreToCamelCase(obj: Record<string, any>) { | |||
| return newObj; | |||
| } | |||
| // camelCase to underscore | |||
| /** | |||
| * Converts all property names in an object from camelCase to underscore notation. | |||
| * | |||
| * If the object is not a plain object, it is returned as is. | |||
| * | |||
| * @param obj - The object whose property names need to be converted. | |||
| * @returns The object with all property names converted to underscore notation. | |||
| */ | |||
| export function camelCaseToUnderscore(obj: Record<string, any>) { | |||
| if (!isPlainObject(obj)) { | |||
| return obj; | |||
| @@ -87,7 +118,14 @@ export function camelCaseToUnderscore(obj: Record<string, any>) { | |||
| return newObj; | |||
| } | |||
| // null to undefined | |||
| /** | |||
| * Recursively converts all null values in an object to undefined. | |||
| * | |||
| * If the given value is not an object, it is returned as is. | |||
| * | |||
| * @param obj - The object whose null values need to be converted. | |||
| * @returns The object with all null values converted to undefined. | |||
| */ | |||
| export function nullToUndefined(obj: Record<string, any> | null) { | |||
| if (obj === null) { | |||
| return undefined; | |||
| @@ -113,7 +151,15 @@ export function nullToUndefined(obj: Record<string, any> | null) { | |||
| return newObj; | |||
| } | |||
| // undefined to null | |||
| /** | |||
| * Recursively converts all undefined values in an object to null. | |||
| * | |||
| * If the given value is not an object, it is returned as is. | |||
| * | |||
| * @param obj - The object whose undefined values need to be converted. | |||
| * @returns The object with all undefined values converted to null. | |||
| */ | |||
| export function undefinedToNull(obj?: Record<string, any>) { | |||
| if (obj === undefined) { | |||
| return null; | |||
| @@ -204,10 +250,20 @@ export const fittingString = (str: string, maxWidth: number, fontSize: number): | |||
| * @param {any} str - the string to be checked | |||
| * @return {boolean} true if the string is empty, undefined, or null, false otherwise | |||
| */ | |||
| export const isEmpty = (str: any): boolean => { | |||
| export const isEmpty = (str?: any | null): boolean => { | |||
| return str === '' || str === undefined || str === null; | |||
| }; | |||
| /** | |||
| * Checks if a given value is undefined or null. | |||
| * | |||
| * @param {any} value - the value to be checked | |||
| * @return {boolean} true if the value is undefined or null, false otherwise | |||
| */ | |||
| export const hasNoValue = (value?: any | null): boolean => { | |||
| return value === undefined || value === null; | |||
| }; | |||
| /** | |||
| * 获取 git 仓库的 url | |||
| * | |||
| @@ -226,12 +282,30 @@ export const getGitUrl = (url: string, branch: string): string => { | |||
| return branch ? `${gitUrl}/tree/${branch}` : gitUrl; | |||
| }; | |||
| // 判断是否需要登录 | |||
| export const needAuth = (pathname: string) => { | |||
| /** | |||
| * 判断是否需要登录 | |||
| * | |||
| * @param {string} pathname - the pathname to be checked | |||
| * @return {boolean} true if the pathname needs to be authorized, false otherwise | |||
| */ | |||
| export const needAuth = (pathname: string): boolean => { | |||
| return pathname !== PageEnum.LOGIN && pathname !== PageEnum.Authorize; | |||
| }; | |||
| // 表格排序 | |||
| /** | |||
| * 表格排序 | |||
| * | |||
| * @param {any} a - the first value to be compared | |||
| * @param {any} b - the second value to be compared | |||
| * @returns {number} -1 if a is less than b, 1 if a is greater than b, 0 if a is equal to b | |||
| * | |||
| * The sorter function compares two values and returns a number indicating their relative order. | |||
| * The function first checks if either value is null or undefined. If so, it returns -1 if b is null or undefined, | |||
| * and 1 if a is null or undefined. | |||
| * If both values are numbers, it returns the difference between the two numbers. | |||
| * If both values are strings, it returns the result of the localeCompare() method. | |||
| * Otherwise, it returns 0. | |||
| */ | |||
| export const tableSorter = (a: any, b: any) => { | |||
| if (b === null || b === undefined) { | |||
| return -1; | |||
| @@ -0,0 +1,11 @@ | |||
| { | |||
| "entryPoints": ["./src/utils"], | |||
| "entryPointStrategy": "expand", | |||
| "out": "docs", | |||
| "excludePrivate": true, | |||
| "excludeProtected": false, | |||
| "excludeExternals": true, | |||
| "includeVersion": true, | |||
| "categorizeByGroup": true, | |||
| "name": "工具类文档" | |||
| } | |||