fix(web-ui): sync route state with URL hash on mount + hashchange
Added useEffect to parse location.hash and update route state. Fixes deep links like /#/library not rendering correct screen. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
66ff7065ec
commit
bda33fedca
1 changed files with 12 additions and 0 deletions
|
|
@ -23,6 +23,18 @@ function App() {
|
||||||
try { localStorage.setItem('df.sidebar.collapsed', next ? '1' : '0'); } catch {}
|
try { localStorage.setItem('df.sidebar.collapsed', next ? '1' : '0'); } catch {}
|
||||||
return next;
|
return next;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Sync route state with URL hash
|
||||||
|
React.useEffect(() => {
|
||||||
|
const parseHash = () => {
|
||||||
|
const hash = window.location.hash.slice(1); // remove #
|
||||||
|
const route = hash.startsWith('/') ? hash.slice(1) : hash || 'home';
|
||||||
|
setRoute(route);
|
||||||
|
};
|
||||||
|
parseHash();
|
||||||
|
window.addEventListener('hashchange', parseHash);
|
||||||
|
return () => window.removeEventListener('hashchange', parseHash);
|
||||||
|
}, []);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue