forked from lobehub/lobe-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ refactor: refactor to prepare for Chat Portal (lobehub#3093)
* ✨ feat: add dock * ♻️ refactor: add plugin render * ✅ test: add tests * ✅ test: add tests * ✅ test: add tests * ♻️ refactor: refactor and add tests * ✅ test: fix tests * ✅ test: fix tests * move files * refactor * 🌐 chore: add locale
- Loading branch information
Showing
118 changed files
with
2,128 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"aiSummary": "تلخيص من قبل المساعد", | ||
"title": "نافذة موسعة" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"aiSummary": "Сумиране от помощник", | ||
"title": "Разширено прозорец" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"aiSummary": "Lassen Sie den Assistenten zusammenfassen", | ||
"title": "Erweiterungsfenster" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"aiSummary": "Let the assistant summarize", | ||
"title": "Expand Window" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"aiSummary": "Resumen del asistente", | ||
"title": "Ventana de expansión" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"aiSummary": "Faire un résumé avec l'assistant", | ||
"title": "Fenêtre d'extension" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"aiSummary": "Riepilogo assistente", | ||
"title": "Finestra di espansione" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"aiSummary": "アシスタントに要約させる", | ||
"title": "拡張ウィンドウ" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"aiSummary": "어시스턴트 요약", | ||
"title": "확장 창" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"aiSummary": "Laat de assistent samenvatten", | ||
"title": "Uitbreidingsvenster" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"aiSummary": "Podsumowanie przez asystenta", | ||
"title": "Okno rozszerzenia" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"aiSummary": "Permita que o assistente resuma", | ||
"title": "Janela de Expansão" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"aiSummary": "Попросите помощника сделать сводку", | ||
"title": "Расширенное окно" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"aiSummary": "Asistanın özetlemesine izin ver", | ||
"title": "Genişletme Penceresi" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"aiSummary": "Tóm tắt bởi trợ lý", | ||
"title": "Cửa sổ mở rộng" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"aiSummary": "让助手总结", | ||
"title": "扩展窗" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"aiSummary": "讓助手總結", | ||
"title": "擴展視窗" | ||
} |
17 changes: 17 additions & 0 deletions
17
src/app/(main)/chat/(workspace)/@portal/_layout/Desktop.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { PropsWithChildren } from 'react'; | ||
import { Flexbox } from 'react-layout-kit'; | ||
|
||
import Header from '../features/Header'; | ||
|
||
const Layout = ({ children }: PropsWithChildren) => { | ||
return ( | ||
<> | ||
<Header /> | ||
<Flexbox height={'100%'} style={{ overflow: 'hidden', position: 'relative' }} width={'100%'}> | ||
{children} | ||
</Flexbox> | ||
</> | ||
); | ||
}; | ||
|
||
export default Layout; |
18 changes: 18 additions & 0 deletions
18
src/app/(main)/chat/(workspace)/@portal/_layout/Mobile.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { PropsWithChildren } from 'react'; | ||
import { Flexbox } from 'react-layout-kit'; | ||
|
||
const Layout = ({ children }: PropsWithChildren) => { | ||
return ( | ||
<Flexbox gap={8} height={'100%'} padding={'8px 8px 0'} style={{ overflow: 'hidden' }}> | ||
<Flexbox | ||
height={'100%'} | ||
style={{ marginInline: -8, overflow: 'hidden', position: 'relative' }} | ||
width={'calc(100% + 16px)'} | ||
> | ||
{children} | ||
</Flexbox> | ||
</Flexbox> | ||
); | ||
}; | ||
|
||
export default Layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, { Suspense, lazy } from 'react'; | ||
|
||
import Loading from '@/components/CircleLoading'; | ||
import { isMobileDevice } from '@/utils/responsive'; | ||
|
||
import Desktop from './_layout/Desktop'; | ||
import Mobile from './_layout/Mobile'; | ||
|
||
const InspectorContent = lazy(() => import('./index')); | ||
|
||
const Inspector = () => { | ||
const mobile = isMobileDevice(); | ||
|
||
const Layout = mobile ? Mobile : Desktop; | ||
|
||
return ( | ||
<Layout> | ||
<Suspense fallback={<Loading />}> | ||
<InspectorContent /> | ||
</Suspense> | ||
</Layout> | ||
); | ||
}; | ||
|
||
Inspector.displayName = 'ChatInspector'; | ||
|
||
export default Inspector; |
52 changes: 52 additions & 0 deletions
52
src/app/(main)/chat/(workspace)/@portal/features/Header.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
'use client'; | ||
|
||
import { ActionIcon } from '@lobehub/ui'; | ||
import { Typography } from 'antd'; | ||
import isEqual from 'fast-deep-equal'; | ||
import { ArrowLeft, XIcon } from 'lucide-react'; | ||
import { memo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { Flexbox } from 'react-layout-kit'; | ||
|
||
import SidebarHeader from '@/components/SidebarHeader'; | ||
import PluginAvatar from '@/features/PluginAvatar'; | ||
import { useChatStore } from '@/store/chat'; | ||
import { chatPortalSelectors } from '@/store/chat/selectors'; | ||
import { pluginHelpers, useToolStore } from '@/store/tool'; | ||
import { toolSelectors } from '@/store/tool/selectors'; | ||
|
||
const Header = memo(() => { | ||
const [showToolUI, toggleInspector, closeToolUI, toolUIIdentifier = ''] = useChatStore((s) => [ | ||
chatPortalSelectors.showToolUI(s), | ||
s.toggleDock, | ||
s.closeToolUI, | ||
chatPortalSelectors.toolUIIdentifier(s), | ||
]); | ||
|
||
const { t } = useTranslation(['plugin', 'portal']); | ||
const pluginMeta = useToolStore(toolSelectors.getMetaById(toolUIIdentifier), isEqual); | ||
const pluginTitle = pluginHelpers.getPluginTitle(pluginMeta) ?? t('unknownPlugin'); | ||
|
||
return ( | ||
<SidebarHeader | ||
actions={<ActionIcon icon={XIcon} onClick={() => toggleInspector(false)} />} | ||
title={ | ||
showToolUI ? ( | ||
<Flexbox align={'center'} gap={4} horizontal> | ||
<ActionIcon icon={ArrowLeft} onClick={() => closeToolUI()} /> | ||
<PluginAvatar identifier={toolUIIdentifier} size={28} /> | ||
<Typography.Text style={{ fontSize: 16 }} type={'secondary'}> | ||
{pluginTitle} | ||
</Typography.Text> | ||
</Flexbox> | ||
) : ( | ||
<Typography.Text style={{ fontSize: 16 }} type={'secondary'}> | ||
{t('portal:title')} | ||
</Typography.Text> | ||
) | ||
} | ||
/> | ||
); | ||
}); | ||
|
||
export default Header; |
Oops, something went wrong.