feat: add id to miniapp

This commit is contained in:
kangfenmao 2024-09-14 17:02:47 +08:00
parent a173a87f29
commit 8566476d91
3 changed files with 28 additions and 30 deletions

View File

@ -16,61 +16,73 @@ import { MinAppType } from '@renderer/types'
const _apps: MinAppType[] = [
{
id: '360-ai-so',
name: '360AI搜索',
logo: AiSearchAppLogo,
url: 'https://so.360.com/'
},
{
id: '360-ai-bot',
name: 'AI 助手',
logo: AiAssistantAppLogo,
url: 'https://bot.360.com/'
},
{
id: 'baidu-ai-chat',
name: '文心一言',
logo: BaiduAiAppLogo,
url: 'https://yiyan.baidu.com/'
},
{
id: 'tencent-yuanbao',
name: '腾讯元宝',
logo: TencentYuanbaoAppLogo,
url: 'https://yuanbao.tencent.com/chat'
},
{
id: 'sensetime-chat',
name: '商量',
logo: SensetimeAppLogo,
url: 'https://chat.sensetime.com/wb/chat'
},
{
id: 'spark-desk',
name: 'SparkDesk',
logo: SparkDeskAppLogo,
url: 'https://xinghuo.xfyun.cn/desk'
},
{
id: 'metaso',
name: '秘塔AI搜索',
logo: MetasoAppLogo,
url: 'https://metaso.cn/'
},
{
id: 'poe',
name: 'Poe',
logo: PoeAppLogo,
url: 'https://poe.com'
},
{
id: 'perplexity',
name: 'perplexity',
logo: PerplexityAppLogo,
url: 'https://www.perplexity.ai/'
},
{
id: 'devv',
name: 'DEVV_',
logo: DevvAppLogo,
url: 'https://devv.ai/'
},
{
id: 'tiangong-ai',
name: '天工AI',
logo: TiangongAiLogo,
url: 'https://www.tiangong.cn/'
},
{
id: 'zhihu-zhiada',
name: '知乎直答',
logo: ZhihuAppLogo,
url: 'https://zhida.zhihu.com/'

View File

@ -136,6 +136,7 @@ export const PROVIDER_CONFIG = {
models: 'https://platform.openai.com/docs/models'
},
app: {
id: 'openai',
name: 'ChatGPT',
url: 'https://chatgpt.com/',
logo: OpenAiProviderLogo
@ -152,6 +153,7 @@ export const PROVIDER_CONFIG = {
models: 'https://ai.google.dev/gemini-api/docs/models/gemini'
},
app: {
id: 'gemini',
name: 'Gemini',
url: 'https://gemini.google.com/',
logo: GeminiProviderLogo
@ -168,6 +170,7 @@ export const PROVIDER_CONFIG = {
models: 'https://docs.siliconflow.cn/docs/model-names'
},
app: {
id: 'silicon',
name: 'SiliconFlow',
url: 'https://cloud.siliconflow.cn/playground/chat',
logo: SiliconFlowProviderLogo
@ -184,6 +187,7 @@ export const PROVIDER_CONFIG = {
models: 'https://platform.deepseek.com/api-docs/'
},
app: {
id: 'deepseek',
name: 'DeepSeek',
url: 'https://chat.deepseek.com/',
logo: DeepSeekProviderLogo
@ -211,6 +215,7 @@ export const PROVIDER_CONFIG = {
models: 'https://platform.lingyiwanwu.com/docs#%E6%A8%A1%E5%9E%8B'
},
app: {
id: 'yi',
name: 'Yi',
url: 'https://www.wanzhi.com/',
logo: YiProviderLogo
@ -227,6 +232,7 @@ export const PROVIDER_CONFIG = {
models: 'https://open.bigmodel.cn/modelcenter/square'
},
app: {
id: 'zhipu',
name: '智谱',
url: 'https://chatglm.cn/main/alltoolsdetail',
logo: ZhipuProviderLogo
@ -243,6 +249,7 @@ export const PROVIDER_CONFIG = {
models: 'https://platform.moonshot.cn/docs/intro#%E6%A8%A1%E5%9E%8B%E5%88%97%E8%A1%A8'
},
app: {
id: 'moonshot',
name: 'Kimi',
url: 'https://kimi.moonshot.cn/',
logo: KimiAppLogo
@ -259,6 +266,7 @@ export const PROVIDER_CONFIG = {
models: 'https://platform.baichuan-ai.com/price'
},
app: {
id: 'baichuan',
name: '百小应',
url: 'https://ying.baichuan-ai.com/chat',
logo: BaicuanAppLogo
@ -275,6 +283,7 @@ export const PROVIDER_CONFIG = {
models: 'https://dashscope.console.aliyun.com/model'
},
app: {
id: 'dashscope',
name: '通义千问',
url: 'https://tongyi.aliyun.com/qianwen/',
logo: QwenModelLogo
@ -291,6 +300,7 @@ export const PROVIDER_CONFIG = {
models: 'https://platform.stepfun.com/docs/llm/text'
},
app: {
id: 'stepfun',
name: '跃问',
url: 'https://yuewen.cn/chats/new',
logo: YuewenAppLogo
@ -307,6 +317,7 @@ export const PROVIDER_CONFIG = {
models: 'https://console.volcengine.com/ark/region:ark+cn-beijing/endpoint'
},
app: {
id: 'doubao',
name: '豆包',
url: 'https://www.doubao.com/chat/',
logo: DoubaoProviderLogo
@ -323,6 +334,7 @@ export const PROVIDER_CONFIG = {
models: 'https://platform.minimaxi.com/document/Models'
},
app: {
id: 'minimax',
name: '海螺',
url: 'https://hailuoai.com/',
logo: HailuoModelLogo
@ -355,6 +367,7 @@ export const PROVIDER_CONFIG = {
models: 'https://console.groq.com/docs/models'
},
app: {
id: 'groq',
name: 'Groq',
url: 'https://chat.groq.com/',
logo: GroqProviderLogo
@ -381,6 +394,7 @@ export const PROVIDER_CONFIG = {
models: 'https://docs.anthropic.com/en/docs/about-claude/models'
},
app: {
id: 'anthropic',
name: 'Claude',
url: 'https://claude.ai/',
logo: AnthropicProviderLogo

View File

@ -4,44 +4,16 @@ import { Center } from '@renderer/components/Layout'
import { getAllMinApps } from '@renderer/config/minapp'
import { Empty, Input } from 'antd'
import { isEmpty } from 'lodash'
import { FC, useEffect, useState } from 'react'
import { FC, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
import styled from 'styled-components'
import App from './App'
// 定义应用的类型
interface AppType {
id: string // 确保 id 是 string 类型
name: string
url: string
logo: string
sortOrder?: number // 可选属性
}
const AppsPage: FC = () => {
const { t } = useTranslation()
const [search, setSearch] = useState('')
const [apps, setApps] = useState<AppType[]>([]) // 使用定义的类型
useEffect(() => {
const list = getAllMinApps()
const processedList: AppType[] = list.map((app, index) => {
// 为每个应用添加 id 和排序编号
const id = app.id ? String(app.id) : app.name.toLowerCase() // 确保 id 是字符串
return {
...app,
id,
sortOrder: index + 1 // 排序编号从 1 开始
}
})
// 存储到本地存储
localStorage.setItem('minApps', JSON.stringify(processedList))
// 更新状态
setApps(processedList)
}, [])
const apps = useMemo(() => getAllMinApps(), [])
const filteredApps = search
? apps.filter(