feat(page-wrapper): added pageWrapper component

This commit is contained in:
vben
2021-01-05 21:45:05 +08:00
parent c031163f34
commit 31ff0559fe
79 changed files with 755 additions and 470 deletions

View File

@@ -19,6 +19,7 @@
import { useRootSetting } from '/@/hooks/setting/useRootSetting';
import { useTransitionSetting } from '/@/hooks/setting/useTransitionSetting';
import PageLayout from '/@/layouts/page/index';
import { useContentViewHeight } from './useContentViewHeight';
import { Loading } from '/@/components/Loading';
export default defineComponent({
@@ -28,6 +29,8 @@
const { prefixCls } = useDesign('layout-content');
const { getOpenPageLoading } = useTransitionSetting();
const { getLayoutContentMode, getPageLoading } = useRootSetting();
useContentViewHeight();
return {
prefixCls,
getOpenPageLoading,

View File

@@ -0,0 +1,19 @@
import type { InjectionKey, ComputedRef } from 'vue';
import { createContext, useContext } from '/@/hooks/core/useContext';
import {} from 'vue';
export interface ContentContextProps {
contentHeight: ComputedRef<number>;
setPageHeight: (height: number) => Promise<void>;
}
const key: InjectionKey<ContentContextProps> = Symbol();
export function createContentContext(context: ContentContextProps) {
return createContext<ContentContextProps>(context, key, { native: true });
}
export function useContentContext() {
return useContext<ContentContextProps>(key);
}

View File

@@ -0,0 +1,30 @@
import { ref, computed, unref } from 'vue';
import { createPageContext } from '/@/hooks/component/usePageContext';
import { useWindowSizeFn } from '/@/hooks/event/useWindowSizeFn';
export const headerHeightRef = ref(0);
export function useContentViewHeight() {
const contentHeight = ref(window.innerHeight);
const pageHeight = ref(window.innerHeight);
const getViewHeight = computed(() => {
return unref(contentHeight) - unref(headerHeightRef) || 0;
});
useWindowSizeFn(
() => {
contentHeight.value = window.innerHeight;
},
100,
{ immediate: true }
);
async function setPageHeight(height: number) {
pageHeight.value = height;
}
createPageContext({
contentHeight: getViewHeight,
setPageHeight,
pageHeight,
});
}

View File

@@ -17,6 +17,7 @@
import { useMultipleTabSetting } from '/@/hooks/setting/useMultipleTabSetting';
import { useAppInject } from '/@/hooks/web/useAppInject';
import { useDesign } from '/@/hooks/web/useDesign';
import { headerHeightRef } from '../content/useContentViewHeight';
const HEADER_HEIGHT = 48;
@@ -75,6 +76,7 @@
if (unref(getShowMultipleTab)) {
height += TABS_HEIGHT;
}
headerHeightRef.value = height;
return {
height: `${height}px`,
};