mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-27 14:47:28 +08:00
feat(page-wrapper): added pageWrapper component
This commit is contained in:
@@ -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,
|
||||
|
19
src/layouts/default/content/useContentContext.ts
Normal file
19
src/layouts/default/content/useContentContext.ts
Normal 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);
|
||||
}
|
30
src/layouts/default/content/useContentViewHeight.ts
Normal file
30
src/layouts/default/content/useContentViewHeight.ts
Normal 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,
|
||||
});
|
||||
}
|
@@ -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`,
|
||||
};
|
||||
|
Reference in New Issue
Block a user