feat(FileManager): persist file manager path in local storage for improved navigation
This commit is contained in:
parent
0efc19b4d4
commit
9ea6af1731
|
|
@ -252,8 +252,10 @@ interface FileManagerProps {
|
|||
|
||||
// ─── Main component ───────────────────────────────────────────────────────────
|
||||
|
||||
const FM_PATH_KEY = 'fileManager.path';
|
||||
|
||||
export default function FileManager({ initialPath = '/', config, setConfig, onBack }: FileManagerProps) {
|
||||
const [path, setPath] = useState(normalizePath(initialPath));
|
||||
const [path, setPath] = useState(() => normalizePath(localStorage.getItem(FM_PATH_KEY) || initialPath));
|
||||
const [entries, setEntries] = useState<EntryInfo[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
|
@ -303,7 +305,12 @@ export default function FileManager({ initialPath = '/', config, setConfig, onBa
|
|||
|
||||
useEffect(() => { void load(path); }, [path, load]);
|
||||
|
||||
const navigateTo = (p: string) => { setPath(normalizePath(p)); setFilter(''); };
|
||||
const navigateTo = (p: string) => {
|
||||
const norm = normalizePath(p);
|
||||
localStorage.setItem(FM_PATH_KEY, norm);
|
||||
setPath(norm);
|
||||
setFilter('');
|
||||
};
|
||||
const navigateUp = () => { if (path !== '/') navigateTo(splitPath(path).parent); };
|
||||
|
||||
// ── Sort + filter ────────────────────────────────────────────────────────
|
||||
|
|
@ -862,7 +869,7 @@ export default function FileManager({ initialPath = '/', config, setConfig, onBa
|
|||
</button>
|
||||
)}
|
||||
|
||||
{actionEntry?.type === 'file' && fileCategory(actionEntry) === 'disk' && (
|
||||
{actionEntry?.type === 'file' && (
|
||||
<button
|
||||
onClick={() => { const e = actionEntry; setActionEntry(null); if (e) setMountEntry(e); }}
|
||||
className="w-full text-left px-4 py-3 rounded border border-neutral-200 hover:bg-neutral-50 inline-flex items-center gap-3"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user