Skip to content

Commit

Permalink
Revert "fix: get isMobile props from RouteContext"
Browse files Browse the repository at this point in the history
This reverts commit 4d986e4.
  • Loading branch information
sendya committed Feb 8, 2021
1 parent 1cbb2b3 commit 7ea945d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
4 changes: 1 addition & 3 deletions src/BasicLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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;

Expand Down Expand Up @@ -61,10 +60,9 @@ 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');
Expand Down
4 changes: 1 addition & 3 deletions src/GlobalHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ 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;
Expand Down Expand Up @@ -52,6 +51,7 @@ export const GlobalHeader: FunctionalComponent<GlobalHeaderProps & PrivateSiderM
{ slots },
) => {
const {
isMobile,
logo,
collapsed,
onCollapse,
Expand All @@ -66,8 +66,6 @@ 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`);
Expand Down
6 changes: 3 additions & 3 deletions src/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const HeaderView = defineComponent({
prefixCls,
headerRender,
headerContentRender,
isMobile,
fixedHeader,
hasSiderMenu,
headerHeight,
Expand All @@ -76,11 +77,10 @@ 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,
() => needFixedHeader.value && hasSiderMenu.value && !isTop.value && !isMobile.value,
);
// cache menu
const clearMenuData = computed(
Expand All @@ -99,7 +99,7 @@ export const HeaderView = defineComponent({
{headerContentRender && headerContentRender.value && headerContentRender.value(props)}
</GlobalHeader>
);
if (isTop.value && !isMobile) {
if (isTop.value && !isMobile.value) {
defaultDom = (
<TopNavHeader
theme={navTheme.value as 'light' | 'dark'}
Expand Down
5 changes: 1 addition & 4 deletions src/SiderMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ 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 => {
const routeContext = useRouteContext();
const { isMobile } = routeContext;
return isMobile ? (
return props.isMobile ? (
<Drawer>
<SiderMenu {...props} />
</Drawer>
Expand Down

0 comments on commit 7ea945d

Please sign in to comment.