@jctrans-materials/comps-vue3 1.0.32 → 1.0.33-beta.1

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.
@@ -14,6 +14,54 @@ export declare const getThirdPartySessions: () => {
14
14
  thirdPartyUserName: string;
15
15
  mobileEmailList: any;
16
16
  };
17
+ /**
18
+ * 第三方 OAuth 登录组合式函数(Facebook、LinkedIn)
19
+ *
20
+ * 管理完整的 OAuth 流程,包括:
21
+ * - 打开认证弹窗
22
+ * - 通过 postMessage 接收并验证授权码
23
+ * - 处理登录成功/失败状态
24
+ * - 管理绑定和注册对话框
25
+ * - 防止弹窗检测和消息处理之间的竞态条件
26
+ *
27
+ * @param {ThirdPartyConfig} 配置 - 包含以下属性的配置对象:
28
+ * - appId: 应用标识符(例如:"CPA")
29
+ * - redirectPath: 登录后的重定向目标
30
+ * - isEn: 语言标志,用于错误消息
31
+ * - onSuccess: 登录成功时的回调函数
32
+ * - onNeedBind: 需要账号绑定时的回调函数
33
+ * - onError: 登录失败时的回调函数
34
+ *
35
+ * @returns {Object} 登录组合式接口,包含:
36
+ * - isLoading: 布尔响应式引用,表示登录操作是否进行中
37
+ * - isBindDialogVisible: 布尔响应式引用,控制绑定对话框的可见性
38
+ * - isRegisterVisible: 布尔响应式引用,控制注册对话框的可见性
39
+ * - isUserClosed: 布尔响应式引用,表示用户是否手动关闭了弹窗
40
+ * - bindList: 数组响应式引用,存储需要绑定的账号列表
41
+ * - loginResult: 对象响应式引用,存储登录响应数据
42
+ * - startLogin: 函数,用于启动 OAuth 登录流程,参数为 ("FACEBOOK" | "LINKEDIN" | "TEST")
43
+ * - resetState: 函数,完全重置所有登录状态并清理监听器
44
+ *
45
+ * @remarks
46
+ * - 使用实例锁(hookInstanceId)处理多个同时进行的登录尝试
47
+ * - 通过 isHandlingMessage 标志实现竞态条件防止
48
+ * - 根据允许列表验证 postMessage 来源,保证安全性
49
+ * - 支持生产和预发布环境,使用不同的 OAuth 端点
50
+ * - 组件卸载时自动清理事件监听器和定时器
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const { startLogin, isLoading, isBindDialogVisible } = useThirdPartyLogin({
55
+ * appId: "CPA",
56
+ * redirectPath: "/dashboard",
57
+ * onSuccess: (data) => console.log("登录成功", data),
58
+ * onNeedBind: (list) => console.log("需要绑定", list)
59
+ * });
60
+ *
61
+ * // 触发登录
62
+ * startLogin("FACEBOOK");
63
+ * ```
64
+ */
17
65
  export declare function useThirdPartyLogin(config: ThirdPartyConfig): {
18
66
  isLoading: import('vue').Ref<boolean, boolean>;
19
67
  isBindDialogVisible: import('vue').Ref<boolean, boolean>;