Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pro-layout
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
packages
pro-layout
Commits
ca83d764
Commit
ca83d764
authored
Jun 08, 2020
by
Sendya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: i18n-render custom close props
parent
e5402180
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
37 additions
and
36 deletions
+37
-36
README.md
README.md
+1
-1
README.zh-CN.md
README.zh-CN.md
+1
-1
BasicLayout.jsx
examples/src/layouts/BasicLayout.jsx
+1
-0
BasicLayout.jsx
src/BasicLayout.jsx
+2
-4
index.js
src/components/ConfigProvider/index.js
+7
-5
index.jsx
src/components/PageHeaderWrapper/index.jsx
+2
-2
BaseMenu.jsx
src/components/RouteMenu/BaseMenu.jsx
+3
-5
BlockCheckbox.jsx
src/components/SettingDrawer/BlockCheckbox.jsx
+3
-2
LayoutChange.jsx
src/components/SettingDrawer/LayoutChange.jsx
+4
-3
ThemeColor.jsx
src/components/SettingDrawer/ThemeColor.jsx
+3
-3
index.jsx
src/components/SettingDrawer/index.jsx
+9
-6
SiderMenu.jsx
src/components/SiderMenu/SiderMenu.jsx
+1
-4
No files found.
README.md
View file @
ca83d764
...
@@ -133,7 +133,7 @@ export default {
...
@@ -133,7 +133,7 @@ export default {
| collapsedButtonRender | custom collapsed button method | (collapsed: boolean) => VNode | - |
| collapsedButtonRender | custom collapsed button method | (collapsed: boolean) => VNode | - |
| footerRender | custom footer render method | (props: BasicLayoutProps) => VNode | - |
| footerRender | custom footer render method | (props: BasicLayoutProps) => VNode | - |
| breadcrumbRender | custom breadcrumb render method | ({ route, params, routes, paths, h }) => VNode
[]
| - |
| breadcrumbRender | custom breadcrumb render method | ({ route, params, routes, paths, h }) => VNode
[]
| - |
| i18nRender | i18n | Function (key: string) => string
| -
|
| i18nRender | i18n | Function (key: string) => string
\|
`false`
|
`false`
|
| handleMediaQuery | media matchs callback | (querys:
[]
) => void | - |
| handleMediaQuery | media matchs callback | (querys:
[]
) => void | - |
| mediaQuery | media matchs | Array | - |
| mediaQuery | media matchs | Array | - |
...
...
README.zh-CN.md
View file @
ca83d764
...
@@ -128,7 +128,7 @@ export default {
...
@@ -128,7 +128,7 @@ export default {
| collapsedButtonRender | 自定义 侧栏收缩按钮 的方法 | (collapsed: boolean) => VNode | - |
| collapsedButtonRender | 自定义 侧栏收缩按钮 的方法 | (collapsed: boolean) => VNode | - |
| footerRender | 自定义 底部区域内容 | (props: BasicLayoutProps) => VNode | - |
| footerRender | 自定义 底部区域内容 | (props: BasicLayoutProps) => VNode | - |
| breadcrumbRender | 自定义面包屑渲染方法 | ({ route, params, routes, paths, h }) => VNode
[]
| - |
| breadcrumbRender | 自定义面包屑渲染方法 | ({ route, params, routes, paths, h }) => VNode
[]
| - |
| i18nRender | 本地化渲染函数 (this.$t) | Function (key: string) => string
| -
|
| i18nRender | 本地化渲染函数 (this.$t) | Function (key: string) => string
\|
`false`
|
`false`
|
| handleMediaQuery | 媒体查询回调 | (querys:
[]
) => void | - |
| handleMediaQuery | 媒体查询回调 | (querys:
[]
) => void | - |
| mediaQuery | ProLayout 当前的媒体查询 | Array | - |
| mediaQuery | ProLayout 当前的媒体查询 | Array | - |
...
...
examples/src/layouts/BasicLayout.jsx
View file @
ca83d764
...
@@ -169,6 +169,7 @@ export default {
...
@@ -169,6 +169,7 @@ export default {
// custom render
// custom render
rightContentRender
,
rightContentRender
,
footerRender
,
footerRender
,
// i18nRender: false,
i18nRender
,
i18nRender
,
menuHeaderRender
,
menuHeaderRender
,
breadcrumbRender
,
breadcrumbRender
,
...
...
src/BasicLayout.jsx
View file @
ca83d764
...
@@ -6,17 +6,15 @@ import { Layout } from 'ant-design-vue'
...
@@ -6,17 +6,15 @@ import { Layout } from 'ant-design-vue'
import
{
ContainerQuery
}
from
'vue-container-query'
import
{
ContainerQuery
}
from
'vue-container-query'
import
{
SiderMenuWrapper
,
GlobalFooter
}
from
'./components'
import
{
SiderMenuWrapper
,
GlobalFooter
}
from
'./components'
import
{
getComponentFromProp
,
isFun
}
from
'./utils/util'
import
{
getComponentFromProp
,
isFun
}
from
'./utils/util'
import
{
SiderMenuProps
}
from
'./components/SiderMenu
/SiderMenu
'
import
{
SiderMenuProps
}
from
'./components/SiderMenu'
import
HeaderView
,
{
HeaderViewProps
}
from
'./Header'
import
HeaderView
,
{
HeaderViewProps
}
from
'./Header'
import
WrapContent
from
'./WrapContent'
import
WrapContent
from
'./WrapContent'
import
ConfigProvider
from
'./components/ConfigProvider'
import
ConfigProvider
from
'./components/ConfigProvider'
const
noop
=
()
=>
{}
export
const
BasicLayoutProps
=
{
export
const
BasicLayoutProps
=
{
...
SiderMenuProps
,
...
SiderMenuProps
,
...
HeaderViewProps
,
...
HeaderViewProps
,
locale
:
PropTypes
.
string
.
def
(
'en-US'
),
locale
:
PropTypes
.
oneOfType
([
PropTypes
.
string
,
PropTypes
.
bool
])
.
def
(
'en-US'
),
breadcrumbRender
:
PropTypes
.
func
,
breadcrumbRender
:
PropTypes
.
func
,
disableMobile
:
PropTypes
.
bool
.
def
(
false
),
disableMobile
:
PropTypes
.
bool
.
def
(
false
),
mediaQuery
:
PropTypes
.
object
.
def
({}),
mediaQuery
:
PropTypes
.
object
.
def
({}),
...
...
src/components/ConfigProvider/index.js
View file @
ca83d764
import
PropTypes
from
'ant-design-vue/es/_util/vue-types'
import
PropTypes
from
'ant-design-vue/es/_util/vue-types'
const
ProConfigProviderProps
=
{
i18nRender
:
PropTypes
.
oneOfType
([
PropTypes
.
func
,
PropTypes
.
bool
]).
def
(
false
),
contentWidth
:
PropTypes
.
bool
,
breadcrumbRender
:
PropTypes
.
func
,
}
const
ConfigProvider
=
{
const
ConfigProvider
=
{
name
:
'ProConfigProvider'
,
name
:
'ProConfigProvider'
,
props
:
{
props
:
ProConfigProviderProps
,
i18nRender
:
PropTypes
.
any
,
contentWidth
:
PropTypes
.
bool
,
breadcrumbRender
:
PropTypes
.
func
,
},
provide
()
{
provide
()
{
const
_self
=
this
const
_self
=
this
return
{
return
{
...
...
src/components/PageHeaderWrapper/index.jsx
View file @
ca83d764
...
@@ -26,8 +26,8 @@ const PageHeaderWrapperProps = {
...
@@ -26,8 +26,8 @@ const PageHeaderWrapperProps = {
breadcrumb
:
PropTypes
.
oneOfType
([
PropTypes
.
object
,
PropTypes
.
bool
]).
def
(
true
),
breadcrumb
:
PropTypes
.
oneOfType
([
PropTypes
.
object
,
PropTypes
.
bool
]).
def
(
true
),
back
:
PropTypes
.
func
,
back
:
PropTypes
.
func
,
//
包装 pro-layout 才能使用
//
only use `pro-layout` in children
i18nRender
:
PropTypes
.
any
,
i18nRender
:
PropTypes
.
oneOfType
([
PropTypes
.
func
,
PropTypes
.
bool
]).
def
(
false
)
,
}
}
const
defaultI18nRender
=
(
t
)
=>
t
const
defaultI18nRender
=
(
t
)
=>
t
...
...
src/components/RouteMenu/BaseMenu.jsx
View file @
ca83d764
...
@@ -11,11 +11,9 @@ export const RouteMenuProps = {
...
@@ -11,11 +11,9 @@ export const RouteMenuProps = {
theme
:
PropTypes
.
string
.
def
(
'dark'
),
theme
:
PropTypes
.
string
.
def
(
'dark'
),
mode
:
PropTypes
.
string
.
def
(
'inline'
),
mode
:
PropTypes
.
string
.
def
(
'inline'
),
collapsed
:
PropTypes
.
bool
.
def
(
false
),
collapsed
:
PropTypes
.
bool
.
def
(
false
),
i18nRender
:
PropTypes
.
func
,
i18nRender
:
PropTypes
.
oneOfType
([
PropTypes
.
func
,
PropTypes
.
bool
]).
def
(
false
)
,
}
}
const
defaultI18nRender
=
(
context
)
=>
context
const
renderMenu
=
(
h
,
item
,
i18nRender
)
=>
{
const
renderMenu
=
(
h
,
item
,
i18nRender
)
=>
{
if
(
item
&&
!
item
.
hidden
)
{
if
(
item
&&
!
item
.
hidden
)
{
const
bool
=
item
.
children
&&
!
item
.
hideChildrenInMenu
const
bool
=
item
.
children
&&
!
item
.
hideChildrenInMenu
...
@@ -71,7 +69,7 @@ const renderIcon = (h, icon) => {
...
@@ -71,7 +69,7 @@ const renderIcon = (h, icon) => {
}
}
const
renderTitle
=
(
h
,
title
,
i18nRender
)
=>
{
const
renderTitle
=
(
h
,
title
,
i18nRender
)
=>
{
return
<
span
>
{
i18nRender
(
title
)
}
</
span
>
return
<
span
>
{
i18nRender
&&
i18nRender
(
title
)
||
title
}
</
span
>
}
}
const
RouteMenu
=
{
const
RouteMenu
=
{
...
@@ -85,7 +83,7 @@ const RouteMenu = {
...
@@ -85,7 +83,7 @@ const RouteMenu = {
}
}
},
},
render
(
h
)
{
render
(
h
)
{
const
{
mode
,
theme
,
menus
,
i18nRender
=
defaultI18nRender
}
=
this
const
{
mode
,
theme
,
menus
,
i18nRender
}
=
this
const
handleOpenChange
=
(
openKeys
)
=>
{
const
handleOpenChange
=
(
openKeys
)
=>
{
// 在水平模式下时,不再执行后续
// 在水平模式下时,不再执行后续
if
(
mode
===
'horizontal'
)
{
if
(
mode
===
'horizontal'
)
{
...
...
src/components/SettingDrawer/BlockCheckbox.jsx
View file @
ca83d764
import
PropTypes
from
'ant-design-vue/es/_util/vue-types'
import
PropTypes
from
'ant-design-vue/es/_util/vue-types'
import
{
Tooltip
,
Icon
}
from
'ant-design-vue'
import
{
Tooltip
,
Icon
}
from
'ant-design-vue'
import
{
defaultI18nRender
}
from
'./index'
const
BlockCheckboxProps
=
{
const
BlockCheckboxProps
=
{
value
:
PropTypes
.
string
,
value
:
PropTypes
.
string
,
// Item: { key, url, title }
// Item: { key, url, title }
list
:
PropTypes
.
array
,
list
:
PropTypes
.
array
,
i18nRender
:
PropTypes
.
oneOfType
([
PropTypes
.
func
,
PropTypes
.
bool
]).
def
(
false
),
}
}
const
baseClassName
=
'ant-pro-setting-drawer-block-checbox'
const
baseClassName
=
'ant-pro-setting-drawer-block-checbox'
...
@@ -16,7 +17,7 @@ const BlockCheckbox = {
...
@@ -16,7 +17,7 @@ const BlockCheckbox = {
inject
:
[
'locale'
],
inject
:
[
'locale'
],
render
(
h
)
{
render
(
h
)
{
const
{
value
,
list
}
=
this
const
{
value
,
list
}
=
this
const
i18n
=
this
.
$props
.
i18nRender
||
this
.
locale
||
defaultI18nRender
const
i18n
=
this
.
$props
.
i18nRender
||
this
.
locale
const
items
=
list
||
[
const
items
=
list
||
[
{
{
...
...
src/components/SettingDrawer/LayoutChange.jsx
View file @
ca83d764
import
PropTypes
from
'ant-design-vue/es/_util/vue-types'
import
PropTypes
from
'ant-design-vue/es/_util/vue-types'
import
{
List
,
Tooltip
,
Select
,
Switch
}
from
'ant-design-vue'
import
{
List
,
Tooltip
,
Select
,
Switch
}
from
'ant-design-vue'
import
{
defaultI18nRender
}
from
'./index'
export
const
renderLayoutSettingItem
=
(
h
,
item
)
=>
{
export
const
renderLayoutSettingItem
=
(
h
,
item
)
=>
{
const
action
=
{...
item
.
action
}
const
action
=
{...
item
.
action
}
...
@@ -17,14 +16,16 @@ export const LayoutSettingProps = {
...
@@ -17,14 +16,16 @@ export const LayoutSettingProps = {
contentWidth
:
PropTypes
.
bool
,
contentWidth
:
PropTypes
.
bool
,
fixedHeader
:
PropTypes
.
bool
,
fixedHeader
:
PropTypes
.
bool
,
fixSiderbar
:
PropTypes
.
bool
,
fixSiderbar
:
PropTypes
.
bool
,
layout
:
PropTypes
.
oneOf
([
'sidemenu'
,
'topmenu'
])
layout
:
PropTypes
.
oneOf
([
'sidemenu'
,
'topmenu'
]),
i18nRender
:
PropTypes
.
oneOfType
([
PropTypes
.
func
,
PropTypes
.
bool
]).
def
(
false
),
}
}
export
default
{
export
default
{
props
:
LayoutSettingProps
,
props
:
LayoutSettingProps
,
inject
:
[
'locale'
],
inject
:
[
'locale'
],
render
(
h
)
{
render
(
h
)
{
const
i18n
=
this
.
$props
.
i18nRender
||
this
.
locale
||
defaultI18nRender
const
i18n
=
this
.
$props
.
i18nRender
||
this
.
locale
const
{
contentWidth
,
fixedHeader
,
layout
,
fixSiderbar
}
=
this
const
{
contentWidth
,
fixedHeader
,
layout
,
fixSiderbar
}
=
this
const
handleChange
=
(
type
,
value
)
=>
{
const
handleChange
=
(
type
,
value
)
=>
{
...
...
src/components/SettingDrawer/ThemeColor.jsx
View file @
ca83d764
...
@@ -2,7 +2,6 @@ import './ThemeColor.less'
...
@@ -2,7 +2,6 @@ import './ThemeColor.less'
import
PropTypes
from
'ant-design-vue/es/_util/vue-types'
import
PropTypes
from
'ant-design-vue/es/_util/vue-types'
import
{
Tooltip
,
Icon
}
from
'ant-design-vue'
import
{
Tooltip
,
Icon
}
from
'ant-design-vue'
import
{
defaultI18nRender
}
from
'./index'
import
{
genThemeToString
}
from
'../../utils/util'
import
{
genThemeToString
}
from
'../../utils/util'
const
baseClassName
=
'theme-color'
const
baseClassName
=
'theme-color'
...
@@ -29,7 +28,8 @@ export const ThemeColorProps = {
...
@@ -29,7 +28,8 @@ export const ThemeColorProps = {
colors
:
PropTypes
.
array
,
colors
:
PropTypes
.
array
,
title
:
PropTypes
.
string
,
title
:
PropTypes
.
string
,
value
:
PropTypes
.
string
,
value
:
PropTypes
.
string
,
i18nRender
:
PropTypes
.
func
i18nRender
:
PropTypes
.
oneOfType
([
PropTypes
.
func
,
PropTypes
.
bool
]).
def
(
false
),
}
}
const
ThemeColor
=
{
const
ThemeColor
=
{
...
@@ -37,7 +37,7 @@ const ThemeColor = {
...
@@ -37,7 +37,7 @@ const ThemeColor = {
inject
:
[
'locale'
],
inject
:
[
'locale'
],
render
(
h
)
{
render
(
h
)
{
const
{
title
,
value
,
colors
=
[]
}
=
this
const
{
title
,
value
,
colors
=
[]
}
=
this
const
i18n
=
this
.
$props
.
i18nRender
||
this
.
locale
||
defaultI18nRender
const
i18n
=
this
.
$props
.
i18nRender
||
this
.
locale
const
handleChange
=
(
key
)
=>
{
const
handleChange
=
(
key
)
=>
{
this
.
$emit
(
'change'
,
key
)
this
.
$emit
(
'change'
,
key
)
}
}
...
...
src/components/SettingDrawer/index.jsx
View file @
ca83d764
...
@@ -10,7 +10,6 @@ import { updateTheme, updateColorWeak } from '../../utils/dynamicTheme'
...
@@ -10,7 +10,6 @@ import { updateTheme, updateColorWeak } from '../../utils/dynamicTheme'
import
{
genStringToTheme
}
from
'../../utils/util'
import
{
genStringToTheme
}
from
'../../utils/util'
import
CopyToClipboard
from
'vue-copy-to-clipboard'
import
CopyToClipboard
from
'vue-copy-to-clipboard'
const
baseClassName
=
'ant-pro-setting-drawer'
const
baseClassName
=
'ant-pro-setting-drawer'
const
BodyProps
=
{
const
BodyProps
=
{
...
@@ -31,7 +30,7 @@ const Body = {
...
@@ -31,7 +30,7 @@ const Body = {
}
}
}
}
export
const
defaultI18nRender
=
(
t
)
=>
t
const
defaultI18nRender
=
(
t
)
=>
t
const
getThemeList
=
(
i18nRender
)
=>
{
const
getThemeList
=
(
i18nRender
)
=>
{
...
@@ -138,7 +137,9 @@ export const settings = {
...
@@ -138,7 +137,9 @@ export const settings = {
export
const
SettingDrawerProps
=
{
export
const
SettingDrawerProps
=
{
getContainer
:
PropTypes
.
func
,
getContainer
:
PropTypes
.
func
,
settings
:
PropTypes
.
objectOf
(
settings
)
settings
:
PropTypes
.
objectOf
(
settings
),
i18nRender
:
PropTypes
.
oneOfType
([
PropTypes
.
func
,
PropTypes
.
bool
]).
def
(
false
),
}
}
const
SettingDrawer
=
{
const
SettingDrawer
=
{
...
@@ -169,7 +170,7 @@ const SettingDrawer = {
...
@@ -169,7 +170,7 @@ const SettingDrawer = {
colorWeak
colorWeak
}
=
settings
}
=
settings
const
i18n
=
this
.
$props
.
i18nRender
||
this
.
locale
const
i18n
=
this
.
$props
.
i18nRender
||
this
.
locale
||
defaultI18nRender
const
themeList
=
getThemeList
(
i18n
)
const
themeList
=
getThemeList
(
i18n
)
const
isTopMenu
=
layout
===
'topmenu'
const
isTopMenu
=
layout
===
'topmenu'
...
@@ -212,12 +213,13 @@ const SettingDrawer = {
...
@@ -212,12 +213,13 @@ const SettingDrawer = {
</
template
>
</
template
>
<
div
class=
{
`${baseClassName}-content`
}
>
<
div
class=
{
`${baseClassName}-content`
}
>
<
Body
title=
{
i18n
(
'app.setting.pagestyle'
)
}
>
<
Body
title=
{
i18n
(
'app.setting.pagestyle'
)
}
>
<
BlockCheckbox
list=
{
themeList
.
themeList
}
value=
{
theme
}
onChange=
{
(
val
)
=>
{
<
BlockCheckbox
i18nRender=
{
i18n
}
list=
{
themeList
.
themeList
}
value=
{
theme
}
onChange=
{
(
val
)
=>
{
changeSetting
(
'theme'
,
val
)
changeSetting
(
'theme'
,
val
)
}
}
/>
}
}
/>
</
Body
>
</
Body
>
<
ThemeColor
<
ThemeColor
i18nRender=
{
i18n
}
title=
{
i18n
(
'app.setting.themecolor'
)
}
title=
{
i18n
(
'app.setting.themecolor'
)
}
value=
{
primaryColor
}
value=
{
primaryColor
}
colors=
{
themeList
.
colorList
[
theme
===
'realDark'
?
'dark'
:
'light'
]
}
colors=
{
themeList
.
colorList
[
theme
===
'realDark'
?
'dark'
:
'light'
]
}
...
@@ -229,12 +231,13 @@ const SettingDrawer = {
...
@@ -229,12 +231,13 @@ const SettingDrawer = {
<
Divider
/>
<
Divider
/>
<
Body
title=
{
i18n
(
'app.setting.navigationmode'
)
}
>
<
Body
title=
{
i18n
(
'app.setting.navigationmode'
)
}
>
<
BlockCheckbox
value=
{
layout
}
onChange=
{
(
value
)
=>
{
<
BlockCheckbox
i18nRender=
{
i18n
}
value=
{
layout
}
onChange=
{
(
value
)
=>
{
changeSetting
(
'layout'
,
value
,
null
)
changeSetting
(
'layout'
,
value
,
null
)
}
}
/>
}
}
/>
</
Body
>
</
Body
>
<
LayoutSetting
<
LayoutSetting
i18nRender=
{
i18n
}
contentWidth=
{
contentWidth
}
contentWidth=
{
contentWidth
}
fixedHeader=
{
fixedHeader
}
fixedHeader=
{
fixedHeader
}
fixSiderbar=
{
isTopMenu
?
false
:
fixSiderbar
}
fixSiderbar=
{
isTopMenu
?
false
:
fixSiderbar
}
...
...
src/components/SiderMenu/SiderMenu.jsx
View file @
ca83d764
...
@@ -7,10 +7,7 @@ import BaseMenu from '../RouteMenu'
...
@@ -7,10 +7,7 @@ import BaseMenu from '../RouteMenu'
const
{
Sider
}
=
Layout
const
{
Sider
}
=
Layout
export
const
SiderMenuProps
=
{
export
const
SiderMenuProps
=
{
i18nRender
:
{
i18nRender
:
PropTypes
.
oneOfType
([
PropTypes
.
func
,
PropTypes
.
bool
]).
def
(
false
),
type
:
Function
,
default
:
()
=>
undefined
},
mode
:
PropTypes
.
string
.
def
(
'inline'
),
mode
:
PropTypes
.
string
.
def
(
'inline'
),
theme
:
PropTypes
.
string
.
def
(
'dark'
),
theme
:
PropTypes
.
string
.
def
(
'dark'
),
contentWidth
:
PropTypes
.
bool
,
contentWidth
:
PropTypes
.
bool
,
...
...
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