Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
知鸟1号
ant-design-pro
提交
d6b8e7aa
A
ant-design-pro
项目概览
知鸟1号
/
ant-design-pro
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ant-design-pro
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
d6b8e7aa
编写于
12月 20, 2020
作者:
陈
陈帅
提交者:
GitHub
12月 21, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: better lint style (#7799)
* better lint style * fix ts
上级
556b04c4
变更
29
显示空白变更内容
内联
并排
Showing
29 changed file
with
206 addition
and
176 deletion
+206
-176
src/components/Authorized/Authorized.tsx
src/components/Authorized/Authorized.tsx
+6
-6
src/components/Authorized/AuthorizedRoute.tsx
src/components/Authorized/AuthorizedRoute.tsx
+3
-3
src/components/Authorized/PromiseRender.tsx
src/components/Authorized/PromiseRender.tsx
+10
-7
src/components/GlobalHeader/AvatarDropdown.tsx
src/components/GlobalHeader/AvatarDropdown.tsx
+6
-5
src/components/GlobalHeader/NoticeIconView.tsx
src/components/GlobalHeader/NoticeIconView.tsx
+10
-13
src/components/GlobalHeader/RightContent.tsx
src/components/GlobalHeader/RightContent.tsx
+7
-5
src/components/HeaderDropdown/index.tsx
src/components/HeaderDropdown/index.tsx
+4
-6
src/components/HeaderSearch/index.tsx
src/components/HeaderSearch/index.tsx
+4
-4
src/components/NoticeIcon/NoticeList.tsx
src/components/NoticeIcon/NoticeList.tsx
+6
-4
src/components/NoticeIcon/index.tsx
src/components/NoticeIcon/index.tsx
+15
-8
src/global.tsx
src/global.tsx
+1
-1
src/layouts/BasicLayout.tsx
src/layouts/BasicLayout.tsx
+9
-12
src/layouts/SecurityLayout.tsx
src/layouts/SecurityLayout.tsx
+8
-7
src/layouts/UserLayout.tsx
src/layouts/UserLayout.tsx
+8
-8
src/models/connect.d.ts
src/models/connect.d.ts
+9
-9
src/models/global.ts
src/models/global.ts
+9
-9
src/models/login.ts
src/models/login.ts
+6
-5
src/models/setting.ts
src/models/setting.ts
+5
-4
src/models/user.ts
src/models/user.ts
+7
-7
src/pages/404.tsx
src/pages/404.tsx
+1
-1
src/pages/ListTableList/components/UpdateForm.tsx
src/pages/ListTableList/components/UpdateForm.tsx
+8
-6
src/pages/ListTableList/data.d.ts
src/pages/ListTableList/data.d.ts
+10
-10
src/pages/ListTableList/index.tsx
src/pages/ListTableList/index.tsx
+18
-7
src/pages/ListTableList/service.ts
src/pages/ListTableList/service.ts
+1
-1
src/pages/Welcome.tsx
src/pages/Welcome.tsx
+1
-1
src/pages/user/login/index.tsx
src/pages/user/login/index.tsx
+22
-18
src/service-worker.js
src/service-worker.js
+6
-4
src/services/login.ts
src/services/login.ts
+2
-2
src/typings.d.ts
src/typings.d.ts
+4
-3
未找到文件。
src/components/Authorized/Authorized.tsx
浏览文件 @
d6b8e7aa
import
React
from
'
react
'
;
import
{
Result
}
from
'
antd
'
;
import
check
,
{
IAuthorityType
}
from
'
./CheckPermissions
'
;
import
check
from
'
./CheckPermissions
'
;
import
type
{
IAuthorityType
}
from
'
./CheckPermissions
'
;
import
type
AuthorizedRoute
from
'
./AuthorizedRoute
'
;
import
type
Secured
from
'
./Secured
'
;
import
AuthorizedRoute
from
'
./AuthorizedRoute
'
;
import
Secured
from
'
./Secured
'
;
interface
AuthorizedProps
{
type
AuthorizedProps
=
{
authority
:
IAuthorityType
;
noMatch
?:
React
.
ReactNode
;
}
}
;
type
IAuthorizedType
=
React
.
FunctionComponent
<
AuthorizedProps
>
&
{
Secured
:
typeof
Secured
;
...
...
src/components/Authorized/AuthorizedRoute.tsx
浏览文件 @
d6b8e7aa
...
...
@@ -2,15 +2,15 @@ import { Redirect, Route } from 'umi';
import
React
from
'
react
'
;
import
Authorized
from
'
./Authorized
'
;
import
{
IAuthorityType
}
from
'
./CheckPermissions
'
;
import
type
{
IAuthorityType
}
from
'
./CheckPermissions
'
;
interface
AuthorizedRouteProps
{
type
AuthorizedRouteProps
=
{
currentAuthority
:
string
;
component
:
React
.
ComponentClass
<
any
,
any
>
;
render
:
(
props
:
any
)
=>
React
.
ReactNode
;
redirectPath
:
string
;
authority
:
IAuthorityType
;
}
}
;
const
AuthorizedRoute
:
React
.
SFC
<
AuthorizedRouteProps
>
=
({
component
:
Component
,
...
...
src/components/Authorized/PromiseRender.tsx
浏览文件 @
d6b8e7aa
...
...
@@ -4,15 +4,15 @@ import isEqual from 'lodash/isEqual';
import
{
isComponentClass
}
from
'
./Secured
'
;
// eslint-disable-next-line import/no-cycle
interface
PromiseRenderProps
<
T
,
K
>
{
type
PromiseRenderProps
<
T
,
K
>
=
{
ok
:
T
;
error
:
K
;
promise
:
Promise
<
boolean
>
;
}
}
;
interface
PromiseRenderState
{
type
PromiseRenderState
=
{
component
:
React
.
ComponentClass
|
React
.
FunctionComponent
;
}
}
;
export
default
class
PromiseRender
<
T
,
K
>
extends
React
.
Component
<
PromiseRenderProps
<
T
,
K
>
,
...
...
@@ -22,11 +22,14 @@ export default class PromiseRender<T, K> extends React.Component<
component
:
()
=>
null
,
};
componentDidMount
()
{
componentDidMount
()
:
void
{
this
.
setRenderComponent
(
this
.
props
);
}
shouldComponentUpdate
=
(
nextProps
:
PromiseRenderProps
<
T
,
K
>
,
nextState
:
PromiseRenderState
)
=>
{
shouldComponentUpdate
=
(
nextProps
:
PromiseRenderProps
<
T
,
K
>
,
nextState
:
PromiseRenderState
,
):
boolean
=>
{
const
{
component
}
=
this
.
state
;
if
(
!
isEqual
(
nextProps
,
this
.
props
))
{
this
.
setRenderComponent
(
nextProps
);
...
...
@@ -36,7 +39,7 @@ export default class PromiseRender<T, K> extends React.Component<
};
// set render Component : ok or error
setRenderComponent
(
props
:
PromiseRenderProps
<
T
,
K
>
)
{
setRenderComponent
(
props
:
PromiseRenderProps
<
T
,
K
>
)
:
void
{
const
ok
=
this
.
checkIsInstantiation
(
props
.
ok
);
const
error
=
this
.
checkIsInstantiation
(
props
.
error
);
props
.
promise
...
...
src/components/GlobalHeader/AvatarDropdown.tsx
浏览文件 @
d6b8e7aa
import
{
LogoutOutlined
,
SettingOutlined
,
UserOutlined
}
from
'
@ant-design/icons
'
;
import
{
Avatar
,
Menu
,
Spin
}
from
'
antd
'
;
import
React
from
'
react
'
;
import
{
history
,
ConnectProps
,
connect
}
from
'
umi
'
;
import
{
ConnectState
}
from
'
@/models/connect
'
;
import
{
CurrentUser
}
from
'
@/models/user
'
;
import
type
{
ConnectProps
}
from
'
umi
'
;
import
{
history
,
connect
}
from
'
umi
'
;
import
type
{
ConnectState
}
from
'
@/models/connect
'
;
import
type
{
CurrentUser
}
from
'
@/models/user
'
;
import
HeaderDropdown
from
'
../HeaderDropdown
'
;
import
styles
from
'
./index.less
'
;
export
interface
GlobalHeaderRightProps
extends
Partial
<
ConnectProps
>
{
export
type
GlobalHeaderRightProps
=
{
currentUser
?:
CurrentUser
;
menu
?:
boolean
;
}
}
&
Partial
<
ConnectProps
>
;
class
AvatarDropdown
extends
React
.
Component
<
GlobalHeaderRightProps
>
{
onMenuClick
=
(
event
:
{
...
...
src/components/GlobalHeader/NoticeIconView.tsx
浏览文件 @
d6b8e7aa
import
React
,
{
Component
}
from
'
react
'
;
import
{
connect
,
ConnectProps
}
from
'
umi
'
;
import
type
{
ConnectProps
}
from
'
umi
'
;
import
{
connect
}
from
'
umi
'
;
import
{
Tag
,
message
}
from
'
antd
'
;
import
groupBy
from
'
lodash/groupBy
'
;
import
moment
from
'
moment
'
;
import
{
NoticeItem
}
from
'
@/models/global
'
;
import
{
CurrentUser
}
from
'
@/models/user
'
;
import
{
ConnectState
}
from
'
@/models/connect
'
;
import
type
{
NoticeItem
}
from
'
@/models/global
'
;
import
type
{
CurrentUser
}
from
'
@/models/user
'
;
import
type
{
ConnectState
}
from
'
@/models/connect
'
;
import
NoticeIcon
from
'
../NoticeIcon
'
;
import
styles
from
'
./index.less
'
;
export
interface
GlobalHeaderRightProps
extends
Partial
<
ConnectProps
>
{
export
type
GlobalHeaderRightProps
=
{
notices
?:
NoticeItem
[];
currentUser
?:
CurrentUser
;
fetchingNotices
?:
boolean
;
onNoticeVisibleChange
?:
(
visible
:
boolean
)
=>
void
;
onNoticeClear
?:
(
tabName
?:
string
)
=>
void
;
}
}
&
Partial
<
ConnectProps
>
;
class
GlobalHeaderRight
extends
Component
<
GlobalHeaderRightProps
>
{
componentDidMount
()
{
...
...
@@ -52,9 +53,7 @@ class GlobalHeaderRight extends Component<GlobalHeaderRightProps> {
}
};
getNoticeData
=
():
{
[
key
:
string
]:
NoticeItem
[];
}
=>
{
getNoticeData
=
():
Record
<
string
,
NoticeItem
[]
>
=>
{
const
{
notices
=
[]
}
=
this
.
props
;
if
(
!
notices
||
notices
.
length
===
0
||
!
Array
.
isArray
(
notices
))
{
...
...
@@ -96,10 +95,8 @@ class GlobalHeaderRight extends Component<GlobalHeaderRightProps> {
return
groupBy
(
newNotices
,
'
type
'
);
};
getUnreadData
=
(
noticeData
:
{
[
key
:
string
]:
NoticeItem
[]
})
=>
{
const
unreadMsg
:
{
[
key
:
string
]:
number
;
}
=
{};
getUnreadData
=
(
noticeData
:
Record
<
string
,
NoticeItem
[]
>
)
=>
{
const
unreadMsg
:
Record
<
string
,
number
>
=
{};
Object
.
keys
(
noticeData
).
forEach
((
key
)
=>
{
const
value
=
noticeData
[
key
];
...
...
src/components/GlobalHeader/RightContent.tsx
浏览文件 @
d6b8e7aa
import
{
Tooltip
,
Tag
}
from
'
antd
'
;
import
{
Settings
as
ProSettings
}
from
'
@ant-design/pro-layout
'
;
import
type
{
Settings
as
ProSettings
}
from
'
@ant-design/pro-layout
'
;
import
{
QuestionCircleOutlined
}
from
'
@ant-design/icons
'
;
import
React
from
'
react
'
;
import
{
connect
,
ConnectProps
,
SelectLang
}
from
'
umi
'
;
import
{
ConnectState
}
from
'
@/models/connect
'
;
import
type
{
ConnectProps
}
from
'
umi
'
;
import
{
connect
,
SelectLang
}
from
'
umi
'
;
import
type
{
ConnectState
}
from
'
@/models/connect
'
;
import
Avatar
from
'
./AvatarDropdown
'
;
import
HeaderSearch
from
'
../HeaderSearch
'
;
import
styles
from
'
./index.less
'
;
export
interface
GlobalHeaderRightProps
extends
Partial
<
ConnectProps
>
,
Partial
<
ProSettings
>
{
export
type
GlobalHeaderRightProps
=
{
theme
?:
ProSettings
[
'
navTheme
'
]
|
'
realDark
'
;
}
}
&
Partial
<
ConnectProps
>
&
Partial
<
ProSettings
>
;
const
ENVTagColor
=
{
dev
:
'
orange
'
,
...
...
src/components/HeaderDropdown/index.tsx
浏览文件 @
d6b8e7aa
import
{
DropDownProps
}
from
'
antd/es/dropdown
'
;
import
type
{
DropDownProps
}
from
'
antd/es/dropdown
'
;
import
{
Dropdown
}
from
'
antd
'
;
import
React
from
'
react
'
;
import
classNames
from
'
classnames
'
;
import
styles
from
'
./index.less
'
;
declare
type
OverlayFunc
=
()
=>
React
.
ReactNode
;
export
interface
HeaderDropdownProps
extends
Omit
<
DropDownProps
,
'
overlay
'
>
{
export
type
HeaderDropdownProps
=
{
overlayClassName
?:
string
;
overlay
:
React
.
ReactNode
|
OverlayFunc
|
any
;
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
}
/>
...
...
src/components/HeaderSearch/index.tsx
浏览文件 @
d6b8e7aa
import
{
SearchOutlined
}
from
'
@ant-design/icons
'
;
import
{
AutoComplete
,
Input
}
from
'
antd
'
;
import
useMergeValue
from
'
use-merge-value
'
;
import
{
AutoCompleteProps
}
from
'
antd/es/auto-complete
'
;
import
type
{
AutoCompleteProps
}
from
'
antd/es/auto-complete
'
;
import
React
,
{
useRef
}
from
'
react
'
;
import
classNames
from
'
classnames
'
;
import
styles
from
'
./index.less
'
;
export
interface
HeaderSearchProps
{
export
type
HeaderSearchProps
=
{
onSearch
?:
(
value
?:
string
)
=>
void
;
onChange
?:
(
value
?:
string
)
=>
void
;
onVisibleChange
?:
(
b
:
boolean
)
=>
void
;
...
...
@@ -18,7 +18,7 @@ export interface HeaderSearchProps {
open
?:
boolean
;
defaultValue
?:
string
;
value
?:
string
;
}
}
;
const
HeaderSearch
:
React
.
FC
<
HeaderSearchProps
>
=
(
props
)
=>
{
const
{
...
...
@@ -38,7 +38,7 @@ const HeaderSearch: React.FC<HeaderSearchProps> = (props) => {
onChange
:
props
.
onChange
,
});
const
[
searchMode
,
setSearchMode
]
=
useMergeValue
(
defaultOpen
||
false
,
{
const
[
searchMode
,
setSearchMode
]
=
useMergeValue
(
defaultOpen
??
false
,
{
value
:
props
.
open
,
onChange
:
onVisibleChange
,
});
...
...
src/components/NoticeIcon/NoticeList.tsx
浏览文件 @
d6b8e7aa
...
...
@@ -2,10 +2,10 @@ import { Avatar, List } from 'antd';
import
React
from
'
react
'
;
import
classNames
from
'
classnames
'
;
import
{
NoticeIconData
}
from
'
./index
'
;
import
type
{
NoticeIconData
}
from
'
./index
'
;
import
styles
from
'
./NoticeList.less
'
;
export
interface
NoticeIconTabProps
{
export
type
NoticeIconTabProps
=
{
count
?:
number
;
name
?:
string
;
showClear
?:
boolean
;
...
...
@@ -21,7 +21,7 @@ export interface NoticeIconTabProps {
viewMoreText
?:
string
;
list
:
NoticeIconData
[];
onViewMore
?:
(
e
:
any
)
=>
void
;
}
}
;
const
NoticeList
:
React
.
SFC
<
NoticeIconTabProps
>
=
({
data
=
[],
onClick
,
...
...
@@ -67,7 +67,9 @@ const NoticeList: React.SFC<NoticeIconTabProps> = ({
<
List
.
Item
className
=
{
itemCls
}
key
=
{
item
.
key
||
i
}
onClick
=
{
()
=>
onClick
&&
onClick
(
item
)
}
onClick
=
{
()
=>
{
onClick
?.(
item
);
}
}
>
<
List
.
Item
.
Meta
className
=
{
styles
.
meta
}
...
...
src/components/NoticeIcon/index.tsx
浏览文件 @
d6b8e7aa
...
...
@@ -3,14 +3,15 @@ import { Badge, Spin, Tabs } from 'antd';
import
useMergeValue
from
'
use-merge-value
'
;
import
React
from
'
react
'
;
import
classNames
from
'
classnames
'
;
import
NoticeList
,
{
NoticeIconTabProps
}
from
'
./NoticeList
'
;
import
type
{
NoticeIconTabProps
}
from
'
./NoticeList
'
;
import
NoticeList
from
'
./NoticeList
'
;
import
HeaderDropdown
from
'
../HeaderDropdown
'
;
import
styles
from
'
./index.less
'
;
const
{
TabPane
}
=
Tabs
;
export
interface
NoticeIconData
{
export
type
NoticeIconData
=
{
avatar
?:
string
|
React
.
ReactNode
;
title
?:
React
.
ReactNode
;
description
?:
React
.
ReactNode
;
...
...
@@ -19,9 +20,9 @@ export interface NoticeIconData {
style
?:
React
.
CSSProperties
;
key
?:
string
|
number
;
read
?:
boolean
;
}
}
;
export
interface
NoticeIconProps
{
export
type
NoticeIconProps
=
{
count
?:
number
;
bell
?:
React
.
ReactNode
;
className
?:
string
;
...
...
@@ -38,7 +39,7 @@ export interface NoticeIconProps {
clearClose
?:
boolean
;
emptyImage
?:
string
;
children
:
React
.
ReactElement
<
NoticeIconTabProps
>
[];
}
}
;
const
NoticeIcon
:
React
.
FC
<
NoticeIconProps
>
&
{
Tab
:
typeof
NoticeList
;
...
...
@@ -73,9 +74,15 @@ const NoticeIcon: React.FC<NoticeIconProps> & {
clearText
=
{
clearText
}
viewMoreText
=
{
viewMoreText
}
data
=
{
list
}
onClear
=
{
():
void
=>
onClear
&&
onClear
(
title
,
tabKey
)
}
onClick
=
{
(
item
):
void
=>
onItemClick
&&
onItemClick
(
item
,
child
.
props
)
}
onViewMore
=
{
(
event
):
void
=>
onViewMore
&&
onViewMore
(
child
.
props
,
event
)
}
onClear
=
{
():
void
=>
{
onClear
?.(
title
,
tabKey
);
}
}
onClick
=
{
(
item
):
void
=>
{
onItemClick
?.(
item
,
child
.
props
);
}
}
onViewMore
=
{
(
event
):
void
=>
{
onViewMore
?.(
child
.
props
,
event
);
}
}
showClear
=
{
showClear
}
showViewMore
=
{
showViewMore
}
title
=
{
title
}
...
...
src/global.tsx
浏览文件 @
d6b8e7aa
...
...
@@ -57,7 +57,7 @@ if (pwa) {
description
:
useIntl
().
formatMessage
({
id
:
'
app.pwa.serviceworker.updated.hint
'
}),
btn
,
key
,
onClose
:
async
()
=>
{}
,
onClose
:
async
()
=>
null
,
});
});
}
else
if
(
'
serviceWorker
'
in
navigator
&&
isHttps
)
{
...
...
src/layouts/BasicLayout.tsx
浏览文件 @
d6b8e7aa
...
...
@@ -3,19 +3,20 @@
* You can view component api by:
* https://github.com/ant-design/ant-design-pro-layout
*/
import
ProLayout
,
{
import
type
{
MenuDataItem
,
BasicLayoutProps
as
ProLayoutProps
,
Settings
,
DefaultFooter
,
}
from
'
@ant-design/pro-layout
'
;
import
ProLayout
,
{
DefaultFooter
}
from
'
@ant-design/pro-layout
'
;
import
React
,
{
useEffect
,
useMemo
,
useRef
}
from
'
react
'
;
import
{
Link
,
useIntl
,
connect
,
Dispatch
,
history
}
from
'
umi
'
;
import
type
{
Dispatch
}
from
'
umi
'
;
import
{
Link
,
useIntl
,
connect
,
history
}
from
'
umi
'
;
import
{
GithubOutlined
}
from
'
@ant-design/icons
'
;
import
{
Result
,
Button
}
from
'
antd
'
;
import
Authorized
from
'
@/utils/Authorized
'
;
import
RightContent
from
'
@/components/GlobalHeader/RightContent
'
;
import
{
ConnectState
}
from
'
@/models/connect
'
;
import
type
{
ConnectState
}
from
'
@/models/connect
'
;
import
{
getMatchMenu
}
from
'
@umijs/route-utils
'
;
import
logo
from
'
../assets/logo.svg
'
;
...
...
@@ -31,20 +32,16 @@ const noMatch = (
}
/>
);
export
interface
BasicLayoutProps
extends
ProLayoutProps
{
breadcrumbNameMap
:
{
[
path
:
string
]:
MenuDataItem
;
};
export
type
BasicLayoutProps
=
{
breadcrumbNameMap
:
Record
<
string
,
MenuDataItem
>
;
route
:
ProLayoutProps
[
'
route
'
]
&
{
authority
:
string
[];
};
settings
:
Settings
;
dispatch
:
Dispatch
;
}
}
&
ProLayoutProps
;
export
type
BasicLayoutContext
=
{
[
K
in
'
location
'
]:
BasicLayoutProps
[
K
]
}
&
{
breadcrumbNameMap
:
{
[
path
:
string
]:
MenuDataItem
;
};
breadcrumbNameMap
:
Record
<
string
,
MenuDataItem
>
;
};
/**
* use Authorized check all menu item
...
...
src/layouts/SecurityLayout.tsx
浏览文件 @
d6b8e7aa
import
React
from
'
react
'
;
import
{
PageLoading
}
from
'
@ant-design/pro-layout
'
;
import
{
Redirect
,
connect
,
ConnectProps
}
from
'
umi
'
;
import
type
{
ConnectProps
}
from
'
umi
'
;
import
{
Redirect
,
connect
}
from
'
umi
'
;
import
{
stringify
}
from
'
querystring
'
;
import
{
ConnectState
}
from
'
@/models/connect
'
;
import
{
CurrentUser
}
from
'
@/models/user
'
;
import
type
{
ConnectState
}
from
'
@/models/connect
'
;
import
type
{
CurrentUser
}
from
'
@/models/user
'
;
interface
SecurityLayoutProps
extends
ConnectProps
{
type
SecurityLayoutProps
=
{
loading
?:
boolean
;
currentUser
?:
CurrentUser
;
}
}
&
ConnectProps
;
interface
SecurityLayoutState
{
type
SecurityLayoutState
=
{
isReady
:
boolean
;
}
}
;
class
SecurityLayout
extends
React
.
Component
<
SecurityLayoutProps
,
SecurityLayoutState
>
{
state
:
SecurityLayoutState
=
{
...
...
src/layouts/UserLayout.tsx
浏览文件 @
d6b8e7aa
import
{
DefaultFooter
,
MenuDataItem
,
getMenuData
,
getPageTitle
}
from
'
@ant-design/pro-layout
'
;
import
type
{
MenuDataItem
}
from
'
@ant-design/pro-layout
'
;
import
{
DefaultFooter
,
getMenuData
,
getPageTitle
}
from
'
@ant-design/pro-layout
'
;
import
{
Helmet
,
HelmetProvider
}
from
'
react-helmet-async
'
;
import
{
Link
,
SelectLang
,
useIntl
,
ConnectProps
,
connect
,
FormattedMessage
}
from
'
umi
'
;
import
type
{
ConnectProps
}
from
'
umi
'
;
import
{
Link
,
SelectLang
,
useIntl
,
connect
,
FormattedMessage
}
from
'
umi
'
;
import
React
from
'
react
'
;
import
{
ConnectState
}
from
'
@/models/connect
'
;
import
type
{
ConnectState
}
from
'
@/models/connect
'
;
import
logo
from
'
../assets/logo.svg
'
;
import
styles
from
'
./UserLayout.less
'
;
export
interface
UserLayoutProps
extends
Partial
<
ConnectProps
>
{
breadcrumbNameMap
:
{
[
path
:
string
]:
MenuDataItem
;
};
}
export
type
UserLayoutProps
=
{
breadcrumbNameMap
:
Record
<
string
,
MenuDataItem
>
;
}
&
Partial
<
ConnectProps
>
;
const
UserLayout
:
React
.
FC
<
UserLayoutProps
>
=
(
props
)
=>
{
const
{
...
...
src/models/connect.d.ts
浏览文件 @
d6b8e7aa
import
{
MenuDataItem
,
Settings
as
ProSettings
}
from
'
@ant-design/pro-layout
'
;
import
type
{
MenuDataItem
,
Settings
as
ProSettings
}
from
'
@ant-design/pro-layout
'
;
import
{
GlobalModelState
}
from
'
./global
'
;
import
{
UserModelState
}
from
'
./user
'
;
import
{
StateType
}
from
'
./login
'
;
import
type
{
StateType
}
from
'
./login
'
;
export
{
GlobalModelState
,
UserModelState
};
export
interface
Loading
{
export
type
Loading
=
{
global
:
boolean
;
effects
:
{
[
key
:
string
]:
boolean
|
undefined
}
;
effects
:
Record
<
string
,
boolean
|
undefined
>
;
models
:
{
global
?:
boolean
;
menu
?:
boolean
;
...
...
@@ -15,16 +15,16 @@ export interface Loading {
user
?:
boolean
;
login
?:
boolean
;
};
}
}
;
export
interface
ConnectState
{
export
type
ConnectState
=
{
global
:
GlobalModelState
;
loading
:
Loading
;
settings
:
ProSettings
;
user
:
UserModelState
;
login
:
StateType
;
}
}
;
export
interface
Route
extends
MenuDataItem
{
export
type
Route
=
{
routes
?:
Route
[];
}
}
&
MenuDataItem
;
src/models/global.ts
浏览文件 @
d6b8e7aa
import
{
Reducer
,
Effect
}
from
'
umi
'
;
import
type
{
Reducer
,
Effect
}
from
'
umi
'
;
import
{
NoticeIconData
}
from
'
@/components/NoticeIcon
'
;
import
type
{
NoticeIconData
}
from
'
@/components/NoticeIcon
'
;
import
{
queryNotices
}
from
'
@/services/user
'
;
import
{
ConnectState
}
from
'
./connect.d
'
;
import
type
{
ConnectState
}
from
'
./connect.d
'
;
export
interface
NoticeItem
extends
NoticeIconData
{
export
type
NoticeItem
=
{
id
:
string
;
type
:
string
;
status
:
string
;
}
}
&
NoticeIconData
;
export
interface
GlobalModelState
{
export
type
GlobalModelState
=
{
collapsed
:
boolean
;
notices
:
NoticeItem
[];
}
}
;
export
interface
GlobalModelType
{
export
type
GlobalModelType
=
{
namespace
:
'
global
'
;
state
:
GlobalModelState
;
effects
:
{
...
...
@@ -28,7 +28,7 @@ export interface GlobalModelType {
saveNotices
:
Reducer
<
GlobalModelState
>
;
saveClearedNotices
:
Reducer
<
GlobalModelState
>
;
};
}
}
;
const
GlobalModel
:
GlobalModelType
=
{
namespace
:
'
global
'
,
...
...
src/models/login.ts
浏览文件 @
d6b8e7aa
import
{
stringify
}
from
'
querystring
'
;
import
{
history
,
Reducer
,
Effect
}
from
'
umi
'
;
import
type
{
Reducer
,
Effect
}
from
'
umi
'
;
import
{
history
}
from
'
umi
'
;
import
{
fakeAccountLogin
}
from
'
@/services/login
'
;
import
{
setAuthority
}
from
'
@/utils/authority
'
;
import
{
getPageQuery
}
from
'
@/utils/utils
'
;
import
{
message
}
from
'
antd
'
;
export
interface
StateType
{
export
type
StateType
=
{
status
?:
'
ok
'
|
'
error
'
;
type
?:
string
;
currentAuthority
?:
'
user
'
|
'
guest
'
|
'
admin
'
;
}
}
;
export
interface
LoginModelType
{
export
type
LoginModelType
=
{
namespace
:
string
;
state
:
StateType
;
effects
:
{
...
...
@@ -22,7 +23,7 @@ export interface LoginModelType {
reducers
:
{
changeLoginStatus
:
Reducer
<
StateType
>
;
};
}
}
;
const
Model
:
LoginModelType
=
{
namespace
:
'
login
'
,
...
...
src/models/setting.ts
浏览文件 @
d6b8e7aa
import
{
Reducer
}
from
'
umi
'
;
import
defaultSettings
,
{
DefaultSettings
}
from
'
../../config/defaultSettings
'
;
import
type
{
Reducer
}
from
'
umi
'
;
import
type
{
DefaultSettings
}
from
'
../../config/defaultSettings
'
;
import
defaultSettings
from
'
../../config/defaultSettings
'
;
export
interface
SettingModelType
{
export
type
SettingModelType
=
{
namespace
:
'
settings
'
;
state
:
DefaultSettings
;
reducers
:
{
changeSetting
:
Reducer
<
DefaultSettings
>
;
};
}
}
;
const
updateColorWeak
:
(
colorWeak
:
boolean
)
=>
void
=
(
colorWeak
)
=>
{
const
root
=
document
.
getElementById
(
'
root
'
);
...
...
src/models/user.ts
浏览文件 @
d6b8e7aa
import
{
Effect
,
Reducer
}
from
'
umi
'
;
import
type
{
Effect
,
Reducer
}
from
'
umi
'
;
import
{
queryCurrent
,
query
as
queryUsers
}
from
'
@/services/user
'
;
export
interface
CurrentUser
{
export
type
CurrentUser
=
{
avatar
?:
string
;
name
?:
string
;
title
?:
string
;
...
...
@@ -14,13 +14,13 @@ export interface CurrentUser {
}[];
userid
?:
string
;
unreadCount
?:
number
;
}
}
;
export
interface
UserModelState
{
export
type
UserModelState
=
{
currentUser
?:
CurrentUser
;
}
}
;
export
interface
UserModelType
{
export
type
UserModelType
=
{
namespace
:
'
user
'
;
state
:
UserModelState
;
effects
:
{
...
...
@@ -31,7 +31,7 @@ export interface UserModelType {
saveCurrentUser
:
Reducer
<
UserModelState
>
;
changeNotifyCount
:
Reducer
<
UserModelState
>
;
};
}
}
;
const
UserModel
:
UserModelType
=
{
namespace
:
'
user
'
,
...
...
src/pages/404.tsx
浏览文件 @
d6b8e7aa
...
...
@@ -2,7 +2,7 @@ import { Button, Result } from 'antd';
import
React
from
'
react
'
;
import
{
history
}
from
'
umi
'
;
const
NoFoundPage
:
React
.
FC
<
{}
>
=
()
=>
(
const
NoFoundPage
:
React
.
FC
=
()
=>
(
<
Result
status
=
"404"
title
=
"404"
...
...
src/pages/ListTableList/components/UpdateForm.tsx
浏览文件 @
d6b8e7aa
...
...
@@ -10,22 +10,22 @@ import {
}
from
'
@ant-design/pro-form
'
;
import
{
useIntl
,
FormattedMessage
}
from
'
umi
'
;
import
{
TableListItem
}
from
'
../data.d
'
;
import
type
{
TableListItem
}
from
'
../data.d
'
;
export
interface
FormValueType
extends
Partial
<
TableListItem
>
{
export
type
FormValueType
=
{
target
?:
string
;
template
?:
string
;
type
?:
string
;
time
?:
string
;
frequency
?:
string
;
}
}
&
Partial
<
TableListItem
>
;
export
interface
UpdateFormProps
{
export
type
UpdateFormProps
=
{
onCancel
:
(
flag
?:
boolean
,
formVals
?:
FormValueType
)
=>
void
;
onSubmit
:
(
values
:
FormValueType
)
=>
Promise
<
void
>
;
updateModalVisible
:
boolean
;
values
:
Partial
<
TableListItem
>
;
}
}
;
const
UpdateForm
:
React
.
FC
<
UpdateFormProps
>
=
(
props
)
=>
{
const
intl
=
useIntl
();
...
...
@@ -46,7 +46,9 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
})
}
visible
=
{
props
.
updateModalVisible
}
footer
=
{
submitter
}
onCancel
=
{
()
=>
props
.
onCancel
()
}
onCancel
=
{
()
=>
{
props
.
onCancel
();
}
}
>
{
dom
}
</
Modal
>
...
...
src/pages/ListTableList/data.d.ts
浏览文件 @
d6b8e7aa
export
interface
TableListItem
{
export
type
TableListItem
=
{
key
:
number
;
disabled
?:
boolean
;
href
:
string
;
...
...
@@ -11,26 +11,26 @@ export interface TableListItem {
updatedAt
:
Date
;
createdAt
:
Date
;
progress
:
number
;
}
}
;
export
interface
TableListPagination
{
export
type
TableListPagination
=
{
total
:
number
;
pageSize
:
number
;
current
:
number
;
}
}
;
export
interface
TableListData
{
export
type
TableListData
=
{
list
:
TableListItem
[];
pagination
:
Partial
<
TableListPagination
>
;
}
}
;
export
interface
TableListParams
{
export
type
TableListParams
=
{
status
?:
string
;
name
?:
string
;
desc
?:
string
;
key
?:
number
;
pageSize
?:
number
;
currentPage
?:
number
;
filter
?:
{
[
key
:
string
]:
any
[]
}
;
sorter
?:
{
[
key
:
string
]:
any
}
;
}
filter
?:
Record
<
string
,
any
[]
>
;
sorter
?:
Record
<
string
,
any
>
;
}
;
src/pages/ListTableList/index.tsx
浏览文件 @
d6b8e7aa
...
...
@@ -3,11 +3,14 @@ import { Button, message, Input, Drawer } from 'antd';
import
React
,
{
useState
,
useRef
}
from
'
react
'
;
import
{
useIntl
,
FormattedMessage
}
from
'
umi
'
;
import
{
PageContainer
,
FooterToolbar
}
from
'
@ant-design/pro-layout
'
;
import
ProTable
,
{
ProColumns
,
ActionType
}
from
'
@ant-design/pro-table
'
;
import
type
{
ProColumns
,
ActionType
}
from
'
@ant-design/pro-table
'
;
import
ProTable
from
'
@ant-design/pro-table
'
;
import
{
ModalForm
,
ProFormText
,
ProFormTextArea
}
from
'
@ant-design/pro-form
'
;
import
ProDescriptions
,
{
ProDescriptionsItemProps
}
from
'
@ant-design/pro-descriptions
'
;
import
UpdateForm
,
{
FormValueType
}
from
'
./components/UpdateForm
'
;
import
{
TableListItem
}
from
'
./data.d
'
;
import
type
{
ProDescriptionsItemProps
}
from
'
@ant-design/pro-descriptions
'
;
import
ProDescriptions
from
'
@ant-design/pro-descriptions
'
;
import
type
{
FormValueType
}
from
'
./components/UpdateForm
'
;
import
UpdateForm
from
'
./components/UpdateForm
'
;
import
type
{
TableListItem
}
from
'
./data.d
'
;
import
{
queryRule
,
updateRule
,
addRule
,
removeRule
}
from
'
./service
'
;
/**
...
...
@@ -72,7 +75,7 @@ const handleRemove = async (selectedRows: TableListItem[]) => {
}
};
const
TableList
:
React
.
FC
<
{}
>
=
()
=>
{
const
TableList
:
React
.
FC
=
()
=>
{
/**
* 新建窗口的弹窗
*/
...
...
@@ -223,14 +226,22 @@ const TableList: React.FC<{}> = () => {
labelWidth
:
120
,
}
}
toolBarRender=
{
()
=>
[
<
Button
type
=
"primary"
key
=
"primary"
onClick
=
{
()
=>
handleModalVisible
(
true
)
}
>
<
Button
type
=
"primary"
key
=
"primary"
onClick
=
{
()
=>
{
handleModalVisible
(
true
);
}
}
>
<
PlusOutlined
/>
<
FormattedMessage
id
=
"pages.searchTable.new"
defaultMessage
=
"新建"
/>
</
Button
>,
]
}
request=
{
(
params
,
sorter
,
filter
)
=>
queryRule
({
...
params
,
sorter
,
filter
})
}
columns=
{
columns
}
rowSelection=
{
{
onChange
:
(
_
,
selectedRows
)
=>
setSelectedRows
(
selectedRows
),
onChange
:
(
_
,
selectedRows
)
=>
{
setSelectedRows
(
selectedRows
);
},
}
}
/>
{
selectedRowsState
?.
length
>
0
&&
(
...
...
src/pages/ListTableList/service.ts
浏览文件 @
d6b8e7aa
import
request
from
'
@/utils/request
'
;
import
{
TableListParams
,
TableListItem
}
from
'
./data.d
'
;
import
type
{
TableListParams
,
TableListItem
}
from
'
./data.d
'
;
export
async
function
queryRule
(
params
?:
TableListParams
)
{
return
request
(
'
/api/rule
'
,
{
...
...
src/pages/Welcome.tsx
浏览文件 @
d6b8e7aa
...
...
@@ -4,7 +4,7 @@ import { Card, Alert, Typography } from 'antd';
import
{
useIntl
,
FormattedMessage
}
from
'
umi
'
;
import
styles
from
'
./Welcome.less
'
;
const
CodePreview
:
React
.
FC
<
{}
>
=
({
children
})
=>
(
const
CodePreview
:
React
.
FC
=
({
children
})
=>
(
<
pre
className
=
{
styles
.
pre
}
>
<
code
>
<
Typography
.
Text
copyable
>
{
children
}
</
Typography
.
Text
>
...
...
src/pages/user/login/index.tsx
浏览文件 @
d6b8e7aa
...
...
@@ -10,18 +10,20 @@ import {
import
{
Alert
,
Space
,
message
,
Tabs
}
from
'
antd
'
;
import
React
,
{
useState
}
from
'
react
'
;
import
ProForm
,
{
ProFormCaptcha
,
ProFormCheckbox
,
ProFormText
}
from
'
@ant-design/pro-form
'
;
import
{
connect
,
Dispatch
,
useIntl
,
FormattedMessage
}
from
'
umi
'
;
import
{
StateType
}
from
'
@/models/login
'
;
import
{
getFakeCaptcha
,
LoginParamsType
}
from
'
@/services/login
'
;
import
{
ConnectState
}
from
'
@/models/connect
'
;
import
{
useIntl
,
connect
,
FormattedMessage
}
from
'
umi
'
;
import
{
getFakeCaptcha
}
from
'
@/services/login
'
;
import
type
{
Dispatch
}
from
'
umi
'
;
import
type
{
StateType
}
from
'
@/models/login
'
;
import
type
{
LoginParamsType
}
from
'
@/services/login
'
;
import
type
{
ConnectState
}
from
'
@/models/connect
'
;
import
styles
from
'
./index.less
'
;
interface
LoginProps
{
export
type
LoginProps
=
{
dispatch
:
Dispatch
;
userLogin
:
StateType
;
submitting
?:
boolean
;
}
}
;
const
LoginMessage
:
React
.
FC
<
{
content
:
string
;
...
...
@@ -65,8 +67,9 @@ const Login: React.FC<LoginProps> = (props) => {
},
},
}
}
onFinish
=
{
async
(
values
)
=>
{
onFinish
=
{
(
values
)
=>
{
handleSubmit
(
values
);
return
Promise
.
resolve
();
}
}
>
<
Tabs
activeKey
=
{
type
}
onChange
=
{
setType
}
>
...
...
@@ -191,17 +194,18 @@ const Login: React.FC<LoginProps> = (props) => {
id
:
'
pages.login.captcha.placeholder
'
,
defaultMessage
:
'
请输入验证码
'
,
})
}
captchaTextRender
=
{
(
timing
,
count
)
=>
timing
?
`
${
count
}
${
intl
.
formatMessage
({
captchaTextRender
=
{
(
timing
,
count
)
=>
{
if
(
timing
)
{
return
`
${
count
}
${
intl
.
formatMessage
({
id
:
'
pages.getCaptchaSecondText
'
,
defaultMessage
:
'
获取验证码
'
,
})}
`
:
intl
.
formatMessage
({
})}
`
;
}
return
intl
.
formatMessage
({
id
:
'
pages.login.phoneLogin.getVerificationCode
'
,
defaultMessage
:
'
获取验证码
'
,
})
}
});
}
}
name
=
"captcha"
rules
=
{
[
{
...
...
src/service-worker.js
浏览文件 @
d6b8e7aa
...
...
@@ -56,14 +56,16 @@ addEventListener('message', (event) => {
if
(
replyPort
&&
message
&&
message
.
type
===
'
skip-waiting
'
)
{
event
.
waitUntil
(
self
.
skipWaiting
().
then
(
()
=>
()
=>
{
replyPort
.
postMessage
({
error
:
null
,
}),
(
error
)
=>
});
},
(
error
)
=>
{
replyPort
.
postMessage
({
error
,
}),
});
},
),
);
}
...
...
src/services/login.ts
浏览文件 @
d6b8e7aa
import
request
from
'
@/utils/request
'
;
export
interface
LoginParamsType
{
export
type
LoginParamsType
=
{
userName
:
string
;
password
:
string
;
mobile
:
string
;
captcha
:
string
;
}
}
;
export
async
function
fakeAccountLogin
(
params
:
LoginParamsType
)
{
return
request
(
'
/api/login/account
'
,
{
...
...
src/typings.d.ts
浏览文件 @
d6b8e7aa
...
...
@@ -13,13 +13,14 @@ declare module '*.tiff';
declare
module
'
omit.js
'
;
// google analytics interface
interface
GAFieldsObject
{
type
GAFieldsObject
=
{
eventCategory
:
string
;
eventAction
:
string
;
eventLabel
?:
string
;
eventValue
?:
number
;
nonInteraction
?:
boolean
;
}
};
interface
Window
{
ga
:
(
command
:
'
send
'
,
...
...
@@ -29,7 +30,7 @@ interface Window {
reloadAuthorized
:
()
=>
void
;
}
declare
let
ga
:
Function
;
declare
let
ga
:
()
=>
void
;
// preview.pro.ant.design only do not use in your production ;
// preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录