fix(send): refresh routes and gate file access

This commit is contained in:
shuaiplus
2026-07-05 23:44:07 +08:00
parent d9a36fefe6
commit 8c481a1564
4 changed files with 31 additions and 12 deletions
+8 -7
View File
@@ -228,6 +228,7 @@ export default function App() {
hint: null,
});
const [inviteCodeFromUrl, setInviteCodeFromUrl] = useState(initialInviteCode);
const [hashPathRaw, setHashPathRaw] = useState(() => (typeof window !== 'undefined' ? window.location.hash || '' : ''));
const [unlockPassword, setUnlockPassword] = useState('');
const [pendingTotp, setPendingTotp] = useState<PendingTotp | null>(null);
const [pendingTotpMode, setPendingTotpMode] = useState<'login' | 'unlock' | null>(null);
@@ -295,15 +296,16 @@ export default function App() {
}, [pushToast]);
useEffect(() => {
const syncInviteFromUrl = () => {
const syncUrlState = () => {
setInviteCodeFromUrl(readInviteCodeFromUrl());
setHashPathRaw(window.location.hash || '');
};
syncInviteFromUrl();
window.addEventListener('hashchange', syncInviteFromUrl);
window.addEventListener('popstate', syncInviteFromUrl);
syncUrlState();
window.addEventListener('hashchange', syncUrlState);
window.addEventListener('popstate', syncUrlState);
return () => {
window.removeEventListener('hashchange', syncInviteFromUrl);
window.removeEventListener('popstate', syncInviteFromUrl);
window.removeEventListener('hashchange', syncUrlState);
window.removeEventListener('popstate', syncUrlState);
};
}, []);
@@ -1862,7 +1864,6 @@ export default function App() {
await pendingAuthRequestsQuery.refetch();
};
const hashPathRaw = typeof window !== 'undefined' ? window.location.hash || '' : '';
const hashPath = hashPathRaw.startsWith('#') ? hashPathRaw.slice(1) : hashPathRaw;
const hashPathOnly = String(hashPath || '').split('?')[0].split('#')[0];
const trimmedHashPath = hashPathOnly.replace(/^\/+/, '').replace(/\/+$/, '');