# 环境变量 context 上下文 的node或则浏览器当中,如果global中不存在context,则赋值到global,如果存在,则获取对应的。 ```ts import { useContextKey } from '@kevisual/context'; const v = useContextKey('a', () => '123'); // 如果是第一次初始化,返回123,否则返回之前初始化的值 ``` ### types ```ts type GlobalContext = { name?: string; [key: string]: any; } & T; declare const useEnv: (initEnv?: GlobalContext, initKey?: string, isOverwrite?: boolean) => Required>; type InitResult = T | Promise | null; type InitFn = () => T | Promise; type Init = T | InitFn | null; type AsyncResult = ASYNC extends true ? Promise : T; type SimpleObject = Record; declare const useEnvKey: (key: string, init?: Init, initKey?: string) => InitResult; declare const usePageEnv: (init?: Init, initKey?: string) => any; declare const useEnvKeyNew: (key: string, initKey?: string, opts?: { getNew?: boolean; init?: Init; }) => any; declare const useContext: (initContext?: GlobalContext, isOverwrite?: boolean) => Required>; declare const useContextKey: (key: string, init?: Init, isNew?: boolean) => AsyncResult; declare const usePageContext: (init?: Init) => any; declare const useConfig: (initConfig?: Partial>, isOverwrite?: boolean) => Required>>>; declare const useConfigKey: (key: string, init?: Init, isNew?: boolean) => AsyncResult; declare const usePageConfig: (init?: Init) => any; export { useConfig, useConfigKey, useContext, useContextKey, useEnv, useEnvKey, useEnvKeyNew, usePageConfig, usePageContext, usePageEnv }; ```