fix:修复所有的包导入错误问题
This commit is contained in:
@@ -8,18 +8,18 @@
|
||||
*
|
||||
* 设计:
|
||||
* - **不**走 Server `redirect()`:避免把 fbid 暴露在 URL 里。
|
||||
* - deviceId 走 sync `authStorage.setDeviceId`(与 `token_interceptor.ts` 同源;
|
||||
* - deviceId 走 `AuthStorage.getInstance().setDeviceId`(与 `token_interceptor.ts` 同源;
|
||||
* 写入键 `cozsweet.deviceId`)。
|
||||
* - fbid 走 `localStorage.setItem("facebook_id", ...)`,对齐 async
|
||||
* `StorageKeys.facebookId`。Sync 单例**没有** `setFacebookId` 方法,本轮
|
||||
* 不重构 storage(见 plan §6.1),仅留 TODO。
|
||||
* - fbid 走 `window.localStorage.setItem(StorageKeys.facebookId, ...)`,
|
||||
* 与 async `AuthStorage.setFacebookId` 同键名。Sync 层暂未统一抽象,
|
||||
* 仅留 TODO。
|
||||
* - 写入完成后 `router.replace('/chat')`,URL 不留深链痕迹。
|
||||
*/
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import { authStorage } from "@/data/storage/auth_storage";
|
||||
import { AuthStorage } from "@/data/storage/auth/auth_storage";
|
||||
import { StorageKeys } from "@/data/storage/storage_keys";
|
||||
import { ROUTES } from "@/lib/routes";
|
||||
|
||||
@@ -33,21 +33,23 @@ export default function DeepLinkPersist({ deviceId, fbid }: DeepLinkPersistProps
|
||||
const [done, setDone] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
try {
|
||||
authStorage.setDeviceId(deviceId);
|
||||
if (fbid && fbid.length > 0) {
|
||||
// TODO: 统一 sync/async AuthStorage 后改为 `authStorage.setFacebookId(fbid)`。
|
||||
// 当前 sync 单例未暴露该方法;使用 `StorageKeys.facebookId` 保持与 async 层
|
||||
// `src/data/storage/auth/auth_storage.ts` 键名一致。
|
||||
window.localStorage.setItem(StorageKeys.facebookId, fbid);
|
||||
void (async () => {
|
||||
try {
|
||||
await AuthStorage.getInstance().setDeviceId(deviceId);
|
||||
if (fbid && fbid.length > 0) {
|
||||
// TODO: 统一 sync/async AuthStorage 后改为 `AuthStorage.getInstance().setFacebookId(fbid)`。
|
||||
// 当前 sync 层未暴露该方法;使用 `StorageKeys.facebookId` 保持与 async 层
|
||||
// `src/data/storage/auth/auth_storage.ts` 键名一致。
|
||||
window.localStorage.setItem(StorageKeys.facebookId, fbid);
|
||||
}
|
||||
} catch (err) {
|
||||
// 写不进 localStorage 时(例如隐私模式)也不阻塞跳转;记录到 console 即可。
|
||||
console.warn("[DeepLinkPersist] failed to persist", err);
|
||||
} finally {
|
||||
setDone(true);
|
||||
router.replace(ROUTES.chat);
|
||||
}
|
||||
} catch (err) {
|
||||
// 写不进 localStorage 时(例如隐私模式)也不阻塞跳转;记录到 console 即可。
|
||||
console.warn("[DeepLinkPersist] failed to persist", err);
|
||||
} finally {
|
||||
setDone(true);
|
||||
router.replace(ROUTES.chat);
|
||||
}
|
||||
})();
|
||||
}, [deviceId, fbid, router]);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user