mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
🐛 fix: library cannot nav (#11828)
* fix lib nav * update memory action
This commit is contained in:
@@ -37,6 +37,7 @@ const Home: FC = () => {
|
||||
right={
|
||||
<Flexbox gap={8} horizontal>
|
||||
{/* <ActionIcon icon={PencilLineIcon} onClick={openEditor} /> */}
|
||||
<MemoryAnalysis iconOnly />
|
||||
<WideScreenButton />
|
||||
</Flexbox>
|
||||
}
|
||||
@@ -44,7 +45,6 @@ const Home: FC = () => {
|
||||
zIndex: 1,
|
||||
}}
|
||||
/>
|
||||
<MemoryAnalysis />
|
||||
<Flexbox
|
||||
height={'100%'}
|
||||
id={SCROLL_PARENT_ID}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { BrainCircuitIcon } from 'lucide-react';
|
||||
import { type FC, memo, useCallback, useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import MemoryAnalysis from '@/app/[variants]/(main)/memory/features/MemoryAnalysis';
|
||||
import { SCROLL_PARENT_ID } from '@/app/[variants]/(main)/memory/features/TimeLineView/useScrollParent';
|
||||
import NavHeader from '@/features/NavHeader';
|
||||
import WideScreenContainer from '@/features/WideScreenContainer';
|
||||
@@ -87,6 +88,7 @@ const ContextsArea = memo(() => {
|
||||
}
|
||||
right={
|
||||
<>
|
||||
<MemoryAnalysis iconOnly />
|
||||
<ViewModeSwitcher onChange={setViewMode} value={viewMode} />
|
||||
<WideScreenButton />
|
||||
</>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { BrainCircuitIcon } from 'lucide-react';
|
||||
import { type FC, memo, useCallback, useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import MemoryAnalysis from '@/app/[variants]/(main)/memory/features/MemoryAnalysis';
|
||||
import { SCROLL_PARENT_ID } from '@/app/[variants]/(main)/memory/features/TimeLineView/useScrollParent';
|
||||
import NavHeader from '@/features/NavHeader';
|
||||
import WideScreenContainer from '@/features/WideScreenContainer';
|
||||
@@ -85,6 +86,7 @@ const ExperiencesArea = memo(() => {
|
||||
}
|
||||
right={
|
||||
<>
|
||||
<MemoryAnalysis iconOnly />
|
||||
<ViewModeSwitcher onChange={setViewMode} value={viewMode} />
|
||||
<WideScreenButton />
|
||||
</>
|
||||
|
||||
@@ -5,7 +5,11 @@ import { useTranslation } from 'react-i18next';
|
||||
|
||||
import AnalysisTrigger from './AnalysisTrigger';
|
||||
|
||||
const AnalysisAction = memo(() => {
|
||||
interface Props {
|
||||
iconOnly?: boolean;
|
||||
}
|
||||
|
||||
const AnalysisAction = memo<Props>(({ iconOnly }) => {
|
||||
const { t } = useTranslation('memory');
|
||||
const [range, setRange] = useState<[Date | null, Date | null]>([null, null]);
|
||||
|
||||
@@ -23,7 +27,14 @@ const AnalysisAction = memo(() => {
|
||||
[range, t],
|
||||
);
|
||||
|
||||
return <AnalysisTrigger footerNote={footerNote} onRangeChange={setRange} range={range} />;
|
||||
return (
|
||||
<AnalysisTrigger
|
||||
footerNote={footerNote}
|
||||
iconOnly={iconOnly}
|
||||
onRangeChange={setRange}
|
||||
range={range}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
AnalysisAction.displayName = 'AnalysisAction';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { Button, Icon } from '@lobehub/ui';
|
||||
import { ActionIcon, Button, Icon } from '@lobehub/ui';
|
||||
import { Tooltip } from 'antd';
|
||||
import { App } from 'antd';
|
||||
import { CalendarClockIcon } from 'lucide-react';
|
||||
import { memo, useState } from 'react';
|
||||
@@ -13,11 +14,12 @@ import DateRangeModal from './DateRangeModal';
|
||||
|
||||
interface Props {
|
||||
footerNote: string;
|
||||
iconOnly?: boolean;
|
||||
onRangeChange: (range: [Date | null, Date | null]) => void;
|
||||
range: [Date | null, Date | null];
|
||||
}
|
||||
|
||||
const AnalysisTrigger = memo<Props>(({ footerNote, range, onRangeChange }) => {
|
||||
const AnalysisTrigger = memo<Props>(({ footerNote, range, onRangeChange, iconOnly }) => {
|
||||
const { t } = useTranslation('memory');
|
||||
const { message } = App.useApp();
|
||||
const { isValidating, refresh } = useMemoryAnalysisAsyncTask();
|
||||
@@ -45,18 +47,30 @@ const AnalysisTrigger = memo<Props>(({ footerNote, range, onRangeChange }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const loading = submitting || isValidating;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
icon={<Icon icon={CalendarClockIcon} />}
|
||||
loading={submitting || isValidating}
|
||||
onClick={() => setOpen(true)}
|
||||
size={'large'}
|
||||
style={{ maxWidth: 300 }}
|
||||
type={'primary'}
|
||||
>
|
||||
{t('analysis.action.button')}
|
||||
</Button>
|
||||
{iconOnly ? (
|
||||
<Tooltip title={t('analysis.action.button')}>
|
||||
<ActionIcon
|
||||
icon={CalendarClockIcon}
|
||||
loading={loading}
|
||||
onClick={() => setOpen(true)}
|
||||
/>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<Button
|
||||
icon={<Icon icon={CalendarClockIcon} />}
|
||||
loading={loading}
|
||||
onClick={() => setOpen(true)}
|
||||
size={'large'}
|
||||
style={{ maxWidth: 300 }}
|
||||
type={'primary'}
|
||||
>
|
||||
{t('analysis.action.button')}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<DateRangeModal
|
||||
footerNote={footerNote}
|
||||
|
||||
@@ -8,7 +8,11 @@ import AnalysisAction from './Action';
|
||||
import { MemoryAnalysisStatus } from './Status';
|
||||
import { useMemoryAnalysisAsyncTask } from './useTask';
|
||||
|
||||
const MemoryAnalysis = memo(() => {
|
||||
interface Props {
|
||||
iconOnly?: boolean;
|
||||
}
|
||||
|
||||
const MemoryAnalysis = memo<Props>(({ iconOnly }) => {
|
||||
const { data, isValidating } = useMemoryAnalysisAsyncTask();
|
||||
|
||||
const { showAction, showStatus } = useMemo(() => {
|
||||
@@ -26,6 +30,11 @@ const MemoryAnalysis = memo(() => {
|
||||
|
||||
if (!showAction && !showStatus) return null;
|
||||
|
||||
// For iconOnly mode, only show the action button
|
||||
if (iconOnly) {
|
||||
return showAction ? <AnalysisAction iconOnly /> : null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Flexbox gap={12} style={{ paddingTop: 16, width: '100%' }}>
|
||||
{showStatus && <MemoryAnalysisStatus task={data} />}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { BrainCircuitIcon } from 'lucide-react';
|
||||
import { type FC, memo, useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import CommonFilterBar from '@/app/[variants]/(main)/memory/features/FilterBar';
|
||||
import MemoryAnalysis from '@/app/[variants]/(main)/memory/features/MemoryAnalysis';
|
||||
import NavHeader from '@/features/NavHeader';
|
||||
import WideScreenContainer from '@/features/WideScreenContainer';
|
||||
import WideScreenButton from '@/features/WideScreenContainer/WideScreenButton';
|
||||
@@ -75,6 +76,7 @@ const IdentitiesArea = memo(() => {
|
||||
}
|
||||
right={
|
||||
<>
|
||||
<MemoryAnalysis iconOnly />
|
||||
<ViewModeSwitcher onChange={setViewMode} value={viewMode} />
|
||||
<WideScreenButton />
|
||||
</>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { BrainCircuitIcon } from 'lucide-react';
|
||||
import { type FC, memo, useCallback, useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import MemoryAnalysis from '@/app/[variants]/(main)/memory/features/MemoryAnalysis';
|
||||
import { SCROLL_PARENT_ID } from '@/app/[variants]/(main)/memory/features/TimeLineView/useScrollParent';
|
||||
import NavHeader from '@/features/NavHeader';
|
||||
import WideScreenContainer from '@/features/WideScreenContainer';
|
||||
@@ -85,6 +86,7 @@ const PreferencesArea = memo(() => {
|
||||
}
|
||||
right={
|
||||
<>
|
||||
<MemoryAnalysis iconOnly />
|
||||
<ViewModeSwitcher onChange={setViewMode} value={viewMode} />
|
||||
<WideScreenButton />
|
||||
</>
|
||||
|
||||
@@ -39,7 +39,7 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
|
||||
const Head = memo<{ id: string }>(({ id }) => {
|
||||
const navigate = useNavigate();
|
||||
const name = useKnowledgeBaseStore(knowledgeBaseSelectors.getKnowledgeBaseNameById(id));
|
||||
const setMode = useResourceManagerStore((s) => s.setMode);
|
||||
const [setMode, setLibraryId] = useResourceManagerStore((s) => [s.setMode, s.setLibraryId]);
|
||||
const isDragActive = useDragActive();
|
||||
const [isDropZoneActive, setIsDropZoneActive] = useState(false);
|
||||
|
||||
@@ -53,10 +53,14 @@ const Head = memo<{ id: string }>(({ id }) => {
|
||||
|
||||
const handleLibrarySwitch = useCallback(
|
||||
(libraryId: string) => {
|
||||
navigate(`/resource/library/${libraryId}`);
|
||||
setLibraryId(libraryId);
|
||||
setMode('explorer');
|
||||
// 使用 setTimeout 确保在下一个事件循环中执行 navigate
|
||||
setTimeout(() => {
|
||||
navigate(`/resource/library/${libraryId}`);
|
||||
}, 0);
|
||||
},
|
||||
[navigate, setMode],
|
||||
[navigate, setLibraryId, setMode],
|
||||
);
|
||||
|
||||
// Native HTML5 drag-and-drop handlers for root directory drop
|
||||
|
||||
Reference in New Issue
Block a user