mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-25 13:45:03 +08:00
feat(skills): flag unmanaged skills with a green dot on the Import button
- Add an optional `enabled` flag to useScanUnmanagedSkills; the Skills panel scans once on mount (enabled:true), with 30s staleTime + keepPreviousData to dedupe disk IO across navigations. - App subscribes to the shared query (enabled:false) and renders a green dot + tooltip on the top-bar Import button when unmanaged skills are available.
This commit is contained in:
@@ -187,12 +187,19 @@ export function useToggleSkillApp() {
|
||||
|
||||
/**
|
||||
* 扫描未管理的 Skills
|
||||
*
|
||||
* - 传 { enabled: true }(Skill 面板挂载时)会在进入页面时自动静默扫描一次,
|
||||
* 30s 内复用结果,避免来回切页时重复磁盘 IO。
|
||||
* - 默认 enabled: false:仅订阅共享缓存(如顶栏「导入」按钮的绿点提示),
|
||||
* 不主动触发扫描。两者共用同一 queryKey,面板扫描完成后绿点会自动亮起。
|
||||
*/
|
||||
export function useScanUnmanagedSkills() {
|
||||
export function useScanUnmanagedSkills(options?: { enabled?: boolean }) {
|
||||
return useQuery({
|
||||
queryKey: ["skills", "unmanaged"],
|
||||
queryFn: () => skillsApi.scanUnmanaged(),
|
||||
enabled: false, // 手动触发
|
||||
enabled: options?.enabled ?? false,
|
||||
staleTime: 30 * 1000,
|
||||
placeholderData: keepPreviousData,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user