| import { fetchAppList } from '@/service/apps' | import { fetchAppList } from '@/service/apps' | ||||
| import { useSelector } from '@/context/app-context' | import { useSelector } from '@/context/app-context' | ||||
| import { NEED_REFRESH_APP_LIST_KEY } from '@/config' | import { NEED_REFRESH_APP_LIST_KEY } from '@/config' | ||||
| import { useTranslation } from 'react-i18next' | |||||
| const getKey = (pageIndex: number, previousPageData: AppListResponse) => { | const getKey = (pageIndex: number, previousPageData: AppListResponse) => { | ||||
| if (!pageIndex || previousPageData.has_more) | if (!pageIndex || previousPageData.has_more) | ||||
| } | } | ||||
| const Apps = () => { | const Apps = () => { | ||||
| const { t } = useTranslation() | |||||
| const { data, isLoading, setSize, mutate } = useSWRInfinite(getKey, fetchAppList, { revalidateFirstPage: false }) | const { data, isLoading, setSize, mutate } = useSWRInfinite(getKey, fetchAppList, { revalidateFirstPage: false }) | ||||
| const loadingStateRef = useRef(false) | const loadingStateRef = useRef(false) | ||||
| const pageContainerRef = useSelector(state => state.pageContainerRef) | const pageContainerRef = useSelector(state => state.pageContainerRef) | ||||
| const anchorRef = useRef<HTMLAnchorElement>(null) | const anchorRef = useRef<HTMLAnchorElement>(null) | ||||
| useEffect(() => { | useEffect(() => { | ||||
| document.title = `${t('app.title')} - Dify`; | |||||
| if(localStorage.getItem(NEED_REFRESH_APP_LIST_KEY) === '1') { | if(localStorage.getItem(NEED_REFRESH_APP_LIST_KEY) === '1') { | ||||
| localStorage.removeItem(NEED_REFRESH_APP_LIST_KEY) | localStorage.removeItem(NEED_REFRESH_APP_LIST_KEY) | ||||
| mutate() | mutate() |
| ) | ) | ||||
| } | } | ||||
| export const metadata = { | |||||
| title: 'Apps - Dify', | |||||
| } | |||||
| export default AppList | export default AppList |
| import { useAppContext } from '@/context/app-context' | import { useAppContext } from '@/context/app-context' | ||||
| import { fetchMembers } from '@/service/common' | import { fetchMembers } from '@/service/common' | ||||
| import { InstalledApp } from '@/models/explore' | import { InstalledApp } from '@/models/explore' | ||||
| import { useTranslation } from 'react-i18next' | |||||
| export interface IExploreProps { | export interface IExploreProps { | ||||
| children: React.ReactNode | children: React.ReactNode | ||||
| const Explore: FC<IExploreProps> = ({ | const Explore: FC<IExploreProps> = ({ | ||||
| children | children | ||||
| }) => { | }) => { | ||||
| const { t } = useTranslation() | |||||
| const [controlUpdateInstalledApps, setControlUpdateInstalledApps] = useState(0) | const [controlUpdateInstalledApps, setControlUpdateInstalledApps] = useState(0) | ||||
| const { userProfile } = useAppContext() | const { userProfile } = useAppContext() | ||||
| const [hasEditPermission, setHasEditPermission] = useState(false) | const [hasEditPermission, setHasEditPermission] = useState(false) | ||||
| const [installedApps, setInstalledApps] = useState<InstalledApp[]>([]) | const [installedApps, setInstalledApps] = useState<InstalledApp[]>([]) | ||||
| useEffect(() => { | useEffect(() => { | ||||
| document.title = `${t('explore.title')} - Dify`; | |||||
| (async () => { | (async () => { | ||||
| const { accounts } = await fetchMembers({ url: '/workspaces/current/members', params: {}}) | const { accounts } = await fetchMembers({ url: '/workspaces/current/members', params: {}}) | ||||
| if(!accounts) return | if(!accounts) return |
| const translation = { | const translation = { | ||||
| title: 'Apps', | |||||
| createApp: 'Create new App', | createApp: 'Create new App', | ||||
| modes: { | modes: { | ||||
| completion: 'Text Generator', | completion: 'Text Generator', |
| const translation = { | const translation = { | ||||
| title: '应用', | |||||
| createApp: '创建应用', | createApp: '创建应用', | ||||
| modes: { | modes: { | ||||
| completion: '文本生成型', | completion: '文本生成型', |
| const translation = { | const translation = { | ||||
| title: 'My Apps', | |||||
| sidebar: { | sidebar: { | ||||
| discovery: 'Discovery', | discovery: 'Discovery', | ||||
| workspace: 'Workspace', | workspace: 'Workspace', |
| const translation = { | const translation = { | ||||
| title: '我的应用', | |||||
| sidebar: { | sidebar: { | ||||
| discovery: '发现', | discovery: '发现', | ||||
| workspace: '工作区', | workspace: '工作区', |