mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-10 03:16:51 +08:00
chore: perfect type definition (#1003)
This commit is contained in:
@@ -7,7 +7,7 @@ import { useContext } from 'use-context-selector'
|
||||
import Toast from '../../base/toast'
|
||||
import s from './style.module.css'
|
||||
import ExploreContext from '@/context/explore-context'
|
||||
import type { App } from '@/models/explore'
|
||||
import type { App, AppCategory } from '@/models/explore'
|
||||
import Category from '@/app/components/explore/category'
|
||||
import AppCard from '@/app/components/explore/app-card'
|
||||
import { fetchAppDetail, fetchAppList, installApp } from '@/service/explore'
|
||||
@@ -22,7 +22,7 @@ const Apps: FC = () => {
|
||||
const { t } = useTranslation()
|
||||
const router = useRouter()
|
||||
const { setControlUpdateInstalledApps, hasEditPermission } = useContext(ExploreContext)
|
||||
const [currCategory, setCurrCategory] = React.useState('')
|
||||
const [currCategory, setCurrCategory] = React.useState<AppCategory | ''>('')
|
||||
const [allList, setAllList] = React.useState<App[]>([])
|
||||
const [isLoaded, setIsLoaded] = React.useState(false)
|
||||
|
||||
@@ -31,7 +31,8 @@ const Apps: FC = () => {
|
||||
return allList
|
||||
return allList.filter(item => item.category === currCategory)
|
||||
})()
|
||||
const [categories, setCategories] = React.useState([])
|
||||
|
||||
const [categories, setCategories] = React.useState<AppCategory[]>([])
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const { categories, recommended_apps }: any = await fetchAppList()
|
||||
|
||||
@@ -4,14 +4,15 @@ import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import cn from 'classnames'
|
||||
import exploreI18n from '@/i18n/lang/explore.en'
|
||||
import type { AppCategory } from '@/models/explore'
|
||||
|
||||
const categoryI18n = exploreI18n.category
|
||||
|
||||
export type ICategoryProps = {
|
||||
className?: string
|
||||
list: string[]
|
||||
list: AppCategory[]
|
||||
value: string
|
||||
onChange: (value: string) => void
|
||||
onChange: (value: AppCategory | '') => void
|
||||
}
|
||||
|
||||
const Category: FC<ICategoryProps> = ({
|
||||
@@ -40,7 +41,7 @@ const Category: FC<ICategoryProps> = ({
|
||||
style={itemStyle(name === value)}
|
||||
onClick={() => onChange(name)}
|
||||
>
|
||||
{(categoryI18n as any)[name] ? t(`explore.category.${name}`) : name}
|
||||
{categoryI18n[name] ? t(`explore.category.${name}`) : name}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user