用户信息
reloginByManual
打开不同类型的登录弹窗
类型签名:
typescript
async function reloginByManual(type: string): Promise<ExternalAppCmdResult>
参数:
type: string
登录弹窗类型, 可选值:'bigmember'
,'switchuser'
等
返回值
Promise<ExternalAppCmdResult>
ret: string
- 打开登录弹窗返回值
使用示例
js
const res = await reloginByManual('bigmember')
console.log(res.ret)
syncLoginCookie
同步登录Cookie
类型签名:
typescript
async function syncLoginCookie(): Promise<ExternalAppCmdResult>
返回值
Promise<ExternalAppCmdResult>
ret: string
- 同步登录Cookie结果
使用示例
js
const res = await syncLoginCookie()
console.log(res.ret)
logout
退出登录 (有提示弹窗)
类型签名:
typescript
async function logout(): Promise<ExternalAppCmdResult>
返回值
Promise<ExternalAppCmdResult>
ret: string
- 退出登录结果
使用示例
js
const res = await logout()
console.log(res.ret)
silentLogout
静默退出登录 (无提示弹窗)
类型签名:
typescript
async function silentLogout(): Promise<ExternalAppCmdResult>
返回值
Promise<ExternalAppCmdResult>
ret: string
- 静默退出登录结果
使用示例
js
const res = await silentLogout()
console.log(res.ret)
getLoginStatus
获取登录状态
类型签名:
typescript
async function getLoginStatus(): Promise<ExternalAppCmdResult>
返回值
Promise<ExternalAppCmdResult>
ret: string
- 获取登录状态结果'0'
- 未登录'1'
- 已登录
使用示例
js
const res = await getLoginStatus()
console.log(res.ret)
getLoginInfo
获取登录信息
类型签名:
typescript
async function getLoginInfo(): Promise<{
Q: string;
T: string;
}>
返回值
Promise<{ Q: string; T: string; }>
Q: string
- 登录账号T: string
- 登录密码
使用示例
js
const res = await getLoginInfo()
console.log(res.Q, res.T)
isLoginViewShowing
判断登录窗是否显示
类型签名:
typescript
async function isLoginViewShowing(): Promise<boolean>
返回值
Promise<boolean>
true
- 登录窗显示false
- 登录窗不显示
使用示例
js
const isShowing = await isLoginViewShowing()
console.log(isShowing)
onLoginStatusUpdated
监听浏览器登录状态变化,登录状态更新后触发
类型签名:
typescript
function onLoginStatusUpdated(): EventWrapper<string>
返回值
EventWrapper<string>
- 登录状态更新事件
使用示例
js
// 示例1,直接监听
onLoginStatusUpdated().addListener((data) => {
console.log('登录状态更新:', data)
})
// 示例2,监听后可移除
const removeListener = onLoginStatusUpdated().addListener((data) => {
console.log('登录状态更新:', data)
})
// 移除监听器
removeListener()
EventWrapper<T>
事件包装器
typescript
/**
* 创建一个 window 对象事件包装器
* 用于管理 window 对象上的自定义事件,支持多个监听器订阅和取消订阅
*
* @template T 事件返回的数据类型
* @param eventName 事件名称,将在 window 对象上创建同名属性
* @returns 事件包装器对象,包含添加监听器和触发事件的方法
*/
interface EventWrapper<T> {
/** 添加事件监听器,返回用于移除该监听器的函数 */
addListener: (callback: TEventListener<T>) => () => void
}
LoginByOtherApp
通过其他应用登录
类型签名:
typescript
async function LoginByOtherApp(userInfo: string): Promise<ExternalAppCmdResult>
参数:
userInfo: string
用户信息
返回值
Promise<ExternalAppCmdResult>
ret: string
- 登录结果
使用示例
js
const res = await LoginByOtherApp('userInfo')
console.log(res.ret)
GetAiMemberEncryptData
获取大会员密钥
类型签名:
typescript
async function GetAiMemberEncryptData(userInfo: string): Promise<ExternalAppCmdResult>
参数:
apiKey: string
api密钥
返回值
Promise<ExternalAppCmdResult>
ret: string
- 大会员密钥
使用示例
js
const res = await GetAiMemberEncryptData('apiKey')
console.log(res.ret)
updateUserMemberInfo
更新用户会员信息
类型签名:
typescript
function updateUserMemberInfo(): void
使用示例
js
updateUserMemberInfo()