2026-01-22 10:16:37 +00:00
|
|
|
import type { App, InstalledApp } from '@/models/explore'
|
2025-12-31 03:13:22 +00:00
|
|
|
import { noop } from 'es-toolkit/function'
|
2025-12-23 08:58:55 +00:00
|
|
|
import { createContext } from 'use-context-selector'
|
2023-05-25 08:59:47 +00:00
|
|
|
|
2026-01-22 10:16:37 +00:00
|
|
|
export type CurrentTryAppParams = {
|
|
|
|
|
appId: string
|
|
|
|
|
app: App
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type IExplore = {
|
2023-05-25 08:59:47 +00:00
|
|
|
controlUpdateInstalledApps: number
|
|
|
|
|
setControlUpdateInstalledApps: (controlUpdateInstalledApps: number) => void
|
|
|
|
|
hasEditPermission: boolean
|
|
|
|
|
installedApps: InstalledApp[]
|
|
|
|
|
setInstalledApps: (installedApps: InstalledApp[]) => void
|
2025-07-17 02:52:10 +00:00
|
|
|
isFetchingInstalledApps: boolean
|
|
|
|
|
setIsFetchingInstalledApps: (isFetchingInstalledApps: boolean) => void
|
2026-01-22 10:16:37 +00:00
|
|
|
currentApp?: CurrentTryAppParams
|
|
|
|
|
isShowTryAppPanel: boolean
|
|
|
|
|
setShowTryAppPanel: (showTryAppPanel: boolean, params?: CurrentTryAppParams) => void
|
2023-05-25 08:59:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ExploreContext = createContext<IExplore>({
|
|
|
|
|
controlUpdateInstalledApps: 0,
|
2025-04-06 09:56:08 +00:00
|
|
|
setControlUpdateInstalledApps: noop,
|
2023-05-25 08:59:47 +00:00
|
|
|
hasEditPermission: false,
|
|
|
|
|
installedApps: [],
|
2025-04-06 09:56:08 +00:00
|
|
|
setInstalledApps: noop,
|
2025-07-17 02:52:10 +00:00
|
|
|
isFetchingInstalledApps: false,
|
|
|
|
|
setIsFetchingInstalledApps: noop,
|
2026-01-22 10:16:37 +00:00
|
|
|
isShowTryAppPanel: false,
|
|
|
|
|
setShowTryAppPanel: noop,
|
|
|
|
|
currentApp: undefined,
|
2023-05-25 08:59:47 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export default ExploreContext
|