Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ant-design-pro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
ant-design-pro
Commits
bd74eb65
Commit
bd74eb65
authored
Sep 02, 2018
by
afc163
Committed by
陈帅
Sep 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化设置渲染的展现
parent
9de7523d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
22 deletions
+41
-22
src/components/SettingDrawer/index.js
src/components/SettingDrawer/index.js
+41
-22
No files found.
src/components/SettingDrawer/index.js
View file @
bd74eb65
import
React
,
{
PureComponent
}
from
'
react
'
;
import
React
,
{
PureComponent
}
from
'
react
'
;
import
{
Select
,
message
,
Drawer
,
List
,
Switch
,
Divider
,
Icon
,
Button
,
Alert
}
from
'
antd
'
;
import
{
Select
,
message
,
Drawer
,
List
,
Switch
,
Divider
,
Icon
,
Button
,
Alert
,
Tooltip
}
from
'
antd
'
;
import
{
formatMessage
}
from
'
umi/locale
'
;
import
{
formatMessage
}
from
'
umi/locale
'
;
import
{
CopyToClipboard
}
from
'
react-copy-to-clipboard
'
;
import
{
CopyToClipboard
}
from
'
react-copy-to-clipboard
'
;
import
{
connect
}
from
'
dva
'
;
import
{
connect
}
from
'
dva
'
;
...
@@ -8,6 +8,8 @@ import styles from './index.less';
...
@@ -8,6 +8,8 @@ import styles from './index.less';
import
ThemeColor
from
'
./ThemeColor
'
;
import
ThemeColor
from
'
./ThemeColor
'
;
import
BlockChecbox
from
'
./BlockChecbox
'
;
import
BlockChecbox
from
'
./BlockChecbox
'
;
const
{
Option
}
=
Select
;
const
Body
=
({
children
,
title
,
style
})
=>
(
const
Body
=
({
children
,
title
,
style
})
=>
(
<
div
<
div
style
=
{{
style
=
{{
...
@@ -33,55 +35,59 @@ class SettingDrawer extends PureComponent {
...
@@ -33,55 +35,59 @@ class SettingDrawer extends PureComponent {
return
[
return
[
{
{
title
:
formatMessage
({
id
:
'
app.setting.content-width
'
}),
title
:
formatMessage
({
id
:
'
app.setting.content-width
'
}),
action
:
[
action
:
(
<
Select
<
Select
value
=
{
contentWidth
}
value
=
{
contentWidth
}
size
=
"
small
"
size
=
"
small
"
onSelect
=
{
value
=>
this
.
changeSetting
(
'
contentWidth
'
,
value
)}
onSelect
=
{
value
=>
this
.
changeSetting
(
'
contentWidth
'
,
value
)}
style
=
{{
width
:
80
}}
style
=
{{
width
:
80
}}
>
>
<
Select
.
Option
value
=
"
Fixed
"
>
{
layout
===
'
sidemenu
'
?
null
:
(
{
formatMessage
({
id
:
'
app.setting.content-width.fixed
'
})}
<
Option
value
=
"
Fixed
"
>
<
/Select.Option
>
{
formatMessage
({
id
:
'
app.setting.content-width.fixed
'
})}
<
Select
.
Option
value
=
"
Fluid
"
>
<
/Option
>
)}
<
Option
value
=
"
Fluid
"
>
{
formatMessage
({
id
:
'
app.setting.content-width.fluid
'
})}
{
formatMessage
({
id
:
'
app.setting.content-width.fluid
'
})}
<
/
Select.
Option
>
<
/Option
>
<
/Select>
,
<
/Select
>
]
,
)
,
},
},
{
{
title
:
formatMessage
({
id
:
'
app.setting.fixedheader
'
}),
title
:
formatMessage
({
id
:
'
app.setting.fixedheader
'
}),
action
:
[
action
:
(
<
Switch
<
Switch
size
=
"
small
"
size
=
"
small
"
checked
=
{
!!
fixedHeader
}
checked
=
{
!!
fixedHeader
}
onChange
=
{
checked
=>
this
.
changeSetting
(
'
fixedHeader
'
,
checked
)}
onChange
=
{
checked
=>
this
.
changeSetting
(
'
fixedHeader
'
,
checked
)}
/>
,
/
>
]
,
)
,
},
},
{
{
title
:
formatMessage
({
id
:
'
app.setting.hideheader
'
}),
title
:
formatMessage
({
id
:
'
app.setting.hideheader
'
}),
hide
:
!
fixedHeader
,
disabled
:
!
fixedHeader
,
action
:
[
disabledReason
:
'
固定 Header 时有效
'
,
action
:
(
<
Switch
<
Switch
size
=
"
small
"
size
=
"
small
"
checked
=
{
!!
autoHideHeader
}
checked
=
{
!!
autoHideHeader
}
onChange
=
{
checked
=>
this
.
changeSetting
(
'
autoHideHeader
'
,
checked
)}
onChange
=
{
checked
=>
this
.
changeSetting
(
'
autoHideHeader
'
,
checked
)}
/>
,
/
>
]
,
)
,
},
},
{
{
title
:
formatMessage
({
id
:
'
app.setting.fixedsidebar
'
}),
title
:
formatMessage
({
id
:
'
app.setting.fixedsidebar
'
}),
hide
:
layout
===
'
topmenu
'
,
disabled
:
layout
===
'
topmenu
'
,
action
:
[
disabledReason
:
'
侧边菜单布局时有效
'
,
action
:
(
<
Switch
<
Switch
size
=
"
small
"
size
=
"
small
"
checked
=
{
!!
fixSiderbar
}
checked
=
{
!!
fixSiderbar
}
onChange
=
{
checked
=>
this
.
changeSetting
(
'
fixSiderbar
'
,
checked
)}
onChange
=
{
checked
=>
this
.
changeSetting
(
'
fixSiderbar
'
,
checked
)}
/>
,
/
>
]
,
)
,
},
},
]
.
filter
(
item
=>
!
item
.
hide
)
;
];
};
};
changeSetting
=
(
key
,
value
)
=>
{
changeSetting
=
(
key
,
value
)
=>
{
...
@@ -107,6 +113,19 @@ class SettingDrawer extends PureComponent {
...
@@ -107,6 +113,19 @@ class SettingDrawer extends PureComponent {
this
.
setState
({
collapse
:
!
collapse
});
this
.
setState
({
collapse
:
!
collapse
});
};
};
renderLayoutSettingItem
=
item
=>
{
const
action
=
React
.
cloneElement
(
item
.
action
,
{
disabled
:
item
.
disabled
,
});
return
(
<
Tooltip
title
=
{
item
.
disabled
?
item
.
disabledReason
:
''
}
placement
=
"
left
"
>
<
List
.
Item
actions
=
{[
action
]}
>
<
span
style
=
{{
opacity
:
item
.
disabled
?
'
0.5
'
:
''
}}
>
{
item
.
title
}
<
/span
>
<
/List.Item
>
<
/Tooltip
>
);
};
render
()
{
render
()
{
const
{
setting
}
=
this
.
props
;
const
{
setting
}
=
this
.
props
;
const
{
navTheme
,
primaryColor
,
layout
,
colorWeak
}
=
setting
;
const
{
navTheme
,
primaryColor
,
layout
,
colorWeak
}
=
setting
;
...
@@ -183,7 +202,7 @@ class SettingDrawer extends PureComponent {
...
@@ -183,7 +202,7 @@ class SettingDrawer extends PureComponent {
<
List
<
List
split
=
{
false
}
split
=
{
false
}
dataSource
=
{
this
.
getLayoutSetting
()}
dataSource
=
{
this
.
getLayoutSetting
()}
renderItem
=
{
item
=>
<
List
.
Item
actions
=
{
item
.
action
}
>
{
item
.
title
}
<
/List.Item>
}
renderItem
=
{
this
.
renderLayoutSettingItem
}
/
>
/
>
<
Divider
/>
<
Divider
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment