项目初始化
This commit is contained in:
18
web-vue/packages/core/hooks/component/usePageContext.ts
Normal file
18
web-vue/packages/core/hooks/component/usePageContext.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { InjectionKey, ComputedRef, Ref } from 'vue';
|
||||
import { createContext, useContext } from '@jeesite/core/hooks/core/useContext';
|
||||
|
||||
export interface PageContextProps {
|
||||
contentHeight: ComputedRef<number>;
|
||||
pageHeight: Ref<number>;
|
||||
setPageHeight: (height: number) => Promise<void>;
|
||||
}
|
||||
|
||||
const key: InjectionKey<PageContextProps> = Symbol();
|
||||
|
||||
export function createPageContext(context: PageContextProps) {
|
||||
return createContext<PageContextProps>(context, key, { native: true });
|
||||
}
|
||||
|
||||
export function usePageContext() {
|
||||
return useContext<PageContextProps>(key);
|
||||
}
|
||||
Reference in New Issue
Block a user