refactor: project

This commit is contained in:
Dawn1Ocean
2024-03-28 13:43:14 +08:00
parent 6095375771
commit bce791a120
50 changed files with 361 additions and 3306 deletions
+1 -5
View File
@@ -1,10 +1,6 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import type { IRuntimeConfig as Plugin0 } from '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-antd/runtimeConfig.d'
import type { IRuntimeConfig as Plugin1 } from '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-initialState/runtimeConfig.d'
import type { IRuntimeConfig as Plugin2 } from '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-layout/runtimeConfig.d'
import type { IRuntimeConfig as Plugin3 } from '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-request/runtimeConfig.d'
interface IDefaultRuntimeConfig {
onRouteChange?: (props: { routes: any, clientRoutes: any, location: any, action: any, isFirst: boolean }) => void;
patchRoutes?: (props: { routes: any }) => void;
@@ -13,7 +9,7 @@ interface IDefaultRuntimeConfig {
rootContainer?: (lastRootContainer: JSX.Element, args?: any) => void;
[key: string]: any;
}
export type RuntimeConfig = IDefaultRuntimeConfig & Plugin0 & Plugin1 & Plugin2 & Plugin3
export type RuntimeConfig = IDefaultRuntimeConfig
export function defineApp(config: RuntimeConfig): RuntimeConfig {
return config;
+3 -28
View File
@@ -1,12 +1,7 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import * as Plugin_0 from '/home/dean/Coding/EVA Tea/Notify-Admin/src/app.ts';
import * as Plugin_1 from '@@/core/helmet.ts';
import * as Plugin_2 from '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-access/runtime.tsx';
import * as Plugin_3 from '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-initialState/runtime.tsx';
import * as Plugin_4 from '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-layout/runtime.tsx';
import * as Plugin_5 from '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-model/runtime.tsx';
import * as Plugin_0 from '@@/core/helmet.ts';
import { PluginManager } from 'umi';
function __defaultExport (obj) {
@@ -18,34 +13,14 @@ function __defaultExport (obj) {
export function getPlugins() {
return [
{
apply: __defaultExport(Plugin_0),
path: process.env.NODE_ENV === 'production' ? void 0 : '/home/dean/Coding/EVA Tea/Notify-Admin/src/app.ts',
},
{
apply: Plugin_1,
apply: Plugin_0,
path: process.env.NODE_ENV === 'production' ? void 0 : '@@/core/helmet.ts',
},
{
apply: Plugin_2,
path: process.env.NODE_ENV === 'production' ? void 0 : '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-access/runtime.tsx',
},
{
apply: Plugin_3,
path: process.env.NODE_ENV === 'production' ? void 0 : '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-initialState/runtime.tsx',
},
{
apply: Plugin_4,
path: process.env.NODE_ENV === 'production' ? void 0 : '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-layout/runtime.tsx',
},
{
apply: Plugin_5,
path: process.env.NODE_ENV === 'production' ? void 0 : '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-model/runtime.tsx',
},
];
}
export function getValidKeys() {
return ['patchRoutes','patchClientRoutes','modifyContextOpts','modifyClientRenderOpts','rootContainer','innerProvider','i18nProvider','accessProvider','dataflowProvider','outerProvider','render','onRouteChange','antd','getInitialState','layout','qiankun','request',];
return ['patchRoutes','patchClientRoutes','modifyContextOpts','modifyClientRenderOpts','rootContainer','innerProvider','i18nProvider','accessProvider','dataflowProvider','outerProvider','render','onRouteChange',];
}
let pluginManager = null;
-81
View File
@@ -275,87 +275,6 @@ interface IConfigTypes {
};
run: {
globals?: (Array<string> | undefined);
};
access: { [x: string]: any };
analytics: {
baidu?: (string | undefined);
ga?: (string | undefined);
ga_v2?: (string | undefined);
};
antd: {
dark?: (boolean | undefined);
compact?: (boolean | undefined);
import?: (boolean | undefined);
style?: ("less" | "css" | undefined);
theme?: ({
components: { [x: string]: { [x: string]: any } };
} | { [x: string]: any } | undefined);
appConfig?: ({ [x: string]: any } | undefined);
momentPicker?: (boolean | undefined);
styleProvider?: ({ [x: string]: any } | undefined);
configProvider?: ({
theme: {
components: { [x: string]: { [x: string]: any } };
} | { [x: string]: any };
} | { [x: string]: any } | undefined);
};
dva: {
extraModels?: (Array<string> | undefined);
immer?: ({ [x: string]: any } | undefined);
skipModelValidate?: (boolean | undefined);
};
initialState: {
loading?: (string | undefined);
};
layout: { [x: string]: any };
locale: {
default?: (string | undefined);
useLocalStorage?: (boolean | undefined);
baseNavigator?: (boolean | undefined);
title?: (boolean | undefined);
antd?: (boolean | undefined);
baseSeparator?: (string | undefined);
};
mf: {
name?: (string | undefined);
remotes?: (Array<{
aliasName?: (string | undefined);
name: string;
entry?: (string | undefined);
entries?: ({
} | undefined);
keyResolver?: (string | undefined);
}> | undefined);
shared?: ({ [x: string]: any } | undefined);
library?: ({ [x: string]: any } | undefined);
remoteHash?: (boolean | undefined);
};
model: {
extraModels?: (Array<string> | undefined);
};
moment2dayjs: {
preset?: ("antd" | "antdv3" | "none" | undefined);
plugins?: (Array<string> | undefined);
};
qiankun: {
slave?: ({ [x: string]: any } | undefined);
master?: ({ [x: string]: any } | undefined);
externalQiankun?: (boolean | undefined);
};
reactQuery: {
devtool?: ({ [x: string]: any } | boolean | undefined);
queryClient?: ({ [x: string]: any } | boolean | undefined);
};
request: {
dataField?: (string | undefined);
};
styledComponents: {
babelPlugin?: ({ [x: string]: any } | undefined);
};
tailwindcss: { [x: string]: any };
valtio: {
};
};
+4 -6
View File
@@ -4,15 +4,13 @@
import React from 'react';
export async function getRoutes() {
const routes = {"1":{"path":"/","redirect":"/home","parentId":"ant-design-pro-layout","id":"1"},"2":{"name":"首页","path":"/home","parentId":"ant-design-pro-layout","id":"2"},"3":{"name":"主席团管理","path":"/admin","parentId":"ant-design-pro-layout","id":"3"},"4":{"name":"日志","path":"/log","parentId":"ant-design-pro-layout","id":"4"},"ant-design-pro-layout":{"id":"ant-design-pro-layout","path":"/","isLayout":true}} as const;
const routes = {"1":{"path":"/","parentId":"@@/global-layout","id":"1"},"2":{"path":"/docs","parentId":"@@/global-layout","id":"2"},"@@/global-layout":{"id":"@@/global-layout","path":"/","isLayout":true}} as const;
return {
routes,
routeComponents: {
'1': React.lazy(() => import( './EmptyRoute')),
'2': React.lazy(() => import(/* webpackChunkName: "p__Home__index" */'@/pages/Home/index.tsx')),
'3': React.lazy(() => import(/* webpackChunkName: "p__Admin__index" */'@/pages/Admin/index.tsx')),
'4': React.lazy(() => import(/* webpackChunkName: "p__Log__index" */'@/pages/Log/index.tsx')),
'ant-design-pro-layout': React.lazy(() => import(/* webpackChunkName: "umi__plugin-layout__Layout" */'/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-layout/Layout.tsx')),
'1': React.lazy(() => import(/* webpackChunkName: "p__index" */'@/pages/index.tsx')),
'2': React.lazy(() => import(/* webpackChunkName: "p__docs" */'@/pages/docs.tsx')),
'@@/global-layout': React.lazy(() => import(/* webpackChunkName: "layouts__index" */'/home/dean/Coding/EVA Tea/Notify-Admin/src/layouts/index.tsx')),
},
};
}
+1 -8
View File
@@ -5,19 +5,12 @@
export { defineApp } from './core/defineApp'
export type { RuntimeConfig } from './core/defineApp'
// plugins
export { Access, useAccess, useAccessMarkedRoutes } from '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-access';
export { Provider, useModel } from '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-model';
export { useRequest, UseRequestProvider, request, getRequestInstance } from '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-request';
// plugins types.d.ts
export * from '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-access/types.d';
export * from '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-antd/types.d';
export * from '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-layout/types.d';
export * from '/home/dean/Coding/EVA Tea/Notify-Admin/src/.umi/plugin-request/types.d';
// @umijs/renderer-*
export { createBrowserHistory, createHashHistory, createMemoryHistory, Helmet, HelmetProvider, createSearchParams, generatePath, matchPath, matchRoutes, Navigate, NavLink, Outlet, resolvePath, useLocation, useMatch, useNavigate, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes, useSearchParams, useAppData, useClientLoaderData, useRouteProps, useSelectedRoutes, useServerLoaderData, renderClient, __getRoot, Link, useRouteData, __useFetcher, withRouter } from '/home/dean/Coding/EVA Tea/Notify-Admin/node_modules/.pnpm/@umijs+renderer-react@4.1.5_react-dom@18.1.0_react@18.1.0/node_modules/@umijs/renderer-react';
export type { History } from '/home/dean/Coding/EVA Tea/Notify-Admin/node_modules/.pnpm/@umijs+renderer-react@4.1.5_react-dom@18.1.0_react@18.1.0/node_modules/@umijs/renderer-react'
// umi/client/client/plugin
export { ApplyPluginsType, PluginManager } from '/home/dean/Coding/EVA Tea/Notify-Admin/node_modules/.pnpm/umi@4.1.5_@babel+core@7.24.3_@types+react@18.2.73_eslint@8.35.0_prettier@2.8.8_react-dom@18.2_wmk56yreolb4q5qtbx2ujd6jh4/node_modules/umi/client/client/plugin.js';
export { ApplyPluginsType, PluginManager } from '/home/dean/Coding/EVA Tea/Notify-Admin/node_modules/.pnpm/umi@4.1.5_@babel+core@7.24.3_@types+react@18.2.73_eslint@8.57.0_prettier@3.2.5_react-dom@18.2_w7wwsm3x2bx2p22eiznh2vdwtm/node_modules/umi/client/client/plugin.js';
export { history, createHistory } from './core/history';
export { terminal } from './core/terminal';
// react ssr
+1 -1
View File
@@ -9,7 +9,7 @@ import { createPluginManager } from './core/plugin';
import { getRoutes } from './core/route';
import type { Location } from 'history';
import 'antd/dist/reset.css';
const publicPath = '/';
const runtimePublicPath = false;
+3 -3
View File
@@ -26,10 +26,10 @@
"@@/*": [
"src/.umi/*"
],
"@umijs/max": [
"/home/dean/Coding/EVA Tea/Notify-Admin/node_modules/.pnpm/umi@4.1.5_@babel+core@7.24.3_@types+react@18.2.73_eslint@8.35.0_prettier@2.8.8_react-dom@18.2_wmk56yreolb4q5qtbx2ujd6jh4/node_modules/umi"
"umi": [
"/home/dean/Coding/EVA Tea/Notify-Admin/node_modules/.pnpm/umi@4.1.5_@babel+core@7.24.3_@types+react@18.2.73_eslint@8.57.0_prettier@3.2.5_react-dom@18.2_w7wwsm3x2bx2p22eiznh2vdwtm/node_modules/umi"
],
"@umijs/max/typings": [
"umi/typings": [
"src/.umi/typings"
]
}
+1 -1
View File
@@ -2,7 +2,7 @@
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import './core/polyfill';
import 'antd/dist/reset.css';
import { renderClient } from '/home/dean/Coding/EVA Tea/Notify-Admin/node_modules/.pnpm/@umijs+renderer-react@4.1.5_react-dom@18.1.0_react@18.1.0/node_modules/@umijs/renderer-react';
import { getRoutes } from './core/route';
import { createPluginManager } from './core/plugin';
-10
View File
@@ -1,10 +0,0 @@
export default (initialState: API.UserInfo) => {
// 在这里按照初始化数据定义项目中的权限,统一管理
// 参考文档 https://umijs.org/docs/max/access
const canSeeAdmin = !!(
initialState && initialState.name !== 'dontHaveAccess'
);
return {
canSeeAdmin,
};
};
-16
View File
@@ -1,16 +0,0 @@
// 运行时配置
// 全局初始化数据配置,用于 Layout 用户信息和权限初始化
// 更多信息见文档:https://umijs.org/docs/api/runtime-config#getinitialstate
export async function getInitialState(): Promise<{ name: string }> {
return { name: '@umijs/max' };
}
export const layout = () => {
return {
logo: 'https://img.alicdn.com/tfs/TB1YHEpwUT1gK0jSZFhXXaAtVXa-28-27.svg',
menu: {
locale: false,
},
};
};
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 177 KiB

-4
View File
@@ -1,4 +0,0 @@
.title {
margin: 0 auto;
font-weight: 200;
}
-23
View File
@@ -1,23 +0,0 @@
import { Layout, Row, Typography } from 'antd';
import React from 'react';
import styles from './Guide.less';
interface Props {
name: string;
}
// 脚手架示例组件
const Guide: React.FC<Props> = (props) => {
const { name } = props;
return (
<Layout>
<Row>
<Typography.Title level={3} className={styles.title}>
欢迎使用 <strong>{name}</strong> !
</Typography.Title>
</Row>
</Layout>
);
};
export default Guide;
-2
View File
@@ -1,2 +0,0 @@
import Guide from './Guide';
export default Guide;
-1
View File
@@ -1 +0,0 @@
export const DEFAULT_NAME = 'Umi Max';
+10
View File
@@ -0,0 +1,10 @@
.navs {
ul {
padding: 0;
list-style: none;
display: flex;
}
li {
margin-right: 1em;
}
}
+21
View File
@@ -0,0 +1,21 @@
import { Link, Outlet } from 'umi';
import styles from './index.less';
export default function Layout() {
return (
<div className={styles.navs}>
<ul>
<li>
<Link to="/">Home</Link>
</li>
<li>
<Link to="/docs">Docs</Link>
</li>
<li>
<a href="https://github.com/umijs/umi">Github</a>
</li>
</ul>
<Outlet />
</div>
);
}
-13
View File
@@ -1,13 +0,0 @@
// 全局共享数据示例
import { DEFAULT_NAME } from '@/constants';
import { useState } from 'react';
const useUser = () => {
const [name, setName] = useState<string>(DEFAULT_NAME);
return {
name,
setName,
};
};
export default useUser;
-21
View File
@@ -1,21 +0,0 @@
import { PageContainer } from '@ant-design/pro-components';
import { Access, useAccess } from '@umijs/max';
import { Button } from 'antd';
const AccessPage: React.FC = () => {
const access = useAccess();
return (
<PageContainer
ghost
header={{
title: '权限示例',
}}
>
<Access accessible={access.canSeeAdmin}>
<Button>只有 Admin 可以看到这个按钮</Button>
</Access>
</PageContainer>
);
};
export default AccessPage;
-3
View File
@@ -1,3 +0,0 @@
.container {
padding-top: 80px;
}
-18
View File
@@ -1,18 +0,0 @@
import Guide from '@/components/Guide';
import { trim } from '@/utils/format';
import { PageContainer } from '@ant-design/pro-components';
import { useModel } from '@umijs/max';
import styles from './index.less';
const HomePage: React.FC = () => {
const { name } = useModel('global');
return (
<PageContainer ghost>
<div className={styles.container}>
<Guide name={trim(name)} />
</div>
</PageContainer>
);
};
export default HomePage;
-26
View File
@@ -1,26 +0,0 @@
import { Modal } from 'antd';
import React, { PropsWithChildren } from 'react';
interface CreateFormProps {
modalVisible: boolean;
onCancel: () => void;
}
const CreateForm: React.FC<PropsWithChildren<CreateFormProps>> = (props) => {
const { modalVisible, onCancel } = props;
return (
<Modal
destroyOnClose
title="新建"
width={420}
open={modalVisible}
onCancel={() => onCancel()}
footer={null}
>
{props.children}
</Modal>
);
};
export default CreateForm;
-138
View File
@@ -1,138 +0,0 @@
import {
ProFormDateTimePicker,
ProFormRadio,
ProFormSelect,
ProFormText,
ProFormTextArea,
StepsForm,
} from '@ant-design/pro-components';
import { Modal } from 'antd';
import React from 'react';
export interface FormValueType extends Partial<API.UserInfo> {
target?: string;
template?: string;
type?: string;
time?: string;
frequency?: string;
}
export interface UpdateFormProps {
onCancel: (flag?: boolean, formVals?: FormValueType) => void;
onSubmit: (values: FormValueType) => Promise<void>;
updateModalVisible: boolean;
values: Partial<API.UserInfo>;
}
const UpdateForm: React.FC<UpdateFormProps> = (props) => (
<StepsForm
stepsProps={{
size: 'small',
}}
stepsFormRender={(dom, submitter) => {
return (
<Modal
width={640}
bodyStyle={{ padding: '32px 40px 48px' }}
destroyOnClose
title="规则配置"
open={props.updateModalVisible}
footer={submitter}
onCancel={() => props.onCancel()}
>
{dom}
</Modal>
);
}}
onFinish={props.onSubmit}
>
<StepsForm.StepForm
initialValues={{
name: props.values.name,
nickName: props.values.nickName,
}}
title="基本信息"
>
<ProFormText
width="md"
name="name"
label="规则名称"
rules={[{ required: true, message: '请输入规则名称!' }]}
/>
<ProFormTextArea
name="desc"
width="md"
label="规则描述"
placeholder="请输入至少五个字符"
rules={[
{ required: true, message: '请输入至少五个字符的规则描述!', min: 5 },
]}
/>
</StepsForm.StepForm>
<StepsForm.StepForm
initialValues={{
target: '0',
template: '0',
}}
title="配置规则属性"
>
<ProFormSelect
width="md"
name="target"
label="监控对象"
valueEnum={{
0: '表一',
1: '表二',
}}
/>
<ProFormSelect
width="md"
name="template"
label="规则模板"
valueEnum={{
0: '规则模板一',
1: '规则模板二',
}}
/>
<ProFormRadio.Group
name="type"
width="md"
label="规则类型"
options={[
{
value: '0',
label: '强',
},
{
value: '1',
label: '弱',
},
]}
/>
</StepsForm.StepForm>
<StepsForm.StepForm
initialValues={{
type: '1',
frequency: 'month',
}}
title="设定调度周期"
>
<ProFormDateTimePicker
name="time"
label="开始时间"
rules={[{ required: true, message: '请选择开始时间!' }]}
/>
<ProFormSelect
name="frequency"
label="监控对象"
width="xs"
valueEnum={{
month: '月',
week: '周',
}}
/>
</StepsForm.StepForm>
</StepsForm>
);
export default UpdateForm;
-270
View File
@@ -1,270 +0,0 @@
import services from '@/services/demo';
import {
ActionType,
FooterToolbar,
PageContainer,
ProDescriptions,
ProDescriptionsItemProps,
ProTable,
} from '@ant-design/pro-components';
import { Button, Divider, Drawer, message } from 'antd';
import React, { useRef, useState } from 'react';
import CreateForm from './components/CreateForm';
import UpdateForm, { FormValueType } from './components/UpdateForm';
const { addUser, queryUserList, deleteUser, modifyUser } =
services.UserController;
/**
* 添加节点
* @param fields
*/
const handleAdd = async (fields: API.UserInfo) => {
const hide = message.loading('正在添加');
try {
await addUser({ ...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 modifyUser(
{
userId: fields.id || '',
},
{
name: fields.name || '',
nickName: fields.nickName || '',
email: fields.email || '',
},
);
hide();
message.success('配置成功');
return true;
} catch (error) {
hide();
message.error('配置失败请重试!');
return false;
}
};
/**
* 删除节点
* @param selectedRows
*/
const handleRemove = async (selectedRows: API.UserInfo[]) => {
const hide = message.loading('正在删除');
if (!selectedRows) return true;
try {
await deleteUser({
userId: selectedRows.find((row) => row.id)?.id || '',
});
hide();
message.success('删除成功,即将刷新');
return true;
} catch (error) {
hide();
message.error('删除失败,请重试');
return false;
}
};
const TableList: React.FC<unknown> = () => {
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
const [updateModalVisible, handleUpdateModalVisible] =
useState<boolean>(false);
const [stepFormValues, setStepFormValues] = useState({});
const actionRef = useRef<ActionType>();
const [row, setRow] = useState<API.UserInfo>();
const [selectedRowsState, setSelectedRows] = useState<API.UserInfo[]>([]);
const columns: ProDescriptionsItemProps<API.UserInfo>[] = [
{
title: '名称',
dataIndex: 'name',
tip: '名称是唯一的 key',
formItemProps: {
rules: [
{
required: true,
message: '名称为必填项',
},
],
},
},
{
title: '昵称',
dataIndex: 'nickName',
valueType: 'text',
},
{
title: '性别',
dataIndex: 'gender',
hideInForm: true,
valueEnum: {
0: { text: '男', status: 'MALE' },
1: { text: '女', status: 'FEMALE' },
},
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
render: (_, record) => (
<>
<a
onClick={() => {
handleUpdateModalVisible(true);
setStepFormValues(record);
}}
>
配置
</a>
<Divider type="vertical" />
<a href="">订阅警报</a>
</>
),
},
];
return (
<PageContainer
header={{
title: 'CRUD 示例',
}}
>
<ProTable<API.UserInfo>
headerTitle="查询表格"
actionRef={actionRef}
rowKey="id"
search={{
labelWidth: 120,
}}
toolBarRender={() => [
<Button
key="1"
type="primary"
onClick={() => handleModalVisible(true)}
>
新建
</Button>,
]}
request={async (params, sorter, filter) => {
const { data, success } = await queryUserList({
...params,
// FIXME: remove @ts-ignore
// @ts-ignore
sorter,
filter,
});
return {
data: data?.list || [],
success,
};
}}
columns={columns}
rowSelection={{
onChange: (_, selectedRows) => setSelectedRows(selectedRows),
}}
/>
{selectedRowsState?.length > 0 && (
<FooterToolbar
extra={
<div>
已选择{' '}
<a style={{ fontWeight: 600 }}>{selectedRowsState.length}</a>{' '}
项&nbsp;&nbsp;
</div>
}
>
<Button
onClick={async () => {
await handleRemove(selectedRowsState);
setSelectedRows([]);
actionRef.current?.reloadAndRest?.();
}}
>
批量删除
</Button>
<Button type="primary">批量审批</Button>
</FooterToolbar>
)}
<CreateForm
onCancel={() => handleModalVisible(false)}
modalVisible={createModalVisible}
>
<ProTable<API.UserInfo, API.UserInfo>
onSubmit={async (value) => {
const success = await handleAdd(value);
if (success) {
handleModalVisible(false);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
rowKey="id"
type="form"
columns={columns}
/>
</CreateForm>
{stepFormValues && Object.keys(stepFormValues).length ? (
<UpdateForm
onSubmit={async (value) => {
const success = await handleUpdate(value);
if (success) {
handleUpdateModalVisible(false);
setStepFormValues({});
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
onCancel={() => {
handleUpdateModalVisible(false);
setStepFormValues({});
}}
updateModalVisible={updateModalVisible}
values={stepFormValues}
/>
) : null}
<Drawer
width={600}
open={!!row}
onClose={() => {
setRow(undefined);
}}
closable={false}
>
{row?.name && (
<ProDescriptions<API.UserInfo>
column={2}
title={row?.name}
request={async () => ({
data: row || {},
})}
params={{
id: row?.name,
}}
columns={columns}
/>
)}
</Drawer>
</PageContainer>
);
};
export default TableList;
+9
View File
@@ -0,0 +1,9 @@
const DocsPage = () => {
return (
<div>
<p>This is umi docs.</p>
</div>
);
};
export default DocsPage;
+15
View File
@@ -0,0 +1,15 @@
import yayJpg from '../assets/yay.jpg';
export default function HomePage() {
return (
<div>
<h2>Yay! Welcome to umi!</h2>
<p>
<img src={yayJpg} width="388" />
</p>
<p>
To get started, edit <code>pages/index.tsx</code> and save to reload.
</p>
</div>
);
}
-70
View File
@@ -1,70 +0,0 @@
import process from 'process';
/**
* State machine for request
*
* @example
*
* let former = this.state.rs;
* this.setState({
* rs: former.trans(true),
* })
*/
export class RequestState {
loading: boolean;
success: boolean;
constructor() {
this.loading = true;
this.success = false;
}
trans(success: boolean): RequestState {
if (this.loading) {
this.loading = false;
this.success = success;
} else {
console.error('calling trans on not loading state');
}
return this;
}
}
/**
* Get URL of backend
* @param path Relative path to base url, begins with `/`
* @returns Full url
*
* @example
*
* ``` tsx
* import { getUrl } from '@/service';
* import { Component, ReactNode } from 'react';
* import Taro from '@tarojs/taro';
*
* class Index extends Component {
* state = {
* testData: {},
* }
* componentDidMount(): void {
* Taro.request({
* url: getUrl('/testdata'),
* method: 'GET',
* }).then(res => {
* console.log(res.data);
* this.setState({ testData: res.data.data });
* });
* }
* render() { ... }
* }
* ```
*/
export function getUrl(path: string): string {
const baseUrl = process.env.ANTD_APP_API;
// console.log('bu:', baseUrl);
if (baseUrl) {
return baseUrl + path;
} else {
console.log('env ANTD_APP_API is undefined');
return '';
}
}
-96
View File
@@ -1,96 +0,0 @@
/* eslint-disable */
// 该文件由 OneAPI 自动生成,请勿手动修改!
import { request } from '@umijs/max';
/** 此处后端没有提供注释 GET /api/v1/queryUserList */
export async function queryUserList(
params: {
// query
/** keyword */
keyword?: string;
/** current */
current?: number;
/** pageSize */
pageSize?: number;
},
options?: { [key: string]: any },
) {
return request<API.Result_PageInfo_UserInfo__>('/api/v1/queryUserList', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 此处后端没有提供注释 POST /api/v1/user */
export async function addUser(
body?: API.UserInfoVO,
options?: { [key: string]: any },
) {
return request<API.Result_UserInfo_>('/api/v1/user', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** 此处后端没有提供注释 GET /api/v1/user/${param0} */
export async function getUserDetail(
params: {
// path
/** userId */
userId?: string;
},
options?: { [key: string]: any },
) {
const { userId: param0 } = params;
return request<API.Result_UserInfo_>(`/api/v1/user/${param0}`, {
method: 'GET',
params: { ...params },
...(options || {}),
});
}
/** 此处后端没有提供注释 PUT /api/v1/user/${param0} */
export async function modifyUser(
params: {
// path
/** userId */
userId?: string;
},
body?: API.UserInfoVO,
options?: { [key: string]: any },
) {
const { userId: param0 } = params;
return request<API.Result_UserInfo_>(`/api/v1/user/${param0}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
params: { ...params },
data: body,
...(options || {}),
});
}
/** 此处后端没有提供注释 DELETE /api/v1/user/${param0} */
export async function deleteUser(
params: {
// path
/** userId */
userId?: string;
},
options?: { [key: string]: any },
) {
const { userId: param0 } = params;
return request<API.Result_string_>(`/api/v1/user/${param0}`, {
method: 'DELETE',
params: { ...params },
...(options || {}),
});
}
-7
View File
@@ -1,7 +0,0 @@
/* eslint-disable */
// 该文件由 OneAPI 自动生成,请勿手动修改!
import * as UserController from './UserController';
export default {
UserController,
};
-68
View File
@@ -1,68 +0,0 @@
/* eslint-disable */
// 该文件由 OneAPI 自动生成,请勿手动修改!
declare namespace API {
interface PageInfo {
/**
1 */
current?: number;
pageSize?: number;
total?: number;
list?: Array<Record<string, any>>;
}
interface PageInfo_UserInfo_ {
/**
1 */
current?: number;
pageSize?: number;
total?: number;
list?: Array<UserInfo>;
}
interface Result {
success?: boolean;
errorMessage?: string;
data?: Record<string, any>;
}
interface Result_PageInfo_UserInfo__ {
success?: boolean;
errorMessage?: string;
data?: PageInfo_UserInfo_;
}
interface Result_UserInfo_ {
success?: boolean;
errorMessage?: string;
data?: UserInfo;
}
interface Result_string_ {
success?: boolean;
errorMessage?: string;
data?: string;
}
type UserGenderEnum = 'MALE' | 'FEMALE';
interface UserInfo {
id?: string;
name?: string;
/** nick */
nickName?: string;
/** email */
email?: string;
gender?: UserGenderEnum;
}
interface UserInfoVO {
name?: string;
/** nick */
nickName?: string;
/** email */
email?: string;
}
type definitions_0 = null;
}
-4
View File
@@ -1,4 +0,0 @@
// 示例方法,没有实际意义
export function trim(str: string) {
return str.trim();
}