@howone/sdk 0.3.7 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +34 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1395,34 +1395,42 @@ var HowOneProvider = ({
|
|
|
1395
1395
|
injectRedirectOverlayStyles();
|
|
1396
1396
|
}
|
|
1397
1397
|
}, [pendingRedirect]);
|
|
1398
|
-
(0, import_react8.
|
|
1399
|
-
if (!
|
|
1400
|
-
|
|
1401
|
-
}
|
|
1402
|
-
if (redirectOnUnauthenticated && !token && !user) {
|
|
1398
|
+
const redirectToAuth = (0, import_react8.useCallback)(() => {
|
|
1399
|
+
if (!redirectOnUnauthenticated || typeof window === "undefined") return;
|
|
1400
|
+
try {
|
|
1403
1401
|
const currentUrl = new URL(window.location.href);
|
|
1404
|
-
if (
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
authUrlObj.searchParams.set("project_id", projectId);
|
|
1411
|
-
}
|
|
1412
|
-
setPendingRedirect(true);
|
|
1413
|
-
requestAnimationFrame(() => {
|
|
1414
|
-
window.location.href = authUrlObj.toString();
|
|
1415
|
-
});
|
|
1416
|
-
} catch (error) {
|
|
1417
|
-
console.error("[HowOneProvider] Failed to build auth URL:", error);
|
|
1418
|
-
setPendingRedirect(true);
|
|
1419
|
-
requestAnimationFrame(() => {
|
|
1420
|
-
window.location.href = resolvedAuthUrl;
|
|
1421
|
-
});
|
|
1402
|
+
if (currentUrl.pathname.includes("/auth")) return;
|
|
1403
|
+
try {
|
|
1404
|
+
const authUrlObj = new URL(resolvedAuthUrl);
|
|
1405
|
+
authUrlObj.searchParams.set("redirect_uri", window.location.href);
|
|
1406
|
+
if (projectId) {
|
|
1407
|
+
authUrlObj.searchParams.set("project_id", projectId);
|
|
1422
1408
|
}
|
|
1409
|
+
setPendingRedirect(true);
|
|
1410
|
+
requestAnimationFrame(() => {
|
|
1411
|
+
window.location.href = authUrlObj.toString();
|
|
1412
|
+
});
|
|
1413
|
+
return;
|
|
1414
|
+
} catch (error) {
|
|
1415
|
+
console.error("[HowOneProvider] Failed to build auth URL:", error);
|
|
1423
1416
|
}
|
|
1417
|
+
setPendingRedirect(true);
|
|
1418
|
+
requestAnimationFrame(() => {
|
|
1419
|
+
window.location.href = resolvedAuthUrl;
|
|
1420
|
+
});
|
|
1421
|
+
} catch {
|
|
1422
|
+
setPendingRedirect(true);
|
|
1423
|
+
requestAnimationFrame(() => {
|
|
1424
|
+
window.location.href = resolvedAuthUrl;
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
}, [redirectOnUnauthenticated, resolvedAuthUrl, projectId]);
|
|
1428
|
+
(0, import_react8.useEffect)(() => {
|
|
1429
|
+
if (!hasCheckedUrlToken) return;
|
|
1430
|
+
if (!token && !user) {
|
|
1431
|
+
redirectToAuth();
|
|
1424
1432
|
}
|
|
1425
|
-
}, [token, user,
|
|
1433
|
+
}, [token, user, hasCheckedUrlToken, redirectToAuth]);
|
|
1426
1434
|
const logout = () => {
|
|
1427
1435
|
try {
|
|
1428
1436
|
setToken(null);
|
|
@@ -1430,6 +1438,7 @@ var HowOneProvider = ({
|
|
|
1430
1438
|
}
|
|
1431
1439
|
setTokenState(null);
|
|
1432
1440
|
setUser(null);
|
|
1441
|
+
redirectToAuth();
|
|
1433
1442
|
};
|
|
1434
1443
|
const value = {
|
|
1435
1444
|
user,
|
|
@@ -2082,7 +2091,7 @@ var createToast = (type) => {
|
|
|
2082
2091
|
theme: getToastifyTheme(),
|
|
2083
2092
|
// 确保圆角样式不被覆盖,添加 rounded-xl 类
|
|
2084
2093
|
className: "!p-0 !shadow-none !rounded-xl",
|
|
2085
|
-
style: { padding: 0, borderRadius: "0.75rem" }
|
|
2094
|
+
style: { padding: 0, borderRadius: "0.75rem", backgroundColor: "transparent" }
|
|
2086
2095
|
}
|
|
2087
2096
|
);
|
|
2088
2097
|
};
|