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
44bb2288
Commit
44bb2288
authored
Feb 02, 2021
by
Sendya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deploy: alpha.5
parent
bed5d170
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
31 deletions
+21
-31
BasicLayout.tsx
src/BasicLayout.tsx
+20
-18
SiderMenu.tsx
src/SiderMenu/SiderMenu.tsx
+0
-1
useMergedState.ts
src/hooks/useMergedState.ts
+0
-12
tsconfig.json
tsconfig.json
+1
-0
No files found.
src/BasicLayout.tsx
View file @
44bb2288
import
{
computed
,
FunctionalComponent
,
CSSProperties
,
VNodeChild
,
VNode
,
ComputedRef
}
from
'vue'
;
import
{
computed
,
FunctionalComponent
,
CSSProperties
,
VNodeChild
,
VNode
}
from
'vue'
;
import
'ant-design-vue/es/layout/style'
;
import
Layout
from
'ant-design-vue/es/layout'
;
import
{
withInstall
}
from
'ant-design-vue/es/_util/type'
;
...
...
@@ -8,7 +8,6 @@ import { WrapContent } from './WrapContent';
import
{
default
as
Header
,
HeaderViewProps
}
from
'./Header'
;
import
{
RenderVNodeType
,
WithFalse
}
from
'./typings'
;
import
{
getComponentOrSlot
,
PropRenderType
,
PropTypes
}
from
'./utils'
;
import
useMergedState
from
'./hooks/useMergedState'
;
import
'./BasicLayout.less'
;
const
defaultI18nRender
=
(
key
:
string
)
=>
key
;
...
...
@@ -50,27 +49,26 @@ export type BasicLayoutProps = SiderMenuWrapperProps &
disableContentMargin
?:
boolean
;
};
const
ProLayout
:
FunctionalComponent
<
BasicLayoutProps
>
=
(
props
,
{
emit
,
slots
,
attrs
})
=>
{
const
ProLayout
:
FunctionalComponent
<
BasicLayoutProps
>
=
(
props
,
{
emit
,
slots
})
=>
{
const
{
onCollapse
:
propsOnCollapse
,
contentStyle
,
disableContentMargin
,
siderWidth
=
208
,
menu
,
isChildrenLayout
:
propsIsChildrenLayout
,
loading
,
//
loading,
layout
,
matchMenuKeys
,
navTheme
,
menuData
,
isMobile
,
defaultCollapsed
,
//
defaultCollapsed,
}
=
props
;
const
isTop
=
computed
(()
=>
layout
===
'top'
);
const
isSide
=
computed
(()
=>
layout
===
'side'
);
const
isMix
=
computed
(()
=>
layout
===
'mix'
);
//
const isSide = computed(() => layout === 'side');
//
const isMix = computed(() => layout === 'mix');
const
handleCollapse
=
(
collapsed
:
boolean
)
=>
{
propsOnCollapse
&&
propsOnCollapse
(
collapsed
);
emit
(
'update:collapsed'
,
collapsed
);
};
const
handleOpenKeys
=
(
openKeys
:
string
[]
|
false
):
void
=>
{
...
...
@@ -92,10 +90,10 @@ const ProLayout: FunctionalComponent<BasicLayoutProps> = (props, { emit, slots,
};
});
const
[
collapsed
,
onCollapse
]
=
useMergedState
<
boolean
>
(
defaultCollapsed
||
false
,
{
value
:
props
.
collapsed
,
onChange
:
propsOnCollapse
,
});
//
const [collapsed, onCollapse] = useMergedState<boolean>(defaultCollapsed || false, {
//
value: props.collapsed,
//
onChange: propsOnCollapse,
//
});
const
headerRender
=
(
props
:
BasicLayoutProps
&
{
hasSiderMenu
:
boolean
;
...
...
@@ -119,8 +117,7 @@ const ProLayout: FunctionalComponent<BasicLayoutProps> = (props, { emit, slots,
hasSiderMenu
:
!
isTop
.
value
,
menuData
,
isMobile
,
collapsed
,
onCollapse
,
onCollapse
:
handleCollapse
,
onSelect
:
handleSelect
,
onOpenKeys
:
handleOpenKeys
,
customHeaderRender
,
...
...
@@ -133,7 +130,7 @@ const ProLayout: FunctionalComponent<BasicLayoutProps> = (props, { emit, slots,
);
const
footerRender
=
getComponentOrSlot
(
props
,
slots
,
'footerRender'
);
const
menuRender
=
getComponentOrSlot
(
props
,
slots
,
'menuRender'
);
//
const menuRender = getComponentOrSlot(props, slots, 'menuRender');
// const menuHeaderRender = getComponentOrSlot(props, slots, 'menuHeaderRender');
return
(
...
...
@@ -154,9 +151,14 @@ const ProLayout: FunctionalComponent<BasicLayoutProps> = (props, { emit, slots,
onOpenKeys=
{
handleOpenKeys
}
/>
)
}
<
Layout
style=
{
contentStyle
}
>
<
Layout
>
{
headerDom
}
<
WrapContent
style=
{
props
.
contentStyle
}
>
{
slots
.
default
?.()
}
</
WrapContent
>
<
WrapContent
isChildrenLayout=
{
propsIsChildrenLayout
}
style=
{
disableContentMargin
?
null
:
contentStyle
}
>
{
slots
.
default
?.()
}
</
WrapContent
>
{
footerRender
!==
false
&&
footerRender
&&
footerRender
}
</
Layout
>
</
Layout
>
...
...
src/SiderMenu/SiderMenu.tsx
View file @
44bb2288
...
...
@@ -11,7 +11,6 @@ import { useProProvider } from '../ProProvider';
import
{
useRouteContext
}
from
'../RouteContext'
;
import
{
getMenuFirstChildren
}
from
'../utils'
;
import
'./index.less'
;
import
{
emit
}
from
'process'
;
const
{
Sider
}
=
Layout
;
...
...
src/hooks/useMergedState.ts
deleted
100644 → 0
View file @
bed5d170
export
default
function
useControlledState
<
T
,
R
=
T
>
(
defaultStateValue
:
T
|
(()
=>
T
),
option
?:
{
defaultValue
?:
T
|
(()
=>
T
);
value
?:
T
;
onChange
?:
(
value
:
T
,
prevValue
:
T
)
=>
void
;
postState
?:
(
value
:
T
)
=>
T
;
},
):
[
R
,
(
value
:
T
)
=>
void
]
{
const
triggerChange
=
()
=>
{};
return
[
null
,
triggerChange
];
}
tsconfig.json
View file @
44bb2288
...
...
@@ -7,6 +7,7 @@
"moduleResolution"
:
"node"
,
"jsx"
:
"preserve"
,
"esModuleInterop"
:
true
,
"skipLibCheck"
:
true
,
"lib"
:
[
"DOM"
,
"DOM.Iterable"
,
...
...
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