diff --git a/package.json b/package.json index b8701fe8..38ce748e 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", "@types/react-helmet": "^6.1.0", - "@umijs/fabric": "^2.3.0", + "@umijs/fabric": "^2.5.1", "@umijs/plugin-blocks": "^2.0.5", "@umijs/plugin-esbuild": "^1.0.1", "@umijs/preset-ant-design-pro": "^1.2.0", @@ -102,8 +102,6 @@ "lint-staged": "^10.0.0", "mockjs": "^1.0.1-beta3", "prettier": "^2.0.1", - "prettier-plugin-style-order": "^0.2.2", - "pro-download": "1.0.1", "puppeteer-core": "^5.0.0", "stylelint": "^13.0.0", "typescript": "^4.0.3" diff --git a/src/components/Authorized/CheckPermissions.tsx b/src/components/Authorized/CheckPermissions.tsx index 887bcc10..8b741385 100644 --- a/src/components/Authorized/CheckPermissions.tsx +++ b/src/components/Authorized/CheckPermissions.tsx @@ -11,8 +11,8 @@ export type IAuthorityType = | ((currentAuthority: string | string[]) => IAuthorityType); /** - * 通用权限检查方法 - * Common check permissions method + * 通用权限检查方法 Common check permissions method + * * @param { 权限判定 | Permission judgment } authority * @param { 你的权限 | Your permission description } currentAuthority * @param { 通过的组件 | Passing components } target diff --git a/src/components/Authorized/Secured.tsx b/src/components/Authorized/Secured.tsx index 0bdbbe4e..372b20eb 100644 --- a/src/components/Authorized/Secured.tsx +++ b/src/components/Authorized/Secured.tsx @@ -1,10 +1,7 @@ import React from 'react'; import CheckPermissions from './CheckPermissions'; -/** - * 默认不能访问任何页面 - * default is "NULL" - */ +/** 默认不能访问任何页面 default is "NULL" */ const Exception403 = () => 403; export const isComponentClass = (component: React.ComponentClass | React.ReactNode): boolean => { @@ -30,25 +27,19 @@ const checkIsInstantiation = (target: React.ComponentClass | React.ReactNode) => }; /** - * 用于判断是否拥有权限访问此 view 权限 - * authority 支持传入 string, () => boolean | Promise - * e.g. 'user' 只有 user 用户能访问 - * e.g. 'user,admin' user 和 admin 都能访问 - * e.g. ()=>boolean 返回true能访问,返回false不能访问 - * e.g. Promise then 能访问 catch不能访问 - * e.g. authority support incoming string, () => boolean | Promise - * e.g. 'user' only user user can access - * e.g. 'user, admin' user and admin can access - * e.g. () => boolean true to be able to visit, return false can not be accessed - * e.g. Promise then can not access the visit to catch + * 用于判断是否拥有权限访问此 view 权限 authority 支持传入 string, () => boolean | Promise e.g. 'user' 只有 user 用户能访问 + * e.g. 'user,admin' user 和 admin 都能访问 e.g. ()=>boolean 返回true能访问,返回false不能访问 e.g. Promise then 能访问 + * catch不能访问 e.g. authority support incoming string, () => boolean | Promise e.g. 'user' only user + * user can access e.g. 'user, admin' user and admin can access e.g. () => boolean true to be able + * to visit, return false can not be accessed e.g. Promise then can not access the visit to catch + * * @param {string | function | Promise} authority * @param {ReactNode} error 非必需参数 */ const authorize = (authority: string, error?: React.ReactNode) => { /** - * conversion into a class - * 防止传入字符串时找不到staticContext造成报错 - * String parameters can cause staticContext not found error + * Conversion into a class 防止传入字符串时找不到staticContext造成报错 String parameters can cause staticContext + * not found error */ let classError: boolean | React.FunctionComponent = false; if (error) { diff --git a/src/components/Authorized/renderAuthorize.ts b/src/components/Authorized/renderAuthorize.ts index df008750..3c34cc66 100644 --- a/src/components/Authorized/renderAuthorize.ts +++ b/src/components/Authorized/renderAuthorize.ts @@ -4,7 +4,8 @@ let CURRENT: string | string[] = 'NULL'; type CurrentAuthorityType = string | string[] | (() => typeof CURRENT); /** - * use authority or getAuthority + * Use authority or getAuthority + * * @param {string|()=>String} currentAuthority */ const renderAuthorize = (Authorized: T): ((currentAuthority: CurrentAuthorityType) => T) => ( diff --git a/src/layouts/BasicLayout.tsx b/src/layouts/BasicLayout.tsx index cd69ce64..6466e214 100644 --- a/src/layouts/BasicLayout.tsx +++ b/src/layouts/BasicLayout.tsx @@ -1,7 +1,7 @@ /** * Ant Design Pro v4 use `@ant-design/pro-layout` to handle Layout. - * You can view component api by: - * https://github.com/ant-design/ant-design-pro-layout + * + * @see You can view component api by: https://github.com/ant-design/ant-design-pro-layout */ import type { MenuDataItem, @@ -43,9 +43,7 @@ export type BasicLayoutProps = { export type BasicLayoutContext = { [K in 'location']: BasicLayoutProps[K] } & { breadcrumbNameMap: Record; }; -/** - * use Authorized check all menu item - */ +/** Use Authorized check all menu item */ const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] => menuList.map((item) => { @@ -101,9 +99,7 @@ const BasicLayout: React.FC = (props) => { }); } }, []); - /** - * init variables - */ + /** Init variables */ const handleMenuCollapse = (payload: boolean): void => { if (dispatch) { diff --git a/src/pages/TableList/index.tsx b/src/pages/TableList/index.tsx index 02956499..20550675 100644 --- a/src/pages/TableList/index.tsx +++ b/src/pages/TableList/index.tsx @@ -15,6 +15,7 @@ import { queryRule, updateRule, addRule, removeRule } from './service'; /** * 添加节点 + * * @param fields */ const handleAdd = async (fields: TableListItem) => { @@ -33,6 +34,7 @@ const handleAdd = async (fields: TableListItem) => { /** * 更新节点 + * * @param fields */ const handleUpdate = async (fields: FormValueType) => { @@ -55,7 +57,8 @@ const handleUpdate = async (fields: FormValueType) => { }; /** - * 删除节点 + * 删除节点 + * * @param selectedRows */ const handleRemove = async (selectedRows: TableListItem[]) => { @@ -76,13 +79,9 @@ const handleRemove = async (selectedRows: TableListItem[]) => { }; const TableList: React.FC = () => { - /** - * 新建窗口的弹窗 - */ + /** 新建窗口的弹窗 */ const [createModalVisible, handleModalVisible] = useState(false); - /** - * 分布更新窗口的弹窗 - */ + /** 分布更新窗口的弹窗 */ const [updateModalVisible, handleUpdateModalVisible] = useState(false); const [showDetail, setShowDetail] = useState(false); @@ -91,9 +90,7 @@ const TableList: React.FC = () => { const [currentRow, setCurrentRow] = useState(); const [selectedRowsState, setSelectedRows] = useState([]); - /** - * 国际化配置 - */ + /** 国际化配置 */ const intl = useIntl(); const columns: ProColumns[] = [ diff --git a/src/service-worker.js b/src/service-worker.js index 6874fe81..6140d86e 100644 --- a/src/service-worker.js +++ b/src/service-worker.js @@ -29,14 +29,10 @@ workbox.routing.registerNavigationRoute('/index.html'); * https://developers.google.com/web/tools/workbox/reference-docs/latest/workbox.strategies */ -/** - * Handle API requests - */ +/** Handle API requests */ workbox.routing.registerRoute(/\/api\//, workbox.strategies.networkFirst()); -/** - * Handle third party requests - */ +/** Handle third party requests */ workbox.routing.registerRoute( /^https:\/\/gw\.alipayobjects\.com\//, workbox.strategies.networkFirst(), @@ -47,9 +43,7 @@ workbox.routing.registerRoute( ); workbox.routing.registerRoute(/\/color.less/, workbox.strategies.networkFirst()); -/** - * Response to client after skipping waiting with MessageChannel - */ +/** Response to client after skipping waiting with MessageChannel */ addEventListener('message', (event) => { const replyPort = event.ports[0]; const message = event.data; diff --git a/src/utils/Authorized.ts b/src/utils/Authorized.ts index 5c789648..cd99bc54 100644 --- a/src/utils/Authorized.ts +++ b/src/utils/Authorized.ts @@ -9,10 +9,7 @@ const reloadAuthorized = (): void => { Authorized = RenderAuthorize(getAuthority()); }; -/** - * hard code - * block need it。 - */ +/** Hard code block need it。 */ window.reloadAuthorized = reloadAuthorized; export { reloadAuthorized }; diff --git a/src/utils/request.ts b/src/utils/request.ts index 270dfade..42062532 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -1,7 +1,4 @@ -/** - * request 网络请求工具 - * 更详细的 api 文档: https://github.com/umijs/umi-request - */ +/** Request 网络请求工具 更详细的 api 文档: https://github.com/umijs/umi-request */ import { extend } from 'umi-request'; import { notification } from 'antd'; @@ -23,9 +20,7 @@ const codeMessage = { 504: '网关超时。', }; -/** - * 异常处理程序 - */ +/** 异常处理程序 */ const errorHandler = (error: { response: Response }): Response => { const { response } = error; if (response && response.status) { @@ -45,9 +40,7 @@ const errorHandler = (error: { response: Response }): Response => { return response; }; -/** - * 配置request请求时的默认参数 - */ +/** 配置request请求时的默认参数 */ const request = extend({ errorHandler, // 默认错误处理 credentials: 'include', // 默认请求是否带上cookie