2024-11-17 17:17:40 +08:00
|
|
|
import { CapabilityService } from "services/capabilityService";
|
|
|
|
import { ThemeService } from "services/themeService";
|
|
|
|
import { createServiceContext } from "./createServiceContext";
|
|
|
|
import { ReactNode } from "react";
|
2024-11-14 23:01:21 +08:00
|
|
|
|
2024-11-17 17:17:40 +08:00
|
|
|
export const { ExtensionProvider, useExtension } = createServiceContext(
|
|
|
|
"Extension",
|
|
|
|
() => CapabilityService.getInstance(),
|
|
|
|
);
|
2024-11-14 23:01:21 +08:00
|
|
|
|
2024-11-17 17:17:40 +08:00
|
|
|
export const { ThemeProvider, useTheme } = createServiceContext("Theme", () =>
|
|
|
|
ThemeService.getInstance(),
|
|
|
|
);
|
2024-11-14 23:01:21 +08:00
|
|
|
|
2024-11-17 17:17:40 +08:00
|
|
|
// File path:hooks/servicesProvider.tsx
|
|
|
|
/**
|
|
|
|
* ServiceProvider 组件用于提供扩展和主题上下文给其子组件。
|
|
|
|
*
|
|
|
|
* @param children - 要渲染的子组件。
|
|
|
|
*/
|
|
|
|
export const ServiceProvider = ({ children }: { children: ReactNode }) => (
|
|
|
|
<ExtensionProvider>
|
|
|
|
<ThemeProvider>{children}</ThemeProvider>
|
|
|
|
</ExtensionProvider>
|
|
|
|
);
|