Used to check for browser translation.
用于检测浏览器翻译。
ブラウザの翻訳を検出する

Specify the behavior of DID Connect via URL.

zhanghan
2024-07-02 01:11
· edited

In some cases, users need to be able to quickly switch to a specified account in any link. This can be achieved by customizing the behavior of the DID Connect section through URL parameters.


The current features include:

  • Ask the user to switch to the specified account
type DIDConnectUrlOptions = {
forceConnected: string;
// sourceAppPid?: string; // 不再需要该字段,会通过 forceConnected 去查询获得
// auto 代表引导切换(进行弹窗提示,用户可选择不切换);
// disabled 代表不提示(适用于支付页面,允许用户不以当前登录账户来进行支付);
// required 代表强制要求切换(进行页面跳转强制切换账号)
// switchAccount?: boolean || 'auto'; // 默认 'auto'
switchBehavior?: 'auto'|'disabled'|'required';
// 是否展示关闭按钮(通常用于 switchBehavior 为 auto 时,但又不想展示关闭按钮的情况使用)
showClose?: boolean; // 默认:undefined(但实际在 Confirm 组件中,默认为 true)
}

The overall parameters are processed by Buffer.from(JSON.stringify(data), 'utf8').toString('base64'), carried through the __did-connect__ parameter.

Reference Example:

bbqa2ma5eznki36ug2xtb2u2qy4fnysu5dnehnoft4a.did.abtnet.io/?__did-connect__=eyJzd2l0Y2hCZWhhdmlvciI6ImF1dG8iLCJmb3JjZUNvbm5lY3RlZCI6InoxZlV3VWdLanRQRUpzNkFCTGVQRWR6amRERXZadndXcDRoIiwic291cmNlQXBwUGlkIjoiek5LWWN5QmdOb0hRM0dIalVRSlVrSkg4b3A0Q0xYeVFINGVlIn0%3D

The final decoded data is

{
    "switchBehavior": "auto",
    "forceConnected": "z1fUwUgKjtPEJs6ABLePEdzjdDEvZvwWp4h",
    "sourceAppPid": "zNKYcyBgNoHQ3GHjUQJUkJH8op4CLXyQH4ee"
}
Sticker