From 3998ad08deca4efcd60979ad38d323a1e110fc9f Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Mon, 13 Jan 2025 13:52:45 +0800 Subject: [PATCH] feat: add qwenlm minapp --- .../src/assets/images/apps/qwenlm.webp | Bin 0 -> 2076 bytes .../src/components/Icons/MinAppIcon.tsx | 39 ++++++++++++++++++ ...AppStorePopover.tsx => MinAppsPopover.tsx} | 22 ++++------ src/renderer/src/components/app/Sidebar.tsx | 14 +------ src/renderer/src/config/minapps.ts | 15 ++++--- src/renderer/src/pages/apps/App.tsx | 16 +------ src/renderer/src/pages/home/Navbar.tsx | 6 +-- .../DisplaySettings/DisplaySettings.tsx | 6 +-- .../DisplaySettings/MiniAppIconsManager.tsx | 7 ++-- src/renderer/src/store/minapps.ts | 4 +- src/renderer/src/types/index.ts | 1 + 11 files changed, 71 insertions(+), 59 deletions(-) create mode 100644 src/renderer/src/assets/images/apps/qwenlm.webp create mode 100644 src/renderer/src/components/Icons/MinAppIcon.tsx rename src/renderer/src/components/Popups/{AppStorePopover.tsx => MinAppsPopover.tsx} (64%) diff --git a/src/renderer/src/assets/images/apps/qwenlm.webp b/src/renderer/src/assets/images/apps/qwenlm.webp new file mode 100644 index 0000000000000000000000000000000000000000..0d720b0b7407ccafd6c7b432254254d171e36e8d GIT binary patch literal 2076 zcmV+%2;=usNk&E#2mkx=zGuu`DgmBu|Gf$ zERSVh?!WjN-+M!r^h0?QDt2kUOMbWC+Dr%hk;6g84cPa`(bCzjk^!H&4{r@SdWfxK zu-b!Q_|OL3)&OY*LoS28MYV_vgOz$oBnyPk`2T$crBxnZ!Zty!&1KS>^8m1?>1L;} zg|T{3b>4&q!uG)MEaemX*J&sP6jPYZ5A7FIusrUfvY#j1dh)C>ubSv^A z%@?;-UIf;!LA95e*F{6p{904G0B{1r_8s3qo;pkCP)%b!g3O4`Bm$0GATP1T^R-CQ zrOV-w?h#}}US-SRq!j#dq1iLa#=Fp-q(4dH=D|~qZ|a}&Yf}R!X;Y(W8(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#Tv{UoFee!}Za*%lV=Cu4 zwar1EIsZxA_~C|2RiW9xMfGD7k0`J+@OM5DdL#zNwCWE4FxIbKbg-}1ANZ)wb9V5S z2#n!5G#mF}=tbJ$r}~ls0Vu|_x7l^Gi_JE>FnkQ!f1mhmrDJ;3ey5*|Sahpbu`k?pz<{&K-?`8a( z*^&uurpDC@%Nxe(2;IA|Bcss1+Ue^jiL*ziKO#22OA2K)caH0|nMHW22$TpC^e-7i zxfhK-H4mbmFRvVH%bRy19FWXkz>2>%QqD*7!5&V}K{Vzz=lb6UGFlJ*ZF`9}#QslkPcX#v-g9wCi&)#+YA&X%6U|q*Wmn>MV>H`YW<8!0-Y5B(U7kA`!Bq} GQ~&_@;R^Bq literal 0 HcmV?d00001 diff --git a/src/renderer/src/components/Icons/MinAppIcon.tsx b/src/renderer/src/components/Icons/MinAppIcon.tsx new file mode 100644 index 00000000..99469d19 --- /dev/null +++ b/src/renderer/src/components/Icons/MinAppIcon.tsx @@ -0,0 +1,39 @@ +import { DEFAULT_MIN_APPS } from '@renderer/config/minapps' +import { MinAppType } from '@renderer/types' +import { FC } from 'react' +import styled from 'styled-components' + +interface Props { + app: MinAppType + size?: number + style?: React.CSSProperties +} + +const MinAppIcon: FC = ({ app, size = 48, style }) => { + const _app = DEFAULT_MIN_APPS.find((item) => item.id === app.id) + + if (!_app) { + return null + } + + return ( + + ) +} + +const Container = styled.img` + border-radius: 16px; + user-select: none; + -webkit-user-drag: none; +` + +export default MinAppIcon diff --git a/src/renderer/src/components/Popups/AppStorePopover.tsx b/src/renderer/src/components/Popups/MinAppsPopover.tsx similarity index 64% rename from src/renderer/src/components/Popups/AppStorePopover.tsx rename to src/renderer/src/components/Popups/MinAppsPopover.tsx index 5f071963..a52d8d6e 100644 --- a/src/renderer/src/components/Popups/AppStorePopover.tsx +++ b/src/renderer/src/components/Popups/MinAppsPopover.tsx @@ -1,11 +1,10 @@ import { Center } from '@renderer/components/Layout' -import { getAllMinApps } from '@renderer/config/minapps' -import { useSettings } from '@renderer/hooks/useSettings' +import { useMinapps } from '@renderer/hooks/useMinapps' import App from '@renderer/pages/apps/App' import { Popover } from 'antd' import { Empty } from 'antd' import { isEmpty } from 'lodash' -import { FC, useMemo, useState } from 'react' +import { FC, useState } from 'react' import { useHotkeys } from 'react-hotkeys-hook' import styled from 'styled-components' @@ -15,16 +14,9 @@ interface Props { children: React.ReactNode } -const AppStorePopover: FC = ({ children }) => { +const MinAppsPopover: FC = ({ children }) => { const [open, setOpen] = useState(false) - const { miniAppIcons } = useSettings() - const allApps = useMemo(() => getAllMinApps(), []) - - // 只显示可见的小程序 - const visibleApps = useMemo(() => { - if (!miniAppIcons?.visible) return allApps - return allApps.filter((app) => miniAppIcons.visible.includes(app.id)) - }, [allApps, miniAppIcons?.visible]) + const { minapps } = useMinapps() useHotkeys('esc', () => { setOpen(false) @@ -37,10 +29,10 @@ const AppStorePopover: FC = ({ children }) => { const content = ( - {visibleApps.map((app) => ( + {minapps.map((app) => ( ))} - {isEmpty(visibleApps) && ( + {isEmpty(minapps) && (
@@ -70,4 +62,4 @@ const AppsContainer = styled.div` gap: 18px; ` -export default AppStorePopover +export default MinAppsPopover diff --git a/src/renderer/src/components/app/Sidebar.tsx b/src/renderer/src/components/app/Sidebar.tsx index 22996db7..db10c8f7 100644 --- a/src/renderer/src/components/app/Sidebar.tsx +++ b/src/renderer/src/components/app/Sidebar.tsx @@ -16,6 +16,7 @@ import { useLocation, useNavigate } from 'react-router-dom' import styled from 'styled-components' import DragableList from '../DragableList' +import MinAppIcon from '../Icons/MinAppIcon' import MinApp from '../MinApp' import UserPopup from '../Popups/UserPopup' @@ -149,14 +150,7 @@ const PinnedApps: FC = () => { MinApp.start(app)}> - + @@ -246,10 +240,6 @@ const StyledLink = styled.div` } ` -const AppIcon = styled.img` - border-radius: 6px; -` - const AppsContainer = styled.div` display: flex; flex: 1; diff --git a/src/renderer/src/config/minapps.ts b/src/renderer/src/config/minapps.ts index 75d20006..f1aceeed 100644 --- a/src/renderer/src/config/minapps.ts +++ b/src/renderer/src/config/minapps.ts @@ -17,6 +17,7 @@ import NamiAiSearchLogo from '@renderer/assets/images/apps/nm.webp' import PerplexityAppLogo from '@renderer/assets/images/apps/perplexity.webp' import PoeAppLogo from '@renderer/assets/images/apps/poe.webp' import ZhipuProviderLogo from '@renderer/assets/images/apps/qingyan.png' +import QwenlmAppLogo from '@renderer/assets/images/apps/qwenlm.webp' import SensetimeAppLogo from '@renderer/assets/images/apps/sensetime.png' import SparkDeskAppLogo from '@renderer/assets/images/apps/sparkdesk.png' import ThinkAnyLogo from '@renderer/assets/images/apps/thinkany.webp' @@ -35,7 +36,7 @@ import SiliconFlowProviderLogo from '@renderer/assets/images/providers/silicon.p import MinApp from '@renderer/components/MinApp' import { MinAppType } from '@renderer/types' -const _apps: MinAppType[] = [ +export const DEFAULT_MIN_APPS: MinAppType[] = [ { id: 'openai', name: 'ChatGPT', @@ -253,14 +254,16 @@ const _apps: MinAppType[] = [ logo: GrokAppLogo, url: 'https://x.com/i/grok', bodered: true + }, + { + id: 'qwenlm', + name: 'QwenLM', + logo: QwenlmAppLogo, + url: 'https://qwenlm.ai/' } ] -export function getAllMinApps() { - return _apps as MinAppType[] -} - export function startMinAppById(id: string) { - const app = getAllMinApps().find((app) => app?.id === id) + const app = DEFAULT_MIN_APPS.find((app) => app?.id === id) app && MinApp.start(app) } diff --git a/src/renderer/src/pages/apps/App.tsx b/src/renderer/src/pages/apps/App.tsx index 8d40231e..a195d380 100644 --- a/src/renderer/src/pages/apps/App.tsx +++ b/src/renderer/src/pages/apps/App.tsx @@ -1,3 +1,4 @@ +import MinAppIcon from '@renderer/components/Icons/MinAppIcon' import MinApp from '@renderer/components/MinApp' import { useMinapps } from '@renderer/hooks/useMinapps' import { MinAppType } from '@renderer/types' @@ -40,14 +41,7 @@ const App: FC = ({ app, onClick, size = 60 }) => { return ( - + {app.name} @@ -63,12 +57,6 @@ const Container = styled.div` overflow: hidden; ` -const AppIcon = styled.img` - border-radius: 16px; - user-select: none; - -webkit-user-drag: none; -` - const AppTitle = styled.div` font-size: 12px; margin-top: 5px; diff --git a/src/renderer/src/pages/home/Navbar.tsx b/src/renderer/src/pages/home/Navbar.tsx index 46019cc8..10a1ba86 100644 --- a/src/renderer/src/pages/home/Navbar.tsx +++ b/src/renderer/src/pages/home/Navbar.tsx @@ -1,7 +1,7 @@ import { FormOutlined, SearchOutlined } from '@ant-design/icons' import { Navbar, NavbarLeft, NavbarRight } from '@renderer/components/app/Navbar' import { HStack } from '@renderer/components/Layout' -import AppStorePopover from '@renderer/components/Popups/AppStorePopover' +import MinAppsPopover from '@renderer/components/Popups/MinAppsPopover' import SearchPopup from '@renderer/components/Popups/SearchPopup' import { isMac, isWindows } from '@renderer/config/constant' import { useAssistant } from '@renderer/hooks/useAssistant' @@ -84,11 +84,11 @@ const HeaderNavbar: FC = ({ activeAssistant }) => { {sidebarIcons.visible.includes('minapp') && ( - + - + )} {topicPosition === 'right' && ( diff --git a/src/renderer/src/pages/settings/DisplaySettings/DisplaySettings.tsx b/src/renderer/src/pages/settings/DisplaySettings/DisplaySettings.tsx index 576f1879..52989df7 100644 --- a/src/renderer/src/pages/settings/DisplaySettings/DisplaySettings.tsx +++ b/src/renderer/src/pages/settings/DisplaySettings/DisplaySettings.tsx @@ -1,5 +1,5 @@ import { isMac } from '@renderer/config/constant' -import { getAllMinApps } from '@renderer/config/minapps' +import { DEFAULT_MIN_APPS } from '@renderer/config/minapps' import { useTheme } from '@renderer/context/ThemeProvider' import { useMinapps } from '@renderer/hooks/useMinapps' import { useSettings } from '@renderer/hooks/useSettings' @@ -59,9 +59,9 @@ const DisplaySettings: FC = () => { }, [dispatch]) const handleResetMinApps = useCallback(() => { - setVisibleMiniApps(getAllMinApps()) + setVisibleMiniApps(DEFAULT_MIN_APPS) setDisabledMiniApps([]) - updateMinapps(getAllMinApps()) + updateMinapps(DEFAULT_MIN_APPS) updateDisabledMinapps([]) }, [updateDisabledMinapps, updateMinapps]) diff --git a/src/renderer/src/pages/settings/DisplaySettings/MiniAppIconsManager.tsx b/src/renderer/src/pages/settings/DisplaySettings/MiniAppIconsManager.tsx index 8fe4bdd6..e2d5dae7 100644 --- a/src/renderer/src/pages/settings/DisplaySettings/MiniAppIconsManager.tsx +++ b/src/renderer/src/pages/settings/DisplaySettings/MiniAppIconsManager.tsx @@ -7,10 +7,10 @@ import { DroppableProvided, DropResult } from '@hello-pangea/dnd' -import { getAllMinApps } from '@renderer/config/minapps' +import { DEFAULT_MIN_APPS } from '@renderer/config/minapps' import { useMinapps } from '@renderer/hooks/useMinapps' import { MinAppType } from '@renderer/types' -import { FC, useCallback, useMemo } from 'react' +import { FC, useCallback } from 'react' import { useTranslation } from 'react-i18next' import styled from 'styled-components' @@ -74,7 +74,6 @@ const MiniAppIconsManager: FC = ({ setDisabledMiniApps }) => { const { t } = useTranslation() - const allApps = useMemo(() => getAllMinApps(), []) const { pinned, updateMinapps, updateDisabledMinapps, updatePinnedMinapps } = useMinapps() const handleListUpdate = useCallback( @@ -130,7 +129,7 @@ const MiniAppIconsManager: FC = ({ ) const renderProgramItem = (program: MinAppType, provided: DraggableProvided, listType: ListType) => { - const { name, logo } = allApps.find((app) => app.id === program.id) || { name: program.name, logo: '' } + const { name, logo } = DEFAULT_MIN_APPS.find((app) => app.id === program.id) || { name: program.name, logo: '' } return ( diff --git a/src/renderer/src/store/minapps.ts b/src/renderer/src/store/minapps.ts index b3a54efb..c6b4ae8a 100644 --- a/src/renderer/src/store/minapps.ts +++ b/src/renderer/src/store/minapps.ts @@ -1,5 +1,5 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import { getAllMinApps } from '@renderer/config/minapps' +import { DEFAULT_MIN_APPS } from '@renderer/config/minapps' import { MinAppType, SidebarIcon } from '@renderer/types' export const DEFAULT_SIDEBAR_ICONS: SidebarIcon[] = [ @@ -19,7 +19,7 @@ export interface MinAppsState { } const initialState: MinAppsState = { - enabled: getAllMinApps(), + enabled: DEFAULT_MIN_APPS, disabled: [], pinned: [] } diff --git a/src/renderer/src/types/index.ts b/src/renderer/src/types/index.ts index 7ffbc6b0..c983310b 100644 --- a/src/renderer/src/types/index.ts +++ b/src/renderer/src/types/index.ts @@ -134,6 +134,7 @@ export type MinAppType = { logo: string url: string bodered?: boolean + background?: string } export interface FileType {