mirror of
https://github.com/langgenius/dify.git
synced 2026-05-13 08:57:28 +08:00
33 lines
800 B
TypeScript
33 lines
800 B
TypeScript
import { PLUGIN_TYPE_SEARCH_MAP } from './marketplace/constants'
|
|
|
|
export type LegacyPluginsSearchParams = Record<string, string | string[] | undefined>
|
|
|
|
const INSTALLED_PLUGINS_TAB = 'plugins'
|
|
const MARKETPLACE_TAB = 'discover'
|
|
|
|
const marketplacePluginTabs = new Set<string>([
|
|
MARKETPLACE_TAB,
|
|
...Object.values(PLUGIN_TYPE_SEARCH_MAP),
|
|
])
|
|
|
|
const getFirstSearchParamValue = (value: string | string[] | undefined) => {
|
|
if (Array.isArray(value))
|
|
return value[0]
|
|
|
|
return value
|
|
}
|
|
|
|
export const getLegacyPluginRedirectPath = (
|
|
searchParams: LegacyPluginsSearchParams = {},
|
|
) => {
|
|
const tab = getFirstSearchParamValue(searchParams.tab)
|
|
|
|
if (!tab || tab === INSTALLED_PLUGINS_TAB)
|
|
return '/integrations'
|
|
|
|
if (marketplacePluginTabs.has(tab))
|
|
return undefined
|
|
|
|
return undefined
|
|
}
|