feat(dashboard,diagnostic,elective): add widgets, layout, parent dashboard, role-config, services, elective components

dashboard:

- Add comparison-badge, dashboard-notification-widget, dashboard-responsive-layout, dashboard-time-range-filter

- Add parent-dashboard components directory

- Add config, hooks, and services directories

diagnostic:

- Add role-config and services directory

elective:

- Add elective-course-detail, elective-stats-cards, parent-selection-view components

- Add data-access-settings and data-access-stats
This commit is contained in:
SpecialX
2026-07-03 10:25:46 +08:00
parent dfffb61e94
commit 138b6f1b00
58 changed files with 3313 additions and 695 deletions

View File

@@ -0,0 +1,46 @@
"use client"
import { createContext, useContext, type ReactNode } from "react"
import type { DiagnosticService } from "./diagnostic-service"
/**
* v2-P1-4: 诊断模块服务 Context。
*
* 组件通过 useDiagnosticService() 获取服务实现,
* 而非直接 import actions实现依赖反转。
*
* 默认由 DefaultDiagnosticServiceProvider 注入真实实现(调用 Server Actions
* 测试时可注入 mock 实现以隔离组件测试。
*/
const DiagnosticServiceContext = createContext<DiagnosticService | null>(null)
interface DiagnosticServiceProviderProps {
service: DiagnosticService
children: ReactNode
}
export function DiagnosticServiceProvider({
service,
children,
}: DiagnosticServiceProviderProps): ReactNode {
return (
<DiagnosticServiceContext.Provider value={service}>
{children}
</DiagnosticServiceContext.Provider>
)
}
/**
* 获取诊断模块服务。
* 必须在 DiagnosticServiceProvider 内部使用。
*/
export function useDiagnosticService(): DiagnosticService {
const service = useContext(DiagnosticServiceContext)
if (!service) {
throw new Error(
"useDiagnosticService must be used within a DiagnosticServiceProvider",
)
}
return service
}