beta-0.1
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @see https://umijs.org/zh-CN/plugins/plugin-access
|
||||
* */
|
||||
export default function access(initialState: { currentUser?: API.CurrentUser } | undefined) {
|
||||
const { currentUser } = initialState ?? {};
|
||||
return {
|
||||
canAdmin: currentUser && currentUser.access === 'admin',
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
import Footer from '@/components/Footer';
|
||||
import RightContent from '@/components/RightContent';
|
||||
import {
|
||||
AppstoreOutlined,
|
||||
MenuOutlined,
|
||||
TeamOutlined,
|
||||
SettingOutlined,
|
||||
UserOutlined,
|
||||
CaretDownFilled,
|
||||
SmileOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import type { MenuDataItem, Settings as LayoutSettings } from '@ant-design/pro-components';
|
||||
import { PageLoading, SettingDrawer } from '@ant-design/pro-components';
|
||||
import { Divider, Dropdown, Menu, Space } from 'antd';
|
||||
import type { RequestConfig, RunTimeLayoutConfig } from 'umi';
|
||||
import { history } from 'umi';
|
||||
import defaultSettings from '../config/defaultSettings';
|
||||
import { currentUser as queryCurrentUser, fetchMenuData } from './services/ant-design-pro/api';
|
||||
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
const loginPath = '/user/login';
|
||||
|
||||
/** 获取用户信息比较慢的时候会展示一个 loading */
|
||||
export const initialStateConfig = {
|
||||
loading: <PageLoading />,
|
||||
};
|
||||
|
||||
/**
|
||||
* @see https://umijs.org/zh-CN/plugins/plugin-initial-state
|
||||
* */
|
||||
export async function getInitialState(): Promise<{
|
||||
settings?: Partial<LayoutSettings>;
|
||||
currentUser?: API.CurrentUser;
|
||||
loading?: boolean;
|
||||
fetchUserInfo?: () => Promise<API.CurrentUser | undefined>;
|
||||
}> {
|
||||
const fetchUserInfo = async () => {
|
||||
try {
|
||||
const msg = await queryCurrentUser();
|
||||
// TODO
|
||||
return msg.datas;
|
||||
} catch (error) {
|
||||
history.push(loginPath);
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
// 如果不是登录页面,执行
|
||||
if (history.location.pathname !== loginPath) {
|
||||
const currentUser = await fetchUserInfo();
|
||||
return {
|
||||
fetchUserInfo,
|
||||
currentUser,
|
||||
settings: defaultSettings,
|
||||
};
|
||||
}
|
||||
return {
|
||||
fetchUserInfo,
|
||||
settings: defaultSettings,
|
||||
};
|
||||
}
|
||||
|
||||
// ProLayout 支持的api https://procomponents.ant.design/components/layout
|
||||
export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => {
|
||||
return {
|
||||
rightContentRender: () => <RightContent />,
|
||||
disableContentMargin: false,
|
||||
waterMarkProps: {
|
||||
content: initialState?.currentUser?.username,
|
||||
},
|
||||
footerRender: () => <Footer />,
|
||||
onPageChange: () => {
|
||||
const { location } = history;
|
||||
// 如果没有登录,重定向到 login
|
||||
if (!initialState?.currentUser && location.pathname !== loginPath) {
|
||||
history.push(loginPath);
|
||||
}
|
||||
},
|
||||
links: isDev
|
||||
? [
|
||||
// <Link key="openapi" to="/umi/plugin/openapi" target="_blank">
|
||||
// <LinkOutlined />
|
||||
// <span>OpenAPI 文档</span>
|
||||
// </Link>,
|
||||
// <Link to="/~docs" key="docs">
|
||||
// <BookOutlined />
|
||||
// <span>业务组件文档</span>
|
||||
// </Link>,
|
||||
]
|
||||
: [],
|
||||
menuHeaderRender: undefined,
|
||||
|
||||
menu: {
|
||||
// 每当 initialState?.currentUser?.userid 发生修改时重新执行 request
|
||||
params: {
|
||||
userId: initialState?.currentUser?.userId,
|
||||
},
|
||||
request: async (_params) => {
|
||||
// initialState.currentUser 中包含了所有用户信息
|
||||
const menuData = await fetchMenuData();
|
||||
|
||||
const mapIcon = (css: string | undefined) => {
|
||||
switch (css) {
|
||||
case 'layui-icon-set':
|
||||
return <SettingOutlined />;
|
||||
case 'layui-icon-friends':
|
||||
return <UserOutlined />;
|
||||
case 'layui-icon-user':
|
||||
return <TeamOutlined />;
|
||||
case 'layui-icon-menu-fill':
|
||||
return <MenuOutlined />;
|
||||
default:
|
||||
return <AppstoreOutlined />;
|
||||
}
|
||||
};
|
||||
|
||||
const mapMenu = (value: API.Menu[]): MenuDataItem[] => {
|
||||
return value.map((item) => {
|
||||
return {
|
||||
key: item.id + '',
|
||||
name: item.name,
|
||||
locale: false,
|
||||
path:
|
||||
item.path?.endsWith('.html') || item.path?.startsWith('http')
|
||||
? item.path
|
||||
: undefined,
|
||||
icon: mapIcon(item.css),
|
||||
children: item.subMenus && mapMenu(item.subMenus),
|
||||
};
|
||||
});
|
||||
};
|
||||
const menus = mapMenu(menuData);
|
||||
return menus;
|
||||
},
|
||||
},
|
||||
headerContentRender: () => {
|
||||
return (
|
||||
<Space>
|
||||
<Divider type="vertical" />
|
||||
<Dropdown
|
||||
placement="top"
|
||||
overlay={
|
||||
<Menu
|
||||
items={[
|
||||
{
|
||||
key: '1',
|
||||
label: (
|
||||
<a
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
href="https://www.kancloud.cn/zlt2000/microservices-platform/936235"
|
||||
>
|
||||
项目更新日志
|
||||
</a>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
label: (
|
||||
<a target="_blank" rel="noopener noreferrer" href="https://zlt2000.gitee.io/">
|
||||
个人博客
|
||||
</a>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: '3',
|
||||
label: (
|
||||
<a
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
href="https://gitee.com/zlt2000/"
|
||||
>
|
||||
个人公众号
|
||||
</a>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: '4',
|
||||
label: (
|
||||
<a
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
href="https://gitbook.cn/gitchat/author/5b2362320398d50d7b7ab29e"
|
||||
>
|
||||
GitChat
|
||||
</a>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: '5',
|
||||
label: (
|
||||
<a
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
href="https://www.aliyun.com/minisite/goods?userCode=dickv1kw&share_source=copy_link"
|
||||
>
|
||||
阿里云优惠
|
||||
</a>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: '6',
|
||||
label: (
|
||||
<a
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
href="https://cloud.tencent.com/act/cps/redirect?redirect=1074&cps_key=5516bbd5876cd224d90bd41d53d3f7fe&from=console"
|
||||
>
|
||||
腾讯云优惠
|
||||
</a>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: '7',
|
||||
label: (
|
||||
<a
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
href="https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=a87e1945-e6c4-4e04-bb43-e0472a54e454&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905"
|
||||
>
|
||||
华为云优惠
|
||||
</a>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<a onClick={(e) => e.preventDefault()}>
|
||||
<Space size="small">
|
||||
相关链接
|
||||
<CaretDownFilled />
|
||||
</Space>
|
||||
</a>
|
||||
</Dropdown>
|
||||
</Space>
|
||||
);
|
||||
},
|
||||
// 自定义 403 页面
|
||||
// unAccessible: <div>unAccessible</div>,
|
||||
// 增加一个 loading 的状态
|
||||
childrenRender: (children, props) => {
|
||||
if (initialState?.loading) return <PageLoading />;
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
{!props.location?.pathname?.includes('/login') && (
|
||||
<SettingDrawer
|
||||
disableUrlParams
|
||||
enableDarkTheme
|
||||
settings={initialState?.settings}
|
||||
onSettingChange={(settings) => {
|
||||
setInitialState((preInitialState) => ({
|
||||
...preInitialState,
|
||||
settings,
|
||||
}));
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
},
|
||||
...initialState?.settings,
|
||||
};
|
||||
};
|
||||
|
||||
const authHeaderInterceptor = (url: string, options: RequestConfig) => {
|
||||
const accessToken = sessionStorage.getItem('access_token');
|
||||
const authHeader = {};
|
||||
if (accessToken && !url.includes('/api-uaa/oauth/token')) {
|
||||
authHeader.Authorization = `Bearer ${accessToken}`;
|
||||
}
|
||||
const newHeaders = { ...options.headers, ...authHeader };
|
||||
return {
|
||||
url,
|
||||
options: { ...options, interceptors: true, headers: newHeaders },
|
||||
};
|
||||
};
|
||||
|
||||
const unauthorizedInterceptor = (response: Response) => {
|
||||
if (response.status === 401) {
|
||||
const { location } = history;
|
||||
// 如果没有登录,重定向到 login
|
||||
if (location.pathname !== loginPath) {
|
||||
history.push(loginPath);
|
||||
}
|
||||
}
|
||||
return response;
|
||||
};
|
||||
|
||||
export const request: RequestConfig = {
|
||||
// 新增自动添加AccessToken的请求前拦截器
|
||||
requestInterceptors: [authHeaderInterceptor],
|
||||
responseInterceptors: [unauthorizedInterceptor],
|
||||
errorConfig: {
|
||||
adaptor: (resData) => {
|
||||
return {
|
||||
...resData,
|
||||
errorMessage: '请求错误',
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
import { GithubOutlined } from '@ant-design/icons';
|
||||
import { DefaultFooter } from '@ant-design/pro-components';
|
||||
import { useIntl } from 'umi';
|
||||
|
||||
const Footer: React.FC = () => {
|
||||
const intl = useIntl();
|
||||
const defaultMessage = intl.formatMessage({
|
||||
id: 'app.copyright.produced',
|
||||
defaultMessage: 'zlt版权所有:https://gitee.com/zlt2000/microservices-platform',
|
||||
});
|
||||
|
||||
// const currentYear = new Date().getFullYear();
|
||||
|
||||
return (
|
||||
<DefaultFooter
|
||||
copyright={`${2018} ${defaultMessage}`}
|
||||
links={[
|
||||
{
|
||||
key: 'github',
|
||||
title: <GithubOutlined />,
|
||||
href: 'https://github.com/zlt2000/microservices-platform',
|
||||
blankTarget: true,
|
||||
},
|
||||
{
|
||||
key: 'beian',
|
||||
title: '粤ICP备19081412号',
|
||||
href: 'https://beian.miit.gov.cn/',
|
||||
blankTarget: true,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default Footer;
|
||||
@@ -0,0 +1,16 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
|
||||
.container > * {
|
||||
background-color: @popover-bg;
|
||||
border-radius: 4px;
|
||||
box-shadow: @shadow-1-down;
|
||||
}
|
||||
|
||||
@media screen and (max-width: @screen-xs) {
|
||||
.container {
|
||||
width: 100% !important;
|
||||
}
|
||||
.container > * {
|
||||
border-radius: 0 !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Dropdown } from 'antd';
|
||||
import type { DropDownProps } from 'antd/es/dropdown';
|
||||
import classNames from 'classnames';
|
||||
import React from 'react';
|
||||
import styles from './index.less';
|
||||
|
||||
export type HeaderDropdownProps = {
|
||||
overlayClassName?: string;
|
||||
overlay: React.ReactNode | (() => React.ReactNode) | any;
|
||||
placement?: 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topCenter' | 'topRight' | 'bottomCenter';
|
||||
} & Omit<DropDownProps, 'overlay'>;
|
||||
|
||||
const HeaderDropdown: React.FC<HeaderDropdownProps> = ({ overlayClassName: cls, ...restProps }) => (
|
||||
<Dropdown overlayClassName={classNames(styles.container, cls)} {...restProps} />
|
||||
);
|
||||
|
||||
export default HeaderDropdown;
|
||||
@@ -0,0 +1,25 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
|
||||
.headerSearch {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
.input {
|
||||
width: 0;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
background: transparent;
|
||||
border-radius: 0;
|
||||
transition: width 0.3s, margin-left 0.3s;
|
||||
:global(.ant-select-selection) {
|
||||
background: transparent;
|
||||
}
|
||||
input {
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
&.show {
|
||||
width: 210px;
|
||||
margin-left: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import { SearchOutlined } from '@ant-design/icons';
|
||||
import type { InputRef } from 'antd';
|
||||
import { AutoComplete, Input } from 'antd';
|
||||
import type { AutoCompleteProps } from 'antd/es/auto-complete';
|
||||
import classNames from 'classnames';
|
||||
import useMergedState from 'rc-util/es/hooks/useMergedState';
|
||||
import React, { useRef } from 'react';
|
||||
import styles from './index.less';
|
||||
|
||||
export type HeaderSearchProps = {
|
||||
onSearch?: (value?: string) => void;
|
||||
onChange?: (value?: string) => void;
|
||||
onVisibleChange?: (b: boolean) => void;
|
||||
className?: string;
|
||||
placeholder?: string;
|
||||
options: AutoCompleteProps['options'];
|
||||
defaultVisible?: boolean;
|
||||
visible?: boolean;
|
||||
defaultValue?: string;
|
||||
value?: string;
|
||||
};
|
||||
|
||||
const HeaderSearch: React.FC<HeaderSearchProps> = (props) => {
|
||||
const {
|
||||
className,
|
||||
defaultValue,
|
||||
onVisibleChange,
|
||||
placeholder,
|
||||
visible,
|
||||
defaultVisible,
|
||||
...restProps
|
||||
} = props;
|
||||
|
||||
const inputRef = useRef<InputRef | null>(null);
|
||||
|
||||
const [value, setValue] = useMergedState<string | undefined>(defaultValue, {
|
||||
value: props.value,
|
||||
onChange: props.onChange,
|
||||
});
|
||||
|
||||
const [searchMode, setSearchMode] = useMergedState(defaultVisible ?? false, {
|
||||
value: props.visible,
|
||||
onChange: onVisibleChange,
|
||||
});
|
||||
|
||||
const inputClass = classNames(styles.input, {
|
||||
[styles.show]: searchMode,
|
||||
});
|
||||
return (
|
||||
<div
|
||||
className={classNames(className, styles.headerSearch)}
|
||||
onClick={() => {
|
||||
setSearchMode(true);
|
||||
if (searchMode && inputRef.current) {
|
||||
inputRef.current.focus();
|
||||
}
|
||||
}}
|
||||
onTransitionEnd={({ propertyName }) => {
|
||||
if (propertyName === 'width' && !searchMode) {
|
||||
if (onVisibleChange) {
|
||||
onVisibleChange(searchMode);
|
||||
}
|
||||
}
|
||||
}}
|
||||
>
|
||||
<SearchOutlined
|
||||
key="Icon"
|
||||
style={{
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
/>
|
||||
<AutoComplete
|
||||
key="AutoComplete"
|
||||
className={inputClass}
|
||||
value={value}
|
||||
options={restProps.options}
|
||||
onChange={(completeValue) => setValue(completeValue)}
|
||||
>
|
||||
<Input
|
||||
size="small"
|
||||
ref={inputRef}
|
||||
defaultValue={defaultValue}
|
||||
aria-label={placeholder}
|
||||
placeholder={placeholder}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
if (restProps.onSearch) {
|
||||
restProps.onSearch(value);
|
||||
}
|
||||
}
|
||||
}}
|
||||
onBlur={() => {
|
||||
setSearchMode(false);
|
||||
}}
|
||||
/>
|
||||
</AutoComplete>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default HeaderSearch;
|
||||
@@ -0,0 +1,126 @@
|
||||
import { BellOutlined } from '@ant-design/icons';
|
||||
import { Badge, Spin, Tabs } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
import useMergedState from 'rc-util/es/hooks/useMergedState';
|
||||
import React from 'react';
|
||||
import HeaderDropdown from '../HeaderDropdown';
|
||||
import styles from './index.less';
|
||||
import type { NoticeIconTabProps } from './NoticeList';
|
||||
import NoticeList from './NoticeList';
|
||||
|
||||
const { TabPane } = Tabs;
|
||||
|
||||
export type NoticeIconProps = {
|
||||
count?: number;
|
||||
bell?: React.ReactNode;
|
||||
className?: string;
|
||||
loading?: boolean;
|
||||
onClear?: (tabName: string, tabKey: string) => void;
|
||||
onItemClick?: (item: API.NoticeIconItem, tabProps: NoticeIconTabProps) => void;
|
||||
onViewMore?: (tabProps: NoticeIconTabProps, e: MouseEvent) => void;
|
||||
onTabChange?: (tabTile: string) => void;
|
||||
style?: React.CSSProperties;
|
||||
onPopupVisibleChange?: (visible: boolean) => void;
|
||||
popupVisible?: boolean;
|
||||
clearText?: string;
|
||||
viewMoreText?: string;
|
||||
clearClose?: boolean;
|
||||
emptyImage?: string;
|
||||
children?: React.ReactElement<NoticeIconTabProps>[];
|
||||
};
|
||||
|
||||
const NoticeIcon: React.FC<NoticeIconProps> & {
|
||||
Tab: typeof NoticeList;
|
||||
} = (props) => {
|
||||
const getNotificationBox = (): React.ReactNode => {
|
||||
const {
|
||||
children,
|
||||
loading,
|
||||
onClear,
|
||||
onTabChange,
|
||||
onItemClick,
|
||||
onViewMore,
|
||||
clearText,
|
||||
viewMoreText,
|
||||
} = props;
|
||||
if (!children) {
|
||||
return null;
|
||||
}
|
||||
const panes: React.ReactNode[] = [];
|
||||
React.Children.forEach(children, (child: React.ReactElement<NoticeIconTabProps>): void => {
|
||||
if (!child) {
|
||||
return;
|
||||
}
|
||||
const { list, title, count, tabKey, showClear, showViewMore } = child.props;
|
||||
const len = list && list.length ? list.length : 0;
|
||||
const msgCount = count || count === 0 ? count : len;
|
||||
const tabTitle: string = msgCount > 0 ? `${title} (${msgCount})` : title;
|
||||
panes.push(
|
||||
<TabPane tab={tabTitle} key={tabKey}>
|
||||
<NoticeList
|
||||
clearText={clearText}
|
||||
viewMoreText={viewMoreText}
|
||||
list={list}
|
||||
tabKey={tabKey}
|
||||
onClear={(): void => onClear && onClear(title, tabKey)}
|
||||
onClick={(item): void => onItemClick && onItemClick(item, child.props)}
|
||||
onViewMore={(event): void => onViewMore && onViewMore(child.props, event)}
|
||||
showClear={showClear}
|
||||
showViewMore={showViewMore}
|
||||
title={title}
|
||||
/>
|
||||
</TabPane>,
|
||||
);
|
||||
});
|
||||
return (
|
||||
<>
|
||||
<Spin spinning={loading} delay={300}>
|
||||
<Tabs className={styles.tabs} onChange={onTabChange}>
|
||||
{panes}
|
||||
</Tabs>
|
||||
</Spin>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const { className, count, bell } = props;
|
||||
|
||||
const [visible, setVisible] = useMergedState<boolean>(false, {
|
||||
value: props.popupVisible,
|
||||
onChange: props.onPopupVisibleChange,
|
||||
});
|
||||
const noticeButtonClass = classNames(className, styles.noticeButton);
|
||||
const notificationBox = getNotificationBox();
|
||||
const NoticeBellIcon = bell || <BellOutlined className={styles.icon} />;
|
||||
const trigger = (
|
||||
<span className={classNames(noticeButtonClass, { opened: visible })}>
|
||||
<Badge count={count} style={{ boxShadow: 'none' }} className={styles.badge}>
|
||||
{NoticeBellIcon}
|
||||
</Badge>
|
||||
</span>
|
||||
);
|
||||
if (!notificationBox) {
|
||||
return trigger;
|
||||
}
|
||||
|
||||
return (
|
||||
<HeaderDropdown
|
||||
placement="bottomRight"
|
||||
overlay={notificationBox}
|
||||
overlayClassName={styles.popover}
|
||||
trigger={['click']}
|
||||
visible={visible}
|
||||
onVisibleChange={setVisible}
|
||||
>
|
||||
{trigger}
|
||||
</HeaderDropdown>
|
||||
);
|
||||
};
|
||||
|
||||
NoticeIcon.defaultProps = {
|
||||
emptyImage: 'https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg',
|
||||
};
|
||||
|
||||
NoticeIcon.Tab = NoticeList;
|
||||
|
||||
export default NoticeIcon;
|
||||
@@ -0,0 +1,103 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
|
||||
.list {
|
||||
max-height: 400px;
|
||||
overflow: auto;
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
.item {
|
||||
padding-right: 24px;
|
||||
padding-left: 24px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
|
||||
.meta {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
margin-top: 4px;
|
||||
background: @component-background;
|
||||
}
|
||||
.iconElement {
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
&.read {
|
||||
opacity: 0.4;
|
||||
}
|
||||
&:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
&:hover {
|
||||
background: @primary-1;
|
||||
}
|
||||
.title {
|
||||
margin-bottom: 8px;
|
||||
font-weight: normal;
|
||||
}
|
||||
.description {
|
||||
font-size: 12px;
|
||||
line-height: @line-height-base;
|
||||
}
|
||||
.datetime {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
line-height: @line-height-base;
|
||||
}
|
||||
.extra {
|
||||
float: right;
|
||||
margin-top: -1.5px;
|
||||
margin-right: 0;
|
||||
color: @text-color-secondary;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
.loadMore {
|
||||
padding: 8px 0;
|
||||
color: @primary-6;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
&.loadedAll {
|
||||
color: rgba(0, 0, 0, 0.25);
|
||||
cursor: unset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.notFound {
|
||||
padding: 73px 0 88px;
|
||||
color: @text-color-secondary;
|
||||
text-align: center;
|
||||
img {
|
||||
display: inline-block;
|
||||
height: 76px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.bottomBar {
|
||||
height: 46px;
|
||||
color: @text-color;
|
||||
line-height: 46px;
|
||||
text-align: center;
|
||||
border-top: 1px solid @border-color-split;
|
||||
border-radius: 0 0 @border-radius-base @border-radius-base;
|
||||
transition: all 0.3s;
|
||||
div {
|
||||
display: inline-block;
|
||||
width: 50%;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
user-select: none;
|
||||
|
||||
&:only-child {
|
||||
width: 100%;
|
||||
}
|
||||
&:not(:only-child):last-child {
|
||||
border-left: 1px solid @border-color-split;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
import { Avatar, List } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
import React from 'react';
|
||||
import styles from './NoticeList.less';
|
||||
|
||||
export type NoticeIconTabProps = {
|
||||
count?: number;
|
||||
showClear?: boolean;
|
||||
showViewMore?: boolean;
|
||||
style?: React.CSSProperties;
|
||||
title: string;
|
||||
tabKey: API.NoticeIconItemType;
|
||||
onClick?: (item: API.NoticeIconItem) => void;
|
||||
onClear?: () => void;
|
||||
emptyText?: string;
|
||||
clearText?: string;
|
||||
viewMoreText?: string;
|
||||
list: API.NoticeIconItem[];
|
||||
onViewMore?: (e: any) => void;
|
||||
};
|
||||
const NoticeList: React.FC<NoticeIconTabProps> = ({
|
||||
list = [],
|
||||
onClick,
|
||||
onClear,
|
||||
title,
|
||||
onViewMore,
|
||||
emptyText,
|
||||
showClear = true,
|
||||
clearText,
|
||||
viewMoreText,
|
||||
showViewMore = false,
|
||||
}) => {
|
||||
if (!list || list.length === 0) {
|
||||
return (
|
||||
<div className={styles.notFound}>
|
||||
<img
|
||||
src="https://gw.alipayobjects.com/zos/rmsportal/sAuJeJzSKbUmHfBQRzmZ.svg"
|
||||
alt="not found"
|
||||
/>
|
||||
<div>{emptyText}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<List<API.NoticeIconItem>
|
||||
className={styles.list}
|
||||
dataSource={list}
|
||||
renderItem={(item, i) => {
|
||||
const itemCls = classNames(styles.item, {
|
||||
[styles.read]: item.read,
|
||||
});
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
const leftIcon = item.avatar ? (
|
||||
typeof item.avatar === 'string' ? (
|
||||
<Avatar className={styles.avatar} src={item.avatar} />
|
||||
) : (
|
||||
<span className={styles.iconElement}>{item.avatar}</span>
|
||||
)
|
||||
) : null;
|
||||
|
||||
return (
|
||||
<div
|
||||
onClick={() => {
|
||||
onClick?.(item);
|
||||
}}
|
||||
>
|
||||
<List.Item className={itemCls} key={item.key || i}>
|
||||
<List.Item.Meta
|
||||
className={styles.meta}
|
||||
avatar={leftIcon}
|
||||
title={
|
||||
<div className={styles.title}>
|
||||
{item.title}
|
||||
<div className={styles.extra}>{item.extra}</div>
|
||||
</div>
|
||||
}
|
||||
description={
|
||||
<div>
|
||||
<div className={styles.description}>{item.description}</div>
|
||||
<div className={styles.datetime}>{item.datetime}</div>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</List.Item>
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<div className={styles.bottomBar}>
|
||||
{showClear ? (
|
||||
<div onClick={onClear}>
|
||||
{clearText} {title}
|
||||
</div>
|
||||
) : null}
|
||||
{showViewMore ? (
|
||||
<div
|
||||
onClick={(e) => {
|
||||
if (onViewMore) {
|
||||
onViewMore(e);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{viewMoreText}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default NoticeList;
|
||||
@@ -0,0 +1,35 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
|
||||
.popover {
|
||||
position: relative;
|
||||
width: 336px;
|
||||
}
|
||||
|
||||
.noticeButton {
|
||||
display: inline-block;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
.icon {
|
||||
padding: 4px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.badge {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
:global {
|
||||
.ant-tabs-nav-list {
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.ant-tabs-nav-scroll {
|
||||
text-align: center;
|
||||
}
|
||||
.ant-tabs-nav {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
import { getNotices } from '@/services/ant-design-pro/api';
|
||||
import { message, Tag } from 'antd';
|
||||
import { groupBy } from 'lodash';
|
||||
import moment from 'moment';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useModel, useRequest } from 'umi';
|
||||
import styles from './index.less';
|
||||
import NoticeIcon from './NoticeIcon';
|
||||
|
||||
export type GlobalHeaderRightProps = {
|
||||
fetchingNotices?: boolean;
|
||||
onNoticeVisibleChange?: (visible: boolean) => void;
|
||||
onNoticeClear?: (tabName?: string) => void;
|
||||
};
|
||||
|
||||
const getNoticeData = (notices: API.NoticeIconItem[]): Record<string, API.NoticeIconItem[]> => {
|
||||
if (!notices || notices.length === 0 || !Array.isArray(notices)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const newNotices = notices.map((notice) => {
|
||||
const newNotice = { ...notice };
|
||||
|
||||
if (newNotice.datetime) {
|
||||
newNotice.datetime = moment(notice.datetime as string).fromNow();
|
||||
}
|
||||
|
||||
if (newNotice.id) {
|
||||
newNotice.key = newNotice.id;
|
||||
}
|
||||
|
||||
if (newNotice.extra && newNotice.status) {
|
||||
const color = {
|
||||
todo: '',
|
||||
processing: 'blue',
|
||||
urgent: 'red',
|
||||
doing: 'gold',
|
||||
}[newNotice.status];
|
||||
newNotice.extra = (
|
||||
<Tag
|
||||
color={color}
|
||||
style={{
|
||||
marginRight: 0,
|
||||
}}
|
||||
>
|
||||
{newNotice.extra}
|
||||
</Tag>
|
||||
) as any;
|
||||
}
|
||||
|
||||
return newNotice;
|
||||
});
|
||||
return groupBy(newNotices, 'type');
|
||||
};
|
||||
|
||||
const getUnreadData = (noticeData: Record<string, API.NoticeIconItem[]>) => {
|
||||
const unreadMsg: Record<string, number> = {};
|
||||
Object.keys(noticeData).forEach((key) => {
|
||||
const value = noticeData[key];
|
||||
|
||||
if (!unreadMsg[key]) {
|
||||
unreadMsg[key] = 0;
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
unreadMsg[key] = value.filter((item) => !item.read).length;
|
||||
}
|
||||
});
|
||||
return unreadMsg;
|
||||
};
|
||||
|
||||
const NoticeIconView: React.FC = () => {
|
||||
const { initialState } = useModel('@@initialState');
|
||||
const { currentUser } = initialState || {};
|
||||
const [notices, setNotices] = useState<API.NoticeIconItem[]>([]);
|
||||
const { data } = useRequest(getNotices);
|
||||
|
||||
useEffect(() => {
|
||||
setNotices(data || []);
|
||||
}, [data]);
|
||||
|
||||
const noticeData = getNoticeData(notices);
|
||||
const unreadMsg = getUnreadData(noticeData || {});
|
||||
|
||||
const changeReadState = (id: string) => {
|
||||
setNotices(
|
||||
notices.map((item) => {
|
||||
const notice = { ...item };
|
||||
if (notice.id === id) {
|
||||
notice.read = true;
|
||||
}
|
||||
return notice;
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
const clearReadState = (title: string, key: string) => {
|
||||
setNotices(
|
||||
notices.map((item) => {
|
||||
const notice = { ...item };
|
||||
if (notice.type === key) {
|
||||
notice.read = true;
|
||||
}
|
||||
return notice;
|
||||
}),
|
||||
);
|
||||
message.success(`${'清空了'} ${title}`);
|
||||
};
|
||||
|
||||
return (
|
||||
<NoticeIcon
|
||||
className={styles.action}
|
||||
count={currentUser && currentUser.unreadCount}
|
||||
onItemClick={(item) => {
|
||||
changeReadState(item.id!);
|
||||
}}
|
||||
onClear={(title: string, key: string) => clearReadState(title, key)}
|
||||
loading={false}
|
||||
clearText="清空"
|
||||
viewMoreText="查看更多"
|
||||
onViewMore={() => message.info('Click on view more')}
|
||||
clearClose
|
||||
>
|
||||
<NoticeIcon.Tab
|
||||
tabKey="notification"
|
||||
count={unreadMsg.notification}
|
||||
list={noticeData.notification}
|
||||
title="通知"
|
||||
emptyText="你已查看所有通知"
|
||||
showViewMore
|
||||
/>
|
||||
<NoticeIcon.Tab
|
||||
tabKey="message"
|
||||
count={unreadMsg.message}
|
||||
list={noticeData.message}
|
||||
title="消息"
|
||||
emptyText="您已读完所有消息"
|
||||
showViewMore
|
||||
/>
|
||||
<NoticeIcon.Tab
|
||||
tabKey="event"
|
||||
title="待办"
|
||||
emptyText="你已完成所有待办"
|
||||
count={unreadMsg.event}
|
||||
list={noticeData.event}
|
||||
showViewMore
|
||||
/>
|
||||
</NoticeIcon>
|
||||
);
|
||||
};
|
||||
|
||||
export default NoticeIconView;
|
||||
@@ -0,0 +1,113 @@
|
||||
import { outLogin } from '@/services/ant-design-pro/api';
|
||||
import { LogoutOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons';
|
||||
import { Avatar, Menu, Spin } from 'antd';
|
||||
import type { ItemType } from 'antd/lib/menu/hooks/useItems';
|
||||
import { stringify } from 'querystring';
|
||||
import type { MenuInfo } from 'rc-menu/lib/interface';
|
||||
import React, { useCallback } from 'react';
|
||||
import { history, useModel } from 'umi';
|
||||
import HeaderDropdown from '../HeaderDropdown';
|
||||
import styles from './index.less';
|
||||
|
||||
export type GlobalHeaderRightProps = {
|
||||
menu?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* 退出登录,并且将当前的 url 保存
|
||||
*/
|
||||
const loginOut = async () => {
|
||||
await outLogin();
|
||||
const { query = {}, search, pathname } = history.location;
|
||||
const { redirect } = query;
|
||||
// Note: There may be security issues, please note
|
||||
if (window.location.pathname !== '/user/login' && !redirect) {
|
||||
history.replace({
|
||||
pathname: '/user/login',
|
||||
search: stringify({
|
||||
redirect: pathname + search,
|
||||
}),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
|
||||
const { initialState, setInitialState } = useModel('@@initialState');
|
||||
|
||||
const onMenuClick = useCallback(
|
||||
(event: MenuInfo) => {
|
||||
const { key } = event;
|
||||
if (key === 'logout') {
|
||||
setInitialState((s) => ({ ...s, currentUser: undefined }));
|
||||
loginOut();
|
||||
return;
|
||||
} else if (key === 'center') {
|
||||
history.push('/system/myInfo.html');
|
||||
}
|
||||
},
|
||||
[setInitialState],
|
||||
);
|
||||
|
||||
const loading = (
|
||||
<span className={`${styles.action} ${styles.account}`}>
|
||||
<Spin
|
||||
size="small"
|
||||
style={{
|
||||
marginLeft: 8,
|
||||
marginRight: 8,
|
||||
}}
|
||||
/>
|
||||
</span>
|
||||
);
|
||||
|
||||
if (!initialState) {
|
||||
return loading;
|
||||
}
|
||||
|
||||
const { currentUser } = initialState;
|
||||
|
||||
if (!currentUser || !currentUser.nickname) {
|
||||
return loading;
|
||||
}
|
||||
|
||||
const menuItems: ItemType[] = [
|
||||
...(menu
|
||||
? [
|
||||
{
|
||||
key: 'center',
|
||||
icon: <UserOutlined />,
|
||||
label: '个人中心',
|
||||
},
|
||||
{
|
||||
key: 'settings',
|
||||
icon: <SettingOutlined />,
|
||||
label: '个人设置',
|
||||
},
|
||||
{
|
||||
type: 'divider' as const,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
|
||||
{
|
||||
key: 'logout',
|
||||
icon: <LogoutOutlined />,
|
||||
label: '退出登录',
|
||||
},
|
||||
];
|
||||
|
||||
const menuHeaderDropdown = (
|
||||
<Menu className={styles.menu} selectedKeys={[]} onClick={onMenuClick} items={menuItems} />
|
||||
);
|
||||
|
||||
return (
|
||||
<HeaderDropdown overlay={menuHeaderDropdown}>
|
||||
<span className={`${styles.action} ${styles.account}`}>
|
||||
<Avatar size="small" className={styles.avatar} src={currentUser.headImgUrl} alt="avatar" />
|
||||
<span className={`${styles.name} anticon`}>{currentUser.nickname}</span>
|
||||
</span>
|
||||
</HeaderDropdown>
|
||||
);
|
||||
};
|
||||
|
||||
export default AvatarDropdown;
|
||||
@@ -0,0 +1,84 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
|
||||
@pro-header-hover-bg: rgba(0, 0, 0, 0.025);
|
||||
|
||||
.menu {
|
||||
:global(.anticon) {
|
||||
margin-right: 8px;
|
||||
}
|
||||
:global(.ant-dropdown-menu-item) {
|
||||
min-width: 160px;
|
||||
}
|
||||
}
|
||||
|
||||
.right {
|
||||
display: flex;
|
||||
float: right;
|
||||
height: 48px;
|
||||
margin-left: auto;
|
||||
overflow: hidden;
|
||||
.action {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 48px;
|
||||
padding: 0 12px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
> span {
|
||||
vertical-align: middle;
|
||||
}
|
||||
&:hover {
|
||||
background: @pro-header-hover-bg;
|
||||
}
|
||||
&:global(.opened) {
|
||||
background: @pro-header-hover-bg;
|
||||
}
|
||||
}
|
||||
.search {
|
||||
padding: 0 12px;
|
||||
&:hover {
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
.account {
|
||||
.avatar {
|
||||
margin-right: 8px;
|
||||
color: @primary-color;
|
||||
vertical-align: top;
|
||||
background: rgba(255, 255, 255, 0.85);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dark {
|
||||
.action {
|
||||
&:hover {
|
||||
background: #252a3d;
|
||||
}
|
||||
&:global(.opened) {
|
||||
background: #252a3d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (max-width: @screen-md) {
|
||||
:global(.ant-divider-vertical) {
|
||||
vertical-align: unset;
|
||||
}
|
||||
.name {
|
||||
display: none;
|
||||
}
|
||||
.right {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 12px;
|
||||
.account {
|
||||
.avatar {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
.search {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import { GithubOutlined, QuestionCircleOutlined } from '@ant-design/icons';
|
||||
import { Space } from 'antd';
|
||||
import React from 'react';
|
||||
import { SelectLang, useModel } from 'umi';
|
||||
import HeaderSearch from '../HeaderSearch';
|
||||
import AvatarDropdown from './AvatarDropdown';
|
||||
import styles from './index.less';
|
||||
|
||||
export type SiderTheme = 'light' | 'dark';
|
||||
|
||||
const GlobalHeaderRight: React.FC = () => {
|
||||
const { initialState } = useModel('@@initialState');
|
||||
|
||||
if (!initialState || !initialState.settings) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { navTheme, layout } = initialState.settings;
|
||||
let className = styles.right;
|
||||
|
||||
if ((navTheme === 'dark' && layout === 'top') || layout === 'mix') {
|
||||
className = `${styles.right} ${styles.dark}`;
|
||||
}
|
||||
return (
|
||||
<Space className={className}>
|
||||
{/* <HeaderSearch
|
||||
className={`${styles.action} ${styles.search}`}
|
||||
placeholder="站内搜索"
|
||||
defaultValue="umi ui"
|
||||
options={[
|
||||
{ label: <a href="https://umijs.org/zh/guide/umi-ui.html">umi ui</a>, value: 'umi ui' },
|
||||
{
|
||||
label: <a href="next.ant.design">Ant Design</a>,
|
||||
value: 'Ant Design',
|
||||
},
|
||||
{
|
||||
label: <a href="https://protable.ant.design/">Pro Table</a>,
|
||||
value: 'Pro Table',
|
||||
},
|
||||
{
|
||||
label: <a href="https://prolayout.ant.design/">Pro Layout</a>,
|
||||
value: 'Pro Layout',
|
||||
},
|
||||
]}
|
||||
onSearch={value => {
|
||||
console.log('input', value);
|
||||
}}
|
||||
/> */}
|
||||
<span
|
||||
className={styles.action}
|
||||
onClick={() => {
|
||||
window.open('https://www.kancloud.cn/zlt2000/microservices-platform');
|
||||
}}
|
||||
>
|
||||
<QuestionCircleOutlined />
|
||||
</span>
|
||||
<span
|
||||
className={styles.action}
|
||||
onClick={() => {
|
||||
window.open('https://github.com/zlt2000/microservices-platform');
|
||||
}}
|
||||
>
|
||||
<GithubOutlined />
|
||||
</span>
|
||||
<AvatarDropdown menu />
|
||||
</Space>
|
||||
);
|
||||
};
|
||||
export default GlobalHeaderRight;
|
||||
@@ -0,0 +1,271 @@
|
||||
---
|
||||
title: 业务组件
|
||||
sidemenu: false
|
||||
---
|
||||
|
||||
> 此功能由[dumi](https://d.umijs.org/zh-CN/guide/advanced#umi-%E9%A1%B9%E7%9B%AE%E9%9B%86%E6%88%90%E6%A8%A1%E5%BC%8F)提供,dumi 是一个 📖 为组件开发场景而生的文档工具,用过的都说好。
|
||||
|
||||
# 业务组件
|
||||
|
||||
这里列举了 Pro 中所有用到的组件,这些组件不适合作为组件库,但是在业务中却真实需要。所以我们准备了这个文档,来指导大家是否需要使用这个组件。
|
||||
|
||||
## Footer 页脚组件
|
||||
|
||||
这个组件自带了一些 Pro 的配置,你一般都需要改掉它的信息。
|
||||
|
||||
```tsx
|
||||
/**
|
||||
* background: '#f0f2f5'
|
||||
*/
|
||||
import Footer from '@/components/Footer';
|
||||
import React from 'react';
|
||||
|
||||
export default () => <Footer />;
|
||||
```
|
||||
|
||||
## HeaderDropdown 头部下拉列表
|
||||
|
||||
HeaderDropdown 是 antd Dropdown 的封装,但是增加了移动端的特殊处理,用法也是相同的。
|
||||
|
||||
```tsx
|
||||
/**
|
||||
* background: '#f0f2f5'
|
||||
*/
|
||||
import HeaderDropdown from '@/components/HeaderDropdown';
|
||||
import { Button, Menu } from 'antd';
|
||||
import React from 'react';
|
||||
|
||||
export default () => {
|
||||
const menuHeaderDropdown = (
|
||||
<Menu selectedKeys={[]}>
|
||||
<Menu.Item key="center">个人中心</Menu.Item>
|
||||
<Menu.Item key="settings">个人设置</Menu.Item>
|
||||
<Menu.Divider />
|
||||
<Menu.Item key="logout">退出登录</Menu.Item>
|
||||
</Menu>
|
||||
);
|
||||
return (
|
||||
<HeaderDropdown overlay={menuHeaderDropdown}>
|
||||
<Button>hover 展示菜单</Button>
|
||||
</HeaderDropdown>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
## HeaderSearch 头部搜索框
|
||||
|
||||
一个带补全数据的输入框,支持收起和展开 Input
|
||||
|
||||
```tsx
|
||||
/**
|
||||
* background: '#f0f2f5'
|
||||
*/
|
||||
import HeaderSearch from '@/components/HeaderSearch';
|
||||
import React from 'react';
|
||||
|
||||
export default () => {
|
||||
return (
|
||||
<HeaderSearch
|
||||
placeholder="站内搜索"
|
||||
defaultValue="umi ui"
|
||||
options={[
|
||||
{ label: 'Ant Design Pro', value: 'Ant Design Pro' },
|
||||
{
|
||||
label: 'Ant Design',
|
||||
value: 'Ant Design',
|
||||
},
|
||||
{
|
||||
label: 'Pro Table',
|
||||
value: 'Pro Table',
|
||||
},
|
||||
{
|
||||
label: 'Pro Layout',
|
||||
value: 'Pro Layout',
|
||||
},
|
||||
]}
|
||||
onSearch={(value) => {
|
||||
console.log('input', value);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
### API
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| --------------- | ---------------------------------- | ---------------------------- | ------ |
|
||||
| value | 输入框的值 | `string` | - |
|
||||
| onChange | 值修改后触发 | `(value?: string) => void` | - |
|
||||
| onSearch | 查询后触发 | `(value?: string) => void` | - |
|
||||
| options | 选项菜单的的列表 | `{label,value}[]` | - |
|
||||
| defaultVisible | 输入框默认是否显示,只有第一次生效 | `boolean` | - |
|
||||
| visible | 输入框是否显示 | `boolean` | - |
|
||||
| onVisibleChange | 输入框显示隐藏的回调函数 | `(visible: boolean) => void` | - |
|
||||
|
||||
## NoticeIcon 通知工具
|
||||
|
||||
通知工具提供一个展示多种通知信息的界面。
|
||||
|
||||
```tsx
|
||||
/**
|
||||
* background: '#f0f2f5'
|
||||
*/
|
||||
import NoticeIcon from '@/components/NoticeIcon/NoticeIcon';
|
||||
import { message } from 'antd';
|
||||
import React from 'react';
|
||||
|
||||
export default () => {
|
||||
const list = [
|
||||
{
|
||||
id: '000000001',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
|
||||
title: '你收到了 14 份新周报',
|
||||
datetime: '2017-08-09',
|
||||
type: 'notification',
|
||||
},
|
||||
{
|
||||
id: '000000002',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png',
|
||||
title: '你推荐的 曲妮妮 已通过第三轮面试',
|
||||
datetime: '2017-08-08',
|
||||
type: 'notification',
|
||||
},
|
||||
];
|
||||
return (
|
||||
<NoticeIcon
|
||||
count={10}
|
||||
onItemClick={(item) => {
|
||||
message.info(`${item.title} 被点击了`);
|
||||
}}
|
||||
onClear={(title: string, key: string) => message.info('点击了清空更多')}
|
||||
loading={false}
|
||||
clearText="清空"
|
||||
viewMoreText="查看更多"
|
||||
onViewMore={() => message.info('点击了查看更多')}
|
||||
clearClose
|
||||
>
|
||||
<NoticeIcon.Tab
|
||||
tabKey="notification"
|
||||
count={2}
|
||||
list={list}
|
||||
title="通知"
|
||||
emptyText="你已查看所有通知"
|
||||
showViewMore
|
||||
/>
|
||||
<NoticeIcon.Tab
|
||||
tabKey="message"
|
||||
count={2}
|
||||
list={list}
|
||||
title="消息"
|
||||
emptyText="您已读完所有消息"
|
||||
showViewMore
|
||||
/>
|
||||
<NoticeIcon.Tab
|
||||
tabKey="event"
|
||||
title="待办"
|
||||
emptyText="你已完成所有待办"
|
||||
count={2}
|
||||
list={list}
|
||||
showViewMore
|
||||
/>
|
||||
</NoticeIcon>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
### NoticeIcon API
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| --- | --- | --- | --- |
|
||||
| count | 有多少未读通知 | `number` | - |
|
||||
| bell | 铃铛的图表 | `ReactNode` | - |
|
||||
| onClear | 点击清空数据按钮 | `(tabName: string, tabKey: string) => void` | - |
|
||||
| onItemClick | 未读消息列被点击 | `(item: API.NoticeIconData, tabProps: NoticeIconTabProps) => void` | - |
|
||||
| onViewMore | 查看更多的按钮点击 | `(tabProps: NoticeIconTabProps, e: MouseEvent) => void` | - |
|
||||
| onTabChange | 通知 Tab 的切换 | `(tabTile: string) => void;` | - |
|
||||
| popupVisible | 通知显示是否展示 | `boolean` | - |
|
||||
| onPopupVisibleChange | 通知信息显示隐藏的回调函数 | `(visible: boolean) => void` | - |
|
||||
| clearText | 清空按钮的文字 | `string` | - |
|
||||
| viewMoreText | 查看更多的按钮文字 | `string` | - |
|
||||
| clearClose | 展示清空按钮 | `boolean` | - |
|
||||
| emptyImage | 列表为空时的兜底展示 | `ReactNode` | - |
|
||||
|
||||
### NoticeIcon.Tab API
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| ------------ | ------------------ | ------------------------------------ | ------ |
|
||||
| count | 有多少未读通知 | `number` | - |
|
||||
| title | 通知 Tab 的标题 | `ReactNode` | - |
|
||||
| showClear | 展示清除按钮 | `boolean` | `true` |
|
||||
| showViewMore | 展示加载更 | `boolean` | `true` |
|
||||
| tabKey | Tab 的唯一 key | `string` | - |
|
||||
| onClick | 子项的单击事件 | `(item: API.NoticeIconData) => void` | - |
|
||||
| onClear | 清楚按钮的点击 | `()=>void` | - |
|
||||
| emptyText | 为空的时候测试 | `()=>void` | - |
|
||||
| viewMoreText | 查看更多的按钮文字 | `string` | - |
|
||||
| onViewMore | 查看更多的按钮点击 | `( e: MouseEvent) => void` | - |
|
||||
| list | 通知信息的列表 | `API.NoticeIconData` | - |
|
||||
|
||||
### NoticeIconData
|
||||
|
||||
```tsx | pure
|
||||
export interface NoticeIconData {
|
||||
id: string;
|
||||
key: string;
|
||||
avatar: string;
|
||||
title: string;
|
||||
datetime: string;
|
||||
type: string;
|
||||
read?: boolean;
|
||||
description: string;
|
||||
clickClose?: boolean;
|
||||
extra: any;
|
||||
status: string;
|
||||
}
|
||||
```
|
||||
|
||||
## RightContent
|
||||
|
||||
RightContent 是以上几个组件的组合,同时新增了 plugins 的 `SelectLang` 插件。
|
||||
|
||||
```tsx | pure
|
||||
<Space>
|
||||
<HeaderSearch
|
||||
placeholder="站内搜索"
|
||||
defaultValue="umi ui"
|
||||
options={[
|
||||
{ label: <a href="https://umijs.org/zh/guide/umi-ui.html">umi ui</a>, value: 'umi ui' },
|
||||
{
|
||||
label: <a href="next.ant.design">Ant Design</a>,
|
||||
value: 'Ant Design',
|
||||
},
|
||||
{
|
||||
label: <a href="https://protable.ant.design/">Pro Table</a>,
|
||||
value: 'Pro Table',
|
||||
},
|
||||
{
|
||||
label: <a href="https://prolayout.ant.design/">Pro Layout</a>,
|
||||
value: 'Pro Layout',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Tooltip title="使用文档">
|
||||
<span
|
||||
className={styles.action}
|
||||
onClick={() => {
|
||||
window.location.href = 'https://pro.ant.design/docs/getting-started';
|
||||
}}
|
||||
>
|
||||
<QuestionCircleOutlined />
|
||||
</span>
|
||||
</Tooltip>
|
||||
<Avatar />
|
||||
{REACT_APP_ENV && (
|
||||
<span>
|
||||
<Tag color={ENVTagColor[REACT_APP_ENV]}>{REACT_APP_ENV}</Tag>
|
||||
</span>
|
||||
)}
|
||||
<SelectLang className={styles.action} />
|
||||
</Space>
|
||||
```
|
||||
@@ -0,0 +1,45 @@
|
||||
import type { Page } from '@playwright/test';
|
||||
import { expect, test } from '@playwright/test';
|
||||
const { uniq } = require('lodash');
|
||||
const RouterConfig = require('../../config/routes').default;
|
||||
|
||||
const BASE_URL = `http://localhost:${process.env.PORT || 8001}`;
|
||||
|
||||
function formatter(routes: any, parentPath = ''): string[] {
|
||||
const fixedParentPath = parentPath.replace(/\/{1,}/g, '/');
|
||||
let result: string[] = [];
|
||||
routes.forEach((item: { path: string; routes: string }) => {
|
||||
if (item.path && !item.path.startsWith('/')) {
|
||||
result.push(`${fixedParentPath}/${item.path}`.replace(/\/{1,}/g, '/'));
|
||||
}
|
||||
if (item.path && item.path.startsWith('/')) {
|
||||
result.push(`${item.path}`.replace(/\/{1,}/g, '/'));
|
||||
}
|
||||
if (item.routes) {
|
||||
result = result.concat(
|
||||
formatter(item.routes, item.path ? `${fixedParentPath}/${item.path}` : parentPath),
|
||||
);
|
||||
}
|
||||
});
|
||||
return uniq(result.filter((item) => !!item));
|
||||
}
|
||||
|
||||
const testPage = (path: string, page: Page) => async () => {
|
||||
await page.evaluate(() => {
|
||||
localStorage.setItem('antd-pro-authority', '["admin"]');
|
||||
});
|
||||
await page.goto(`${BASE_URL}${path}`);
|
||||
await page.waitForSelector('footer', {
|
||||
timeout: 2000,
|
||||
});
|
||||
const haveFooter = await page.evaluate(() => document.getElementsByTagName('footer').length > 0);
|
||||
expect(haveFooter).toBeTruthy();
|
||||
};
|
||||
|
||||
const routers = formatter(RouterConfig);
|
||||
|
||||
routers.forEach((route) => {
|
||||
test(`test route page ${route}`, async ({ page }) => {
|
||||
await testPage(route, page);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
@import '~antd/es/style/variable.less';
|
||||
|
||||
html,
|
||||
body,
|
||||
#root {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.colorWeak {
|
||||
filter: invert(80%);
|
||||
}
|
||||
|
||||
.ant-layout {
|
||||
min-height: 100vh;
|
||||
}
|
||||
.ant-pro-sider.ant-layout-sider.ant-pro-sider-fixed {
|
||||
left: unset;
|
||||
}
|
||||
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
|
||||
body {
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
ul,
|
||||
ol {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.ant-layout-content {
|
||||
.query-filter {
|
||||
margin-bottom: @margin-md;
|
||||
padding: @padding-lg;
|
||||
padding-bottom: 0;
|
||||
background: @component-background;
|
||||
}
|
||||
}
|
||||
|
||||
.audit-log {
|
||||
mark {
|
||||
background-color: @gold-3;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: @screen-xs) {
|
||||
.ant-table {
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
&-thead > tr,
|
||||
&-tbody > tr {
|
||||
> th,
|
||||
> td {
|
||||
white-space: pre;
|
||||
> span {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compatible with IE11
|
||||
@media screen and(-ms-high-contrast: active), (-ms-high-contrast: none) {
|
||||
body .ant-design-pro > .ant-layout {
|
||||
min-height: 100vh;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import { Button, message, notification } from 'antd';
|
||||
import { useIntl } from 'umi';
|
||||
import defaultSettings from '../config/defaultSettings';
|
||||
|
||||
const { pwa } = defaultSettings;
|
||||
const isHttps = document.location.protocol === 'https:';
|
||||
|
||||
const clearCache = () => {
|
||||
// remove all caches
|
||||
if (window.caches) {
|
||||
caches
|
||||
.keys()
|
||||
.then((keys) => {
|
||||
keys.forEach((key) => {
|
||||
caches.delete(key);
|
||||
});
|
||||
})
|
||||
.catch((e) => console.log(e));
|
||||
}
|
||||
};
|
||||
|
||||
// if pwa is true
|
||||
if (pwa) {
|
||||
// Notify user if offline now
|
||||
window.addEventListener('sw.offline', () => {
|
||||
message.warning(useIntl().formatMessage({ id: 'app.pwa.offline' }));
|
||||
});
|
||||
|
||||
// Pop up a prompt on the page asking the user if they want to use the latest version
|
||||
window.addEventListener('sw.updated', (event: Event) => {
|
||||
const e = event as CustomEvent;
|
||||
const reloadSW = async () => {
|
||||
// Check if there is sw whose state is waiting in ServiceWorkerRegistration
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration
|
||||
const worker = e.detail && e.detail.waiting;
|
||||
if (!worker) {
|
||||
return true;
|
||||
}
|
||||
// Send skip-waiting event to waiting SW with MessageChannel
|
||||
await new Promise((resolve, reject) => {
|
||||
const channel = new MessageChannel();
|
||||
channel.port1.onmessage = (msgEvent) => {
|
||||
if (msgEvent.data.error) {
|
||||
reject(msgEvent.data.error);
|
||||
} else {
|
||||
resolve(msgEvent.data);
|
||||
}
|
||||
};
|
||||
worker.postMessage({ type: 'skip-waiting' }, [channel.port2]);
|
||||
});
|
||||
|
||||
clearCache();
|
||||
window.location.reload();
|
||||
return true;
|
||||
};
|
||||
const key = `open${Date.now()}`;
|
||||
const btn = (
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
notification.close(key);
|
||||
reloadSW();
|
||||
}}
|
||||
>
|
||||
{useIntl().formatMessage({ id: 'app.pwa.serviceworker.updated.ok' })}
|
||||
</Button>
|
||||
);
|
||||
notification.open({
|
||||
message: useIntl().formatMessage({ id: 'app.pwa.serviceworker.updated' }),
|
||||
description: useIntl().formatMessage({ id: 'app.pwa.serviceworker.updated.hint' }),
|
||||
btn,
|
||||
key,
|
||||
onClose: async () => null,
|
||||
});
|
||||
});
|
||||
} else if ('serviceWorker' in navigator && isHttps) {
|
||||
// unregister service worker
|
||||
const { serviceWorker } = navigator;
|
||||
if (serviceWorker.getRegistrations) {
|
||||
serviceWorker.getRegistrations().then((sws) => {
|
||||
sws.forEach((sw) => {
|
||||
sw.unregister();
|
||||
});
|
||||
});
|
||||
}
|
||||
serviceWorker.getRegistration().then((sw) => {
|
||||
if (sw) sw.unregister();
|
||||
});
|
||||
|
||||
clearCache();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import component from './zh-CN/component';
|
||||
import globalHeader from './zh-CN/globalHeader';
|
||||
import menu from './zh-CN/menu';
|
||||
import pages from './zh-CN/pages';
|
||||
import pwa from './zh-CN/pwa';
|
||||
import settingDrawer from './zh-CN/settingDrawer';
|
||||
import settings from './zh-CN/settings';
|
||||
|
||||
export default {
|
||||
'navBar.lang': '语言',
|
||||
'layout.user.link.help': '帮助',
|
||||
'layout.user.link.privacy': '隐私',
|
||||
'layout.user.link.terms': '条款',
|
||||
'app.copyright.produced': 'zlt版权所有:https://gitee.com/zlt2000/microservices-platform',
|
||||
'app.preview.down.block': '下载此页面到本地项目',
|
||||
'app.welcome.link.fetch-blocks': '获取全部区块',
|
||||
'app.welcome.link.block-list': '基于 block 开发,快速构建标准页面',
|
||||
...pages,
|
||||
...globalHeader,
|
||||
...menu,
|
||||
...settingDrawer,
|
||||
...settings,
|
||||
...pwa,
|
||||
...component,
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
export default {
|
||||
'component.tagSelect.expand': '展开',
|
||||
'component.tagSelect.collapse': '收起',
|
||||
'component.tagSelect.all': '全部',
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
export default {
|
||||
'component.globalHeader.search': '站内搜索',
|
||||
'component.globalHeader.search.example1': '搜索提示一',
|
||||
'component.globalHeader.search.example2': '搜索提示二',
|
||||
'component.globalHeader.search.example3': '搜索提示三',
|
||||
'component.globalHeader.help': '使用文档',
|
||||
'component.globalHeader.notification': '通知',
|
||||
'component.globalHeader.notification.empty': '你已查看所有通知',
|
||||
'component.globalHeader.message': '消息',
|
||||
'component.globalHeader.message.empty': '您已读完所有消息',
|
||||
'component.globalHeader.event': '待办',
|
||||
'component.globalHeader.event.empty': '你已完成所有待办',
|
||||
'component.noticeIcon.clear': '清空',
|
||||
'component.noticeIcon.cleared': '清空了',
|
||||
'component.noticeIcon.empty': '暂无数据',
|
||||
'component.noticeIcon.view-more': '查看更多',
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
export default {
|
||||
'menu.welcome': '欢迎',
|
||||
'menu.more-blocks': '更多区块',
|
||||
'menu.home': '首页',
|
||||
'menu.admin': '管理页',
|
||||
'menu.admin.sub-page': '二级管理页',
|
||||
'menu.login': '登录',
|
||||
'menu.register': '注册',
|
||||
'menu.register-result': '注册结果',
|
||||
'menu.dashboard': 'Dashboard',
|
||||
'menu.dashboard.analysis': '分析页',
|
||||
'menu.dashboard.monitor': '监控页',
|
||||
'menu.dashboard.workplace': '工作台',
|
||||
'menu.exception.403': '403',
|
||||
'menu.exception.404': '404',
|
||||
'menu.exception.500': '500',
|
||||
'menu.form': '表单页',
|
||||
'menu.form.basic-form': '基础表单',
|
||||
'menu.form.step-form': '分步表单',
|
||||
'menu.form.step-form.info': '分步表单(填写转账信息)',
|
||||
'menu.form.step-form.confirm': '分步表单(确认转账信息)',
|
||||
'menu.form.step-form.result': '分步表单(完成)',
|
||||
'menu.form.advanced-form': '高级表单',
|
||||
'menu.list': '列表页',
|
||||
'menu.list.table-list': '查询表格',
|
||||
'menu.list.basic-list': '标准列表',
|
||||
'menu.list.card-list': '卡片列表',
|
||||
'menu.list.search-list': '搜索列表',
|
||||
'menu.list.search-list.articles': '搜索列表(文章)',
|
||||
'menu.list.search-list.projects': '搜索列表(项目)',
|
||||
'menu.list.search-list.applications': '搜索列表(应用)',
|
||||
'menu.profile': '详情页',
|
||||
'menu.profile.basic': '基础详情页',
|
||||
'menu.profile.advanced': '高级详情页',
|
||||
'menu.result': '结果页',
|
||||
'menu.result.success': '成功页',
|
||||
'menu.result.fail': '失败页',
|
||||
'menu.exception': '异常页',
|
||||
'menu.exception.not-permission': '403',
|
||||
'menu.exception.not-find': '404',
|
||||
'menu.exception.server-error': '500',
|
||||
'menu.exception.trigger': '触发错误',
|
||||
'menu.account': '个人页',
|
||||
'menu.account.center': '个人中心',
|
||||
'menu.account.settings': '个人设置',
|
||||
'menu.account.trigger': '触发报错',
|
||||
'menu.account.logout': '退出登录',
|
||||
'menu.editor': '图形编辑器',
|
||||
'menu.editor.flow': '流程编辑器',
|
||||
'menu.editor.mind': '脑图编辑器',
|
||||
'menu.editor.koni': '拓扑编辑器',
|
||||
};
|
||||
@@ -0,0 +1,65 @@
|
||||
export default {
|
||||
'pages.layouts.userLayout.title': '前后端分离的企业级微服务架构',
|
||||
'pages.login.accountLogin.tab': '账户密码登录',
|
||||
'pages.login.accountLogin.errorMessage': '错误的账号和密码(admin/ant.design)',
|
||||
'pages.login.failure': '登录失败,请重试!',
|
||||
'pages.login.success': '登录成功!',
|
||||
'pages.login.username.placeholder': '账号',
|
||||
'pages.login.username.required': '账号是必填项!',
|
||||
'pages.login.password.placeholder': '密码',
|
||||
'pages.login.password.required': '密码是必填项!',
|
||||
'pages.login.phoneLogin.tab': '手机号登录',
|
||||
'pages.login.phoneLogin.errorMessage': '验证码错误',
|
||||
'pages.login.phoneNumber.placeholder': '请输入手机号!',
|
||||
'pages.login.phoneNumber.required': '手机号是必填项!',
|
||||
'pages.login.phoneNumber.invalid': '不合法的手机号!',
|
||||
'pages.login.captcha.placeholder': '请输入验证码!',
|
||||
'pages.login.captcha.required': '验证码是必填项!',
|
||||
'pages.login.phoneLogin.getVerificationCode': '获取验证码',
|
||||
'pages.getCaptchaSecondText': '秒后重新获取',
|
||||
'pages.login.rememberMe': '自动登录',
|
||||
'pages.login.forgotPassword': '忘记密码 ?',
|
||||
'pages.login.submit': '登录',
|
||||
'pages.login.loginWith': '其他登录方式 :',
|
||||
'pages.login.registerAccount': '注册账户',
|
||||
'pages.welcome.link': '欢迎使用',
|
||||
'pages.welcome.alertMessage': '更快更强的重型组件,已经发布。',
|
||||
'pages.admin.subPage.title': ' 这个页面只有 admin 权限才能查看',
|
||||
'pages.admin.subPage.alertMessage': 'umi ui 现已发布,欢迎使用 npm run ui 启动体验。',
|
||||
'pages.searchTable.createForm.newRule': '新建规则',
|
||||
'pages.searchTable.updateForm.ruleConfig': '规则配置',
|
||||
'pages.searchTable.updateForm.basicConfig': '基本信息',
|
||||
'pages.searchTable.updateForm.ruleName.nameLabel': '规则名称',
|
||||
'pages.searchTable.updateForm.ruleName.nameRules': '请输入规则名称!',
|
||||
'pages.searchTable.updateForm.ruleDesc.descLabel': '规则描述',
|
||||
'pages.searchTable.updateForm.ruleDesc.descPlaceholder': '请输入至少五个字符',
|
||||
'pages.searchTable.updateForm.ruleDesc.descRules': '请输入至少五个字符的规则描述!',
|
||||
'pages.searchTable.updateForm.ruleProps.title': '配置规则属性',
|
||||
'pages.searchTable.updateForm.object': '监控对象',
|
||||
'pages.searchTable.updateForm.ruleProps.templateLabel': '规则模板',
|
||||
'pages.searchTable.updateForm.ruleProps.typeLabel': '规则类型',
|
||||
'pages.searchTable.updateForm.schedulingPeriod.title': '设定调度周期',
|
||||
'pages.searchTable.updateForm.schedulingPeriod.timeLabel': '开始时间',
|
||||
'pages.searchTable.updateForm.schedulingPeriod.timeRules': '请选择开始时间!',
|
||||
'pages.searchTable.titleDesc': '描述',
|
||||
'pages.searchTable.ruleName': '规则名称为必填项',
|
||||
'pages.searchTable.titleCallNo': '服务调用次数',
|
||||
'pages.searchTable.titleStatus': '状态',
|
||||
'pages.searchTable.nameStatus.default': '关闭',
|
||||
'pages.searchTable.nameStatus.running': '运行中',
|
||||
'pages.searchTable.nameStatus.online': '已上线',
|
||||
'pages.searchTable.nameStatus.abnormal': '异常',
|
||||
'pages.searchTable.titleUpdatedAt': '上次调度时间',
|
||||
'pages.searchTable.exception': '请输入异常原因!',
|
||||
'pages.searchTable.titleOption': '操作',
|
||||
'pages.searchTable.config': '配置',
|
||||
'pages.searchTable.subscribeAlert': '订阅警报',
|
||||
'pages.searchTable.title': '查询表格',
|
||||
'pages.searchTable.new': '新建',
|
||||
'pages.searchTable.chosen': '已选择',
|
||||
'pages.searchTable.item': '项',
|
||||
'pages.searchTable.totalServiceCalls': '服务调用次数总计',
|
||||
'pages.searchTable.tenThousand': '万',
|
||||
'pages.searchTable.batchDeletion': '批量删除',
|
||||
'pages.searchTable.batchApproval': '批量审批',
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
export default {
|
||||
'app.pwa.offline': '当前处于离线状态',
|
||||
'app.pwa.serviceworker.updated': '有新内容',
|
||||
'app.pwa.serviceworker.updated.hint': '请点击“刷新”按钮或者手动刷新页面',
|
||||
'app.pwa.serviceworker.updated.ok': '刷新',
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
export default {
|
||||
'app.setting.pagestyle': '整体风格设置',
|
||||
'app.setting.pagestyle.dark': '暗色菜单风格',
|
||||
'app.setting.pagestyle.light': '亮色菜单风格',
|
||||
'app.setting.content-width': '内容区域宽度',
|
||||
'app.setting.content-width.fixed': '定宽',
|
||||
'app.setting.content-width.fluid': '流式',
|
||||
'app.setting.themecolor': '主题色',
|
||||
'app.setting.themecolor.dust': '薄暮',
|
||||
'app.setting.themecolor.volcano': '火山',
|
||||
'app.setting.themecolor.sunset': '日暮',
|
||||
'app.setting.themecolor.cyan': '明青',
|
||||
'app.setting.themecolor.green': '极光绿',
|
||||
'app.setting.themecolor.daybreak': '拂晓蓝(默认)',
|
||||
'app.setting.themecolor.geekblue': '极客蓝',
|
||||
'app.setting.themecolor.purple': '酱紫',
|
||||
'app.setting.navigationmode': '导航模式',
|
||||
'app.setting.sidemenu': '侧边菜单布局',
|
||||
'app.setting.topmenu': '顶部菜单布局',
|
||||
'app.setting.fixedheader': '固定 Header',
|
||||
'app.setting.fixedsidebar': '固定侧边菜单',
|
||||
'app.setting.fixedsidebar.hint': '侧边菜单布局时可配置',
|
||||
'app.setting.hideheader': '下滑时隐藏 Header',
|
||||
'app.setting.hideheader.hint': '固定 Header 时可配置',
|
||||
'app.setting.othersettings': '其他设置',
|
||||
'app.setting.weakmode': '色弱模式',
|
||||
'app.setting.copy': '拷贝设置',
|
||||
'app.setting.copyinfo': '拷贝成功,请到 config/defaultSettings.js 中替换默认配置',
|
||||
'app.setting.production.hint':
|
||||
'配置栏只在开发环境用于预览,生产环境不会展现,请拷贝后手动修改配置文件',
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
export default {
|
||||
'app.settings.menuMap.basic': '基本设置',
|
||||
'app.settings.menuMap.security': '安全设置',
|
||||
'app.settings.menuMap.binding': '账号绑定',
|
||||
'app.settings.menuMap.notification': '新消息通知',
|
||||
'app.settings.basic.avatar': '头像',
|
||||
'app.settings.basic.change-avatar': '更换头像',
|
||||
'app.settings.basic.email': '邮箱',
|
||||
'app.settings.basic.email-message': '请输入您的邮箱!',
|
||||
'app.settings.basic.nickname': '昵称',
|
||||
'app.settings.basic.nickname-message': '请输入您的昵称!',
|
||||
'app.settings.basic.profile': '个人简介',
|
||||
'app.settings.basic.profile-message': '请输入个人简介!',
|
||||
'app.settings.basic.profile-placeholder': '个人简介',
|
||||
'app.settings.basic.country': '国家/地区',
|
||||
'app.settings.basic.country-message': '请输入您的国家或地区!',
|
||||
'app.settings.basic.geographic': '所在省市',
|
||||
'app.settings.basic.geographic-message': '请输入您的所在省市!',
|
||||
'app.settings.basic.address': '街道地址',
|
||||
'app.settings.basic.address-message': '请输入您的街道地址!',
|
||||
'app.settings.basic.phone': '联系电话',
|
||||
'app.settings.basic.phone-message': '请输入您的联系电话!',
|
||||
'app.settings.basic.update': '更新基本信息',
|
||||
'app.settings.security.strong': '强',
|
||||
'app.settings.security.medium': '中',
|
||||
'app.settings.security.weak': '弱',
|
||||
'app.settings.security.password': '账户密码',
|
||||
'app.settings.security.password-description': '当前密码强度',
|
||||
'app.settings.security.phone': '密保手机',
|
||||
'app.settings.security.phone-description': '已绑定手机',
|
||||
'app.settings.security.question': '密保问题',
|
||||
'app.settings.security.question-description': '未设置密保问题,密保问题可有效保护账户安全',
|
||||
'app.settings.security.email': '备用邮箱',
|
||||
'app.settings.security.email-description': '已绑定邮箱',
|
||||
'app.settings.security.mfa': 'MFA 设备',
|
||||
'app.settings.security.mfa-description': '未绑定 MFA 设备,绑定后,可以进行二次确认',
|
||||
'app.settings.security.modify': '修改',
|
||||
'app.settings.security.set': '设置',
|
||||
'app.settings.security.bind': '绑定',
|
||||
'app.settings.binding.taobao': '绑定淘宝',
|
||||
'app.settings.binding.taobao-description': '当前未绑定淘宝账号',
|
||||
'app.settings.binding.alipay': '绑定支付宝',
|
||||
'app.settings.binding.alipay-description': '当前未绑定支付宝账号',
|
||||
'app.settings.binding.dingding': '绑定钉钉',
|
||||
'app.settings.binding.dingding-description': '当前未绑定钉钉账号',
|
||||
'app.settings.binding.bind': '绑定',
|
||||
'app.settings.notification.password': '账户密码',
|
||||
'app.settings.notification.password-description': '其他用户的消息将以站内信的形式通知',
|
||||
'app.settings.notification.messages': '系统消息',
|
||||
'app.settings.notification.messages-description': '系统消息将以站内信的形式通知',
|
||||
'app.settings.notification.todo': '待办任务',
|
||||
'app.settings.notification.todo-description': '待办任务将以站内信的形式通知',
|
||||
'app.settings.open': '开',
|
||||
'app.settings.close': '关',
|
||||
};
|
||||
@@ -1,2 +1,13 @@
|
||||
package com.central.ui;public class UiBootApplication {
|
||||
package com.central.ui;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class UiBootApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(UiBootApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "Ant Design Pro",
|
||||
"short_name": "Ant Design Pro",
|
||||
"display": "standalone",
|
||||
"start_url": "./?utm_source=homescreen",
|
||||
"theme_color": "#002140",
|
||||
"background_color": "#001529",
|
||||
"icons": [
|
||||
{
|
||||
"src": "icons/icon-192x192.png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-128x128.png",
|
||||
"sizes": "128x128"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-512x512.png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Button, Result } from 'antd';
|
||||
import React from 'react';
|
||||
import { history } from 'umi';
|
||||
|
||||
const NoFoundPage: React.FC = () => (
|
||||
<Result
|
||||
status="404"
|
||||
title="404"
|
||||
subTitle="Sorry, the page you visited does not exist."
|
||||
extra={
|
||||
<Button type="primary" onClick={() => history.push('/')}>
|
||||
Back Home
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
);
|
||||
|
||||
export default NoFoundPage;
|
||||
@@ -0,0 +1,45 @@
|
||||
import { HeartTwoTone, SmileTwoTone } from '@ant-design/icons';
|
||||
import { PageHeaderWrapper } from '@ant-design/pro-components';
|
||||
import { Alert, Card, Typography } from 'antd';
|
||||
import React from 'react';
|
||||
import { useIntl } from 'umi';
|
||||
|
||||
const Admin: React.FC = () => {
|
||||
const intl = useIntl();
|
||||
return (
|
||||
<PageHeaderWrapper
|
||||
content={intl.formatMessage({
|
||||
id: 'pages.admin.subPage.title',
|
||||
defaultMessage: 'This page can only be viewed by admin',
|
||||
})}
|
||||
>
|
||||
<Card>
|
||||
<Alert
|
||||
message={intl.formatMessage({
|
||||
id: 'pages.welcome.alertMessage',
|
||||
defaultMessage: 'Faster and stronger heavy-duty components have been released.',
|
||||
})}
|
||||
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>
|
||||
);
|
||||
};
|
||||
|
||||
export default Admin;
|
||||
@@ -0,0 +1,14 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
|
||||
.stat {
|
||||
margin-top: @margin-md;
|
||||
padding: @padding-md;
|
||||
background-color: @white;
|
||||
}
|
||||
|
||||
.pre {
|
||||
margin: 12px 0;
|
||||
padding: 12px 20px;
|
||||
background: @input-bg;
|
||||
box-shadow: @card-shadow;
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
import { PageContainer, StatisticCard } from '@ant-design/pro-components';
|
||||
import { Alert, Card, Typography, Tag, Space, Tabs } from 'antd';
|
||||
import RcResizeObserver from 'rc-resize-observer';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { FormattedMessage, useIntl } from 'umi';
|
||||
import { statistic } from '@/services/welcome/api';
|
||||
import { Area, Pie } from '@ant-design/plots';
|
||||
import styles from './Welcome.less';
|
||||
|
||||
const CodePreview: React.FC = ({ children }) => (
|
||||
<pre className={styles.pre}>
|
||||
<code>
|
||||
<Typography.Text copyable>{children}</Typography.Text>
|
||||
</code>
|
||||
</pre>
|
||||
);
|
||||
|
||||
const { Divider } = StatisticCard;
|
||||
|
||||
const Welcome: React.FC = () => {
|
||||
const [responsive, setResponsive] = useState<boolean>(false);
|
||||
const [statistics, setStatistics] = useState<WELCOME.Statistic>({});
|
||||
const [weeks, setWeeks] = useState<WELCOME.AreaData[]>([]);
|
||||
const [days, setDays] = useState<WELCOME.AreaData[]>([]);
|
||||
const intl = useIntl();
|
||||
|
||||
const mapWeek = (result: WELCOME.Statistic) => {
|
||||
const { statWeek_items, statWeek_pv, statWeek_uv } = result;
|
||||
if (statWeek_items && statWeek_pv && statWeek_uv) {
|
||||
const weekData = statWeek_pv
|
||||
.map((pv, index) => {
|
||||
return { type: '访问量(PV)', date: statWeek_items[index], value: pv };
|
||||
})
|
||||
.concat(
|
||||
statWeek_uv.map((uv, index) => {
|
||||
return { type: '独立用户(UV)', date: statWeek_items[index], value: uv };
|
||||
}),
|
||||
);
|
||||
setWeeks(weekData);
|
||||
}
|
||||
};
|
||||
|
||||
const mapDay = (result: WELCOME.Statistic) => {
|
||||
const { statDate_items, statDate_pv, statDate_uv } = result;
|
||||
if (statDate_items && statDate_pv && statDate_uv) {
|
||||
const dayData = statDate_pv
|
||||
.map((pv, index) => {
|
||||
return { type: '访问量(PV)', date: statDate_items[index], value: pv };
|
||||
})
|
||||
.concat(
|
||||
statDate_uv.map((uv, index) => {
|
||||
return { type: '独立用户(UV)', date: statDate_items[index], value: uv };
|
||||
}),
|
||||
);
|
||||
setDays(dayData);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const result = await statistic();
|
||||
if (result) {
|
||||
setStatistics(result);
|
||||
mapWeek(result);
|
||||
mapDay(result);
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<PageContainer
|
||||
subTitle="前后端分离的企业级微服务架构"
|
||||
tags={
|
||||
<>
|
||||
<Tag color="blue">简单</Tag>
|
||||
<Tag color="blue">高效</Tag>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<RcResizeObserver
|
||||
key="resize-observer"
|
||||
onResize={(offset) => {
|
||||
setResponsive(offset.width < 596);
|
||||
}}
|
||||
>
|
||||
<StatisticCard.Group direction={responsive ? 'column' : 'row'}>
|
||||
<StatisticCard
|
||||
statistic={{
|
||||
title: (
|
||||
<Space size="small">
|
||||
在线人数<Tag color="#434343">时</Tag>
|
||||
</Space>
|
||||
),
|
||||
value: statistics.currHour_uv,
|
||||
}}
|
||||
/>
|
||||
<Divider type={responsive ? 'horizontal' : 'vertical'} />
|
||||
<StatisticCard
|
||||
statistic={{
|
||||
title: (
|
||||
<Space size="small">
|
||||
PV<Tag color="#52c41a">天</Tag>
|
||||
</Space>
|
||||
),
|
||||
value: statistics.currDate_pv,
|
||||
}}
|
||||
/>
|
||||
<Divider type={responsive ? 'horizontal' : 'vertical'} />
|
||||
<StatisticCard
|
||||
statistic={{
|
||||
title: (
|
||||
<Space size="small">
|
||||
UV<Tag color="#52c41a">天</Tag>
|
||||
</Space>
|
||||
),
|
||||
value: statistics.currDate_uv,
|
||||
}}
|
||||
/>
|
||||
<Divider type={responsive ? 'horizontal' : 'vertical'} />
|
||||
<StatisticCard
|
||||
statistic={{
|
||||
title: (
|
||||
<Space size="small">
|
||||
周访问量<Tag color="#1890ff">周</Tag>
|
||||
</Space>
|
||||
),
|
||||
value: statistics.currWeek_pv,
|
||||
}}
|
||||
/>
|
||||
<Divider type={responsive ? 'horizontal' : 'vertical'} />
|
||||
<StatisticCard
|
||||
statistic={{
|
||||
title: (
|
||||
<Space size="small">
|
||||
月访问量<Tag color="#faad14">月</Tag>
|
||||
</Space>
|
||||
),
|
||||
value: statistics.currMonth_pv,
|
||||
}}
|
||||
/>
|
||||
</StatisticCard.Group>
|
||||
</RcResizeObserver>
|
||||
<Tabs defaultActiveKey="1" className={styles.stat}>
|
||||
<Tabs.TabPane tab="周流量趋势" key="1">
|
||||
<Area
|
||||
data={weeks}
|
||||
xField="date"
|
||||
yField="value"
|
||||
seriesField="type"
|
||||
smooth
|
||||
height={200}
|
||||
legend={{
|
||||
layout: 'horizontal',
|
||||
position: 'top',
|
||||
}}
|
||||
/>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane tab="天流量趋势" key="2">
|
||||
<Area
|
||||
data={days}
|
||||
xField="date"
|
||||
yField="value"
|
||||
seriesField="type"
|
||||
smooth
|
||||
height={200}
|
||||
legend={{
|
||||
layout: 'horizontal',
|
||||
position: 'top',
|
||||
}}
|
||||
/>
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
<Pie
|
||||
height={200}
|
||||
data={statistics.browser_datas ?? []}
|
||||
angleField="value"
|
||||
colorField="name"
|
||||
appendPadding={10}
|
||||
radius={0.75}
|
||||
label={{
|
||||
type: 'spider',
|
||||
labelHeight: 28,
|
||||
content: '{name}\n{percentage}',
|
||||
}}
|
||||
interactions={[
|
||||
{
|
||||
type: 'element-selected',
|
||||
},
|
||||
{
|
||||
type: 'element-active',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Card>
|
||||
<Alert
|
||||
message={intl.formatMessage({
|
||||
id: 'pages.welcome.alertMessage',
|
||||
defaultMessage: 'Faster and stronger heavy-duty components have been released.',
|
||||
})}
|
||||
type="success"
|
||||
showIcon
|
||||
banner
|
||||
style={{
|
||||
margin: -12,
|
||||
marginBottom: 24,
|
||||
}}
|
||||
/>
|
||||
<Typography.Text strong>
|
||||
<a
|
||||
href="https://procomponents.ant.design/components/table"
|
||||
rel="noopener noreferrer"
|
||||
target="__blank"
|
||||
>
|
||||
<FormattedMessage id="pages.welcome.link" defaultMessage="Welcome" />
|
||||
</a>
|
||||
</Typography.Text>
|
||||
<CodePreview>前后端分离的企业级微服务架构</CodePreview>
|
||||
</Card>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default Welcome;
|
||||
@@ -0,0 +1,226 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="theme-color" content="#1890ff" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="keywords"
|
||||
content="antd,umi,umijs,ant design,Scaffolding, layout, Ant Design, project, Pro, admin, console, homepage, out-of-the-box, middle and back office, solution, component library" />
|
||||
<meta name="description" content="
|
||||
An out-of-box UI solution for enterprise applications as a React boilerplate." />
|
||||
<meta name="description" content="
|
||||
Out-of-the-box mid-stage front-end/design solution." />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
||||
<title>Microservices-Platform</title>
|
||||
<link rel="icon" href="<%= context.config.publicPath +'favicon.ico'%>" type="image/x-icon" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<noscript>
|
||||
<div class="noscript-container">
|
||||
Hi there! Please
|
||||
<div class="noscript-enableJS">
|
||||
<a href="https://www.enablejavascript.io/en" target="_blank" rel="noopener noreferrer">
|
||||
<b>enable Javascript</b>
|
||||
</a>
|
||||
</div>
|
||||
in your browser to use Ant Design, Out-of-the-box mid-stage front/design solution!
|
||||
</div>
|
||||
</noscript>
|
||||
<div id="root">
|
||||
<style>
|
||||
html,
|
||||
body,
|
||||
#root {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#root {
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100% auto;
|
||||
}
|
||||
|
||||
.noscript-container {
|
||||
display: flex;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
margin-top: 90px;
|
||||
font-size: 20px;
|
||||
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode',
|
||||
Geneva, Verdana, sans-serif;
|
||||
}
|
||||
|
||||
.noscript-enableJS {
|
||||
padding-right: 3px;
|
||||
padding-left: 3px;
|
||||
}
|
||||
|
||||
.page-loading-warp {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 98px;
|
||||
}
|
||||
|
||||
.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;
|
||||
text-align: center;
|
||||
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 {
|
||||
position: static;
|
||||
display: inline-block;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.ant-spin-dot {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.ant-spin-dot-item {
|
||||
position: absolute;
|
||||
display: block;
|
||||
width: 9px;
|
||||
height: 9px;
|
||||
background-color: #1890ff;
|
||||
border-radius: 100%;
|
||||
-webkit-transform: scale(0.75);
|
||||
-ms-transform: scale(0.75);
|
||||
transform: scale(0.75);
|
||||
-webkit-transform-origin: 50% 50%;
|
||||
-ms-transform-origin: 50% 50%;
|
||||
transform-origin: 50% 50%;
|
||||
opacity: 0.3;
|
||||
-webkit-animation: antspinmove 1s infinite linear alternate;
|
||||
animation: antSpinMove 1s infinite linear alternate;
|
||||
}
|
||||
|
||||
.ant-spin-dot-item:nth-child(1) {
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.ant-spin-dot-item:nth-child(2) {
|
||||
top: 0;
|
||||
right: 0;
|
||||
-webkit-animation-delay: 0.4s;
|
||||
animation-delay: 0.4s;
|
||||
}
|
||||
|
||||
.ant-spin-dot-item:nth-child(3) {
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
-webkit-animation-delay: 0.8s;
|
||||
animation-delay: 0.8s;
|
||||
}
|
||||
|
||||
.ant-spin-dot-item:nth-child(4) {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
-webkit-animation-delay: 1.2s;
|
||||
animation-delay: 1.2s;
|
||||
}
|
||||
|
||||
.ant-spin-dot-spin {
|
||||
-webkit-transform: rotate(45deg);
|
||||
-ms-transform: rotate(45deg);
|
||||
transform: rotate(45deg);
|
||||
-webkit-animation: antrotate 1.2s infinite linear;
|
||||
animation: antRotate 1.2s infinite linear;
|
||||
}
|
||||
|
||||
.ant-spin-lg .ant-spin-dot {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.ant-spin-lg .ant-spin-dot i {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
@media all and (-ms-high-contrast: none),
|
||||
(-ms-high-contrast: active) {
|
||||
.ant-spin-blur {
|
||||
background: #fff;
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes antSpinMove {
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes antSpinMove {
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes antRotate {
|
||||
to {
|
||||
-webkit-transform: rotate(405deg);
|
||||
transform: rotate(405deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes antRotate {
|
||||
to {
|
||||
-webkit-transform: rotate(405deg);
|
||||
transform: rotate(405deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<div style="
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
min-height: 420px;
|
||||
">
|
||||
<img src="<%= context.config.publicPath +'campaign.svg'%>" alt="logo" width="256" />
|
||||
<div class="page-loading-warp">
|
||||
<div class="ant-spin ant-spin-lg ant-spin-spinning">
|
||||
<span class="ant-spin-dot ant-spin-dot-spin"><i class="ant-spin-dot-item"></i><i
|
||||
class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; justify-content: center">
|
||||
<img src="/logo.png" width="32" style="margin-right: 8px" />
|
||||
microservices-platform
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
@@ -0,0 +1,130 @@
|
||||
import { auditlog } from '@/services/search/api';
|
||||
import type { ProColumns } from '@ant-design/pro-components';
|
||||
import {
|
||||
PageContainer,
|
||||
ProFormText,
|
||||
ProTable,
|
||||
QueryFilter,
|
||||
ProFormSelect,
|
||||
} from '@ant-design/pro-components';
|
||||
import React, { useState } from 'react';
|
||||
import moment from 'moment';
|
||||
import { Typography } from 'antd';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const AuditLog: React.FC = () => {
|
||||
const [params, setParams] = useState<Record<string, string | number>>();
|
||||
|
||||
const highlight = (str: string | undefined) => {
|
||||
const pattern = /<.*?>/;
|
||||
return <Text mark>{str}</Text>;
|
||||
};
|
||||
|
||||
const columns: ProColumns<SEARCH.AuditLog>[] = [
|
||||
{
|
||||
dataIndex: 'index',
|
||||
valueType: 'indexBorder',
|
||||
width: 20,
|
||||
},
|
||||
{
|
||||
title: '日志时间',
|
||||
key: 'timestamp',
|
||||
width: 75,
|
||||
render(_, entity) {
|
||||
return moment(entity.timestamp).format('YYYY-MM-DD HH:mm:SS');
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '用户id',
|
||||
dataIndex: 'userId',
|
||||
width: 30,
|
||||
},
|
||||
{
|
||||
title: '用户名',
|
||||
dataIndex: 'userName',
|
||||
width: 40,
|
||||
},
|
||||
{
|
||||
title: '租户id',
|
||||
dataIndex: 'clientId',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
title: '操作信息',
|
||||
dataIndex: 'operation',
|
||||
width: 150,
|
||||
ellipsis: true,
|
||||
render: (_, entity) =>
|
||||
entity.operation && <span dangerouslySetInnerHTML={{ __html: entity.operation }} />,
|
||||
},
|
||||
{
|
||||
title: '应用名',
|
||||
dataIndex: 'appName',
|
||||
width: 50,
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '类名',
|
||||
dataIndex: 'className',
|
||||
width: 150,
|
||||
ellipsis: true,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<PageContainer header={{ subTitle: '查看系统日志' }}>
|
||||
<QueryFilter
|
||||
defaultCollapsed
|
||||
split
|
||||
span={8}
|
||||
className="query-filter"
|
||||
onFinish={async (values) => {
|
||||
let queryStr = '';
|
||||
const { searchKey, searchValue } = values;
|
||||
if (searchKey && searchValue) {
|
||||
if (searchKey === 'none') {
|
||||
queryStr = searchValue;
|
||||
} else {
|
||||
queryStr = `${searchKey}:${searchValue}`;
|
||||
}
|
||||
}
|
||||
setParams({ ...params, queryStr });
|
||||
}}
|
||||
// onReset={() => setParams({})}
|
||||
>
|
||||
<ProFormSelect
|
||||
name="searchKey"
|
||||
label="搜索"
|
||||
valueEnum={{
|
||||
none: '全文搜索',
|
||||
appName: '应用名',
|
||||
classname: '类别',
|
||||
methodName: '方法名',
|
||||
userId: '用户ID',
|
||||
userName: '用户名',
|
||||
clientId: '租户ID',
|
||||
operation: '操作信息',
|
||||
}}
|
||||
/>
|
||||
<ProFormText name="searchValue" />
|
||||
</QueryFilter>
|
||||
<ProTable<SEARCH.AuditLog>
|
||||
className="audit-log"
|
||||
rowKey="id"
|
||||
headerTitle="系统日志"
|
||||
request={auditlog}
|
||||
columns={columns}
|
||||
search={false}
|
||||
params={params}
|
||||
size="small"
|
||||
pagination={{
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
}}
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default AuditLog;
|
||||
@@ -0,0 +1 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
@@ -0,0 +1,112 @@
|
||||
import { auditlog, slowQueryLog } from '@/services/search/api';
|
||||
import type { ProColumns } from '@ant-design/pro-components';
|
||||
import {
|
||||
PageContainer,
|
||||
ProFormText,
|
||||
ProTable,
|
||||
QueryFilter,
|
||||
ProFormSelect,
|
||||
} from '@ant-design/pro-components';
|
||||
import React, { useState } from 'react';
|
||||
import { Typography } from 'antd';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const SlowSqlLog: React.FC = () => {
|
||||
const [params, setParams] = useState<Record<string, string | number>>();
|
||||
|
||||
const columns: ProColumns<SEARCH.AuditLog>[] = [
|
||||
{
|
||||
dataIndex: 'index',
|
||||
valueType: 'indexBorder',
|
||||
width: 20,
|
||||
},
|
||||
{
|
||||
title: '日志时间',
|
||||
key: 'timestamp',
|
||||
width: 75,
|
||||
},
|
||||
{
|
||||
title: '查询语句',
|
||||
dataIndex: 'userId',
|
||||
width: 30,
|
||||
},
|
||||
{
|
||||
title: '查询时间(ms)',
|
||||
dataIndex: 'userName',
|
||||
width: 40,
|
||||
},
|
||||
{
|
||||
title: '锁等待时间(ms)',
|
||||
dataIndex: 'clientId',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
title: '返回行数',
|
||||
dataIndex: 'operation',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '优化器扫描行数',
|
||||
dataIndex: 'appName',
|
||||
width: 50,
|
||||
ellipsis: true,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<PageContainer header={{ subTitle: '查看慢查询日志' }}>
|
||||
<QueryFilter
|
||||
defaultCollapsed
|
||||
split
|
||||
span={8}
|
||||
className="query-filter"
|
||||
onFinish={async (values) => {
|
||||
let queryStr = '';
|
||||
const { searchKey, searchValue } = values;
|
||||
if (searchKey && searchValue) {
|
||||
if (searchKey === 'none') {
|
||||
queryStr = searchValue;
|
||||
} else {
|
||||
queryStr = `${searchKey}:${searchValue}`;
|
||||
}
|
||||
}
|
||||
setParams({ ...params, queryStr });
|
||||
}}
|
||||
// onReset={() => setParams({})}
|
||||
>
|
||||
<ProFormSelect
|
||||
name="searchKey"
|
||||
label="搜索"
|
||||
valueEnum={{
|
||||
none: '全文搜索',
|
||||
appName: '应用名',
|
||||
classname: '类别',
|
||||
methodName: '方法名',
|
||||
userId: '用户ID',
|
||||
userName: '用户名',
|
||||
clientId: '租户ID',
|
||||
operation: '操作信息',
|
||||
}}
|
||||
/>
|
||||
<ProFormText name="searchValue" />
|
||||
</QueryFilter>
|
||||
<ProTable<SEARCH.AuditLog>
|
||||
className="audit-log"
|
||||
rowKey="id"
|
||||
headerTitle="慢查询日志"
|
||||
request={slowQueryLog}
|
||||
columns={columns}
|
||||
search={false}
|
||||
params={params}
|
||||
size="small"
|
||||
pagination={{
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
}}
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default SlowSqlLog;
|
||||
@@ -0,0 +1,76 @@
|
||||
import { Button, Modal, Table } from 'antd';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { tracelog } from '@/services/search/api';
|
||||
import styles from '../index.less';
|
||||
import type { TableColumnType } from 'antd';
|
||||
import { treeify } from 'treeify-js';
|
||||
import { NodeIndexOutlined } from '@ant-design/icons';
|
||||
|
||||
type IndexViewProps = {
|
||||
traceId?: string;
|
||||
onCancel: () => void;
|
||||
open: boolean;
|
||||
};
|
||||
|
||||
const TraceView: React.FC<IndexViewProps> = (props) => {
|
||||
const [traces, setTraces] = useState<SEARCH.TraceLog[]>();
|
||||
const { traceId } = props;
|
||||
|
||||
const columns: TableColumnType<SEARCH.TraceLog>[] = [
|
||||
{
|
||||
title: '应用名',
|
||||
dataIndex: 'appName',
|
||||
},
|
||||
{
|
||||
title: 'spanId',
|
||||
dataIndex: 'spanId',
|
||||
},
|
||||
{
|
||||
title: '服务ip',
|
||||
dataIndex: 'serverIp',
|
||||
},
|
||||
{
|
||||
title: '服务端口',
|
||||
dataIndex: 'serverPort',
|
||||
},
|
||||
];
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (traceId) {
|
||||
const data = (await tracelog(traceId)) ?? [];
|
||||
const treeData = treeify(data, { id: 'spanId', root: '-1', multi: true });
|
||||
setTraces(treeData);
|
||||
}
|
||||
})();
|
||||
}, [traceId]);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={
|
||||
<>
|
||||
<NodeIndexOutlined />
|
||||
日志链路
|
||||
</>
|
||||
}
|
||||
className={styles.viewModal}
|
||||
width={800}
|
||||
open={props.open}
|
||||
onCancel={props.onCancel}
|
||||
footer={
|
||||
<Button type="primary" onClick={props.onCancel}>
|
||||
关闭
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<Table<SEARCH.TraceLog>
|
||||
columns={columns}
|
||||
dataSource={traces}
|
||||
pagination={false}
|
||||
size="small"
|
||||
/>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default TraceView;
|
||||
@@ -0,0 +1,12 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
|
||||
.view {
|
||||
height: 400px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.viewModal {
|
||||
.ant-modal-body {
|
||||
padding: @padding-md;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
import { syslog } from '@/services/search/api';
|
||||
import type { ProColumns } from '@ant-design/pro-components';
|
||||
import {
|
||||
PageContainer,
|
||||
ProFormText,
|
||||
ProTable,
|
||||
QueryFilter,
|
||||
ProFormSelect,
|
||||
} from '@ant-design/pro-components';
|
||||
import React, { useState } from 'react';
|
||||
import moment from 'moment';
|
||||
import TraceView from './components/TraceView';
|
||||
import { Typography } from 'antd';
|
||||
|
||||
type TraceViewProps = {
|
||||
traceId?: string;
|
||||
open: boolean;
|
||||
};
|
||||
|
||||
const { Link } = Typography;
|
||||
|
||||
const TableList: React.FC = () => {
|
||||
const [params, setParams] = useState<Record<string, string | number>>({
|
||||
sortCol: 'timestamp',
|
||||
isHighlighter: 'true',
|
||||
});
|
||||
const [traceView, setTraceView] = useState<TraceViewProps>({ open: false });
|
||||
|
||||
const columns: ProColumns<SEARCH.SysLog>[] = [
|
||||
{
|
||||
dataIndex: 'index',
|
||||
valueType: 'indexBorder',
|
||||
width: 20,
|
||||
},
|
||||
{
|
||||
title: '时间',
|
||||
key: 'timestamp',
|
||||
width: 75,
|
||||
render(_, entity) {
|
||||
return moment(entity.timestamp).format('YYYY-MM-DD HH:mm:SS');
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '日志信息',
|
||||
dataIndex: 'message',
|
||||
ellipsis: true,
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
title: '日志级别',
|
||||
dataIndex: 'logLevel',
|
||||
width: 40,
|
||||
},
|
||||
{
|
||||
title: '应用名',
|
||||
dataIndex: 'appName',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
title: '追踪id',
|
||||
key: 'traceId',
|
||||
width: 80,
|
||||
render(_, entity) {
|
||||
return (
|
||||
<Link
|
||||
onClick={() => {
|
||||
setTraceView({ traceId: entity.traceId, open: true });
|
||||
}}
|
||||
>
|
||||
{entity.traceId}
|
||||
</Link>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'spanId',
|
||||
dataIndex: 'spanId',
|
||||
width: 40,
|
||||
},
|
||||
{
|
||||
title: '类名',
|
||||
dataIndex: 'classname',
|
||||
width: 110,
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '线程名',
|
||||
dataIndex: 'threadName',
|
||||
width: 50,
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '服务ip',
|
||||
dataIndex: 'serverIp',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
title: '服务端口',
|
||||
dataIndex: 'serverPort',
|
||||
width: 35,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<PageContainer header={{ subTitle: '查看系统日志' }}>
|
||||
<QueryFilter
|
||||
defaultCollapsed
|
||||
split
|
||||
span={8}
|
||||
className="query-filter"
|
||||
onFinish={async (values) => {
|
||||
let queryStr = '';
|
||||
const { searchKey, searchValue } = values;
|
||||
if (searchKey && searchValue) {
|
||||
if (searchKey === 'none') {
|
||||
queryStr = searchValue;
|
||||
} else {
|
||||
queryStr = `${searchKey}:${searchValue}`;
|
||||
}
|
||||
}
|
||||
setParams({ ...params, queryStr });
|
||||
}}
|
||||
// onReset={() => setParams({})}
|
||||
>
|
||||
<ProFormSelect
|
||||
name="searchKey"
|
||||
label="搜索"
|
||||
valueEnum={{
|
||||
none: '全文搜索',
|
||||
message: '日志信息',
|
||||
logLevel: '日志级别',
|
||||
appName: '应用名',
|
||||
classname: '类别',
|
||||
traceId: '链路追踪ID',
|
||||
}}
|
||||
/>
|
||||
<ProFormText name="searchValue" />
|
||||
</QueryFilter>
|
||||
<ProTable<SEARCH.SysLog>
|
||||
rowKey="id"
|
||||
headerTitle="系统日志"
|
||||
request={syslog}
|
||||
columns={columns}
|
||||
search={false}
|
||||
params={params}
|
||||
size="small"
|
||||
pagination={{
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
}}
|
||||
scroll={{ x: 1600 }}
|
||||
/>
|
||||
<TraceView {...traceView} onCancel={() => setTraceView({ open: false })} />
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableList;
|
||||
@@ -0,0 +1,57 @@
|
||||
import { Button, Modal } from 'antd';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { JSONTree } from 'react-json-tree';
|
||||
import { index } from '@/services/search/api';
|
||||
import styles from '../index.less';
|
||||
import { NodeIndexOutlined } from '@ant-design/icons';
|
||||
|
||||
type IndexViewProps = {
|
||||
indexName?: string;
|
||||
onCancel: () => void;
|
||||
open: boolean;
|
||||
};
|
||||
|
||||
const IndexView: React.FC<IndexViewProps> = (props) => {
|
||||
const [json, setJson] = useState<any>({});
|
||||
const { indexName } = props;
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (indexName) {
|
||||
const data = await index(indexName);
|
||||
console.log(data);
|
||||
setJson(data);
|
||||
}
|
||||
})();
|
||||
}, [indexName]);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={
|
||||
<>
|
||||
<NodeIndexOutlined />
|
||||
查看索引
|
||||
</>
|
||||
}
|
||||
className={styles.viewModal}
|
||||
width={800}
|
||||
open={props.open}
|
||||
onCancel={props.onCancel}
|
||||
footer={
|
||||
<Button type="primary" onClick={props.onCancel}>
|
||||
关闭
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<div className={styles.view}>
|
||||
<JSONTree
|
||||
data={json}
|
||||
hideRoot
|
||||
shouldExpandNode={(a, b, level) => level < 3}
|
||||
invertTheme={false}
|
||||
/>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default IndexView;
|
||||
@@ -0,0 +1,12 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
|
||||
.view {
|
||||
height: 400px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.viewModal {
|
||||
.ant-modal-body {
|
||||
padding: @padding-md;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
import { indice } from '@/services/search/api';
|
||||
import { PlusOutlined } from '@ant-design/icons';
|
||||
import type { ProColumns } from '@ant-design/pro-components';
|
||||
import {
|
||||
ModalForm,
|
||||
ProForm,
|
||||
ProFormTextArea,
|
||||
PageContainer,
|
||||
ProFormText,
|
||||
ProTable,
|
||||
QueryFilter,
|
||||
} from '@ant-design/pro-components';
|
||||
import { Typography, message, Space, Button } from 'antd';
|
||||
import React, { useState } from 'react';
|
||||
import IndexView from './components/IndexView';
|
||||
|
||||
const { Link } = Typography;
|
||||
|
||||
type IndexViewProps = {
|
||||
indexName?: string;
|
||||
open: boolean;
|
||||
};
|
||||
|
||||
const TableList: React.FC = () => {
|
||||
const [params, setParams] = useState<Record<string, string | number>>();
|
||||
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
|
||||
const [indexView, setIndexView] = useState<IndexViewProps>({ open: false });
|
||||
|
||||
const columns: ProColumns<SEARCH.Indice>[] = [
|
||||
{
|
||||
dataIndex: 'index',
|
||||
valueType: 'indexBorder',
|
||||
},
|
||||
{
|
||||
title: '索引健康',
|
||||
dataIndex: 'health',
|
||||
},
|
||||
{
|
||||
title: '索引状态',
|
||||
dataIndex: 'status',
|
||||
},
|
||||
{
|
||||
title: '索引名',
|
||||
dataIndex: 'index',
|
||||
},
|
||||
{
|
||||
title: '文档数',
|
||||
dataIndex: 'docsCount',
|
||||
},
|
||||
{
|
||||
title: '文档删除数',
|
||||
dataIndex: 'docsDeleted',
|
||||
},
|
||||
{
|
||||
title: '索引大小',
|
||||
dataIndex: 'storeSize',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
render: (_, record) => (
|
||||
<Space>
|
||||
<Link
|
||||
onClick={() => {
|
||||
setIndexView({ indexName: record.index, open: true });
|
||||
}}
|
||||
>
|
||||
查看
|
||||
</Link>
|
||||
<Link onClick={() => message.info('演示环境不支持该功能')}>删除</Link>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<PageContainer header={{ subTitle: '索引管理' }}>
|
||||
<QueryFilter
|
||||
defaultCollapsed
|
||||
split
|
||||
span={12}
|
||||
className="query-filter"
|
||||
onFinish={async (values) => setParams(values)}
|
||||
// onReset={() => setParams({})}
|
||||
>
|
||||
<ProFormText
|
||||
name="queryStr"
|
||||
label="索引名"
|
||||
placeholder="输入关键字,模糊搜索需要加通配符*"
|
||||
/>
|
||||
</QueryFilter>
|
||||
<ProTable<SEARCH.Indice>
|
||||
rowKey="index"
|
||||
headerTitle="索引管理"
|
||||
request={indice}
|
||||
columns={columns}
|
||||
search={false}
|
||||
params={params}
|
||||
pagination={false}
|
||||
toolBarRender={() => [
|
||||
<>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
handleModalVisible(true);
|
||||
}}
|
||||
>
|
||||
<PlusOutlined /> 添加
|
||||
</Button>
|
||||
</>,
|
||||
]}
|
||||
/>
|
||||
<ModalForm
|
||||
title="新增索引"
|
||||
// layout="horizontal"
|
||||
width={800}
|
||||
visible={createModalVisible}
|
||||
onVisibleChange={handleModalVisible}
|
||||
onFinish={async () => {
|
||||
message.info('演示环境不支持该功能');
|
||||
}}
|
||||
>
|
||||
<ProForm.Group>
|
||||
<ProFormText
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '索引名不为空',
|
||||
},
|
||||
]}
|
||||
width="md"
|
||||
name="index"
|
||||
label="索引名"
|
||||
placeholder="输入索引名"
|
||||
/>
|
||||
<ProFormText
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '分片数不为空',
|
||||
},
|
||||
]}
|
||||
width="md"
|
||||
name="numberOfShards"
|
||||
label="分片数"
|
||||
placeholder="输入分片数"
|
||||
/>
|
||||
<ProFormText
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '副本数不为空',
|
||||
},
|
||||
]}
|
||||
width="md"
|
||||
name="numberOfReplicas"
|
||||
label="副本数"
|
||||
placeholder="输入副本数"
|
||||
/>
|
||||
<ProFormText
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '类型不为空',
|
||||
},
|
||||
]}
|
||||
width="md"
|
||||
name="type"
|
||||
label="类型"
|
||||
placeholder="输入类型"
|
||||
/>
|
||||
<ProFormTextArea
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: 'mappings不为空',
|
||||
},
|
||||
]}
|
||||
width="xl"
|
||||
name="mappingsSource"
|
||||
label="mappings"
|
||||
placeholder="输入mappings的JSON内容"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
<IndexView {...indexView} onCancel={() => setIndexView({ open: false })} />
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableList;
|
||||
@@ -0,0 +1 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
@@ -0,0 +1,88 @@
|
||||
import { user } from '@/services/system/api';
|
||||
import type { ProColumns } from '@ant-design/pro-components';
|
||||
import {
|
||||
ProFormSelect,
|
||||
PageContainer,
|
||||
ProFormText,
|
||||
ProTable,
|
||||
QueryFilter,
|
||||
} from '@ant-design/pro-components';
|
||||
import React, { useState } from 'react';
|
||||
|
||||
const TableList: React.FC = () => {
|
||||
const [params, setParams] = useState<Record<string, string | number>>({});
|
||||
|
||||
const columns: ProColumns<SYSTEM.User>[] = [
|
||||
{
|
||||
dataIndex: 'index',
|
||||
valueType: 'indexBorder',
|
||||
},
|
||||
{
|
||||
title: '用户编号',
|
||||
dataIndex: 'id',
|
||||
},
|
||||
{
|
||||
title: '账号',
|
||||
dataIndex: 'username',
|
||||
},
|
||||
{
|
||||
title: '用户名',
|
||||
dataIndex: 'nickname',
|
||||
},
|
||||
{
|
||||
title: '手机号',
|
||||
dataIndex: 'mobile',
|
||||
},
|
||||
{
|
||||
title: '性别',
|
||||
dataIndex: 'sex',
|
||||
render: (value) => (value === 0 ? '男' : '女'),
|
||||
},
|
||||
{
|
||||
title: '类别',
|
||||
dataIndex: 'type',
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
valueType: 'dateTime',
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<PageContainer header={{ subTitle: '查询系统中的用户账号' }}>
|
||||
<QueryFilter
|
||||
defaultCollapsed
|
||||
split
|
||||
className="query-filter"
|
||||
onFinish={async (values) => setParams(values)}
|
||||
>
|
||||
<ProFormSelect
|
||||
name="searchKey"
|
||||
label="搜索"
|
||||
valueEnum={{
|
||||
user_id: 'ID',
|
||||
username: '账号',
|
||||
nick_name: '用户名',
|
||||
mobile: '手机号',
|
||||
}}
|
||||
/>
|
||||
<ProFormText name="searchValue" />
|
||||
</QueryFilter>
|
||||
<ProTable<SYSTEM.User>
|
||||
rowKey="id"
|
||||
headerTitle="用户管理"
|
||||
request={user}
|
||||
columns={columns}
|
||||
search={false}
|
||||
params={params}
|
||||
pagination={{
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
}}
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableList;
|
||||
@@ -0,0 +1 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
@@ -0,0 +1,109 @@
|
||||
import { app } from '@/services/system/api';
|
||||
import type { ProColumns } from '@ant-design/pro-components';
|
||||
import { PageContainer, ProFormText, ProTable, QueryFilter } from '@ant-design/pro-components';
|
||||
import { Typography, message } from 'antd';
|
||||
import React, { useState } from 'react';
|
||||
import styles from '@/global.less';
|
||||
|
||||
const { Link } = Typography;
|
||||
|
||||
const TableList: React.FC = () => {
|
||||
const [params, setParams] = useState<Record<string, string | number>>();
|
||||
|
||||
const columns: ProColumns<SYSTEM.App>[] = [
|
||||
{
|
||||
dataIndex: 'index',
|
||||
valueType: 'indexBorder',
|
||||
width: 20,
|
||||
},
|
||||
{
|
||||
title: '应用标识',
|
||||
dataIndex: 'clientId',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
title: '应用名称',
|
||||
dataIndex: 'clientName',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
title: '回调地址',
|
||||
dataIndex: 'webServerRedirectUri',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
title: 'oauth授权方式',
|
||||
dataIndex: 'authorizedGrantTypes',
|
||||
ellipsis: true,
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
title: '自动审批',
|
||||
key: 'autoapprove',
|
||||
width: 40,
|
||||
align: 'center',
|
||||
render: (_, record) => (record.autoapprove === 'true' ? '是' : '否'),
|
||||
},
|
||||
{
|
||||
title: '令牌时效',
|
||||
dataIndex: 'accessTokenValiditySeconds',
|
||||
valueType: 'second',
|
||||
width: 40,
|
||||
},
|
||||
{
|
||||
title: '刷新时效',
|
||||
dataIndex: 'refreshTokenValiditySeconds',
|
||||
valueType: 'second',
|
||||
width: 40,
|
||||
},
|
||||
{
|
||||
title: '支持ID令牌',
|
||||
key: 'supportIdToken',
|
||||
width: 40,
|
||||
align: 'center',
|
||||
render: (_, record) => (record.supportIdToken ? '是' : '否'),
|
||||
},
|
||||
{
|
||||
title: 'ID时效',
|
||||
dataIndex: 'idTokenValiditySeconds',
|
||||
valueType: 'second',
|
||||
width: 40,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
fixed: 'right',
|
||||
width: 40,
|
||||
render: () => <Link onClick={() => message.info('演示环境不支持该功能')}>删除</Link>,
|
||||
},
|
||||
];
|
||||
return (
|
||||
<PageContainer header={{ subTitle: '管理App' }}>
|
||||
<QueryFilter
|
||||
defaultCollapsed
|
||||
split
|
||||
span={6}
|
||||
className="query-filter"
|
||||
onFinish={async (values) => setParams(values)}
|
||||
// onReset={() => setParams({})}
|
||||
>
|
||||
<ProFormText name="searchKey" label="搜索" />
|
||||
</QueryFilter>
|
||||
<ProTable<SYSTEM.App>
|
||||
rowKey="id"
|
||||
headerTitle="Token管理"
|
||||
request={app}
|
||||
columns={columns}
|
||||
search={false}
|
||||
params={params}
|
||||
scroll={{ x: 1300 }}
|
||||
pagination={{
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
}}
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableList;
|
||||
@@ -0,0 +1 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
@@ -0,0 +1,77 @@
|
||||
import { exportGenerator, generator } from '@/services/system/api';
|
||||
import type { ProColumns } from '@ant-design/pro-components';
|
||||
import { PageContainer, ProFormText, ProTable, QueryFilter } from '@ant-design/pro-components';
|
||||
import { Typography } from 'antd';
|
||||
import React, { useState } from 'react';
|
||||
|
||||
const { Link } = Typography;
|
||||
|
||||
const Generator: React.FC = () => {
|
||||
const [params, setParams] = useState<Record<string, string | number>>();
|
||||
|
||||
const columns: ProColumns<SYSTEM.Generator>[] = [
|
||||
{
|
||||
dataIndex: 'index',
|
||||
valueType: 'indexBorder',
|
||||
width: 20,
|
||||
},
|
||||
{
|
||||
title: '数据库引擎',
|
||||
dataIndex: 'engine',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
title: '表名',
|
||||
dataIndex: 'tableName',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
valueType: 'dateTime',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
fixed: 'right',
|
||||
width: 40,
|
||||
render: (_, entity) => (
|
||||
<Link
|
||||
onClick={() => {
|
||||
if (entity.tableName) exportGenerator(entity.tableName);
|
||||
}}
|
||||
>
|
||||
生成
|
||||
</Link>
|
||||
),
|
||||
},
|
||||
];
|
||||
return (
|
||||
<PageContainer header={{ subTitle: '生成代码' }}>
|
||||
<QueryFilter
|
||||
defaultCollapsed
|
||||
split
|
||||
span={6}
|
||||
className="query-filter"
|
||||
onFinish={async (values) => setParams(values)}
|
||||
// onReset={() => setParams({})}
|
||||
>
|
||||
<ProFormText name="tableName" label="搜索" placeholder="输入表名" />
|
||||
</QueryFilter>
|
||||
<ProTable<SYSTEM.Generator>
|
||||
headerTitle="代码生成器"
|
||||
request={generator}
|
||||
columns={columns}
|
||||
search={false}
|
||||
params={params}
|
||||
pagination={{
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
}}
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default Generator;
|
||||
@@ -0,0 +1 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
@@ -0,0 +1,144 @@
|
||||
import { menu } from '@/services/system/api';
|
||||
import { treeify } from '@/util/treeify';
|
||||
import { FolderOpenOutlined, MenuOutlined, ProfileOutlined } from '@ant-design/icons';
|
||||
import type { ProColumns } from '@ant-design/pro-components';
|
||||
import { ProFormSelect } from '@ant-design/pro-components';
|
||||
import { PageContainer, ProFormText, ProTable, QueryFilter } from '@ant-design/pro-components';
|
||||
import { Space, Tag, Typography } from 'antd';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
const { Link } = Typography;
|
||||
|
||||
const Generator: React.FC = () => {
|
||||
const [data, setData] = useState<SYSTEM.Menu[]>();
|
||||
|
||||
const query = async (params: Record<string, string | number>) => {
|
||||
const menus = (await menu(params)) ?? [];
|
||||
const treeData = treeify(menus, {});
|
||||
menus.forEach((node) => {
|
||||
if (node.children && node.children.length === 0) delete node.children;
|
||||
});
|
||||
// debugger;
|
||||
setData(treeData);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
query({ tenantId: 'webApp' });
|
||||
}, []);
|
||||
|
||||
const columns: ProColumns<SYSTEM.Menu>[] = [
|
||||
{
|
||||
title: '菜单名称',
|
||||
key: 'name',
|
||||
width: 80,
|
||||
render(dom, entity) {
|
||||
if (entity.type === 1) {
|
||||
if (entity.url?.startsWith('javascript')) {
|
||||
return (
|
||||
<Space size="small">
|
||||
<FolderOpenOutlined />
|
||||
{entity.name}
|
||||
</Space>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<Space size="small">
|
||||
<MenuOutlined />
|
||||
{entity.name}
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return (
|
||||
<Space size="small">
|
||||
<ProfileOutlined />
|
||||
{entity.name}
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '菜单url',
|
||||
dataIndex: 'url',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '菜单path',
|
||||
dataIndex: 'path',
|
||||
width: 100,
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '样式',
|
||||
dataIndex: 'css',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: '排序号',
|
||||
dataIndex: 'sort',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
key: 'type',
|
||||
width: 50,
|
||||
render(_, entity) {
|
||||
if (entity.type === 1) {
|
||||
if (entity.url?.startsWith('javascript')) {
|
||||
return <Tag color="green">目录</Tag>;
|
||||
} else {
|
||||
return <Tag color="blue">菜单</Tag>;
|
||||
}
|
||||
} else {
|
||||
return <Tag color="cyan">资源</Tag>;
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
fixed: 'right',
|
||||
width: 80,
|
||||
render: (_, entity) => (
|
||||
<Space>
|
||||
<Link onClick={() => {}}>修改</Link>
|
||||
<Link onClick={() => {}}>删除</Link>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
return (
|
||||
<PageContainer header={{ subTitle: '生成代码' }}>
|
||||
<QueryFilter
|
||||
defaultCollapsed
|
||||
split
|
||||
span={6}
|
||||
className="query-filter"
|
||||
onFinish={async (values) => query(values)}
|
||||
// onReset={() => setParams({})}
|
||||
>
|
||||
<ProFormSelect
|
||||
name="tenantId"
|
||||
label="所属应用"
|
||||
valueEnum={{
|
||||
webApp: 'pc端',
|
||||
app: '移动端',
|
||||
zlt: '第三方应用',
|
||||
}}
|
||||
/>
|
||||
<ProFormText name="searchValue" />
|
||||
</QueryFilter>
|
||||
<ProTable<SYSTEM.Menu>
|
||||
rowKey="id"
|
||||
headerTitle="菜单管理"
|
||||
dataSource={data}
|
||||
columns={columns}
|
||||
search={false}
|
||||
pagination={false}
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default Generator;
|
||||
@@ -0,0 +1,65 @@
|
||||
import { menuForAuth } from '@/services/system/api';
|
||||
import { treeify } from '@/util/treeify';
|
||||
import type { TreeDataNode } from 'antd';
|
||||
import { Modal, Tree, message } from 'antd';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
type AssignAuthProps = {
|
||||
roleId?: number;
|
||||
tenantId?: string;
|
||||
onCancel: () => void;
|
||||
assignModalVisible: boolean;
|
||||
};
|
||||
|
||||
type Key = string | number;
|
||||
|
||||
const AssignAuth: React.FC<AssignAuthProps> = (props) => {
|
||||
const [treeData, setTreeData] = useState<TreeDataNode[]>([]);
|
||||
const [checkedKeys, setCheckedKeys] = useState<Key[]>([]);
|
||||
const { roleId, tenantId } = props;
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (roleId && tenantId) {
|
||||
const menus = await menuForAuth(roleId, tenantId);
|
||||
const arr: (SYSTEM.Menu & TreeDataNode)[] = menus.map((m) => {
|
||||
return { ...m, title: m.name, key: m.id };
|
||||
});
|
||||
// console.log(menus);
|
||||
const tree = treeify(arr, { parentId: 'pId' });
|
||||
const keys = menus.filter((m) => m.checked).map((m) => m.id);
|
||||
setTreeData(tree);
|
||||
setCheckedKeys(keys);
|
||||
}
|
||||
})();
|
||||
}, [roleId, tenantId]);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title="权限分配"
|
||||
// layout="horizontal"
|
||||
open={props.assignModalVisible}
|
||||
// initialValues={formData}
|
||||
onOk={() => {
|
||||
message.info('演示环境不支持该功能');
|
||||
props.onCancel();
|
||||
}}
|
||||
onCancel={() => {
|
||||
setTreeData([]);
|
||||
setCheckedKeys([]);
|
||||
props.onCancel();
|
||||
}}
|
||||
>
|
||||
<Tree
|
||||
defaultExpandAll
|
||||
checkable
|
||||
treeData={treeData}
|
||||
checkedKeys={checkedKeys}
|
||||
onCheck={(keys) => {
|
||||
setCheckedKeys(Array.isArray(keys) ? keys : keys.checked);
|
||||
}}
|
||||
/>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default AssignAuth;
|
||||
@@ -0,0 +1,70 @@
|
||||
import { role } from '@/services/system/api';
|
||||
import {
|
||||
ModalForm,
|
||||
ProForm,
|
||||
ProFormRadio,
|
||||
ProFormSelect,
|
||||
ProFormText,
|
||||
} from '@ant-design/pro-components';
|
||||
import { Form } from 'antd';
|
||||
import React, { useEffect } from 'react';
|
||||
|
||||
export type FormValueType = Partial<SYSTEM.Role>;
|
||||
|
||||
export type UpdateFormProps = {
|
||||
onCancel: (flag?: boolean, formVals?: FormValueType) => void;
|
||||
onSubmit: (values: FormValueType) => Promise<void>;
|
||||
updateModalVisible: boolean;
|
||||
values: Partial<SYSTEM.Role>;
|
||||
};
|
||||
|
||||
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||
const [form] = Form.useForm();
|
||||
const { values } = props;
|
||||
|
||||
useEffect(() => {
|
||||
form.setFieldsValue(values);
|
||||
}, [values]);
|
||||
|
||||
return (
|
||||
<ModalForm
|
||||
title="修改角色"
|
||||
form={form}
|
||||
width={500}
|
||||
// layout="horizontal"
|
||||
visible={props.updateModalVisible}
|
||||
// initialValues={formData}
|
||||
onFinish={props.onSubmit}
|
||||
onVisibleChange={props.onCancel}
|
||||
>
|
||||
<ProForm.Group>
|
||||
<ProFormText
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '角色名不为空',
|
||||
},
|
||||
]}
|
||||
width="lg"
|
||||
name="name"
|
||||
label="角色名"
|
||||
placeholder="输入角色名"
|
||||
/>
|
||||
<ProFormText
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: 'Code不为空',
|
||||
},
|
||||
]}
|
||||
width="lg"
|
||||
name="code"
|
||||
label="Code"
|
||||
placeholder="输入Code"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
);
|
||||
};
|
||||
|
||||
export default UpdateForm;
|
||||
@@ -0,0 +1 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
@@ -0,0 +1,191 @@
|
||||
import { pageRole } from '@/services/system/api';
|
||||
import { PlusOutlined } from '@ant-design/icons';
|
||||
import type { ProColumns } from '@ant-design/pro-components';
|
||||
import {
|
||||
ProFormSelect,
|
||||
ModalForm,
|
||||
PageContainer,
|
||||
ProFormText,
|
||||
ProForm,
|
||||
ProTable,
|
||||
QueryFilter,
|
||||
} from '@ant-design/pro-components';
|
||||
import { Space, Typography } from 'antd';
|
||||
import { Button, message } from 'antd';
|
||||
import React, { useState } from 'react';
|
||||
import AssignAuth from './components/AssignAuth';
|
||||
import UpdateForm from './components/UpdateForm';
|
||||
|
||||
const { Link } = Typography;
|
||||
|
||||
type AssignAuthProps = {
|
||||
roleId?: number;
|
||||
tenantId?: string;
|
||||
assignModalVisible: boolean;
|
||||
};
|
||||
|
||||
const TableList: React.FC = () => {
|
||||
const [params, setParams] = useState<Record<string, string | number>>({});
|
||||
|
||||
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
|
||||
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
|
||||
|
||||
const [currentRow, setCurrentRow] = useState<SYSTEM.User>();
|
||||
|
||||
const [assignAuth, setAssignAuth] = useState<AssignAuthProps>({ assignModalVisible: false });
|
||||
|
||||
const columns: ProColumns<SYSTEM.Role>[] = [
|
||||
{
|
||||
dataIndex: 'index',
|
||||
valueType: 'indexBorder',
|
||||
},
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
},
|
||||
{
|
||||
title: '角色名',
|
||||
dataIndex: 'name',
|
||||
},
|
||||
{
|
||||
title: 'CODE',
|
||||
dataIndex: 'code',
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
valueType: 'dateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
render: (_, record) => (
|
||||
<Space>
|
||||
<Link
|
||||
onClick={() => {
|
||||
handleUpdateModalVisible(true);
|
||||
setCurrentRow(record);
|
||||
}}
|
||||
>
|
||||
修改
|
||||
</Link>
|
||||
<Link onClick={() => message.info('演示环境不支持该功能')}>删除</Link>
|
||||
<Link
|
||||
onClick={() => {
|
||||
setAssignAuth({ roleId: record.id, assignModalVisible: true, tenantId: 'webApp' });
|
||||
}}
|
||||
>
|
||||
权限分配
|
||||
</Link>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<PageContainer header={{ subTitle: '管理系统中的角色' }}>
|
||||
<QueryFilter
|
||||
defaultCollapsed
|
||||
split
|
||||
span={6}
|
||||
className="query-filter"
|
||||
onFinish={async (values) => setParams(values)}
|
||||
>
|
||||
<ProFormSelect
|
||||
name="tenantId"
|
||||
label="所属应用"
|
||||
valueEnum={{
|
||||
webApp: 'pc端',
|
||||
app: '移动端',
|
||||
zlt: '第三方应用',
|
||||
}}
|
||||
/>
|
||||
<ProFormSelect
|
||||
name="searchKey"
|
||||
label="搜索"
|
||||
valueEnum={{
|
||||
name: '角色名称',
|
||||
}}
|
||||
/>
|
||||
<ProFormText name="searchValue" />
|
||||
</QueryFilter>
|
||||
<ProTable<SYSTEM.Role>
|
||||
rowKey="id"
|
||||
headerTitle="角色管理"
|
||||
request={pageRole}
|
||||
columns={columns}
|
||||
search={false}
|
||||
params={params}
|
||||
pagination={{
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
}}
|
||||
toolBarRender={() => [
|
||||
<>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
handleModalVisible(true);
|
||||
}}
|
||||
>
|
||||
<PlusOutlined /> 添加
|
||||
</Button>
|
||||
</>,
|
||||
]}
|
||||
/>
|
||||
<ModalForm
|
||||
title="添加角色"
|
||||
// layout="horizontal"
|
||||
width={500}
|
||||
visible={createModalVisible}
|
||||
onVisibleChange={handleModalVisible}
|
||||
onFinish={async () => {
|
||||
message.info('演示环境不支持该功能');
|
||||
}}
|
||||
>
|
||||
<ProForm.Group>
|
||||
<ProFormText
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '角色名不为空',
|
||||
},
|
||||
]}
|
||||
width="lg"
|
||||
name="name"
|
||||
label="角色名"
|
||||
placeholder="输入角色名"
|
||||
/>
|
||||
<ProFormText
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: 'Code不为空',
|
||||
},
|
||||
]}
|
||||
width="lg"
|
||||
name="code"
|
||||
label="Code"
|
||||
placeholder="输入Code"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
<UpdateForm
|
||||
onSubmit={async () => {
|
||||
message.info('演示环境不支持该功能');
|
||||
handleUpdateModalVisible(false);
|
||||
setCurrentRow(undefined);
|
||||
}}
|
||||
onCancel={(flag) => {
|
||||
handleUpdateModalVisible(flag ?? true);
|
||||
setCurrentRow(undefined);
|
||||
}}
|
||||
updateModalVisible={updateModalVisible}
|
||||
values={currentRow || {}}
|
||||
/>
|
||||
<AssignAuth {...assignAuth} onCancel={() => setAssignAuth({ assignModalVisible: false })} />
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableList;
|
||||
@@ -0,0 +1 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
@@ -0,0 +1,94 @@
|
||||
import { token } from '@/services/system/api';
|
||||
import type { ProColumns } from '@ant-design/pro-components';
|
||||
import {
|
||||
ProFormSelect,
|
||||
PageContainer,
|
||||
ProFormText,
|
||||
ProTable,
|
||||
QueryFilter,
|
||||
} from '@ant-design/pro-components';
|
||||
import { Typography, message } from 'antd';
|
||||
import React, { useState } from 'react';
|
||||
|
||||
const { Link } = Typography;
|
||||
|
||||
const TableList: React.FC = () => {
|
||||
const [params, setParams] = useState<Record<string, string | number>>({ tenantId: 'webApp' });
|
||||
|
||||
const columns: ProColumns<SYSTEM.Token>[] = [
|
||||
{
|
||||
dataIndex: 'index',
|
||||
valueType: 'indexBorder',
|
||||
},
|
||||
{
|
||||
title: 'token',
|
||||
dataIndex: 'tokenValue',
|
||||
},
|
||||
{
|
||||
title: '到期时间',
|
||||
dataIndex: 'expiration',
|
||||
valueType: 'dateTime',
|
||||
},
|
||||
{
|
||||
title: '用户名',
|
||||
dataIndex: 'username',
|
||||
},
|
||||
{
|
||||
title: '授权类型',
|
||||
dataIndex: 'grantType',
|
||||
},
|
||||
{
|
||||
title: '所属应用',
|
||||
dataIndex: 'clientId',
|
||||
},
|
||||
{
|
||||
title: '账号类型',
|
||||
dataIndex: 'accountType',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
render: () => <Link onClick={() => message.info('演示环境不支持该功能')}>删除</Link>,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<PageContainer header={{ subTitle: '管理会话Token' }}>
|
||||
<QueryFilter
|
||||
defaultCollapsed
|
||||
split
|
||||
span={6}
|
||||
className="query-filter"
|
||||
initialValues={params}
|
||||
onFinish={async (values) => setParams(values)}
|
||||
// onReset={() => setParams({})}
|
||||
>
|
||||
<ProFormSelect
|
||||
name="tenantId"
|
||||
label="所属应用"
|
||||
valueEnum={{
|
||||
webApp: 'pc端',
|
||||
app: '移动端',
|
||||
zlt: '第三方应用',
|
||||
}}
|
||||
allowClear={false}
|
||||
/>
|
||||
<ProFormText name="username" label="搜索" placeholder="输入用户名" />
|
||||
</QueryFilter>
|
||||
<ProTable<SYSTEM.Token>
|
||||
rowKey="tokenValue"
|
||||
headerTitle="Token管理"
|
||||
request={token}
|
||||
columns={columns}
|
||||
search={false}
|
||||
params={params}
|
||||
pagination={{
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
}}
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableList;
|
||||
@@ -0,0 +1,116 @@
|
||||
import { role } from '@/services/system/api';
|
||||
import {
|
||||
ModalForm,
|
||||
ProForm,
|
||||
ProFormRadio,
|
||||
ProFormSelect,
|
||||
ProFormText,
|
||||
} from '@ant-design/pro-components';
|
||||
import { Form } from 'antd';
|
||||
import React, { useEffect } from 'react';
|
||||
|
||||
export type FormValueType = {
|
||||
roleCodes?: string[];
|
||||
} & Partial<SYSTEM.User>;
|
||||
|
||||
export type UpdateFormProps = {
|
||||
onCancel: (flag?: boolean, formVals?: FormValueType) => void;
|
||||
onSubmit: (values: FormValueType) => Promise<void>;
|
||||
updateModalVisible: boolean;
|
||||
values: Partial<SYSTEM.User>;
|
||||
};
|
||||
|
||||
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||
const [form] = Form.useForm();
|
||||
const { values } = props;
|
||||
|
||||
useEffect(() => {
|
||||
if (values.roles) {
|
||||
const roleCodes = values.roles.map((r) => r.code);
|
||||
const formData: FormValueType = { ...values, roleCodes };
|
||||
form.setFieldsValue(formData);
|
||||
}
|
||||
}, [values]);
|
||||
return (
|
||||
<ModalForm
|
||||
title="修改用户"
|
||||
form={form}
|
||||
// layout="horizontal"
|
||||
visible={props.updateModalVisible}
|
||||
// initialValues={formData}
|
||||
onFinish={props.onSubmit}
|
||||
onVisibleChange={props.onCancel}
|
||||
>
|
||||
<ProForm.Group>
|
||||
<ProFormText
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '账号不为空',
|
||||
},
|
||||
]}
|
||||
width="md"
|
||||
name="username"
|
||||
label="账号"
|
||||
placeholder="输入账号"
|
||||
/>
|
||||
<ProFormText
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '用户名不为空',
|
||||
},
|
||||
]}
|
||||
width="md"
|
||||
name="nickname"
|
||||
label="用户名"
|
||||
placeholder="输入用户名"
|
||||
/>
|
||||
<ProFormText
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '手机号不为空',
|
||||
},
|
||||
]}
|
||||
width="md"
|
||||
name="mobile"
|
||||
label="手机号"
|
||||
placeholder="输入手机号"
|
||||
/>
|
||||
<ProFormRadio.Group
|
||||
name="sex"
|
||||
label="性别"
|
||||
width="md"
|
||||
options={[
|
||||
{
|
||||
label: '男',
|
||||
value: 0,
|
||||
},
|
||||
{
|
||||
label: '女',
|
||||
value: 1,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<ProFormSelect
|
||||
mode="multiple"
|
||||
name="roleCodes"
|
||||
label="角色"
|
||||
width="md"
|
||||
request={async () => {
|
||||
const roles = await role();
|
||||
if (roles)
|
||||
return roles.map((r) => {
|
||||
return { label: r.name, value: r.code };
|
||||
});
|
||||
return [];
|
||||
}}
|
||||
placeholder="选择角色"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
);
|
||||
};
|
||||
|
||||
export default UpdateForm;
|
||||
@@ -0,0 +1 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
@@ -0,0 +1,247 @@
|
||||
import { user, exportUser, role } from '@/services/system/api';
|
||||
import { ExportOutlined, ImportOutlined, PlusOutlined } from '@ant-design/icons';
|
||||
import type { ProColumns } from '@ant-design/pro-components';
|
||||
import {
|
||||
ProFormRadio,
|
||||
ProFormSelect,
|
||||
ModalForm,
|
||||
PageContainer,
|
||||
ProFormText,
|
||||
ProForm,
|
||||
ProTable,
|
||||
QueryFilter,
|
||||
} from '@ant-design/pro-components';
|
||||
import { Space, Typography } from 'antd';
|
||||
import { Button, Switch, message } from 'antd';
|
||||
import React, { useState } from 'react';
|
||||
import UpdateForm from './components/UpdateForm';
|
||||
|
||||
const { Link } = Typography;
|
||||
|
||||
const TableList: React.FC = () => {
|
||||
const [params, setParams] = useState<Record<string, string | number>>({});
|
||||
|
||||
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
|
||||
|
||||
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
|
||||
const [currentRow, setCurrentRow] = useState<SYSTEM.User>();
|
||||
|
||||
const columns: ProColumns<SYSTEM.User>[] = [
|
||||
{
|
||||
dataIndex: 'index',
|
||||
valueType: 'indexBorder',
|
||||
},
|
||||
{
|
||||
title: '用户编号',
|
||||
dataIndex: 'id',
|
||||
},
|
||||
{
|
||||
title: '账号',
|
||||
dataIndex: 'username',
|
||||
},
|
||||
{
|
||||
title: '用户名',
|
||||
dataIndex: 'nickname',
|
||||
},
|
||||
{
|
||||
title: '手机号',
|
||||
dataIndex: 'mobile',
|
||||
},
|
||||
{
|
||||
title: '性别',
|
||||
dataIndex: 'sex',
|
||||
render: (value) => (value === 0 ? '男' : '女'),
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
valueType: 'dateTime',
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'enabled',
|
||||
render: (_dom, entity) => (
|
||||
<Switch
|
||||
checkedChildren="正常"
|
||||
unCheckedChildren="锁定"
|
||||
checked={entity.enabled}
|
||||
onClick={() => message.info('演示环境不支持该功能')}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
render: (_, record) => (
|
||||
<Space>
|
||||
<Link
|
||||
onClick={() => {
|
||||
handleUpdateModalVisible(true);
|
||||
setCurrentRow(record);
|
||||
}}
|
||||
>
|
||||
修改
|
||||
</Link>
|
||||
<Link onClick={() => message.info('演示环境不支持该功能')}>重置密码</Link>
|
||||
<Link onClick={() => message.info('演示环境不支持该功能')}>删除</Link>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<PageContainer header={{ subTitle: '管理系统中的用户账号' }}>
|
||||
<QueryFilter
|
||||
defaultCollapsed
|
||||
split
|
||||
className="query-filter"
|
||||
onFinish={async (values) => setParams(values)}
|
||||
>
|
||||
<ProFormSelect
|
||||
name="searchKey"
|
||||
label="搜索"
|
||||
valueEnum={{
|
||||
user_id: 'ID',
|
||||
username: '账号',
|
||||
nick_name: '用户名',
|
||||
mobile: '手机号',
|
||||
}}
|
||||
/>
|
||||
<ProFormText name="searchValue" />
|
||||
</QueryFilter>
|
||||
<ProTable<SYSTEM.User>
|
||||
rowKey="id"
|
||||
headerTitle="用户管理"
|
||||
request={user}
|
||||
columns={columns}
|
||||
search={false}
|
||||
params={params}
|
||||
pagination={{
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
}}
|
||||
toolBarRender={() => [
|
||||
<>
|
||||
<Button
|
||||
onClick={() => {
|
||||
exportUser();
|
||||
}}
|
||||
>
|
||||
<ExportOutlined /> 导出
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
message.info('演示环境不支持该功能');
|
||||
}}
|
||||
>
|
||||
<ImportOutlined /> 导入
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
handleModalVisible(true);
|
||||
}}
|
||||
>
|
||||
<PlusOutlined /> 添加
|
||||
</Button>
|
||||
</>,
|
||||
]}
|
||||
/>
|
||||
<ModalForm
|
||||
title="添加用户"
|
||||
// layout="horizontal"
|
||||
visible={createModalVisible}
|
||||
onVisibleChange={handleModalVisible}
|
||||
initialValues={{ sex: 0 }}
|
||||
onFinish={async (values) => {
|
||||
console.log(values);
|
||||
message.info('演示环境不支持该功能');
|
||||
}}
|
||||
>
|
||||
<ProForm.Group>
|
||||
<ProFormText
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '账号不为空',
|
||||
},
|
||||
]}
|
||||
width="md"
|
||||
name="username"
|
||||
label="账号"
|
||||
placeholder="输入账号"
|
||||
/>
|
||||
<ProFormText
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '用户名不为空',
|
||||
},
|
||||
]}
|
||||
width="md"
|
||||
name="nickname"
|
||||
label="用户名"
|
||||
placeholder="输入用户名"
|
||||
/>
|
||||
<ProFormText
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '手机号不为空',
|
||||
},
|
||||
]}
|
||||
width="md"
|
||||
name="mobile"
|
||||
label="手机号"
|
||||
placeholder="输入手机号"
|
||||
/>
|
||||
<ProFormRadio.Group
|
||||
name="sex"
|
||||
label="性别"
|
||||
width="md"
|
||||
options={[
|
||||
{
|
||||
label: '男',
|
||||
value: 0,
|
||||
},
|
||||
{
|
||||
label: '女',
|
||||
value: 1,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<ProFormSelect
|
||||
mode="multiple"
|
||||
name="roleCodes"
|
||||
label="角色"
|
||||
width="md"
|
||||
request={async () => {
|
||||
const roles = await role();
|
||||
if (roles)
|
||||
return roles.map((r) => {
|
||||
return { label: r.name, value: r.code };
|
||||
});
|
||||
return [];
|
||||
}}
|
||||
placeholder="选择角色"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
<UpdateForm
|
||||
onSubmit={async () => {
|
||||
message.info('演示环境不支持该功能');
|
||||
handleUpdateModalVisible(false);
|
||||
setCurrentRow(undefined);
|
||||
}}
|
||||
onCancel={(flag) => {
|
||||
handleUpdateModalVisible(flag ?? true);
|
||||
setCurrentRow(undefined);
|
||||
}}
|
||||
updateModalVisible={updateModalVisible}
|
||||
values={currentRow || {}}
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableList;
|
||||
@@ -0,0 +1,42 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
|
||||
.baseView {
|
||||
display: flex;
|
||||
padding: @padding-lg;
|
||||
background: @component-background;
|
||||
|
||||
:global {
|
||||
.ant-legacy-form-item .ant-legacy-form-item-control-wrapper {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.left {
|
||||
min-width: 224px;
|
||||
max-width: 448px;
|
||||
}
|
||||
.right {
|
||||
flex: 1;
|
||||
padding-left: 104px;
|
||||
.avatar_title {
|
||||
height: 22px;
|
||||
margin-bottom: 8px;
|
||||
color: @heading-color;
|
||||
font-size: @font-size-base;
|
||||
line-height: 22px;
|
||||
}
|
||||
.avatar {
|
||||
width: 144px;
|
||||
height: 144px;
|
||||
margin-bottom: 12px;
|
||||
overflow: hidden;
|
||||
img {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.button_view {
|
||||
width: 144px;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import { currentUser2 } from '@/services/ant-design-pro/api';
|
||||
import { UploadOutlined } from '@ant-design/icons';
|
||||
import type { ProFormInstance } from '@ant-design/pro-components';
|
||||
import { PageContainer, ProFormText, ProForm, ProFormRadio } from '@ant-design/pro-components';
|
||||
import { Button, Upload } from 'antd';
|
||||
import React, { useRef } from 'react';
|
||||
import { useModel } from 'umi';
|
||||
import styles from './index.less';
|
||||
|
||||
const AvatarView = ({ avatar }: { avatar: string }) => (
|
||||
<>
|
||||
<div className={styles.avatar_title}>头像</div>
|
||||
<div className={styles.avatar}>
|
||||
<img src={avatar} alt="avatar" />
|
||||
</div>
|
||||
<Upload showUploadList={false}>
|
||||
<div className={styles.button_view}>
|
||||
<Button>
|
||||
<UploadOutlined />
|
||||
更换头像
|
||||
</Button>
|
||||
</div>
|
||||
</Upload>
|
||||
</>
|
||||
);
|
||||
|
||||
const UserInfo: React.FC = () => {
|
||||
const formRef = useRef<ProFormInstance<API.CurrentUser>>();
|
||||
const { initialState } = useModel('@@initialState');
|
||||
const { currentUser } = initialState;
|
||||
|
||||
return (
|
||||
<PageContainer header={{ subTitle: '更新个人信息' }}>
|
||||
<div className={styles.baseView}>
|
||||
<div className={styles.left}>
|
||||
<ProForm<API.CurrentUser>
|
||||
formRef={formRef}
|
||||
//layout="horizontal"
|
||||
request={currentUser2}
|
||||
// labelCol={{ span: 8 }}
|
||||
// wrapperCol={{ span: 16 }}
|
||||
>
|
||||
<ProFormText name="username" label="账号" readonly />
|
||||
<ProFormText
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '用户名不为空',
|
||||
},
|
||||
]}
|
||||
width="md"
|
||||
name="nickname"
|
||||
label="用户名"
|
||||
placeholder="输入用户名"
|
||||
/>
|
||||
<ProFormText
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '手机号不为空',
|
||||
},
|
||||
]}
|
||||
width="md"
|
||||
name="mobile"
|
||||
label="手机号"
|
||||
placeholder="输入手机号"
|
||||
/>
|
||||
<ProFormRadio.Group
|
||||
name="sex"
|
||||
label="性别"
|
||||
width="md"
|
||||
options={[
|
||||
{
|
||||
label: '男',
|
||||
value: 0,
|
||||
},
|
||||
{
|
||||
label: '女',
|
||||
value: 1,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</ProForm>
|
||||
</div>
|
||||
<div className={styles.right}>
|
||||
<AvatarView avatar={currentUser.headImgUrl} />
|
||||
</div>
|
||||
</div>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default UserInfo;
|
||||
@@ -0,0 +1,50 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
overflow: auto;
|
||||
background: @layout-body-background;
|
||||
}
|
||||
|
||||
.lang {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
line-height: 44px;
|
||||
text-align: right;
|
||||
:global(.ant-dropdown-trigger) {
|
||||
margin-right: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
padding: 32px 0;
|
||||
}
|
||||
|
||||
@media (min-width: @screen-md-min) {
|
||||
.container {
|
||||
background-image: url('https://gw.alipayobjects.com/zos/rmsportal/TVYTbAXWheQpRcWDaDMu.svg');
|
||||
background-repeat: no-repeat;
|
||||
background-position: center 110px;
|
||||
background-size: 100%;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 32px 0 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.icon {
|
||||
margin-left: 8px;
|
||||
color: rgba(0, 0, 0, 0.2);
|
||||
font-size: 24px;
|
||||
vertical-align: middle;
|
||||
cursor: pointer;
|
||||
transition: color 0.3s;
|
||||
|
||||
&:hover {
|
||||
color: @primary-color;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
import Footer from '@/components/Footer';
|
||||
import { login } from '@/services/ant-design-pro/api';
|
||||
import { LockOutlined, UserOutlined } from '@ant-design/icons';
|
||||
import { LoginForm, ProFormCaptcha, ProFormText } from '@ant-design/pro-components';
|
||||
import { Alert, message } from 'antd';
|
||||
import React, { useState } from 'react';
|
||||
import { FormattedMessage, history, useIntl, useModel } from 'umi';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import styles from './index.less';
|
||||
|
||||
const LoginMessage: React.FC<{
|
||||
content: string;
|
||||
}> = ({ content }) => (
|
||||
<Alert
|
||||
style={{
|
||||
marginBottom: 24,
|
||||
}}
|
||||
message={content}
|
||||
type="error"
|
||||
showIcon
|
||||
/>
|
||||
);
|
||||
|
||||
const Login: React.FC = () => {
|
||||
// const [userLoginState, setUserLoginState] = useState<API.LoginResult>({});
|
||||
const [uuid, setUuid] = useState<string>(uuidv4());
|
||||
const { initialState, setInitialState } = useModel('@@initialState');
|
||||
|
||||
const intl = useIntl();
|
||||
|
||||
const fetchUserInfo = async () => {
|
||||
const userInfo = await initialState?.fetchUserInfo?.();
|
||||
if (userInfo) {
|
||||
await setInitialState((s) => ({
|
||||
...s,
|
||||
currentUser: userInfo,
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = async (values: API.LoginParams) => {
|
||||
try {
|
||||
// 登录
|
||||
const msg = await login({ ...values });
|
||||
if (msg.resp_code === 0) {
|
||||
const defaultLoginSuccessMessage = intl.formatMessage({
|
||||
id: 'pages.login.success',
|
||||
defaultMessage: '登录成功!',
|
||||
});
|
||||
const loginResult = msg.datas;
|
||||
if (loginResult && loginResult.access_token)
|
||||
sessionStorage.setItem('access_token', loginResult.access_token);
|
||||
message.success(defaultLoginSuccessMessage);
|
||||
await fetchUserInfo();
|
||||
/** 此方法会跳转到 redirect 参数所在的位置 */
|
||||
if (!history) return;
|
||||
const { query } = history.location;
|
||||
const { redirect } = query as { redirect: string };
|
||||
history.push(redirect || '/');
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果失败去设置用户错误信息
|
||||
//setUserLoginState(msg);
|
||||
} catch (error) {
|
||||
const defaultLoginFailureMessage = intl.formatMessage({
|
||||
id: 'pages.login.failure',
|
||||
defaultMessage: '登录失败,请重试!',
|
||||
});
|
||||
message.error(defaultLoginFailureMessage);
|
||||
}
|
||||
};
|
||||
|
||||
const captchaUrl = `/api-uaa/validata/code/${uuid}`;
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<div className={styles.content}>
|
||||
<LoginForm
|
||||
logo={<img alt="logo" src="/logo.png" />}
|
||||
title="microservices-platform"
|
||||
subTitle={intl.formatMessage({ id: 'pages.layouts.userLayout.title' })}
|
||||
initialValues={{
|
||||
autoLogin: true,
|
||||
}}
|
||||
onFinish={async (values) => {
|
||||
await handleSubmit({ ...values, deviceId: uuid } as API.LoginParams);
|
||||
}}
|
||||
>
|
||||
{/* {status === 'error' && loginType === 'account' && (
|
||||
<LoginMessage
|
||||
content={intl.formatMessage({
|
||||
id: 'pages.login.accountLogin.errorMessage',
|
||||
defaultMessage: '账户或密码错误(admin/ant.design)',
|
||||
})}
|
||||
/>
|
||||
)} */}
|
||||
<>
|
||||
<ProFormText
|
||||
name="username"
|
||||
fieldProps={{
|
||||
size: 'large',
|
||||
prefix: <UserOutlined className={styles.prefixIcon} />,
|
||||
}}
|
||||
placeholder={intl.formatMessage({
|
||||
id: 'pages.login.username.placeholder',
|
||||
defaultMessage: '账号',
|
||||
})}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: (
|
||||
<FormattedMessage
|
||||
id="pages.login.username.required"
|
||||
defaultMessage="请输入账号!"
|
||||
/>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<ProFormText.Password
|
||||
name="password"
|
||||
fieldProps={{
|
||||
size: 'large',
|
||||
prefix: <LockOutlined className={styles.prefixIcon} />,
|
||||
}}
|
||||
placeholder={intl.formatMessage({
|
||||
id: 'pages.login.password.placeholder',
|
||||
defaultMessage: '密码',
|
||||
})}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: (
|
||||
<FormattedMessage
|
||||
id="pages.login.password.required"
|
||||
defaultMessage="请输入密码!"
|
||||
/>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<ProFormCaptcha
|
||||
name="validCode"
|
||||
fieldProps={{
|
||||
size: 'large',
|
||||
prefix: <LockOutlined className={'prefixIcon'} />,
|
||||
}}
|
||||
captchaProps={{
|
||||
size: 'large',
|
||||
}}
|
||||
placeholder={'验证码'}
|
||||
captchaTextRender={() => (
|
||||
<span onClick={() => setUuid(uuidv4())}>
|
||||
<img src={captchaUrl} alt="验证码" />
|
||||
</span>
|
||||
)}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '请输入验证码!',
|
||||
},
|
||||
]}
|
||||
onGetCaptcha={async () => {}}
|
||||
/>
|
||||
</>
|
||||
</LoginForm>
|
||||
</div>
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Login;
|
||||
@@ -0,0 +1,65 @@
|
||||
/* eslint-disable no-restricted-globals */
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
/* globals workbox */
|
||||
workbox.core.setCacheNameDetails({
|
||||
prefix: 'antd-pro',
|
||||
suffix: 'v5',
|
||||
});
|
||||
// Control all opened tabs ASAP
|
||||
workbox.clientsClaim();
|
||||
|
||||
/**
|
||||
* Use precaching list generated by workbox in build process.
|
||||
* https://developers.google.com/web/tools/workbox/reference-docs/latest/workbox.precaching
|
||||
*/
|
||||
workbox.precaching.precacheAndRoute(self.__precacheManifest || []);
|
||||
|
||||
/**
|
||||
* Register a navigation route.
|
||||
* https://developers.google.com/web/tools/workbox/modules/workbox-routing#how_to_register_a_navigation_route
|
||||
*/
|
||||
workbox.routing.registerNavigationRoute('/index.html');
|
||||
|
||||
/**
|
||||
* Use runtime cache:
|
||||
* https://developers.google.com/web/tools/workbox/reference-docs/latest/workbox.routing#.registerRoute
|
||||
*
|
||||
* Workbox provides all common caching strategies including CacheFirst, NetworkFirst etc.
|
||||
* https://developers.google.com/web/tools/workbox/reference-docs/latest/workbox.strategies
|
||||
*/
|
||||
|
||||
/** Handle API requests */
|
||||
workbox.routing.registerRoute(/\/api\//, workbox.strategies.networkFirst());
|
||||
|
||||
/** Handle third party requests */
|
||||
workbox.routing.registerRoute(
|
||||
/^https:\/\/gw\.alipayobjects\.com\//,
|
||||
workbox.strategies.networkFirst(),
|
||||
);
|
||||
workbox.routing.registerRoute(
|
||||
/^https:\/\/cdnjs\.cloudflare\.com\//,
|
||||
workbox.strategies.networkFirst(),
|
||||
);
|
||||
workbox.routing.registerRoute(/\/color.less/, workbox.strategies.networkFirst());
|
||||
|
||||
/** Response to client after skipping waiting with MessageChannel */
|
||||
addEventListener('message', (event) => {
|
||||
const replyPort = event.ports[0];
|
||||
const message = event.data;
|
||||
if (replyPort && message && message.type === 'skip-waiting') {
|
||||
event.waitUntil(
|
||||
self.skipWaiting().then(
|
||||
() => {
|
||||
replyPort.postMessage({
|
||||
error: null,
|
||||
});
|
||||
},
|
||||
(error) => {
|
||||
replyPort.postMessage({
|
||||
error,
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
import { request } from 'umi';
|
||||
|
||||
export async function currentUser(options?: { [key: string]: any }) {
|
||||
return request<API.OptionalResult<API.CurrentUser>>('/api-user/users/current', {
|
||||
method: 'GET',
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
export async function currentUser2(options?: { [key: string]: any }) {
|
||||
const result = await request<API.OptionalResult<API.CurrentUser>>('/api-user/users/current', {
|
||||
method: 'GET',
|
||||
...(options || {}),
|
||||
});
|
||||
return result.datas ?? {};
|
||||
}
|
||||
|
||||
export async function fetchMenuData(options?: { [key: string]: any }) {
|
||||
return request<API.Menu[]>('/api-user/menus/current', {
|
||||
method: 'GET',
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** 退出登录接口 POST /api/login/outLogin */
|
||||
export async function outLogin(options?: { [key: string]: any }) {
|
||||
return request<Record<string, any>>('/api/login/outLogin', {
|
||||
method: 'POST',
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
export async function login(body: API.LoginParams, options?: { [key: string]: any }) {
|
||||
return request<API.OptionalResult<API.LoginResult>>('/api-uaa/oauth/token', {
|
||||
method: 'POST',
|
||||
requestType: 'form',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
Authorization: 'Basic d2ViQXBwOndlYkFwcA==',
|
||||
},
|
||||
data: { ...body, grant_type: 'password_code' },
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
// API 更新时间:
|
||||
// API 唯一标识:
|
||||
import * as api from './api';
|
||||
export default {
|
||||
api,
|
||||
};
|
||||
@@ -0,0 +1,59 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
|
||||
declare namespace API {
|
||||
type Result<T> = {
|
||||
resp_code?: number;
|
||||
resp_msg?: number;
|
||||
datas?: T[];
|
||||
};
|
||||
|
||||
type OptionalResult<T> = {
|
||||
resp_code?: number;
|
||||
resp_msg?: number;
|
||||
datas?: T;
|
||||
};
|
||||
|
||||
type CurrentUser = {
|
||||
userId?: string;
|
||||
username?: string;
|
||||
nickname?: string;
|
||||
headImgUrl?: string;
|
||||
sex?: number;
|
||||
type?: string;
|
||||
};
|
||||
|
||||
type Menu = {
|
||||
id?: number;
|
||||
name?: string;
|
||||
path?: string;
|
||||
url?: string;
|
||||
css?: string;
|
||||
subMenus?: Menu[];
|
||||
};
|
||||
|
||||
type LoginResult = {
|
||||
access_token?: string;
|
||||
token_type?: string;
|
||||
refresh_token?: string;
|
||||
expires_in?: number;
|
||||
scope?: string;
|
||||
account_type?: string;
|
||||
};
|
||||
|
||||
type LoginParams = {
|
||||
username?: string;
|
||||
password?: string;
|
||||
validCode?: string;
|
||||
deviceId?: string;
|
||||
};
|
||||
|
||||
type ErrorResponse = {
|
||||
/** 业务约定的错误码 */
|
||||
errorCode: string;
|
||||
/** 业务上的错误信息 */
|
||||
errorMessage?: string;
|
||||
/** 业务上的请求是否成功 */
|
||||
success?: boolean;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
import { request } from 'umi';
|
||||
|
||||
export async function indice(params?: { [key: string]: string | number }) {
|
||||
const { current, pageSize, ...rest } = params ?? {};
|
||||
const result = await request<SYSTEM.Page<SEARCH.Indice>>('/api-search/admin/indices', {
|
||||
method: 'GET',
|
||||
params: { page: current, limit: pageSize, ...rest },
|
||||
});
|
||||
return { data: result.data };
|
||||
}
|
||||
|
||||
export async function index(indexName: string) {
|
||||
const result = await request<API.OptionalResult<any>>('/api-search/admin/index', {
|
||||
method: 'GET',
|
||||
params: { indexName },
|
||||
});
|
||||
return result.datas;
|
||||
}
|
||||
|
||||
export async function syslog(params?: { [key: string]: string | number }) {
|
||||
const { current, pageSize, ...rest } = params ?? {};
|
||||
const result = await request<SYSTEM.Page<SEARCH.SysLog>>('/api-log/sysLog', {
|
||||
method: 'GET',
|
||||
params: { page: current, limit: pageSize, ...rest },
|
||||
});
|
||||
return { data: result.data, total: result.count };
|
||||
}
|
||||
|
||||
export async function tracelog(traceId: string) {
|
||||
const params = { queryStr: `traceId:${traceId}`, sortCol: 'timestamp', sortOrder: 'ASC' };
|
||||
const result = await request<SYSTEM.Page<SEARCH.TraceLog>>('/api-log/traceLog', {
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
return result.data;
|
||||
}
|
||||
|
||||
export async function auditlog(params?: { [key: string]: string | number }) {
|
||||
const { current, pageSize, ...rest } = params ?? {};
|
||||
const result = await request<SYSTEM.Page<SEARCH.TraceLog>>('/api-log/auditLog', {
|
||||
method: 'GET',
|
||||
params: { page: current, limit: pageSize, ...rest },
|
||||
});
|
||||
return { data: result.data, total: result.count };
|
||||
}
|
||||
|
||||
export async function slowQueryLog(params?: { [key: string]: string | number }) {
|
||||
const { current, pageSize, ...rest } = params ?? {};
|
||||
const result = await request<SYSTEM.Page<SEARCH.TraceLog>>('/api-log/slowQueryLog', {
|
||||
method: 'GET',
|
||||
params: { page: current, limit: pageSize, ...rest },
|
||||
});
|
||||
return { data: result.data, total: result.count };
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
// API 更新时间:
|
||||
// API 唯一标识:
|
||||
import * as api from './api';
|
||||
export default {
|
||||
api,
|
||||
};
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
|
||||
declare namespace SEARCH {
|
||||
type Indice = {
|
||||
docsCount?: string;
|
||||
docsDeleted?: string;
|
||||
health?: string;
|
||||
index?: string;
|
||||
status?: string;
|
||||
storeSize?: string;
|
||||
};
|
||||
|
||||
type SysLog = {
|
||||
id?: string;
|
||||
'@timestamp'?: Date;
|
||||
agent?: { name?: string; type?: string; id?: string; version?: string };
|
||||
appName?: string;
|
||||
classname?: string;
|
||||
id?: string;
|
||||
logLevel?: string;
|
||||
serverIp?: string;
|
||||
serverPort?: string;
|
||||
timestamp?: string;
|
||||
message?: string;
|
||||
traceId?: string;
|
||||
spanId?: string;
|
||||
threadName?: string;
|
||||
};
|
||||
|
||||
type TraceLog = {
|
||||
appName?: string;
|
||||
parentId?: string;
|
||||
serverIp?: string;
|
||||
serverPort?: string;
|
||||
spanId?: string;
|
||||
};
|
||||
|
||||
type AuditLog = {
|
||||
id?: string;
|
||||
appName?: string;
|
||||
className?: string;
|
||||
clientId?: string;
|
||||
methodName?: string;
|
||||
operation?: string;
|
||||
timestamp?: string;
|
||||
userId?: string;
|
||||
userName?: string;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// @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,0 +1,166 @@
|
||||
// @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,0 +1,54 @@
|
||||
// @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 || {}),
|
||||
});
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
// @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,0 +1,114 @@
|
||||
// @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 || {}),
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
import { download } from '@/util/download';
|
||||
import { request } from 'umi';
|
||||
|
||||
export async function user(params?: { [key: string]: string | number }) {
|
||||
const { current, pageSize, ...rest } = params ?? {};
|
||||
const result = await request<SYSTEM.Page<SYSTEM.User>>('/api-user/users', {
|
||||
method: 'GET',
|
||||
params: { page: current, limit: pageSize, ...rest },
|
||||
});
|
||||
return { data: result.data, total: result.count };
|
||||
}
|
||||
|
||||
export async function role() {
|
||||
const result = await request<SYSTEM.Page<SYSTEM.Role>>('/api-user/roles', {
|
||||
method: 'GET',
|
||||
});
|
||||
return result.data;
|
||||
}
|
||||
|
||||
export async function pageRole(params?: { [key: string]: string | number }) {
|
||||
const { current, pageSize, ...rest } = params ?? {};
|
||||
const result = await request<SYSTEM.Page<SYSTEM.Role>>('/api-user/roles', {
|
||||
method: 'GET',
|
||||
params: { page: current, limit: pageSize, ...rest },
|
||||
});
|
||||
return { data: result.data, total: result.count };
|
||||
}
|
||||
|
||||
export async function menuForAuth(roleId: number, tenantId: string) {
|
||||
const url = `/api-user/menus/${roleId}/menus`;
|
||||
const result = await request<SYSTEM.Menu[]>(url, {
|
||||
method: 'GET',
|
||||
params: { tenantId },
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
export function exportUser(params?: { [key: string]: string | number }) {
|
||||
return request('/api-user/users/export', {
|
||||
method: 'POST',
|
||||
params,
|
||||
responseType: 'blob',
|
||||
}).then((res) => {
|
||||
const blob = new Blob([res]);
|
||||
const objectURL = URL.createObjectURL(blob);
|
||||
let btn = document.createElement('a');
|
||||
btn.download = 'user.xls';
|
||||
btn.href = objectURL;
|
||||
btn.click();
|
||||
URL.revokeObjectURL(objectURL);
|
||||
});
|
||||
}
|
||||
|
||||
export async function token(params?: { [key: string]: string | number }) {
|
||||
const { current, pageSize, ...rest } = params ?? {};
|
||||
const result = await request<SYSTEM.Page<SYSTEM.Token>>('/api-uaa/tokens', {
|
||||
method: 'GET',
|
||||
params: { page: current, limit: pageSize, ...rest },
|
||||
});
|
||||
return { data: result.data, total: result.count };
|
||||
}
|
||||
|
||||
export async function app(params?: { [key: string]: string | number }) {
|
||||
const { current, pageSize, ...rest } = params ?? {};
|
||||
const result = await request<SYSTEM.Page<SYSTEM.App>>('/api-uaa/clients/list', {
|
||||
method: 'GET',
|
||||
params: { page: current, limit: pageSize, ...rest },
|
||||
});
|
||||
return { data: result.data, total: result.count };
|
||||
}
|
||||
|
||||
export async function generator(params?: { [key: string]: string | number }) {
|
||||
const { current, pageSize, ...rest } = params ?? {};
|
||||
const result = await request<SYSTEM.Page<SYSTEM.Generator>>('/api-generator/generator/list', {
|
||||
method: 'GET',
|
||||
params: { page: current, limit: pageSize, ...rest },
|
||||
});
|
||||
return { data: result.data, total: result.count };
|
||||
}
|
||||
|
||||
export function exportGenerator(tables: string) {
|
||||
return request('/api-generator/generator/code', {
|
||||
method: 'GET',
|
||||
params: { tables },
|
||||
responseType: 'blob',
|
||||
getResponse: true,
|
||||
}).then((res) => {
|
||||
download(res);
|
||||
});
|
||||
}
|
||||
|
||||
export async function menu(params: { [key: string]: string | number }) {
|
||||
const result = await request<SYSTEM.Page<SYSTEM.Menu>>('/api-user/menus/findAlls', {
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
return result.data;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
// API 更新时间:
|
||||
// API 唯一标识:
|
||||
import * as api from './api';
|
||||
export default {
|
||||
api,
|
||||
};
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
|
||||
declare namespace SYSTEM {
|
||||
type Page<T> = {
|
||||
code?: number;
|
||||
count?: number;
|
||||
data?: T[];
|
||||
};
|
||||
|
||||
type Role = {
|
||||
id: number;
|
||||
createTime?: Date;
|
||||
updateTime?: Date;
|
||||
code: string;
|
||||
name: string;
|
||||
userId?: string;
|
||||
};
|
||||
|
||||
type User = {
|
||||
id?: number;
|
||||
username?: string;
|
||||
nickname?: string;
|
||||
headImgUrl?: string;
|
||||
sex?: number;
|
||||
type?: string;
|
||||
mobile?: string;
|
||||
createTime?: Date;
|
||||
enabled?: boolean;
|
||||
del?: boolean;
|
||||
roles?: Role[];
|
||||
};
|
||||
|
||||
type Menu = {
|
||||
id: number;
|
||||
name?: string;
|
||||
pId?: number;
|
||||
parentId?: number;
|
||||
url?: string;
|
||||
type?: number;
|
||||
css?: string;
|
||||
checked?: boolean;
|
||||
open?: boolean;
|
||||
sort?: number;
|
||||
children?: Menu[];
|
||||
};
|
||||
|
||||
type Token = {
|
||||
accountType?: string;
|
||||
clientId?: string;
|
||||
expiration?: Date;
|
||||
grantType?: string;
|
||||
tokenValue?: string;
|
||||
username?: string;
|
||||
};
|
||||
|
||||
type App = {
|
||||
id: number;
|
||||
accessTokenValiditySeconds?: number;
|
||||
additionalInformation?: string;
|
||||
authorities?: string;
|
||||
authorizedGrantTypes?: string;
|
||||
autoapprove?: string;
|
||||
clientId?: string;
|
||||
clientName?: string;
|
||||
clientSecret?: string;
|
||||
clientSecretStr?: string;
|
||||
createTime?: Date;
|
||||
idTokenValiditySeconds?: number;
|
||||
refreshTokenValiditySeconds?: number;
|
||||
resourceIds?: string;
|
||||
scope?: string;
|
||||
supportIdToken?: boolean;
|
||||
updateTime?: Date;
|
||||
webServerRedirectUri?: string;
|
||||
};
|
||||
|
||||
type Generator = {
|
||||
createTime?: Date;
|
||||
engine?: string;
|
||||
tableComment?: string;
|
||||
tableName?: string;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
import { request } from 'umi';
|
||||
|
||||
export async function statistic() {
|
||||
return request<WELCOME.Statistic>('/api-log/requestStat', {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
// API 更新时间:
|
||||
// API 唯一标识:
|
||||
import * as api from './api';
|
||||
export default {
|
||||
api,
|
||||
};
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
|
||||
declare namespace WELCOME {
|
||||
type Browser = {
|
||||
name?: number;
|
||||
value?: string;
|
||||
};
|
||||
|
||||
type Statistic = {
|
||||
browser_datas?: Browser[];
|
||||
browser_legendData?: string[];
|
||||
currDate_pv?: number;
|
||||
currDate_uv?: number;
|
||||
currHour_uv?: number;
|
||||
currMonth_pv?: number;
|
||||
currWeek_pv?: number;
|
||||
|
||||
operatingSystem_datas?: Browser[];
|
||||
operatingSystem_legendData?: string[];
|
||||
statDate_items?: Date[];
|
||||
statDate_pv?: number[];
|
||||
statDate_uv?: number[];
|
||||
statWeek_items?: Date[];
|
||||
statWeek_pv?: number[];
|
||||
statWeek_uv?: number[];
|
||||
};
|
||||
|
||||
type AreaData = {
|
||||
type: string;
|
||||
date: Date;
|
||||
value: number;
|
||||
};
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
declare module 'slash2';
|
||||
declare module '*.css';
|
||||
declare module '*.less';
|
||||
declare module '*.scss';
|
||||
declare module '*.sass';
|
||||
declare module '*.svg';
|
||||
declare module '*.png';
|
||||
declare module '*.jpg';
|
||||
declare module '*.jpeg';
|
||||
declare module '*.gif';
|
||||
declare module '*.bmp';
|
||||
declare module '*.tiff';
|
||||
declare module 'omit.js';
|
||||
declare module 'numeral';
|
||||
declare module '@antv/data-set';
|
||||
declare module 'mockjs';
|
||||
declare module 'react-fittext';
|
||||
declare module 'bizcharts-plugin-slider';
|
||||
declare module 'treeify-js';
|
||||
|
||||
// preview.pro.ant.design only do not use in your production ;
|
||||
// preview.pro.ant.design Dedicated environment variable, please do not use it in your project.
|
||||
declare let ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: 'site' | undefined;
|
||||
|
||||
declare const REACT_APP_ENV: 'test' | 'dev' | 'pre' | false;
|
||||
@@ -0,0 +1,26 @@
|
||||
import type { RequestResponse } from 'umi-request';
|
||||
|
||||
export function download(res: RequestResponse): void {
|
||||
const blob = new Blob([res.data]); //type是文件类,详情可以参阅blob文件类型
|
||||
// 创建新的URL并指向File对象或者Blob对象的地址
|
||||
const blobURL = window.URL.createObjectURL(blob);
|
||||
// 创建a标签,用于跳转至下载链接
|
||||
const tempLink = document.createElement('a');
|
||||
tempLink.style.display = 'none';
|
||||
tempLink.href = blobURL;
|
||||
const disposition = res.response.headers.get('content-disposition');
|
||||
const temp: string = disposition ? disposition.split(';')[1].split('=')[1] : 'unkown';
|
||||
const filename = temp.substring(1, temp.length - 1);
|
||||
|
||||
tempLink.setAttribute('download', filename);
|
||||
// 兼容:某些浏览器不支持HTML5的download属性
|
||||
if (typeof tempLink.download === 'undefined') {
|
||||
tempLink.setAttribute('target', '_blank');
|
||||
}
|
||||
// 挂载a标签
|
||||
document.body.appendChild(tempLink);
|
||||
tempLink.click();
|
||||
document.body.removeChild(tempLink);
|
||||
// 释放blob URL地址
|
||||
window.URL.revokeObjectURL(blobURL);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
type Configure = {
|
||||
id: string;
|
||||
parentId: string;
|
||||
};
|
||||
|
||||
type Tree<T> = T & {
|
||||
children?: Tree<T>[];
|
||||
};
|
||||
|
||||
export function treeify<T>(data: T[], configure: Partial<Configure>): Tree<T>[] {
|
||||
const config: Configure = Object.assign(
|
||||
{
|
||||
id: 'id',
|
||||
parentId: 'parentId',
|
||||
},
|
||||
configure,
|
||||
);
|
||||
|
||||
const disposable = {}; // an object which is temp used.
|
||||
|
||||
const roots: Tree<T>[] = []; // Root node
|
||||
const setRoots = (el: Tree<T>) => {
|
||||
roots.push(el);
|
||||
};
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const el = data[i];
|
||||
const id = el[config.id];
|
||||
const parentId = el[config.parentId];
|
||||
|
||||
if (!(id in disposable)) {
|
||||
disposable[id] = [];
|
||||
}
|
||||
|
||||
if (!(parentId in disposable)) {
|
||||
disposable[parentId] = [];
|
||||
}
|
||||
|
||||
el.children = disposable[id];
|
||||
disposable[parentId].push(el);
|
||||
if (parentId == -1) setRoots(el);
|
||||
}
|
||||
|
||||
return roots;
|
||||
}
|
||||
Reference in New Issue
Block a user