chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
60158935f4
commit
6519682885
15831 files changed
+3063428
No files matched your search
@@ -0,0 +1,48 @@
|
||||
'use client'
|
||||
|
||||
import type { RefObject } from 'react'
|
||||
import type { PLUGIN_TYPE_SEARCH_MAP } from '../marketplace/constants'
|
||||
import type { FilterState } from './filter-management'
|
||||
import { noop } from 'es-toolkit/function'
|
||||
import { createContext, useContextSelector } from 'use-context-selector'
|
||||
import { PLUGIN_PAGE_TABS_MAP } from '../hooks'
|
||||
|
||||
export type PluginPageTab =
|
||||
| (typeof PLUGIN_PAGE_TABS_MAP)[keyof typeof PLUGIN_PAGE_TABS_MAP]
|
||||
| (typeof PLUGIN_TYPE_SEARCH_MAP)[keyof typeof PLUGIN_TYPE_SEARCH_MAP]
|
||||
|
||||
export type PluginPageSelection =
|
||||
| { type: 'builtinTool'; id: string }
|
||||
| { type: 'plugin'; id: string }
|
||||
|
||||
type PluginPageContextValue = {
|
||||
containerRef: RefObject<HTMLDivElement | null>
|
||||
selectedItem: PluginPageSelection | undefined
|
||||
setSelectedItem: (item?: PluginPageSelection) => void
|
||||
filters: FilterState
|
||||
setFilters: (filter: FilterState) => void
|
||||
activeTab: PluginPageTab
|
||||
setActiveTab: (tab: PluginPageTab) => void
|
||||
options: Array<{ value: string; text: string }>
|
||||
}
|
||||
|
||||
const emptyContainerRef: RefObject<HTMLDivElement | null> = { current: null }
|
||||
|
||||
export const PluginPageContext = createContext<PluginPageContextValue>({
|
||||
containerRef: emptyContainerRef,
|
||||
selectedItem: undefined,
|
||||
setSelectedItem: noop,
|
||||
filters: {
|
||||
categories: [],
|
||||
tags: [],
|
||||
searchQuery: '',
|
||||
},
|
||||
setFilters: noop,
|
||||
activeTab: PLUGIN_PAGE_TABS_MAP.plugins,
|
||||
setActiveTab: noop,
|
||||
options: [],
|
||||
})
|
||||
|
||||
export function usePluginPageContext<T>(selector: (value: PluginPageContextValue) => T) {
|
||||
return useContextSelector(PluginPageContext, selector)
|
||||
}
|
||||
Reference in new issue
Block a user