Skip to content

Commit bedcbcb

Browse files
committed
feat: 移除iosSafariToastDone状态管理,直接使用localStorage存储状态;优化ProtectedRoute逻辑
1 parent 59f452d commit bedcbcb

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

web/src/route/protectedRoute.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import LoadingPlaceholder from '@/components/others/LoadingPlaceholder';
2-
import { useIosSafariToastDone } from '@/state/iosSafariToastDone';
32
import type { Profile } from '@/types/main';
43
import { get } from '@/utils/api';
54
import { useAPIGet } from '@/utils/fetcher';
65
import MobileDetect from 'mobile-detect';
7-
import { useEffect } from 'react';
6+
import { useEffect, useState } from 'react';
87
import { Navigate } from 'react-router-dom';
98
import { toast } from 'sonner';
109

@@ -13,7 +12,9 @@ export const ProtectedRoute = ({ children }: any) => {
1312
get('/users/me/profile').then((res) => res.data)
1413
);
1514

16-
const [iosSafariToastDone, setIosSafariToastDone] = useIosSafariToastDone();
15+
const [iosSafariToastDone, setIosSafariToastDone] = useState(
16+
localStorage.getItem('iosSafariToastDone') === 'true'
17+
);
1718

1819
const isIosSafari = () => {
1920
const md = new MobileDetect(window.navigator.userAgent);
@@ -39,6 +40,7 @@ export const ProtectedRoute = ({ children }: any) => {
3940
icon: '🤖',
4041
});
4142
setIosSafariToastDone(true);
43+
localStorage.setItem('iosSafariToastDone', 'true');
4244
}
4345
}, [iosSafariToastDone, setIosSafariToastDone]);
4446

web/src/state/iosSafariToastDone.tsx

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)