Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Jan 15, 2021
1 parent 71338d5 commit 9118371
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 95 deletions.
28 changes: 7 additions & 21 deletions example/config/defaultSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,19 @@ import { MenuTheme } from 'antd/es/menu/MenuContext';
export type ContentWidth = 'Fluid' | 'Fixed';

export interface DefaultSettings {
/**
* theme for nav menu
*/
/** Theme for nav menu */
navTheme: MenuTheme;
/**
* primary color of ant design
*/
/** Primary color of ant design */
primaryColor: string;
/**
* nav menu position: `sidemenu` or `topmenu`
*/
/** Nav menu position: `sidemenu` or `topmenu` */
layout: 'sidemenu' | 'topmenu';
/**
* layout of content: `Fluid` or `Fixed`, only works when layout is topmenu
*/
/** Layout of content: `Fluid` or `Fixed`, only works when layout is topmenu */
contentWidth: ContentWidth;
/**
* sticky header
*/
/** Sticky header */
fixedHeader: boolean;
/**
* auto hide header
*/
/** Auto hide header */
autoHideHeader: boolean;
/**
* sticky siderbar
*/
/** Sticky siderbar */
fixSiderbar: boolean;
menu: { locale: boolean };
title: string;
Expand Down
4 changes: 2 additions & 2 deletions example/src/components/Authorized/CheckPermissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 9 additions & 18 deletions example/src/components/Authorized/Secured.tsx
Original file line number Diff line number Diff line change
@@ -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 => {
Expand All @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion example/src/components/Authorized/renderAuthorize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <T>(Authorized: T): ((currentAuthority: CurrentAuthorityType) => T) => (
Expand Down
15 changes: 4 additions & 11 deletions example/src/layouts/BasicLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* Ant Design Pro v4 use `@ant-design/pro-layout` to handle Layout.
* You can view component api by:
* 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
*/
import type {
Expand Down Expand Up @@ -44,9 +43,7 @@ export type BasicLayoutProps = {
export type BasicLayoutContext = { [K in 'location']: BasicLayoutProps[K] } & {
breadcrumbNameMap: Record<string, MenuDataItem>;
};
/**
* use Authorized check all menu item
*/
/** Use Authorized check all menu item */

const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] =>
menuList.map((item) => {
Expand Down Expand Up @@ -115,9 +112,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
pathname: '/',
},
} = props;
/**
* constructor
*/
/** Constructor */

useEffect(() => {
if (dispatch) {
Expand All @@ -126,9 +121,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
});
}
}, []);
/**
* init variables
*/
/** Init variables */

const handleMenuCollapse = (payload: boolean): void => {
if (dispatch) {
Expand Down
4 changes: 1 addition & 3 deletions example/src/models/connect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ export type Route = {
routes?: Route[];
} & MenuDataItem;

/**
* @type T: Params matched in dynamic routing
*/
/** @type T: Params matched in dynamic routing */
export type ConnectProps<T = any> = {
dispatch?: Dispatch<AnyAction>;
} & Partial<RouterTypes<Route, T>>;
4 changes: 1 addition & 3 deletions example/src/pages/DashboardAnalysis/utils/Yuan.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from 'react';
import { yuan } from '../components/Charts';
/**
* 减少使用 dangerouslySetInnerHTML
*/
/** 减少使用 dangerouslySetInnerHTML */
export default class Yuan extends React.Component<{
children: React.ReactText;
}> {
Expand Down
5 changes: 4 additions & 1 deletion example/src/pages/ListTableList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { queryRule, updateRule, addRule, removeRule } from './service';

/**
* 添加节点
*
* @param fields
*/
const handleAdd = async (fields: FormValueType) => {
Expand All @@ -32,6 +33,7 @@ const handleAdd = async (fields: FormValueType) => {

/**
* 更新节点
*
* @param fields
*/
const handleUpdate = async (fields: FormValueType) => {
Expand All @@ -54,7 +56,8 @@ const handleUpdate = async (fields: FormValueType) => {
};

/**
* 删除节点
* 删除节点
*
* @param selectedRows
*/
const handleRemove = async (selectedRows: TableListItem[]) => {
Expand Down
20 changes: 10 additions & 10 deletions example/src/pages/document.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,34 @@
<div id="root">
<style>
.page-loading-warp {
padding: 120px;
display: flex;
justify-content: center;
align-items: center;
justify-content: center;
padding: 120px;
}
.ant-spin {
position: absolute;
display: none;
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
color: rgba(0, 0, 0, 0.65);
color: #1890ff;
font-size: 14px;
font-variant: tabular-nums;
line-height: 1.5;
list-style: none;
-webkit-font-feature-settings: 'tnum';
font-feature-settings: 'tnum';
position: absolute;
display: none;
color: #1890ff;
text-align: center;
vertical-align: middle;
list-style: none;
opacity: 0;
-webkit-transition: -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
transition: -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86),
-webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
-webkit-font-feature-settings: 'tnum';
font-feature-settings: 'tnum';
}
.ant-spin-spinning {
Expand All @@ -54,9 +54,9 @@
.ant-spin-dot {
position: relative;
display: inline-block;
font-size: 20px;
width: 20px;
height: 20px;
font-size: 20px;
}
.ant-spin-dot-item {
Expand Down Expand Up @@ -112,9 +112,9 @@
}
.ant-spin-lg .ant-spin-dot {
font-size: 32px;
width: 32px;
height: 32px;
font-size: 32px;
}
.ant-spin-lg .ant-spin-dot i {
Expand Down
12 changes: 3 additions & 9 deletions example/src/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions example/src/utils/Authorized.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
13 changes: 3 additions & 10 deletions example/src/utils/request.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -23,9 +20,7 @@ const codeMessage = {
504: '网关超时。',
};

/**
* 异常处理程序
*/
/** 异常处理程序 */
const errorHandler = (error: { response: Response }): Response => {
const { response } = error;
if (response && response.status) {
Expand All @@ -45,9 +40,7 @@ const errorHandler = (error: { response: Response }): Response => {
return response;
};

/**
* 配置request请求时的默认参数
*/
/** 配置request请求时的默认参数 */
const request = extend({
errorHandler, // 默认错误处理
credentials: 'include', // 默认请求是否带上cookie
Expand Down
5 changes: 3 additions & 2 deletions example/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ export const isAntDesignProOrDev = (): boolean => {
export const getPageQuery = () => parse(window.location.href.split('?')[1]);

/**
* props.route.routes
* Props.route.routes
*
* @param router [{}]
* @param pathname string
* @param pathname String
*/
export const getAuthorityFromRouter = <T extends { path?: string }>(
router: T[] = [],
Expand Down

0 comments on commit 9118371

Please sign in to comment.