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
a3019d84
Unverified
Commit
a3019d84
authored
Apr 16, 2020
by
Sendya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: PageHeaderWrapper @back event
parent
078000d6
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
133 additions
and
32 deletions
+133
-32
router.config.js
examples/src/config/router.config.js
+6
-5
lazyload.js
examples/src/core/antd/lazyload.js
+2
-2
BasicLayout.jsx
examples/src/layouts/BasicLayout.jsx
+13
-2
en-US.js
examples/src/locales/lang/en-US.js
+12
-2
zh-CN.js
examples/src/locales/lang/zh-CN.js
+12
-2
BlockPage.vue
examples/src/views/BlockPage.vue
+12
-6
analysis.vue
examples/src/views/dashboard/analysis.vue
+51
-0
index.jsx
src/components/PageHeaderWrapper/index.jsx
+25
-13
No files found.
examples/src/config/router.config.js
View file @
a3019d84
// eslint-disable-next-line
// eslint-disable-next-line
import
BasicLayout
from
'../layouts/BasicLayout'
import
BasicLayout
from
'../layouts/BasicLayout'
const
renderRouterView
=
{
const
RouteView
=
{
name
:
'RouteView'
,
render
:
(
h
)
=>
h
(
'router-view'
)
render
:
(
h
)
=>
h
(
'router-view'
)
}
}
...
@@ -18,7 +19,7 @@ const asyncRouterMap = [
...
@@ -18,7 +19,7 @@ const asyncRouterMap = [
name
:
'dashboard'
,
name
:
'dashboard'
,
meta
:
{
keepAlive
:
true
,
title
:
'menu.dashboard.default'
,
icon
:
'dashboard'
},
meta
:
{
keepAlive
:
true
,
title
:
'menu.dashboard.default'
,
icon
:
'dashboard'
},
redirect
:
'/dashboard/analysis'
,
redirect
:
'/dashboard/analysis'
,
component
:
renderRouter
View
,
component
:
Route
View
,
children
:
[
children
:
[
{
{
path
:
'/dashboard/analysis'
,
path
:
'/dashboard/analysis'
,
...
@@ -28,7 +29,7 @@ const asyncRouterMap = [
...
@@ -28,7 +29,7 @@ const asyncRouterMap = [
icon
:
'smile'
,
icon
:
'smile'
,
title
:
'menu.dashboard.analysis'
title
:
'menu.dashboard.analysis'
},
},
component
:
()
=>
import
(
/* webpackChunkName: "
about" */
'../views/BlockPage
'
)
component
:
()
=>
import
(
/* webpackChunkName: "
dashboard" */
'../views/dashboard/analysis
'
)
},
},
{
{
path
:
'/dashboard/workplace/:id?'
,
path
:
'/dashboard/workplace/:id?'
,
...
@@ -39,7 +40,7 @@ const asyncRouterMap = [
...
@@ -39,7 +40,7 @@ const asyncRouterMap = [
icon
:
'smile'
,
icon
:
'smile'
,
title
:
'menu.dashboard.workplace'
title
:
'menu.dashboard.workplace'
},
},
component
:
()
=>
import
(
/* webpackChunkName: "
about
" */
'../views/TestPage'
)
component
:
()
=>
import
(
/* webpackChunkName: "
dashboard
" */
'../views/TestPage'
)
}
}
]
]
},
},
...
@@ -51,7 +52,7 @@ const asyncRouterMap = [
...
@@ -51,7 +52,7 @@ const asyncRouterMap = [
title
:
'menu.form.default'
,
title
:
'menu.form.default'
,
icon
:
'video-camera'
icon
:
'video-camera'
},
},
component
:
renderRouter
View
,
component
:
Route
View
,
children
:
[
children
:
[
{
{
path
:
'/form/basic-form'
,
path
:
'/form/basic-form'
,
...
...
examples/src/core/antd/lazyload.js
View file @
a3019d84
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
*/
*/
import
Vue
from
'vue'
import
Vue
from
'vue'
import
{
import
{
Locale
Provider
,
Config
Provider
,
Layout
,
Layout
,
Input
,
Input
,
InputNumber
,
InputNumber
,
...
@@ -50,7 +50,7 @@ import {
...
@@ -50,7 +50,7 @@ import {
notification
notification
}
from
'ant-design-vue'
}
from
'ant-design-vue'
Vue
.
use
(
Locale
Provider
)
Vue
.
use
(
Config
Provider
)
Vue
.
use
(
Layout
)
Vue
.
use
(
Layout
)
Vue
.
use
(
Input
)
Vue
.
use
(
Input
)
Vue
.
use
(
InputNumber
)
Vue
.
use
(
InputNumber
)
...
...
examples/src/layouts/BasicLayout.jsx
View file @
a3019d84
import
'./BasicLayout.less'
import
'./BasicLayout.less'
import
{
Avatar
,
Dropdown
,
Menu
,
Icon
}
from
'ant-design-vue'
import
{
Avatar
,
Dropdown
,
Menu
,
Icon
,
Modal
}
from
'ant-design-vue'
import
{
asyncRouterMap
}
from
'../config/router.config.js'
import
{
asyncRouterMap
}
from
'../config/router.config.js'
import
{
i18nRender
}
from
'../locales'
import
{
i18nRender
}
from
'../locales'
import
ProLayout
,
{
GlobalFooter
}
from
'@ant-design-vue/pro-layout'
import
ProLayout
,
{
GlobalFooter
}
from
'@ant-design-vue/pro-layout'
...
@@ -20,7 +20,18 @@ const Account = {
...
@@ -20,7 +20,18 @@ const Account = {
<
Icon
type=
{
'setting'
}
/>
个人设置
<
Icon
type=
{
'setting'
}
/>
个人设置
</
Menu
.
Item
>
</
Menu
.
Item
>
<
Menu
.
Divider
/>
<
Menu
.
Divider
/>
<
Menu
.
Item
key=
"logout"
>
<
Menu
.
Item
key=
"logout"
onClick=
{
()
=>
{
Modal
.
confirm
({
title
:
i18nRender
(
'layouts.usermenu.dialog.title'
),
content
:
i18nRender
(
'layouts.usermenu.dialog.content'
),
onOk
:
()
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(
Math
.
random
()
>
0.5
?
resolve
:
reject
,
1500
)
}).
catch
(()
=>
console
.
log
(
'Oops errors!'
))
},
onCancel
()
{}
})
}
}
>
<
Icon
type=
{
'logout'
}
/>
退出登录
<
Icon
type=
{
'logout'
}
/>
退出登录
</
Menu
.
Item
>
</
Menu
.
Item
>
</
Menu
>
</
Menu
>
...
...
examples/src/locales/lang/en-US.js
View file @
a3019d84
...
@@ -3,7 +3,12 @@ export default {
...
@@ -3,7 +3,12 @@ export default {
lang
:
'Language'
lang
:
'Language'
},
},
layouts
:
{
layouts
:
{
usermenu
:
{
dialog
:
{
title
:
'Log-out'
,
content
:
'Do you want log-out?'
}
}
},
},
menu
:
{
menu
:
{
home
:
'Home'
,
home
:
'Home'
,
...
@@ -29,7 +34,12 @@ export default {
...
@@ -29,7 +34,12 @@ export default {
headers
:
{
headers
:
{
btn1
:
'Button1'
btn1
:
'Button1'
},
},
content
:
'Form pages are used to collect or verify information to users, and basic forms are common in scenarios where there are fewer data items.'
content
:
'Form pages are used to collect or verify information to users, and basic forms are common in scenarios where there are fewer data items.'
,
tabs
:
{
tab1
:
'Tab1'
,
tab2
:
'Tab2'
,
tab3
:
'Tab3'
}
}
}
}
}
}
}
...
...
examples/src/locales/lang/zh-CN.js
View file @
a3019d84
...
@@ -3,7 +3,12 @@ export default {
...
@@ -3,7 +3,12 @@ export default {
lang
:
'语言'
lang
:
'语言'
},
},
layouts
:
{
layouts
:
{
usermenu
:
{
dialog
:
{
title
:
'注销'
,
content
:
'要注销账户吗?'
}
}
},
},
menu
:
{
menu
:
{
home
:
'首页'
,
home
:
'首页'
,
...
@@ -29,7 +34,12 @@ export default {
...
@@ -29,7 +34,12 @@ export default {
headers
:
{
headers
:
{
btn1
:
'按钮1'
btn1
:
'按钮1'
},
},
content
:
'表单页用于向用户收集或验证信息,基础表单常见于数据项较少的表单场景。'
content
:
'表单页用于向用户收集或验证信息,基础表单常见于数据项较少的表单场景。'
,
tabs
:
{
tab1
:
'标签1'
,
tab2
:
'标签2'
,
tab3
:
'标签3'
}
}
}
}
}
}
}
...
...
examples/src/views/BlockPage.vue
View file @
a3019d84
...
@@ -6,12 +6,18 @@
...
@@ -6,12 +6,18 @@
this.tabActiveKey = key
this.tabActiveKey = key
console.log('PageHeader::tabChange', key)
console.log('PageHeader::tabChange', key)
}"
}"
:breadcrumb="false"
@back="() => {
console.log('PageHeader::@back')
}"
:back="() => {
// 自定义 back,不会覆盖 onBack 事件
console.log('PageHeader::.back')
}"
>
>
<template
slot=
"content"
>
<template
v-slot:content
>
<span>
{{
$t
(
'pages.form.basicform.content'
)
}}
</span>
<span>
{{
$t
(
'pages.form.basicform.content'
)
}}
</span>
</
template
>
</
template
>
<
template
slot=
"extraContent"
>
<
template
v-slot:extraContent
>
<div><a-button>
{{
$t
(
'pages.form.basicform.headers.btn1'
)
}}
</a-button></div>
<div><a-button>
{{
$t
(
'pages.form.basicform.headers.btn1'
)
}}
</a-button></div>
</
template
>
</
template
>
<div>
<div>
...
@@ -27,9 +33,9 @@ export default {
...
@@ -27,9 +33,9 @@ export default {
return
{
return
{
console
:
window
.
console
,
console
:
window
.
console
,
tabList
:
[
tabList
:
[
{
tab
:
'
T
ab1'
,
key
:
'tab1'
},
{
tab
:
'
pages.form.basicform.tabs.t
ab1'
,
key
:
'tab1'
},
{
tab
:
'
T
ab2'
,
key
:
'tab2'
},
{
tab
:
'
pages.form.basicform.tabs.t
ab2'
,
key
:
'tab2'
},
{
tab
:
'
T
ab3'
,
key
:
'tab3'
}
{
tab
:
'
pages.form.basicform.tabs.t
ab3'
,
key
:
'tab3'
}
],
],
tabActiveKey
:
'tab1'
tabActiveKey
:
'tab1'
}
}
...
...
examples/src/views/dashboard/analysis.vue
0 → 100644
View file @
a3019d84
<
template
>
<page-header-wrapper
:tab-list=
"tabList"
:tab-active-key=
"tabActiveKey"
:tab-change=
"(key) =>
{
this.tabActiveKey = key
console.log('PageHeader::tabChange', key)
}"
@back="() => {
console.log('PageHeader::@back')
}"
:back="() => {
// 自定义 back,不会覆盖 onBack 事件
console.log('PageHeader::.back')
}"
>
<template
v-slot:content
>
<span>
{{
$t
(
'pages.dashboard.analysis.content'
)
}}
</span>
</
template
>
<div>
<strong>
Analysis Page
</strong>
</div>
</page-header-wrapper>
</template>
<
script
>
export
default
{
name
:
'Analysis'
,
data
()
{
return
{
console
:
window
.
console
,
tabList
:
[
{
tab
:
'pages.form.basicform.tabs.tab1'
,
key
:
'tab1'
},
{
tab
:
'pages.form.basicform.tabs.tab2'
,
key
:
'tab2'
},
{
tab
:
'pages.form.basicform.tabs.tab3'
,
key
:
'tab3'
}
],
tabActiveKey
:
'tab1'
}
},
methods
:
{
handleTabChange
(
key
)
{
this
.
tabActiveKey
=
key
console
.
log
(
'PageHeader::tabChange'
,
key
)
}
}
}
</
script
>
<
style
scoped
>
</
style
>
src/components/PageHeaderWrapper/index.jsx
View file @
a3019d84
...
@@ -3,6 +3,7 @@ import './index.less'
...
@@ -3,6 +3,7 @@ import './index.less'
import
PropTypes
from
'ant-design-vue/es/_util/vue-types'
import
PropTypes
from
'ant-design-vue/es/_util/vue-types'
import
GridContent
from
'../GridContent'
import
GridContent
from
'../GridContent'
import
{
PageHeader
,
Tabs
}
from
'ant-design-vue'
import
{
PageHeader
,
Tabs
}
from
'ant-design-vue'
import
{
getComponentFromProp
}
from
'ant-design-vue/lib/_util/props-util'
const
{
PageHeaderProps
}
=
PageHeader
const
{
PageHeaderProps
}
=
PageHeader
...
@@ -22,7 +23,8 @@ const PageHeaderWrapperProps = {
...
@@ -22,7 +23,8 @@ const PageHeaderWrapperProps = {
content
:
PropTypes
.
any
,
content
:
PropTypes
.
any
,
extraContent
:
PropTypes
.
any
,
extraContent
:
PropTypes
.
any
,
pageHeaderRender
:
PropTypes
.
func
,
pageHeaderRender
:
PropTypes
.
func
,
breadcrumb
:
PropTypes
.
oneOf
([
PropTypes
.
object
,
false
]),
breadcrumb
:
PropTypes
.
oneOf
([
PropTypes
.
object
,
PropTypes
.
bool
]).
def
(
true
),
back
:
PropTypes
.
func
,
// 包装 pro-layout 才能使用
// 包装 pro-layout 才能使用
i18nRender
:
PropTypes
.
any
i18nRender
:
PropTypes
.
any
...
@@ -36,7 +38,7 @@ const useContext = (route) => {
...
@@ -36,7 +38,7 @@ const useContext = (route) => {
}
||
null
}
||
null
}
}
const
renderFooter
=
(
h
,
tabConfigProps
)
=>
{
const
renderFooter
=
(
h
,
tabConfigProps
,
i18nRender
)
=>
{
const
{
const
{
tabList
,
tabList
,
tabActiveKey
,
tabActiveKey
,
...
@@ -57,7 +59,7 @@ const renderFooter = (h, tabConfigProps) => {
...
@@ -57,7 +59,7 @@ const renderFooter = (h, tabConfigProps) => {
{
...
tabProps
}
{
...
tabProps
}
>
>
{
tabList
.
map
(
item
=>
(
{
tabList
.
map
(
item
=>
(
<
Tabs
.
TabPane
{
...
item
}
tab=
{
i
tem
.
tab
}
key=
{
item
.
key
}
/>
<
Tabs
.
TabPane
{
...
item
}
tab=
{
i
18nRender
(
item
.
tab
)
}
key=
{
item
.
key
}
/>
))
}
))
}
</
Tabs
>
</
Tabs
>
)
)
...
@@ -85,29 +87,30 @@ const renderPageHeader = (h, content, extraContent) => {
...
@@ -85,29 +87,30 @@ const renderPageHeader = (h, content, extraContent) => {
)
)
}
}
const
defaultPageHeaderRender
=
(
h
,
props
,
value
,
i18nRender
)
=>
{
const
defaultPageHeaderRender
=
(
h
,
props
,
pageMeta
,
i18nRender
)
=>
{
const
{
const
{
title
,
title
,
content
,
content
,
pageHeaderRender
,
pageHeaderRender
,
extraContent
,
extraContent
,
breadcrumb
,
breadcrumb
,
back
:
handleBack
,
...
restProps
...
restProps
}
=
props
}
=
props
if
(
pageHeaderRender
)
{
if
(
pageHeaderRender
)
{
return
pageHeaderRender
({
...
props
})
return
pageHeaderRender
({
...
props
})
}
}
let
pageHeaderTitle
=
title
let
pageHeaderTitle
=
title
if
((
!
title
&&
title
!==
false
)
||
value
.
title
!==
false
)
{
if
((
!
title
&&
title
!==
false
)
||
pageMeta
.
title
!==
false
)
{
pageHeaderTitle
=
value
.
title
pageHeaderTitle
=
pageMeta
.
title
}
}
return
(
return
(
<
PageHeader
<
PageHeader
title=
{
i18nRender
(
pageHeaderTitle
)
}
title=
{
i18nRender
(
pageHeaderTitle
)
}
breadcrumb=
{
breadcrumb
}
breadcrumb=
{
breadcrumb
}
{
...
props
}
{
...
props
}
onBack=
{
()
=>
null
}
onBack=
{
handleBack
}
footer=
{
renderFooter
(
h
,
restProps
)
}
footer=
{
renderFooter
(
h
,
restProps
,
i18nRender
)
}
>
>
{
renderPageHeader
(
h
,
content
,
extraContent
)
}
{
renderPageHeader
(
h
,
content
,
extraContent
)
}
</
PageHeader
>
</
PageHeader
>
...
@@ -121,11 +124,17 @@ const PageHeaderWrapper = {
...
@@ -121,11 +124,17 @@ const PageHeaderWrapper = {
inject
:
[
'locale'
],
inject
:
[
'locale'
],
render
(
h
)
{
render
(
h
)
{
const
children
=
this
.
$slots
.
default
const
children
=
this
.
$slots
.
default
const
content
=
this
.
$slots
.
content
const
content
=
getComponentFromProp
(
this
,
'content'
)
const
extraContent
=
this
.
$slots
.
extraContent
const
extraContent
=
getComponentFromProp
(
this
,
'extraContent'
)
const
value
=
useContext
(
this
.
$props
.
route
||
this
.
$route
)
const
pageMeta
=
useContext
(
this
.
$props
.
route
||
this
.
$route
)
const
i18n
=
this
.
$props
.
i18nRender
||
this
.
locale
||
defaultI18nRender
const
i18n
=
this
.
$props
.
i18nRender
||
this
.
locale
||
defaultI18nRender
const
onBack
=
this
.
$props
.
back
const
back
=
()
=>
{
this
.
$emit
(
'back'
)
// call props back func
onBack
&&
onBack
()
}
const
propsBreadcrumb
=
this
.
$props
.
breadcrumb
const
propsBreadcrumb
=
this
.
$props
.
breadcrumb
let
breadcrumb
=
{}
let
breadcrumb
=
{}
...
@@ -139,17 +148,20 @@ const PageHeaderWrapper = {
...
@@ -139,17 +148,20 @@ const PageHeaderWrapper = {
breadcrumb
=
{
props
:
{
routes
}}
breadcrumb
=
{
props
:
{
routes
}}
}
}
console
.
log
(
'breadcrumb'
,
breadcrumb
)
const
props
=
{
const
props
=
{
...
this
.
$props
,
...
this
.
$props
,
content
,
content
,
extraContent
,
extraContent
,
breadcrumb
breadcrumb
,
back
}
}
return
(
return
(
<
div
class=
"ant-pro-page-header-wrap"
>
<
div
class=
"ant-pro-page-header-wrap"
>
<
div
class=
{
`${prefixedClassName}-page-header-warp`
}
>
<
div
class=
{
`${prefixedClassName}-page-header-warp`
}
>
<
GridContent
>
{
defaultPageHeaderRender
(
h
,
props
,
value
,
i18n
)
}
</
GridContent
>
<
GridContent
>
{
defaultPageHeaderRender
(
h
,
props
,
pageMeta
,
i18n
)
}
</
GridContent
>
</
div
>
</
div
>
{
children
?
(
{
children
?
(
<
GridContent
>
<
GridContent
>
...
...
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