@axiom-lattice/react-sdk 2.1.92 → 2.1.93
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 +61 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30908,25 +30908,30 @@ var PersonalAssistantChannelModal = ({
|
|
|
30908
30908
|
const [qrLoading, setQrLoading] = (0, import_react101.useState)(false);
|
|
30909
30909
|
const [qrCodeUrl, setQrCodeUrl] = (0, import_react101.useState)(null);
|
|
30910
30910
|
const [qrStatus, setQrStatus] = (0, import_react101.useState)("idle");
|
|
30911
|
+
const [qrCountdown, setQrCountdown] = (0, import_react101.useState)(0);
|
|
30911
30912
|
const qrCodeRef = (0, import_react101.useRef)(null);
|
|
30912
|
-
const
|
|
30913
|
-
const
|
|
30914
|
-
if (
|
|
30915
|
-
clearInterval(
|
|
30916
|
-
|
|
30913
|
+
const qrCountdownRef = (0, import_react101.useRef)(null);
|
|
30914
|
+
const clearQrCountdown = (0, import_react101.useCallback)(() => {
|
|
30915
|
+
if (qrCountdownRef.current) {
|
|
30916
|
+
clearInterval(qrCountdownRef.current);
|
|
30917
|
+
qrCountdownRef.current = null;
|
|
30917
30918
|
}
|
|
30918
30919
|
}, []);
|
|
30919
30920
|
const resetQrState = (0, import_react101.useCallback)(() => {
|
|
30920
|
-
|
|
30921
|
+
clearQrCountdown();
|
|
30921
30922
|
setQrLoading(false);
|
|
30922
30923
|
setQrCodeUrl(null);
|
|
30923
30924
|
setQrStatus("idle");
|
|
30925
|
+
setQrCountdown(0);
|
|
30924
30926
|
qrCodeRef.current = null;
|
|
30925
|
-
}, [
|
|
30927
|
+
}, [clearQrCountdown]);
|
|
30928
|
+
const QR_EXPIRY_SECONDS = 300;
|
|
30926
30929
|
const fetchQrCode = (0, import_react101.useCallback)(async () => {
|
|
30927
30930
|
setQrLoading(true);
|
|
30928
30931
|
setQrStatus("loading");
|
|
30929
30932
|
setQrCodeUrl(null);
|
|
30933
|
+
clearQrCountdown();
|
|
30934
|
+
setQrCountdown(0);
|
|
30930
30935
|
try {
|
|
30931
30936
|
const res = await get(
|
|
30932
30937
|
"/api/channels/wechat/setup/qrcode"
|
|
@@ -30935,32 +30940,17 @@ var PersonalAssistantChannelModal = ({
|
|
|
30935
30940
|
qrCodeRef.current = res.data.qrcode;
|
|
30936
30941
|
setQrCodeUrl(res.data.qrcodeImgUrl);
|
|
30937
30942
|
setQrStatus("wait");
|
|
30938
|
-
|
|
30939
|
-
|
|
30940
|
-
|
|
30941
|
-
|
|
30942
|
-
|
|
30943
|
-
|
|
30944
|
-
|
|
30945
|
-
setQrStatus("confirmed");
|
|
30946
|
-
clearQrPoll();
|
|
30947
|
-
form.setFieldsValue({
|
|
30948
|
-
botToken: statusRes.data.botToken,
|
|
30949
|
-
uin: statusRes.data.uin
|
|
30950
|
-
});
|
|
30951
|
-
import_antd90.message.success("WeChat login confirmed!");
|
|
30952
|
-
} else if (s === "expired") {
|
|
30953
|
-
setQrStatus("expired");
|
|
30954
|
-
clearQrPoll();
|
|
30955
|
-
} else if (s === "scaned") {
|
|
30956
|
-
setQrStatus("scaned");
|
|
30957
|
-
} else if (s === "wait") {
|
|
30958
|
-
setQrStatus("wait");
|
|
30959
|
-
}
|
|
30943
|
+
setQrCountdown(QR_EXPIRY_SECONDS);
|
|
30944
|
+
qrCountdownRef.current = setInterval(() => {
|
|
30945
|
+
setQrCountdown((prev) => {
|
|
30946
|
+
if (prev <= 1) {
|
|
30947
|
+
clearQrCountdown();
|
|
30948
|
+
setQrStatus("expired");
|
|
30949
|
+
return 0;
|
|
30960
30950
|
}
|
|
30961
|
-
|
|
30962
|
-
}
|
|
30963
|
-
},
|
|
30951
|
+
return prev - 1;
|
|
30952
|
+
});
|
|
30953
|
+
}, 1e3);
|
|
30964
30954
|
} else {
|
|
30965
30955
|
setQrStatus("error");
|
|
30966
30956
|
import_antd90.message.error("Failed to get QR code");
|
|
@@ -30971,10 +30961,36 @@ var PersonalAssistantChannelModal = ({
|
|
|
30971
30961
|
} finally {
|
|
30972
30962
|
setQrLoading(false);
|
|
30973
30963
|
}
|
|
30974
|
-
}, [get,
|
|
30964
|
+
}, [get, clearQrCountdown]);
|
|
30965
|
+
const checkQrStatus = (0, import_react101.useCallback)(async () => {
|
|
30966
|
+
if (!qrCodeRef.current) return;
|
|
30967
|
+
try {
|
|
30968
|
+
const statusRes = await get(`/api/channels/wechat/setup/status?qrcode=${encodeURIComponent(qrCodeRef.current)}`);
|
|
30969
|
+
if (statusRes.success && statusRes.data) {
|
|
30970
|
+
const s = statusRes.data.status;
|
|
30971
|
+
if (s === "confirmed" && statusRes.data.botToken) {
|
|
30972
|
+
setQrStatus("confirmed");
|
|
30973
|
+
clearQrCountdown();
|
|
30974
|
+
form.setFieldsValue({
|
|
30975
|
+
botToken: statusRes.data.botToken,
|
|
30976
|
+
uin: statusRes.data.uin
|
|
30977
|
+
});
|
|
30978
|
+
import_antd90.message.success("WeChat login confirmed!");
|
|
30979
|
+
} else if (s === "expired") {
|
|
30980
|
+
setQrStatus("expired");
|
|
30981
|
+
clearQrCountdown();
|
|
30982
|
+
setQrCountdown(0);
|
|
30983
|
+
} else if (s === "scaned") {
|
|
30984
|
+
setQrStatus("scaned");
|
|
30985
|
+
}
|
|
30986
|
+
}
|
|
30987
|
+
} catch {
|
|
30988
|
+
import_antd90.message.error("Failed to check QR status");
|
|
30989
|
+
}
|
|
30990
|
+
}, [get, clearQrCountdown, form]);
|
|
30975
30991
|
(0, import_react101.useEffect)(() => {
|
|
30976
30992
|
return () => {
|
|
30977
|
-
if (
|
|
30993
|
+
if (qrCountdownRef.current) clearInterval(qrCountdownRef.current);
|
|
30978
30994
|
};
|
|
30979
30995
|
}, []);
|
|
30980
30996
|
const loadInstallations = (0, import_react101.useCallback)(async () => {
|
|
@@ -31352,7 +31368,7 @@ var PersonalAssistantChannelModal = ({
|
|
|
31352
31368
|
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_antd90.Spin, {}),
|
|
31353
31369
|
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Text48, { type: "secondary", style: { display: "block", marginTop: 8, fontSize: 12 }, children: "Generating QR code..." })
|
|
31354
31370
|
] }),
|
|
31355
|
-
(qrStatus === "wait" || qrStatus === "scaned") && qrCodeUrl && /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("div", { children: [
|
|
31371
|
+
(qrStatus === "wait" || qrStatus === "scaned") && qrCodeUrl && /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("div", { style: { display: "flex", flexDirection: "column", alignItems: "center" }, children: [
|
|
31356
31372
|
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_antd90.QRCode, { value: qrCodeUrl, size: 180 }),
|
|
31357
31373
|
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
|
|
31358
31374
|
Text48,
|
|
@@ -31367,7 +31383,16 @@ var PersonalAssistantChannelModal = ({
|
|
|
31367
31383
|
children: qrStatus === "scaned" ? "Scanned! Confirm on your phone..." : "Scan with WeChat"
|
|
31368
31384
|
}
|
|
31369
31385
|
),
|
|
31370
|
-
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Text48, { type: "secondary", style: { fontSize: 11, marginTop: 4, display: "block" }, children:
|
|
31386
|
+
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Text48, { type: "secondary", style: { fontSize: 11, marginTop: 4, display: "block" }, children: qrCountdown > 0 ? `Expires in ${Math.floor(qrCountdown / 60)}:${String(qrCountdown % 60).padStart(2, "0")}` : "QR code expired" }),
|
|
31387
|
+
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
|
|
31388
|
+
import_antd90.Button,
|
|
31389
|
+
{
|
|
31390
|
+
size: "small",
|
|
31391
|
+
style: { marginTop: 8 },
|
|
31392
|
+
onClick: checkQrStatus,
|
|
31393
|
+
children: "Refresh Status"
|
|
31394
|
+
}
|
|
31395
|
+
)
|
|
31371
31396
|
] }),
|
|
31372
31397
|
qrStatus === "confirmed" && /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("div", { style: { padding: "12px 0" }, children: [
|
|
31373
31398
|
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Text48, { strong: true, style: { fontSize: 14, color: "var(--color-success, #22c55e)", display: "block" }, children: "Login confirmed!" }),
|