@gup-fe/js-sdk 2.1.0 → 2.1.2
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/README.md +13 -2
- package/dist/index.d.ts +2 -1
- package/dist/js-sdk.js +28 -23
- package/dist/js-sdk.umd.js +2 -2
- package/package.json +13 -15
package/README.md
CHANGED
|
@@ -18,6 +18,13 @@ npm install @gup-fe/js-sdk
|
|
|
18
18
|
pnpm add @gup-fe/js-sdk
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
> **⚠️ 特别注意(针对 Vue 3 或非 React 项目):**
|
|
22
|
+
> 本 SDK 的底层 UI 是基于 React 渲染的,但为了避免在 React 宿主项目中产生冲突(导致 Invalid Hook Call 等报错),SDK **没有将 React 打包进源码中**。
|
|
23
|
+
> 因此,如果您在 **Vue 3** 等其他非 React 环境中使用,必须手动在您的项目中安装 `react` 和 `react-dom` 作为运行时依赖,打包工具(如 Vite/Webpack)才能正常为您编译:
|
|
24
|
+
> ```bash
|
|
25
|
+
> npm install react react-dom
|
|
26
|
+
> ```
|
|
27
|
+
|
|
21
28
|
## 快速上手
|
|
22
29
|
|
|
23
30
|
### 方式一:命令式调用(推荐,适用于任意框架)
|
|
@@ -82,8 +89,12 @@ function App() {
|
|
|
82
89
|
<title>JS SDK Demo</title>
|
|
83
90
|
</head>
|
|
84
91
|
<body>
|
|
85
|
-
<!--
|
|
86
|
-
<script src="https://unpkg.com
|
|
92
|
+
<!-- 1. 必须先引入 React 运行时库 -->
|
|
93
|
+
<script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
|
|
94
|
+
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
|
|
95
|
+
|
|
96
|
+
<!-- 2. 引入 SDK 的 UMD 产物 -->
|
|
97
|
+
<script src="https://unpkg.com/@gup-fe/js-sdk@2.1.0/dist/js-sdk.umd.js"></script>
|
|
87
98
|
|
|
88
99
|
<script>
|
|
89
100
|
// 直接使用全局变量 SDK 调用
|
package/dist/index.d.ts
CHANGED
|
@@ -47,8 +47,9 @@ declare interface ConfigProviderProps {
|
|
|
47
47
|
|
|
48
48
|
export declare function Login({ open, onOpenChange, sceneId, onPhoneLoginSuccess, onAccountLoginSuccess, onUidLoginSuccess, onLoginSuccess, onLoginError, closeable, mountToaster, toastConfigs, ...props }: Props): JSX.Element;
|
|
49
49
|
|
|
50
|
-
export declare function login({ loginTypes, gameId, onLoginSuccess, onLoginError, }: {
|
|
50
|
+
export declare function login({ loginTypes, defaultLoginType, gameId, onLoginSuccess, onLoginError, }: {
|
|
51
51
|
loginTypes?: LoginTypes[];
|
|
52
|
+
defaultLoginType?: LoginTypes;
|
|
52
53
|
gameId: string;
|
|
53
54
|
onLoginSuccess?: (data: any) => void;
|
|
54
55
|
onLoginError?: (error: any) => void;
|
package/dist/js-sdk.js
CHANGED
|
@@ -11996,7 +11996,9 @@ const Wn = new cS({
|
|
|
11996
11996
|
},
|
|
11997
11997
|
async responseInterceptor(e, t) {
|
|
11998
11998
|
if ([
|
|
11999
|
-
"/passport-api/v2/ztgame/auth/login"
|
|
11999
|
+
"/passport-api/v2/ztgame/auth/login",
|
|
12000
|
+
"/passport-api/v2/sms-captchas",
|
|
12001
|
+
"/passport-api/v2/ztgame/auth/mobile-register"
|
|
12000
12002
|
].some((r) => t.url.includes(r)))
|
|
12001
12003
|
return e;
|
|
12002
12004
|
if (e?.code !== 0)
|
|
@@ -25787,49 +25789,52 @@ function Bf({
|
|
|
25787
25789
|
}
|
|
25788
25790
|
function lI({
|
|
25789
25791
|
loginTypes: e,
|
|
25790
|
-
|
|
25791
|
-
|
|
25792
|
-
|
|
25792
|
+
defaultLoginType: t,
|
|
25793
|
+
gameId: n,
|
|
25794
|
+
onLoginSuccess: r,
|
|
25795
|
+
onLoginError: o
|
|
25793
25796
|
}) {
|
|
25794
25797
|
if (document.querySelector(".login-sdk-container"))
|
|
25795
25798
|
return console.warn("Login component is already active. Multiple instances are not allowed."), { close: () => {
|
|
25796
25799
|
} };
|
|
25797
|
-
const
|
|
25798
|
-
|
|
25799
|
-
const
|
|
25800
|
+
const s = document.createElement("div");
|
|
25801
|
+
s.className = "login-sdk-container", document.body.appendChild(s);
|
|
25802
|
+
const i = jv.createRoot(s), a = () => {
|
|
25800
25803
|
setTimeout(() => {
|
|
25801
|
-
|
|
25804
|
+
i.unmount(), s.remove();
|
|
25802
25805
|
}, 200);
|
|
25803
|
-
},
|
|
25804
|
-
|
|
25806
|
+
}, l = () => {
|
|
25807
|
+
i.render(
|
|
25805
25808
|
/* @__PURE__ */ A(
|
|
25806
25809
|
Bf,
|
|
25807
25810
|
{
|
|
25808
|
-
gameId:
|
|
25811
|
+
gameId: n,
|
|
25809
25812
|
loginTypes: e,
|
|
25813
|
+
defaultLoginType: t,
|
|
25810
25814
|
open: !1,
|
|
25811
|
-
onOpenChange:
|
|
25812
|
-
onLoginSuccess:
|
|
25813
|
-
onLoginError:
|
|
25815
|
+
onOpenChange: c,
|
|
25816
|
+
onLoginSuccess: r,
|
|
25817
|
+
onLoginError: o
|
|
25814
25818
|
}
|
|
25815
25819
|
)
|
|
25816
|
-
),
|
|
25817
|
-
},
|
|
25818
|
-
|
|
25820
|
+
), a();
|
|
25821
|
+
}, c = (u) => {
|
|
25822
|
+
u || l();
|
|
25819
25823
|
};
|
|
25820
|
-
return
|
|
25824
|
+
return i.render(
|
|
25821
25825
|
/* @__PURE__ */ A(
|
|
25822
25826
|
Bf,
|
|
25823
25827
|
{
|
|
25824
|
-
gameId:
|
|
25828
|
+
gameId: n,
|
|
25825
25829
|
loginTypes: e,
|
|
25830
|
+
defaultLoginType: t,
|
|
25826
25831
|
open: !0,
|
|
25827
|
-
onOpenChange:
|
|
25828
|
-
onLoginSuccess:
|
|
25829
|
-
onLoginError:
|
|
25832
|
+
onOpenChange: c,
|
|
25833
|
+
onLoginSuccess: r,
|
|
25834
|
+
onLoginError: o
|
|
25830
25835
|
}
|
|
25831
25836
|
)
|
|
25832
|
-
), { close:
|
|
25837
|
+
), { close: l };
|
|
25833
25838
|
}
|
|
25834
25839
|
const bI = {
|
|
25835
25840
|
login: lI
|