external knowledge api (#8913)
Co-authored-by: Yi <yxiaoisme@gmail.com>
This commit is contained in:
parent
77aef9ff1d
commit
9d221a5e19
90 changed files with 4623 additions and 1171 deletions
28
web/context/external-api-panel-context.tsx
Normal file
28
web/context/external-api-panel-context.tsx
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
'use client'
|
||||
|
||||
import React, { createContext, useContext, useState } from 'react'
|
||||
|
||||
type ExternalApiPanelContextType = {
|
||||
showExternalApiPanel: boolean
|
||||
setShowExternalApiPanel: (show: boolean) => void
|
||||
}
|
||||
|
||||
const ExternalApiPanelContext = createContext<ExternalApiPanelContextType | undefined>(undefined)
|
||||
|
||||
export const ExternalApiPanelProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||
const [showExternalApiPanel, setShowExternalApiPanel] = useState(false)
|
||||
|
||||
return (
|
||||
<ExternalApiPanelContext.Provider value={{ showExternalApiPanel, setShowExternalApiPanel }}>
|
||||
{children}
|
||||
</ExternalApiPanelContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export const useExternalApiPanel = () => {
|
||||
const context = useContext(ExternalApiPanelContext)
|
||||
if (context === undefined)
|
||||
throw new Error('useExternalApiPanel must be used within an ExternalApiPanelProvider')
|
||||
|
||||
return context
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue