瀏覽代碼

refactor: 剔除项目自带多余模块

lanjianrong 4 年之前
父節點
當前提交
e7625a7c8f

+ 5 - 29
config/routes.ts

@@ -16,6 +16,10 @@
     ]
   },
   {
+    path: '/',
+    redirect: '/welcome'
+  },
+  {
     path: '/welcome',
     name: 'welcome',
     icon: 'HomeOutlined',
@@ -28,7 +32,7 @@
     routes: [
       {
         path: '/role',
-        redirect: '/Role/System'
+        redirect: '/role/system'
       },
       {
         path: '/role/system',
@@ -44,32 +48,4 @@
       }
     ]
   }
-  // {
-  //   path: '/admin',
-  //   name: 'admin',
-  //   icon: 'crown',
-  //   access: 'canAdmin',
-  //   component: './Admin',
-  //   routes: [
-  //     {
-  //       path: '/admin/sub-page',
-  //       name: 'sub-page',
-  //       icon: 'smile',
-  //       component: './Welcome',
-  //     },
-  //   ],
-  // },
-  // {
-  //   name: 'list.table-list',
-  //   icon: 'table',
-  //   path: '/list',
-  //   component: './TableList',
-  // },
-  // {
-  //   path: '/',
-  //   redirect: '/welcome',
-  // },
-  // {
-  //   component: './404',
-  // },
 ]

+ 2 - 2
src/access.ts

@@ -2,13 +2,13 @@
  * @see https://umijs.org/zh-CN/plugins/plugin-access
  * */
 export default function access(initialState: { currentUser?: API.CurrentUser | undefined }) {
-  const { currentUser, hasRoutes = [] } = initialState || {}
+  const { currentUser, roles = [] } = initialState || {}
   return {
     authRouteFilter: route => {
       if (currentUser?.isAdmin) {
         return true
       }
-      return hasRoutes.includes(route.name)
+      return roles.includes(route.name)
     }
   }
 }

+ 18 - 16
src/app.tsx

@@ -6,7 +6,7 @@ import { getIntl, getLocale, history, Link } from 'umi'
 import RightContent from '@/components/RightContent'
 import Footer from '@/components/Footer'
 import type { RequestOptionsInit, ResponseError } from 'umi-request'
-import { currentUser as queryCurrentUser, queryMenuList, queryMenuRole } from './services/user/api'
+import { currentUser as queryCurrentUser } from './services/user/api'
 import { BookOutlined, LinkOutlined } from '@ant-design/icons'
 import consts from './utils/consts'
 
@@ -35,28 +35,28 @@ export async function getInitialState(): Promise<{
     return currentUser
   }
 
-  // 获取菜单列表id
-  const fetchMenuList = async () => {
-    const menuList = await queryMenuList()
-    return menuList
-  }
+  // // 获取菜单列表id
+  // const fetchMenuList = async () => {
+  //   const menuList = await queryMenuList()
+  //   return menuList
+  // }
 
-  // 获取用户权限
-  const fetchRoles = async () => {
-    const roles = await queryMenuRole()
-    return roles
-  }
+  // // 获取用户权限
+  // const fetchRoles = async () => {
+  //   const roles = await queryMenuRole()
+  //   return roles
+  // }
   // 如果是登录页面,不执行
   if (history.location.pathname !== loginPath) {
     try {
       const currentUser = await fetchUserInfo()
-      const menuList = await fetchMenuList()
-      const roles = await fetchRoles()
+      // const menuList = await fetchMenuList()
+      // const roles = await fetchRoles()
       return {
         fetchUserInfo,
-        menuList: menuList.data,
-        roles: roles.data,
-        currentUser: currentUser.data,
+        menuList: currentUser.menus,
+        roles: currentUser.staff.roles || [],
+        currentUser: currentUser.staff,
         settings: {}
       }
     } catch (error) {
@@ -66,6 +66,8 @@ export async function getInitialState(): Promise<{
   }
   return {
     settings: {}
+    // fetchMenuList,
+    // fetchRoles
   }
 }
 

+ 25 - 25
src/components/RightContent/index.tsx

@@ -1,35 +1,35 @@
-import { Tag, Space } from 'antd';
-import { QuestionCircleOutlined } from '@ant-design/icons';
-import React from 'react';
-import { useModel, SelectLang } from 'umi';
-import Avatar from './AvatarDropdown';
-import HeaderSearch from '../HeaderSearch';
-import styles from './index.less';
+import { Tag, Space } from 'antd'
+// import { QuestionCircleOutlined } from '@ant-design/icons'
+import React from 'react'
+import { useModel, SelectLang } from 'umi'
+import Avatar from './AvatarDropdown'
+// import HeaderSearch from '../HeaderSearch'
+import styles from './index.less'
 
-export type SiderTheme = 'light' | 'dark';
+export type SiderTheme = 'light' | 'dark'
 
 const ENVTagColor = {
   dev: 'orange',
   test: 'green',
-  pre: '#87d068',
-};
+  pre: '#87d068'
+}
 
 const GlobalHeaderRight: React.FC = () => {
-  const { initialState } = useModel('@@initialState');
+  const { initialState } = useModel('@@initialState')
 
   if (!initialState || !initialState.settings) {
-    return null;
+    return null
   }
 
-  const { navTheme, layout } = initialState.settings;
-  let className = styles.right;
+  const { navTheme, layout } = initialState.settings
+  let className = styles.right
 
   if ((navTheme === 'dark' && layout === 'top') || layout === 'mix') {
-    className = `${styles.right}  ${styles.dark}`;
+    className = `${styles.right}  ${styles.dark}`
   }
   return (
     <Space className={className}>
-      <HeaderSearch
+      {/* <HeaderSearch
         className={`${styles.action} ${styles.search}`}
         placeholder="站内搜索"
         defaultValue="umi ui"
@@ -48,18 +48,18 @@ const GlobalHeaderRight: React.FC = () => {
             value: 'Pro Layout',
           },
         ]}
-        // onSearch={value => {
-        //   console.log('input', value);
-        // }}
-      />
-      <span
+        onSearch={value => {
+          console.log('input', value);
+        }}
+      /> */}
+      {/* <span
         className={styles.action}
         onClick={() => {
           window.open('https://pro.ant.design/docs/getting-started');
         }}
       >
         <QuestionCircleOutlined />
-      </span>
+      </span> */}
       <Avatar />
       {REACT_APP_ENV && (
         <span>
@@ -68,6 +68,6 @@ const GlobalHeaderRight: React.FC = () => {
       )}
       <SelectLang className={styles.action} />
     </Space>
-  );
-};
-export default GlobalHeaderRight;
+  )
+}
+export default GlobalHeaderRight

+ 0 - 42
src/pages/Admin.tsx

@@ -1,42 +0,0 @@
-import React from 'react'
-import { HeartTwoTone, SmileTwoTone } from '@ant-design/icons'
-import { Card, Typography, Alert } from 'antd'
-import { PageHeaderWrapper } from '@ant-design/pro-layout'
-import { useIntl } from 'umi'
-
-export default (): React.ReactNode => {
-  const intl = useIntl()
-  return (
-    <PageHeaderWrapper
-      content={intl.formatMessage({
-        id: 'pages.admin.subPage.title',
-        defaultMessage: ' 这个页面只有 admin 权限才能查看'
-      })}>
-      <Card>
-        <Alert
-          message={intl.formatMessage({
-            id: 'pages.welcome.alertMessage',
-            defaultMessage: '更快更强的重型组件,已经发布。'
-          })}
-          type="success"
-          showIcon
-          banner
-          style={{
-            margin: -12,
-            marginBottom: 48
-          }}
-        />
-        <Typography.Title level={2} style={{ textAlign: 'center' }}>
-          <SmileTwoTone /> Ant Design Pro <HeartTwoTone twoToneColor="#eb2f96" /> You
-        </Typography.Title>
-      </Card>
-      <p style={{ textAlign: 'center', marginTop: 24 }}>
-        Want to add more pages? Please refer to{' '}
-        <a href="https://pro.ant.design/docs/block-cn" target="_blank" rel="noopener noreferrer">
-          use block
-        </a>
-        。
-      </p>
-    </PageHeaderWrapper>
-  )
-}

+ 19 - 18
src/pages/Role/System/components/ConnectModal/index.tsx

@@ -3,7 +3,6 @@ import { Button, Input, message, Modal } from 'antd'
 import React, { useState, useRef, useEffect } from 'react'
 import { addRoleStaff, fetchStaffList } from '@/services/user/api'
 import './index.less'
-import QueueAnim from 'rc-queue-anim'
 import { LoadingOutlined, MoreOutlined } from '@ant-design/icons'
 
 interface ConnectModalProps {
@@ -23,6 +22,9 @@ const ConnectModal: React.FC<ConnectModalProps> = ({ title, dataId, onSelect })
       onSuccess: () => {
         message.success('关联成功')
         setVisible(false)
+      },
+      onError: e => {
+        message.error(e.message)
       }
     }
   )
@@ -84,26 +86,25 @@ const ConnectModal: React.FC<ConnectModalProps> = ({ title, dataId, onSelect })
             placeholder="搜索员工(姓名)"
             onSearch={value => handleSearch(value)}
             onPressEnter={e => handleSearch(e.currentTarget.value)}
-            style={{ width: '95%' }}></Input.Search>
+            style={{ width: '95%' }}
+            allowClear={true}></Input.Search>
         }>
         <div ref={containerRef} className="h-60vh overflow-y-auto overflow-x-hidden modal-content">
-          <QueueAnim>
-            {list.map(item => (
-              <div className="card" key={item.staffId}>
-                <div className="w-4/3 flex justify-between">
-                  <span className="w-1/5">{item.username}</span>
-                  <span className="w-2/5">{item.phone}</span>
-                  <span className="w-1/5">{item.position}</span>
-                  <span className="w-1/5">{item.category}</span>
-                </div>
-                <div className="w-1/4 flex justify-end">
-                  <span className="btn-outline" onClick={() => itemSelectHandler(item.staffId)}>
-                    选择ta
-                  </span>
-                </div>
+          {list.map(item => (
+            <div className="card" key={item.staffId}>
+              <div className="w-4/3 flex justify-between">
+                <span className="w-1/5">{item.username}</span>
+                <span className="w-2/5">{item.phone}</span>
+                <span className="w-1/5">{item.position}</span>
+                <span className="w-1/5">{item.category}</span>
               </div>
-            ))}
-          </QueueAnim>
+              <div className="w-1/4 flex justify-end">
+                <span className="btn-outline" onClick={() => itemSelectHandler(item.staffId)}>
+                  选择ta
+                </span>
+              </div>
+            </div>
+          ))}
           {noMore && <div className="text-center text-gray-400">已到底部</div>}
           {!noMore && (
             <div className="text-center mt-3 cursor-pointer">

+ 0 - 209
src/pages/TableList/components/UpdateForm.tsx

@@ -1,209 +0,0 @@
-import React from 'react';
-import { Modal } from 'antd';
-import {
-  ProFormSelect,
-  ProFormText,
-  ProFormTextArea,
-  StepsForm,
-  ProFormRadio,
-  ProFormDateTimePicker,
-} from '@ant-design/pro-form';
-import { useIntl, FormattedMessage } from 'umi';
-
-export type FormValueType = {
-  target?: string;
-  template?: string;
-  type?: string;
-  time?: string;
-  frequency?: string;
-} & Partial<API.RuleListItem>;
-
-export type UpdateFormProps = {
-  onCancel: (flag?: boolean, formVals?: FormValueType) => void;
-  onSubmit: (values: FormValueType) => Promise<void>;
-  updateModalVisible: boolean;
-  values: Partial<API.RuleListItem>;
-};
-
-const UpdateForm: React.FC<UpdateFormProps> = (props) => {
-  const intl = useIntl();
-  return (
-    <StepsForm
-      stepsProps={{
-        size: 'small',
-      }}
-      stepsFormRender={(dom, submitter) => {
-        return (
-          <Modal
-            width={640}
-            bodyStyle={{ padding: '32px 40px 48px' }}
-            destroyOnClose
-            title={intl.formatMessage({
-              id: 'pages.searchTable.updateForm.ruleConfig',
-              defaultMessage: '规则配置',
-            })}
-            visible={props.updateModalVisible}
-            footer={submitter}
-            onCancel={() => {
-              props.onCancel();
-            }}
-          >
-            {dom}
-          </Modal>
-        );
-      }}
-      onFinish={props.onSubmit}
-    >
-      <StepsForm.StepForm
-        initialValues={{
-          name: props.values.name,
-          desc: props.values.desc,
-        }}
-        title={intl.formatMessage({
-          id: 'pages.searchTable.updateForm.basicConfig',
-          defaultMessage: '基本信息',
-        })}
-      >
-        <ProFormText
-          name="name"
-          label={intl.formatMessage({
-            id: 'pages.searchTable.updateForm.ruleName.nameLabel',
-            defaultMessage: '规则名称',
-          })}
-          width="md"
-          rules={[
-            {
-              required: true,
-              message: (
-                <FormattedMessage
-                  id="pages.searchTable.updateForm.ruleName.nameRules"
-                  defaultMessage="请输入规则名称!"
-                />
-              ),
-            },
-          ]}
-        />
-        <ProFormTextArea
-          name="desc"
-          width="md"
-          label={intl.formatMessage({
-            id: 'pages.searchTable.updateForm.ruleDesc.descLabel',
-            defaultMessage: '规则描述',
-          })}
-          placeholder={intl.formatMessage({
-            id: 'pages.searchTable.updateForm.ruleDesc.descPlaceholder',
-            defaultMessage: '请输入至少五个字符',
-          })}
-          rules={[
-            {
-              required: true,
-              message: (
-                <FormattedMessage
-                  id="pages.searchTable.updateForm.ruleDesc.descRules"
-                  defaultMessage="请输入至少五个字符的规则描述!"
-                />
-              ),
-              min: 5,
-            },
-          ]}
-        />
-      </StepsForm.StepForm>
-      <StepsForm.StepForm
-        initialValues={{
-          target: '0',
-          template: '0',
-        }}
-        title={intl.formatMessage({
-          id: 'pages.searchTable.updateForm.ruleProps.title',
-          defaultMessage: '配置规则属性',
-        })}
-      >
-        <ProFormSelect
-          name="target"
-          width="md"
-          label={intl.formatMessage({
-            id: 'pages.searchTable.updateForm.object',
-            defaultMessage: '监控对象',
-          })}
-          valueEnum={{
-            0: '表一',
-            1: '表二',
-          }}
-        />
-        <ProFormSelect
-          name="template"
-          width="md"
-          label={intl.formatMessage({
-            id: 'pages.searchTable.updateForm.ruleProps.templateLabel',
-            defaultMessage: '规则模板',
-          })}
-          valueEnum={{
-            0: '规则模板一',
-            1: '规则模板二',
-          }}
-        />
-        <ProFormRadio.Group
-          name="type"
-          label={intl.formatMessage({
-            id: 'pages.searchTable.updateForm.ruleProps.typeLabel',
-            defaultMessage: '规则类型',
-          })}
-          options={[
-            {
-              value: '0',
-              label: '强',
-            },
-            {
-              value: '1',
-              label: '弱',
-            },
-          ]}
-        />
-      </StepsForm.StepForm>
-      <StepsForm.StepForm
-        initialValues={{
-          type: '1',
-          frequency: 'month',
-        }}
-        title={intl.formatMessage({
-          id: 'pages.searchTable.updateForm.schedulingPeriod.title',
-          defaultMessage: '设定调度周期',
-        })}
-      >
-        <ProFormDateTimePicker
-          name="time"
-          width="md"
-          label={intl.formatMessage({
-            id: 'pages.searchTable.updateForm.schedulingPeriod.timeLabel',
-            defaultMessage: '开始时间',
-          })}
-          rules={[
-            {
-              required: true,
-              message: (
-                <FormattedMessage
-                  id="pages.searchTable.updateForm.schedulingPeriod.timeRules"
-                  defaultMessage="请选择开始时间!"
-                />
-              ),
-            },
-          ]}
-        />
-        <ProFormSelect
-          name="frequency"
-          label={intl.formatMessage({
-            id: 'pages.searchTable.updateForm.object',
-            defaultMessage: '监控对象',
-          })}
-          width="md"
-          valueEnum={{
-            month: '月',
-            week: '周',
-          }}
-        />
-      </StepsForm.StepForm>
-    </StepsForm>
-  );
-};
-
-export default UpdateForm;

+ 0 - 350
src/pages/TableList/index.tsx

@@ -1,350 +0,0 @@
-import { PlusOutlined } from '@ant-design/icons'
-import { Button, message, Input, Drawer } from 'antd'
-import React, { useState, useRef } from 'react'
-import { useIntl, FormattedMessage } from 'umi'
-import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'
-import type { ProColumns, ActionType } from '@ant-design/pro-table'
-import ProTable from '@ant-design/pro-table'
-import { ModalForm, ProFormText, ProFormTextArea } from '@ant-design/pro-form'
-import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions'
-import ProDescriptions from '@ant-design/pro-descriptions'
-import type { FormValueType } from './components/UpdateForm'
-import UpdateForm from './components/UpdateForm'
-import { rule, addRule, updateRule, removeRule } from '@/services/user/api'
-
-/**
- * 添加节点
- *
- * @param fields
- */
-const handleAdd = async (fields: API.RuleListItem) => {
-  const hide = message.loading('正在添加')
-  try {
-    await addRule({ ...fields })
-    hide()
-    message.success('添加成功')
-    return true
-  } catch (error) {
-    hide()
-    message.error('添加失败请重试!')
-    return false
-  }
-}
-
-/**
- * 更新节点
- *
- * @param fields
- */
-const handleUpdate = async (fields: FormValueType) => {
-  const hide = message.loading('正在配置')
-  try {
-    await updateRule({
-      name: fields.name,
-      desc: fields.desc,
-      key: fields.key
-    })
-    hide()
-
-    message.success('配置成功')
-    return true
-  } catch (error) {
-    hide()
-    message.error('配置失败请重试!')
-    return false
-  }
-}
-
-/**
- * 删除节点
- *
- * @param selectedRows
- */
-const handleRemove = async (selectedRows: API.RuleListItem[]) => {
-  const hide = message.loading('正在删除')
-  if (!selectedRows) return true
-  try {
-    await removeRule({
-      key: selectedRows.map(row => row.key)
-    })
-    hide()
-    message.success('删除成功,即将刷新')
-    return true
-  } catch (error) {
-    hide()
-    message.error('删除失败,请重试')
-    return false
-  }
-}
-
-const TableList: React.FC = () => {
-  /** 新建窗口的弹窗 */
-  const [createModalVisible, handleModalVisible] = useState<boolean>(false)
-  /** 分布更新窗口的弹窗 */
-  const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false)
-
-  const [showDetail, setShowDetail] = useState<boolean>(false)
-
-  const actionRef = useRef<ActionType>()
-  const [currentRow, setCurrentRow] = useState<API.RuleListItem>()
-  const [selectedRowsState, setSelectedRows] = useState<API.RuleListItem[]>([])
-
-  /** 国际化配置 */
-  const intl = useIntl()
-
-  const columns: ProColumns<API.RuleListItem>[] = [
-    {
-      title: (
-        <FormattedMessage
-          id="pages.searchTable.updateForm.ruleName.nameLabel"
-          defaultMessage="规则名称"
-        />
-      ),
-      dataIndex: 'name',
-      tip: '规则名称是唯一的 key',
-      render: (dom, entity) => {
-        return (
-          <a
-            onClick={() => {
-              setCurrentRow(entity)
-              setShowDetail(true)
-            }}>
-            {dom}
-          </a>
-        )
-      }
-    },
-    {
-      title: <FormattedMessage id="pages.searchTable.titleDesc" defaultMessage="描述" />,
-      dataIndex: 'desc',
-      valueType: 'textarea'
-    },
-    {
-      title: <FormattedMessage id="pages.searchTable.titleCallNo" defaultMessage="服务调用次数" />,
-      dataIndex: 'callNo',
-      sorter: true,
-      hideInForm: true,
-      renderText: (val: string) =>
-        `${val}${intl.formatMessage({
-          id: 'pages.searchTable.tenThousand',
-          defaultMessage: ' 万 '
-        })}`
-    },
-    {
-      title: <FormattedMessage id="pages.searchTable.titleStatus" defaultMessage="状态" />,
-      dataIndex: 'status',
-      hideInForm: true,
-      valueEnum: {
-        0: {
-          text: (
-            <FormattedMessage id="pages.searchTable.nameStatus.default" defaultMessage="关闭" />
-          ),
-          status: 'Default'
-        },
-        1: {
-          text: (
-            <FormattedMessage id="pages.searchTable.nameStatus.running" defaultMessage="运行中" />
-          ),
-          status: 'Processing'
-        },
-        2: {
-          text: (
-            <FormattedMessage id="pages.searchTable.nameStatus.online" defaultMessage="已上线" />
-          ),
-          status: 'Success'
-        },
-        3: {
-          text: (
-            <FormattedMessage id="pages.searchTable.nameStatus.abnormal" defaultMessage="异常" />
-          ),
-          status: 'Error'
-        }
-      }
-    },
-    {
-      title: (
-        <FormattedMessage id="pages.searchTable.titleUpdatedAt" defaultMessage="上次调度时间" />
-      ),
-      sorter: true,
-      dataIndex: 'updatedAt',
-      valueType: 'dateTime',
-      renderFormItem: (item, { defaultRender, ...rest }, form) => {
-        const status = form.getFieldValue('status')
-        if (`${status}` === '0') {
-          return false
-        }
-        if (`${status}` === '3') {
-          return (
-            <Input
-              {...rest}
-              placeholder={intl.formatMessage({
-                id: 'pages.searchTable.exception',
-                defaultMessage: '请输入异常原因!'
-              })}
-            />
-          )
-        }
-        return defaultRender(item)
-      }
-    },
-    {
-      title: <FormattedMessage id="pages.searchTable.titleOption" defaultMessage="操作" />,
-      dataIndex: 'option',
-      valueType: 'option',
-      render: (_, record) => [
-        <a
-          key="config"
-          onClick={() => {
-            handleUpdateModalVisible(true)
-            setCurrentRow(record)
-          }}>
-          <FormattedMessage id="pages.searchTable.config" defaultMessage="配置" />
-        </a>,
-        <a key="subscribeAlert" href="https://procomponents.ant.design/">
-          <FormattedMessage id="pages.searchTable.subscribeAlert" defaultMessage="订阅警报" />
-        </a>
-      ]
-    }
-  ]
-
-  return (
-    <PageContainer>
-      <ProTable<API.RuleListItem, API.PageParams>
-        headerTitle={intl.formatMessage({
-          id: 'pages.searchTable.title',
-          defaultMessage: '查询表格'
-        })}
-        actionRef={actionRef}
-        rowKey="key"
-        search={{
-          labelWidth: 120
-        }}
-        toolBarRender={() => [
-          <Button
-            type="primary"
-            key="primary"
-            onClick={() => {
-              handleModalVisible(true)
-            }}>
-            <PlusOutlined /> <FormattedMessage id="pages.searchTable.new" defaultMessage="新建" />
-          </Button>
-        ]}
-        request={rule}
-        columns={columns}
-        rowSelection={{
-          onChange: (_, selectedRows) => {
-            setSelectedRows(selectedRows)
-          }
-        }}
-      />
-      {selectedRowsState?.length > 0 && (
-        <FooterToolbar
-          extra={
-            <div>
-              <FormattedMessage id="pages.searchTable.chosen" defaultMessage="已选择" />{' '}
-              <a style={{ fontWeight: 600 }}>{selectedRowsState.length}</a>{' '}
-              <FormattedMessage id="pages.searchTable.item" defaultMessage="项" />
-              &nbsp;&nbsp;
-              <span>
-                <FormattedMessage
-                  id="pages.searchTable.totalServiceCalls"
-                  defaultMessage="服务调用次数总计"
-                />{' '}
-                {selectedRowsState.reduce((pre, item) => pre + item.callNo!, 0)}{' '}
-                <FormattedMessage id="pages.searchTable.tenThousand" defaultMessage="万" />
-              </span>
-            </div>
-          }>
-          <Button
-            onClick={async () => {
-              await handleRemove(selectedRowsState)
-              setSelectedRows([])
-              actionRef.current?.reloadAndRest?.()
-            }}>
-            <FormattedMessage id="pages.searchTable.batchDeletion" defaultMessage="批量删除" />
-          </Button>
-          <Button type="primary">
-            <FormattedMessage id="pages.searchTable.batchApproval" defaultMessage="批量审批" />
-          </Button>
-        </FooterToolbar>
-      )}
-      <ModalForm
-        title={intl.formatMessage({
-          id: 'pages.searchTable.createForm.newRule',
-          defaultMessage: '新建规则'
-        })}
-        width="400px"
-        visible={createModalVisible}
-        onVisibleChange={handleModalVisible}
-        onFinish={async value => {
-          const success = await handleAdd(value as API.RuleListItem)
-          if (success) {
-            handleModalVisible(false)
-            if (actionRef.current) {
-              actionRef.current.reload()
-            }
-          }
-        }}>
-        <ProFormText
-          rules={[
-            {
-              required: true,
-              message: (
-                <FormattedMessage
-                  id="pages.searchTable.ruleName"
-                  defaultMessage="规则名称为必填项"
-                />
-              )
-            }
-          ]}
-          width="md"
-          name="name"
-        />
-        <ProFormTextArea width="md" name="desc" />
-      </ModalForm>
-      <UpdateForm
-        onSubmit={async value => {
-          const success = await handleUpdate(value)
-          if (success) {
-            handleUpdateModalVisible(false)
-            setCurrentRow(undefined)
-            if (actionRef.current) {
-              actionRef.current.reload()
-            }
-          }
-        }}
-        onCancel={() => {
-          handleUpdateModalVisible(false)
-          setCurrentRow(undefined)
-        }}
-        updateModalVisible={updateModalVisible}
-        values={currentRow || {}}
-      />
-
-      <Drawer
-        width={600}
-        visible={showDetail}
-        onClose={() => {
-          setCurrentRow(undefined)
-          setShowDetail(false)
-        }}
-        closable={false}>
-        {currentRow?.name && (
-          <ProDescriptions<API.RuleListItem>
-            column={2}
-            title={currentRow?.name}
-            request={async () => ({
-              data: currentRow || {}
-            })}
-            params={{
-              id: currentRow?.name
-            }}
-            columns={columns as ProDescriptionsItemProps<API.RuleListItem>[]}
-          />
-        )}
-      </Drawer>
-    </PageContainer>
-  )
-}
-
-export default TableList

+ 7 - 2
src/pages/user/Login/index.tsx

@@ -44,8 +44,13 @@ const Login: React.FC = () => {
 
   const { run, loading } = useRequest(queryCurrentUser, {
     manual: true,
-    onSuccess: result => {
-      setInitialState({ ...initialState, currentUser: result })
+    onSuccess: async result => {
+      setInitialState({
+        ...initialState,
+        currentUser: result.staff,
+        menuList: result.menus,
+        roles: result.staff?.roles || []
+      })
       goto()
     }
   })

+ 0 - 12
src/services/swagger/index.ts

@@ -1,12 +0,0 @@
-// @ts-ignore
-/* eslint-disable */
-// API 更新时间:
-// API 唯一标识:
-import * as pet from './pet';
-import * as store from './store';
-import * as user from './user';
-export default {
-  pet,
-  store,
-  user,
-};

+ 0 - 166
src/services/swagger/pet.ts

@@ -1,166 +0,0 @@
-// @ts-ignore
-/* eslint-disable */
-import { request } from 'umi';
-
-/** Update an existing pet PUT /pet */
-export async function updatePet(body: API.Pet, options?: { [key: string]: any }) {
-  return request<any>('/pet', {
-    method: 'PUT',
-    headers: {
-      'Content-Type': 'application/json',
-    },
-    data: body,
-    ...(options || {}),
-  });
-}
-
-/** Add a new pet to the store POST /pet */
-export async function addPet(body: API.Pet, options?: { [key: string]: any }) {
-  return request<any>('/pet', {
-    method: 'POST',
-    headers: {
-      'Content-Type': 'application/json',
-    },
-    data: body,
-    ...(options || {}),
-  });
-}
-
-/** Finds Pets by status Multiple status values can be provided with comma separated strings GET /pet/findByStatus */
-export async function findPetsByStatus(
-  params: {
-    // query
-    /** Status values that need to be considered for filter */
-    status: 'available' | 'pending' | 'sold'[];
-  },
-  options?: { [key: string]: any },
-) {
-  return request<API.Pet[]>('/pet/findByStatus', {
-    method: 'GET',
-    params: {
-      ...params,
-    },
-
-    ...(options || {}),
-  });
-}
-
-/** Finds Pets by tags Muliple tags can be provided with comma separated strings. Use         tag1, tag2, tag3 for testing. GET /pet/findByTags */
-export async function findPetsByTags(
-  params: {
-    // query
-    /** Tags to filter by */
-    tags: string[];
-  },
-  options?: { [key: string]: any },
-) {
-  return request<API.Pet[]>('/pet/findByTags', {
-    method: 'GET',
-    params: {
-      ...params,
-    },
-
-    ...(options || {}),
-  });
-}
-
-/** Find pet by ID Returns a single pet GET /pet/${param0} */
-export async function getPetById(
-  params: {
-    // path
-    /** ID of pet to return */
-    petId: number;
-  },
-  options?: { [key: string]: any },
-) {
-  const { petId: param0 } = params;
-  return request<API.Pet>(`/pet/${param0}`, {
-    method: 'GET',
-    params: { ...params },
-
-    ...(options || {}),
-  });
-}
-
-/** Updates a pet in the store with form data POST /pet/${param0} */
-export async function updatePetWithForm(
-  params: {
-    // path
-    /** ID of pet that needs to be updated */
-    petId: number;
-  },
-  body: { name?: string; status?: string },
-  options?: { [key: string]: any },
-) {
-  const { petId: param0 } = params;
-  const formData = new FormData();
-
-  Object.keys(body).forEach((ele) => {
-    const item = (body as any)[ele];
-
-    if (item !== undefined && item !== null) {
-      formData.append(ele, typeof item === 'object' ? JSON.stringify(item) : item);
-    }
-  });
-
-  return request<any>(`/pet/${param0}`, {
-    method: 'POST',
-    headers: {
-      'Content-Type': 'application/x-www-form-urlencoded',
-    },
-    params: { ...params },
-    data: formData,
-    ...(options || {}),
-  });
-}
-
-/** Deletes a pet DELETE /pet/${param0} */
-export async function deletePet(
-  params: {
-    // header
-    api_key?: string;
-    // path
-    /** Pet id to delete */
-    petId: number;
-  },
-  options?: { [key: string]: any },
-) {
-  const { petId: param0 } = params;
-  return request<any>(`/pet/${param0}`, {
-    method: 'DELETE',
-    params: { ...params },
-    ...(options || {}),
-  });
-}
-
-/** uploads an image POST /pet/${param0}/uploadImage */
-export async function uploadFile(
-  params: {
-    // path
-    /** ID of pet to update */
-    petId: number;
-  },
-  body: { additionalMetadata?: string; file?: string },
-  options?: { [key: string]: any },
-) {
-  const { petId: param0 } = params;
-  const formData = new FormData();
-
-  Object.keys(body).forEach((ele) => {
-    const item = (body as any)[ele];
-
-    if (item !== undefined && item !== null) {
-      formData.append(ele, typeof item === 'object' ? JSON.stringify(item) : item);
-    }
-  });
-
-  return request<API.ApiResponse>(`/pet/${param0}/uploadImage`, {
-    method: 'POST',
-    headers: {
-      'Content-Type': 'multipart/form-data',
-    },
-    params: { ...params },
-    data: formData,
-    ...(options || {}),
-  });
-}

+ 0 - 54
src/services/swagger/store.ts

@@ -1,54 +0,0 @@
-// @ts-ignore
-/* eslint-disable */
-import { request } from 'umi';
-
-/** Returns pet inventories by status Returns a map of status codes to quantities GET /store/inventory */
-export async function getInventory(options?: { [key: string]: any }) {
-  return request<Record<string, any>>('/store/inventory', {
-    method: 'GET',
-    ...(options || {}),
-  });
-}
-
-/** Place an order for a pet POST /store/order */
-export async function placeOrder(body: API.Order, options?: { [key: string]: any }) {
-  return request<API.Order>('/store/order', {
-    method: 'POST',
-    data: body,
-    ...(options || {}),
-  });
-}
-
-/** Find purchase order by ID For valid response try integer IDs with value >= 1 and <= 10.         Other values will generated exceptions GET /store/order/${param0} */
-export async function getOrderById(
-  params: {
-    // path
-    /** ID of pet that needs to be fetched */
-    orderId: number;
-  },
-  options?: { [key: string]: any },
-) {
-  const { orderId: param0 } = params;
-  return request<API.Order>(`/store/order/${param0}`, {
-    method: 'GET',
-    params: { ...params },
-    ...(options || {}),
-  });
-}
-
-/** Delete purchase order by ID For valid response try integer IDs with positive integer value.         Negative or non-integer values will generate API errors DELETE /store/order/${param0} */
-export async function deleteOrder(
-  params: {
-    // path
-    /** ID of the order that needs to be deleted */
-    orderId: number;
-  },
-  options?: { [key: string]: any },
-) {
-  const { orderId: param0 } = params;
-  return request<any>(`/store/order/${param0}`, {
-    method: 'DELETE',
-    params: { ...params },
-    ...(options || {}),
-  });
-}

+ 0 - 52
src/services/swagger/typings.d.ts

@@ -1,52 +0,0 @@
-// @ts-ignore
-/* eslint-disable */
-
-declare namespace API {
-  type Order = {
-    id?: number;
-    petId?: number;
-    quantity?: number;
-    shipDate?: string;
-    /** Order Status */
-    status?: 'placed' | 'approved' | 'delivered';
-    complete?: boolean;
-  };
-
-  type Category = {
-    id?: number;
-    name?: string;
-  };
-
-  type User = {
-    id?: number;
-    username?: string;
-    firstName?: string;
-    lastName?: string;
-    email?: string;
-    password?: string;
-    phone?: string;
-    /** User Status */
-    userStatus?: number;
-  };
-
-  type Tag = {
-    id?: number;
-    name?: string;
-  };
-
-  type Pet = {
-    id?: number;
-    category?: Category;
-    name: string;
-    photoUrls: string[];
-    tags?: Tag[];
-    /** pet status in the store */
-    status?: 'available' | 'pending' | 'sold';
-  };
-
-  type ApiResponse = {
-    code?: number;
-    type?: string;
-    message?: string;
-  };
-}

+ 0 - 114
src/services/swagger/user.ts

@@ -1,114 +0,0 @@
-// @ts-ignore
-/* eslint-disable */
-import { request } from 'umi';
-
-/** Create user This can only be done by the logged in user. POST /user */
-export async function createUser(body: API.User, options?: { [key: string]: any }) {
-  return request<any>('/user', {
-    method: 'POST',
-    data: body,
-    ...(options || {}),
-  });
-}
-
-/** Creates list of users with given input array POST /user/createWithArray */
-export async function createUsersWithArrayInput(
-  body: API.User[],
-  options?: { [key: string]: any },
-) {
-  return request<any>('/user/createWithArray', {
-    method: 'POST',
-    data: body,
-    ...(options || {}),
-  });
-}
-
-/** Creates list of users with given input array POST /user/createWithList */
-export async function createUsersWithListInput(body: API.User[], options?: { [key: string]: any }) {
-  return request<any>('/user/createWithList', {
-    method: 'POST',
-    data: body,
-    ...(options || {}),
-  });
-}
-
-/** Logs user into the system GET /user/login */
-export async function loginUser(
-  params: {
-    // query
-    /** The user name for login */
-    username: string;
-    /** The password for login in clear text */
-    password: string;
-  },
-  options?: { [key: string]: any },
-) {
-  return request<string>('/user/login', {
-    method: 'GET',
-    params: {
-      ...params,
-    },
-    ...(options || {}),
-  });
-}
-
-/** Logs out current logged in user session GET /user/logout */
-export async function logoutUser(options?: { [key: string]: any }) {
-  return request<any>('/user/logout', {
-    method: 'GET',
-    ...(options || {}),
-  });
-}
-
-/** Get user by user name GET /user/${param0} */
-export async function getUserByName(
-  params: {
-    // path
-    /** The name that needs to be fetched. Use user1 for testing.  */
-    username: string;
-  },
-  options?: { [key: string]: any },
-) {
-  const { username: param0 } = params;
-  return request<API.User>(`/user/${param0}`, {
-    method: 'GET',
-    params: { ...params },
-    ...(options || {}),
-  });
-}
-
-/** Updated user This can only be done by the logged in user. PUT /user/${param0} */
-export async function updateUser(
-  params: {
-    // path
-    /** name that need to be updated */
-    username: string;
-  },
-  body: API.User,
-  options?: { [key: string]: any },
-) {
-  const { username: param0 } = params;
-  return request<any>(`/user/${param0}`, {
-    method: 'PUT',
-    params: { ...params },
-    data: body,
-    ...(options || {}),
-  });
-}
-
-/** Delete user This can only be done by the logged in user. DELETE /user/${param0} */
-export async function deleteUser(
-  params: {
-    // path
-    /** The name that needs to be deleted */
-    username: string;
-  },
-  options?: { [key: string]: any },
-) {
-  const { username: param0 } = params;
-  return request<any>(`/user/${param0}`, {
-    method: 'DELETE',
-    params: { ...params },
-    ...(options || {}),
-  });
-}

+ 14 - 10
src/services/user/typings.d.ts

@@ -3,16 +3,20 @@
 
 declare namespace API {
   type CurrentUser = {
-    staffId: string
-    categoryId: string
-    departmentId: string
-    departmentName: string
-    username: string
-    category: string
-    avatar: string
-    qq: string
-    qualifications: string
-    isAdmin: number
+    staff: {
+      staffId: string
+      categoryId: string
+      departmentId: string
+      departmentName: string
+      username: string
+      category: string
+      avatar: string
+      qq: string
+      qualifications: string
+      isAdmin: number
+      roles: string[]
+    }
+    menus: MenuListItem[]
   }
 
   type LoginResult = {