Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* useSetting模块:menu onClick的事件类型的正确声明;去掉无用的props声明 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/layouts/baseLayout/header/userSetting.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import React, { FC } from 'react';
import { connect, Dispatch } from 'umi';
import { ClickParam } from 'antd/es/menu';
import { MenuInfo } from 'rc-menu/lib/interface';
import { Dropdown, Menu } from 'antd';
import {
SettingOutlined,
LogoutOutlined,
DownOutlined,
} from '@ant-design/icons';
import { LoginModelState, GlobalModelState } from '@/models/connect';
import { GlobalModelState } from '@/models/connect';

export interface HeaderLayoutProps {
dispatch: Dispatch;
global: GlobalModelState;
}

const UserSettingLayout: FC<HeaderLayoutProps> = ({ global, dispatch }) => {
function handleSubmit(event: ClickParam) {
function handleSubmit(event: MenuInfo) {
const { key } = event;
if (key === 'logout') {
dispatch({
Expand Down Expand Up @@ -56,10 +56,8 @@ const UserSettingLayout: FC<HeaderLayoutProps> = ({ global, dispatch }) => {

export default connect(
({
login,
global,
}: {
login: LoginModelState;
global: GlobalModelState;
}) => ({ login, global }),
}) => ({ global }),
)(UserSettingLayout);
6 changes: 2 additions & 4 deletions src/layouts/baseLayout/menu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { FC } from 'react';
import { Link, connect, useLocation, Loading } from 'umi';
import { Link, connect, useLocation } from 'umi';
import { Menu } from 'antd';
import { GlobalModelState } from '@/models/connect';
import { queryKeysByPath } from '@/utils/utils';
Expand All @@ -8,7 +8,6 @@ const { SubMenu, Item } = Menu;

export interface BasicLayoutProps {
global: GlobalModelState;
loading: boolean;
}

const MenuContent: FC<BasicLayoutProps> = ({ global }) => {
Expand Down Expand Up @@ -55,8 +54,7 @@ const MenuContent: FC<BasicLayoutProps> = ({ global }) => {
};

export default connect(
({ global, loading }: { global: GlobalModelState; loading: Loading }) => ({
({ global }: { global: GlobalModelState }) => ({
global,
loading: loading.models.index,
}),
)(MenuContent);
4 changes: 2 additions & 2 deletions src/models/connect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export interface MenusDate {
children: any;
}
export interface LoginUserInfoState {
id: string;
name: string;
username: string;
userid: string;
role?: string;
[key: string]: any;
}
14 changes: 10 additions & 4 deletions src/models/dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import { Effect, Reducer, history } from 'umi';
import { message } from 'antd';
import { queryCard } from '@/services/dashboard';

import { ConnectState } from './connect.d';

export interface DashboardState {
data: DataProps[];
cardSource: any;
cardSource: totalDataType;
}

interface DataProps {
id: string;
name: string;
}

export type totalDataType = {
headCount?: number;
surveyCount?: number;
totalCount?: number;
deadLine?: string;
rate?: string;
lossRate?: string;
};

export interface DashboardType {
namespace: 'dashboard';
state: DashboardState;
Expand Down
4 changes: 2 additions & 2 deletions src/models/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const GlobalModel: GlobalModelType = {
name: '',
menusData: menusSource,
userInfo: {
id: '',
name: '',
userid: '',
username: '',
},
},
effects: {
Expand Down
4 changes: 2 additions & 2 deletions src/models/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const LoginModel: LoginModelType = {
namespace: 'login',
state: {
userInfo: {
id: '',
name: '',
userid: '',
username: '',
},
isError: false,
},
Expand Down
2 changes: 1 addition & 1 deletion src/models/queryTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const QueryTableModel: QueryTableType = {
effects: {
*queryTableList(_, { call, put, select }) {
const { searchContentVal, statusVal } = yield select(
(state: QueryTableState) => state,
(state: any) => state.queryTable,
);
const response = yield call(queryTableList, {
searchContentVal,
Expand Down
10 changes: 2 additions & 8 deletions src/pages/dashboard/components/visitCard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import React, { FC, memo } from 'react';
import { Row, Col, Tooltip, Skeleton } from 'antd';
import { totalDataType } from '@/models/dashboard';
import styles from '../../index.less';

const userImg = require('@/assets/visit_user.png');
const surveyImg = require('@/assets/visit_survey.png');
const totalImg = require('@/assets/visit_total.png');

type totalDataType = {
headCount?: number;
surveyCount?: number;
totalCount?: number;
deadLine?: string;
rate?: string;
lossRate?: string;
};

interface VisitCardProps {
totalData: totalDataType;
loading: boolean | undefined;
Expand Down
7 changes: 2 additions & 5 deletions src/pages/login/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import React, { FC } from 'react';
import { connect, Dispatch } from 'umi';
import { Row, Col } from 'antd';
import { ConnectState } from '@/models/connect';
import LoginForm from './components/loginForm';
import styles from './index.less';

export interface LoginLayoutProps {
dispatch: Dispatch;
login: ConnectState;
loading: boolean;
}

Expand All @@ -17,6 +15,7 @@ export interface SubmitValProps {
}

const Login: FC<LoginLayoutProps> = ({ dispatch }) => {

function handleSubmit(values: SubmitValProps) {
dispatch({
type: 'login/queryLogin',
Expand Down Expand Up @@ -52,6 +51,4 @@ const Login: FC<LoginLayoutProps> = ({ dispatch }) => {
);
};

export default connect(({ login }: { login: ConnectState }) => ({ login }))(
Login,
);
export default connect()(Login);