chore: perfect type definition (#940)
This commit is contained in:
@@ -13,8 +13,10 @@ import AppCard from '@/app/components/explore/app-card'
|
||||
import { fetchAppDetail, fetchAppList, installApp } from '@/service/explore'
|
||||
import { createApp } from '@/service/apps'
|
||||
import CreateAppModal from '@/app/components/explore/create-app-modal'
|
||||
import type { CreateAppModalProps } from '@/app/components/explore/create-app-modal'
|
||||
import Loading from '@/app/components/base/loading'
|
||||
import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
|
||||
import { type AppMode } from '@/types/app'
|
||||
|
||||
const Apps: FC = () => {
|
||||
const { t } = useTranslation()
|
||||
@@ -50,7 +52,7 @@ const Apps: FC = () => {
|
||||
|
||||
const [currApp, setCurrApp] = React.useState<App | null>(null)
|
||||
const [isShowCreateModal, setIsShowCreateModal] = React.useState(false)
|
||||
const onCreate = async ({ name, icon, icon_background }: any) => {
|
||||
const onCreate: CreateAppModalProps['onConfirm'] = async ({ name, icon, icon_background }) => {
|
||||
const { app_model_config: model_config } = await fetchAppDetail(currApp?.app.id as string)
|
||||
|
||||
try {
|
||||
@@ -58,7 +60,7 @@ const Apps: FC = () => {
|
||||
name,
|
||||
icon,
|
||||
icon_background,
|
||||
mode: currApp?.app.mode as any,
|
||||
mode: currApp?.app.mode as AppMode,
|
||||
config: model_config,
|
||||
})
|
||||
setIsShowCreateModal(false)
|
||||
|
||||
@@ -9,10 +9,14 @@ import Toast from '@/app/components/base/toast'
|
||||
import AppIcon from '@/app/components/base/app-icon'
|
||||
import EmojiPicker from '@/app/components/base/emoji-picker'
|
||||
|
||||
type IProps = {
|
||||
export type CreateAppModalProps = {
|
||||
appName: string
|
||||
show: boolean
|
||||
onConfirm: (info: any) => void
|
||||
onConfirm: (info: {
|
||||
name: string
|
||||
icon: string
|
||||
icon_background: string
|
||||
}) => Promise<void>
|
||||
onHide: () => void
|
||||
}
|
||||
|
||||
@@ -21,7 +25,7 @@ const CreateAppModal = ({
|
||||
show = false,
|
||||
onConfirm,
|
||||
onHide,
|
||||
}: IProps) => {
|
||||
}: CreateAppModalProps) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const [name, setName] = React.useState('')
|
||||
|
||||
@@ -6,12 +6,13 @@ import { useTranslation } from 'react-i18next'
|
||||
import s from './style.module.css'
|
||||
import Config from '@/app/components/explore/universal-chat/config'
|
||||
import type { ProviderEnum } from '@/app/components/header/account-setting/model-page/declarations'
|
||||
import type { DataSet } from '@/models/datasets'
|
||||
|
||||
type Props = {
|
||||
modelId: string
|
||||
providerName: ProviderEnum
|
||||
plugins: Record<string, boolean>
|
||||
dataSets: any[]
|
||||
dataSets: DataSet[]
|
||||
}
|
||||
const ConfigViewPanel: FC<Props> = ({
|
||||
modelId,
|
||||
|
||||
@@ -10,12 +10,13 @@ import ConfigDetail from '@/app/components/explore/universal-chat/config-view/de
|
||||
import type { ProviderEnum } from '@/app/components/header/account-setting/model-page/declarations'
|
||||
import ModelName from '@/app/components/app/configuration/config-model/model-name'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
import type { DataSet } from '@/models/datasets'
|
||||
|
||||
export type ISummaryProps = {
|
||||
modelId: string
|
||||
providerName: ProviderEnum
|
||||
plugins: Record<string, boolean>
|
||||
dataSets: any[]
|
||||
dataSets: DataSet[]
|
||||
}
|
||||
|
||||
const getColorInfo = (modelId: string) => {
|
||||
|
||||
@@ -5,6 +5,7 @@ import ModelConfig from './model-config'
|
||||
import DataConfig from './data-config'
|
||||
import PluginConfig from './plugins-config'
|
||||
import type { ProviderEnum } from '@/app/components/header/account-setting/model-page/declarations'
|
||||
import type { DataSet } from '@/models/datasets'
|
||||
|
||||
export type IConfigProps = {
|
||||
className?: string
|
||||
@@ -14,8 +15,8 @@ export type IConfigProps = {
|
||||
onModelChange?: (modelId: string, providerName: ProviderEnum) => void
|
||||
plugins: Record<string, boolean>
|
||||
onPluginChange?: (key: string, value: boolean) => void
|
||||
dataSets: any[]
|
||||
onDataSetsChange?: (contexts: any[]) => void
|
||||
dataSets: DataSet[]
|
||||
onDataSetsChange?: (contexts: DataSet[]) => void
|
||||
}
|
||||
|
||||
const Config: FC<IConfigProps> = ({
|
||||
|
||||
@@ -19,7 +19,8 @@ const plugins = [
|
||||
{ key: 'google_search', icon: <Google /> },
|
||||
{ key: 'web_reader', icon: <WebReader /> },
|
||||
{ key: 'wikipedia', icon: <Wikipedia /> },
|
||||
]
|
||||
] as const
|
||||
|
||||
const Plugins: FC<IPluginsProps> = ({
|
||||
readonly,
|
||||
config,
|
||||
|
||||
Reference in New Issue
Block a user