@@ -2,7 +2,7 @@ import type { ReactNode, PropsWithChildren } from "react";
22
33export function render ( app : ReactNode ) : ReactNode ;
44
5- export function Routes ( props : PropsWithChildren < { } > ) : ReactNode ;
5+ export function Routes ( props : PropsWithChildren < { slot ?: string } > ) : ReactNode ;
66
77export function Route ( props : {
88 path : string ;
@@ -43,6 +43,20 @@ export interface App {
4343 config : Record < string , any > ;
4444}
4545
46+ /** 获取当前的特性开关配置 */
47+ export function useFlags ( ) : Record < string , boolean > ;
48+
49+ /** 获取当前的媒体查询信息 */
50+ export function useMedia ( ) : {
51+ // 屏幕宽度断点名(大屏优先)
52+ // xLarge: >= 1920px
53+ // large: >= 1600px
54+ // medium: >= 1280px
55+ // small: >= 1024px
56+ // xSmall: < 1024px
57+ breakpoint : "xSmall" | "small" | "medium" | "large" | "xLarge" ;
58+ } ;
59+
4660/** 获取当前的 URL search 参数 */
4761export function useQuery ( ) : {
4862 readonly [ key : string ] : string | undefined ;
@@ -53,6 +67,9 @@ export function usePathParams(): {
5367 readonly [ key : string ] : string | undefined ;
5468} ;
5569
70+ /** 获取当前的 URL path name */
71+ export function usePathName ( ) : string ;
72+
5673/** 获取用于进行导航跳转的对象 */
5774export function useHistory ( ) : History ;
5875
@@ -94,7 +111,7 @@ export function createContext<T>(defaultValue?: T): Context<T>;
94111
95112export interface Context < T > {
96113 /** 提供 Context 数据的组件 */
97- Provider : ( props : { value : T ; children : React . ReactNode } ) => any ;
114+ Provider : ( props : { value : T ; children : React . ReactNode } ) => ReactNode ;
98115}
99116
100117/** 将 children 放置在统一提供的 portal 容器中渲染 */
@@ -115,10 +132,7 @@ export function translate(
115132 * 第二个参数可传递变量用于替换文本中的占位符(形如 `{{ propName }}`),
116133 * 也可传递默认值,当找不到对应 key 的翻译时使用该默认值。
117134 */
118- export function translate (
119- key : string ,
120- defaultValue ?: string
121- ) : string ;
135+ export function translate ( key : string , defaultValue ?: string ) : string ;
122136
123137export function translateByRecord ( record : Record < string , string > ) : string ;
124138
0 commit comments