echoes/frontend/hooks/servicesProvider.tsx
lsy 5ca72e42cf 前端:创建api,主题,路由服务,重新定义主题插件的约束,错误,加载组件
后端:去除文章和模板的自义定路径,创建获取系统令牌api
2024-11-18 01:09:28 +08:00

35 lines
1.0 KiB
TypeScript

import { CapabilityService } from "services/capabilityService";
import { ThemeService } from "services/themeService";
import { ApiService } from "services/apiService";
import { createServiceContext } from "hooks/createServiceContext";
import { ReactNode } from "react";
export const { CapabilityProvider, useCapability } = createServiceContext(
"Capability", () => CapabilityService.getInstance(),
);
export const { ThemeProvider, useTheme } = createServiceContext(
"Theme", () => ThemeService.getInstance(),
);
export const { ApiProvider, useApi } = createServiceContext(
"Api", () => ThemeService.getInstance(),
);
// File path:hooks/servicesProvider.tsx
/**
* ServiceProvider 组件用于提供扩展和主题上下文给其子组件。
*
* @param children - 要渲染的子组件。
*/
export const ServiceProvider = ({ children }: { children: ReactNode }) => (
<ApiProvider>
<CapabilityProvider>
<ThemeProvider>
{children}
</ThemeProvider>
</CapabilityProvider>
</ApiProvider>
);