| }, | }, | ||||
| ] | ] | ||||
| return navs | return navs | ||||
| }, [t]) | |||||
| }, []) | |||||
| useEffect(() => { | useEffect(() => { | ||||
| if (appDetail) { | if (appDetail) { | ||||
| }).finally(() => { | }).finally(() => { | ||||
| setIsLoadingAppDetail(false) | setIsLoadingAppDetail(false) | ||||
| }) | }) | ||||
| }, [appId, router, setAppDetail]) | |||||
| }, [appId, pathname]) | |||||
| useEffect(() => { | useEffect(() => { | ||||
| if (!appDetailRes || isLoadingCurrentWorkspace || isLoadingAppDetail) | if (!appDetailRes || isLoadingCurrentWorkspace || isLoadingAppDetail) | ||||
| } | } | ||||
| } | } | ||||
| // eslint-disable-next-line react-hooks/exhaustive-deps | // eslint-disable-next-line react-hooks/exhaustive-deps | ||||
| }, [appDetailRes, appId, getNavigations, isCurrentWorkspaceEditor, isLoadingAppDetail, isLoadingCurrentWorkspace, router, setAppDetail, systemFeatures.enable_web_sso_switch_component]) | |||||
| }, [appDetailRes, isCurrentWorkspaceEditor, isLoadingAppDetail, isLoadingCurrentWorkspace, systemFeatures.enable_web_sso_switch_component]) | |||||
| useUnmount(() => { | useUnmount(() => { | ||||
| setAppDetail() | setAppDetail() |
| import { useSelectedLayoutSegment } from 'next/navigation' | import { useSelectedLayoutSegment } from 'next/navigation' | ||||
| import Link from 'next/link' | import Link from 'next/link' | ||||
| import classNames from '@/utils/classnames' | import classNames from '@/utils/classnames' | ||||
| import type { RemixiconComponentType } from '@remixicon/react' | |||||
| export type NavIcon = React.ComponentType< | export type NavIcon = React.ComponentType< | ||||
| React.PropsWithoutRef<React.ComponentProps<'svg'>> & { | React.PropsWithoutRef<React.ComponentProps<'svg'>> & { | ||||
| title?: string | undefined | title?: string | undefined | ||||
| titleId?: string | undefined | titleId?: string | undefined | ||||
| } | |||||
| > | |||||
| }> | RemixiconComponentType | |||||
| export type NavLinkProps = { | export type NavLinkProps = { | ||||
| name: string | name: string |
| }))) | }))) | ||||
| const { data: fileUploadConfigResponse } = useSWR({ url: '/files/upload' }, fetchFileUploadConfig) | const { data: fileUploadConfigResponse } = useSWR({ url: '/files/upload' }, fetchFileUploadConfig) | ||||
| const latestPublishedAt = useMemo(() => appDetail?.model_config.updated_at, [appDetail]) | |||||
| const latestPublishedAt = useMemo(() => appDetail?.model_config?.updated_at, [appDetail]) | |||||
| const [formattingChanged, setFormattingChanged] = useState(false) | const [formattingChanged, setFormattingChanged] = useState(false) | ||||
| const { setShowAccountSettingModal } = useModalContext() | const { setShowAccountSettingModal } = useModalContext() | ||||
| const [hasFetchedDetail, setHasFetchedDetail] = useState(false) | const [hasFetchedDetail, setHasFetchedDetail] = useState(false) |
| icon_background, | icon_background, | ||||
| description, | description, | ||||
| }) => { | }) => { | ||||
| const { export_data } = await fetchAppDetail( | |||||
| const { export_data, mode } = await fetchAppDetail( | |||||
| currApp?.app.id as string, | currApp?.app.id as string, | ||||
| ) | ) | ||||
| try { | try { | ||||
| if (app.app_id) | if (app.app_id) | ||||
| await handleCheckPluginDependencies(app.app_id) | await handleCheckPluginDependencies(app.app_id) | ||||
| localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') | localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') | ||||
| getRedirection(isCurrentWorkspaceEditor, { id: app.app_id }, push) | |||||
| getRedirection(isCurrentWorkspaceEditor, { id: app.app_id, mode }, push) | |||||
| } | } | ||||
| catch (e) { | catch (e) { | ||||
| Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) | Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) |
| icon_background, | icon_background, | ||||
| description, | description, | ||||
| }) => { | }) => { | ||||
| const { export_data } = await fetchAppDetail( | |||||
| const { export_data, mode } = await fetchAppDetail( | |||||
| currApp?.app.id as string, | currApp?.app.id as string, | ||||
| ) | ) | ||||
| try { | try { | ||||
| if (app.app_id) | if (app.app_id) | ||||
| await handleCheckPluginDependencies(app.app_id) | await handleCheckPluginDependencies(app.app_id) | ||||
| localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') | localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') | ||||
| getRedirection(isCurrentWorkspaceEditor, { id: app.app_id }, push) | |||||
| getRedirection(isCurrentWorkspaceEditor, { id: app.app_id, mode }, push) | |||||
| } | } | ||||
| catch (e) { | catch (e) { | ||||
| Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) | Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) |