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
4d986e46
Commit
4d986e46
authored
Feb 05, 2021
by
ref
Committed by
言肆
Feb 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: get isMobile props from RouteContext
parent
ba39810c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
6 deletions
+13
-6
BasicLayout.tsx
src/BasicLayout.tsx
+3
-1
index.tsx
src/GlobalHeader/index.tsx
+3
-1
Header.tsx
src/Header.tsx
+3
-3
index.tsx
src/SiderMenu/index.tsx
+4
-1
No files found.
src/BasicLayout.tsx
View file @
4d986e46
...
...
@@ -9,6 +9,7 @@ import { default as Header, HeaderViewProps } from './Header';
import
{
RenderVNodeType
,
WithFalse
}
from
'./typings'
;
import
{
getComponentOrSlot
,
PropRenderType
,
PropTypes
}
from
'./utils'
;
import
'./BasicLayout.less'
;
import
{
useRouteContext
}
from
'./RouteContext'
;
const
defaultI18nRender
=
(
key
:
string
)
=>
key
;
...
...
@@ -60,9 +61,10 @@ const ProLayout: FunctionalComponent<BasicLayoutProps> = (props, { emit, slots }
matchMenuKeys
,
navTheme
,
menuData
,
isMobile
,
// defaultCollapsed,
}
=
props
;
const
routeContext
=
useRouteContext
();
const
{
isMobile
}
=
routeContext
;
const
isTop
=
computed
(()
=>
layout
===
'top'
);
// const isSide = computed(() => layout === 'side');
// const isMix = computed(() => layout === 'mix');
...
...
src/GlobalHeader/index.tsx
View file @
4d986e46
...
...
@@ -13,6 +13,7 @@ import { clearMenuItem } from '../utils';
import
type
{
HeaderViewProps
}
from
'../Header'
;
import
'./index.less'
;
import
{
useProProvider
}
from
'../ProProvider'
;
import
{
useRouteContext
}
from
'../RouteContext'
;
export
interface
GlobalHeaderProps
extends
Partial
<
PureSettings
>
{
collapsed
?:
boolean
;
...
...
@@ -51,7 +52,6 @@ export const GlobalHeader: FunctionalComponent<GlobalHeaderProps & PrivateSiderM
{
slots
},
)
=>
{
const
{
isMobile
,
logo
,
collapsed
,
onCollapse
,
...
...
@@ -66,6 +66,8 @@ export const GlobalHeader: FunctionalComponent<GlobalHeaderProps & PrivateSiderM
menuData
,
prefixCls
:
customPrefixCls
,
}
=
props
;
const
routeContext
=
useRouteContext
();
const
{
isMobile
}
=
routeContext
;
const
{
getPrefixCls
}
=
useProProvider
();
const
prefixCls
=
customPrefixCls
||
getPrefixCls
();
const
baseClassName
=
computed
(()
=>
`
${
prefixCls
}
-global-header`
);
...
...
src/Header.tsx
View file @
4d986e46
...
...
@@ -68,7 +68,6 @@ export const HeaderView = defineComponent({
prefixCls
,
headerRender
,
headerContentRender
,
isMobile
,
fixedHeader
,
hasSiderMenu
,
headerHeight
,
...
...
@@ -77,10 +76,11 @@ export const HeaderView = defineComponent({
onCollapse
,
}
=
toRefs
(
props
);
const
context
=
useRouteContext
();
const
{
isMobile
}
=
context
;
const
needFixedHeader
=
computed
(()
=>
fixedHeader
.
value
||
layout
.
value
===
'mix'
);
const
isTop
=
computed
(()
=>
layout
.
value
===
'top'
);
const
needSettingWidth
=
computed
(
()
=>
needFixedHeader
.
value
&&
hasSiderMenu
.
value
&&
!
isTop
.
value
&&
!
isMobile
.
value
,
()
=>
needFixedHeader
.
value
&&
hasSiderMenu
.
value
&&
!
isTop
.
value
&&
!
isMobile
,
);
// cache menu
const
clearMenuData
=
computed
(
...
...
@@ -99,7 +99,7 @@ export const HeaderView = defineComponent({
{
headerContentRender
&&
headerContentRender
.
value
&&
headerContentRender
.
value
(
props
)
}
</
GlobalHeader
>
);
if
(
isTop
.
value
&&
!
isMobile
.
value
)
{
if
(
isTop
.
value
&&
!
isMobile
)
{
defaultDom
=
(
<
TopNavHeader
theme=
{
navTheme
.
value
as
'light'
|
'dark'
}
...
...
src/SiderMenu/index.tsx
View file @
4d986e46
...
...
@@ -4,11 +4,14 @@ import 'ant-design-vue/es/drawer/style';
import
Drawer
from
'ant-design-vue/es/drawer'
;
import
SiderMenu
,
{
SiderMenuProps
,
PrivateSiderMenuProps
}
from
'./SiderMenu'
;
import
{
useRouteContext
}
from
'../RouteContext'
;
export
type
SiderMenuWrapperProps
=
SiderMenuProps
&
Partial
<
PrivateSiderMenuProps
>
;
const
SiderMenuWrapper
:
FunctionalComponent
<
SiderMenuWrapperProps
>
=
props
=>
{
return
props
.
isMobile
?
(
const
routeContext
=
useRouteContext
();
const
{
isMobile
}
=
routeContext
;
return
isMobile
?
(
<
Drawer
>
<
SiderMenu
{
...
props
}
/>
</
Drawer
>
...
...
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