feat: add wallet login modal

This commit is contained in:
TerryM
2026-06-02 00:32:46 +08:00
parent 71dac8373e
commit 43700d9fdc
12 changed files with 584 additions and 0 deletions

29
src/wallet/deepLinks.ts Normal file
View File

@@ -0,0 +1,29 @@
type WalletKind = "tokenPocket" | "metaMask" | "imToken";
function currentDappUrl(): string {
if (typeof window === "undefined") return "https://ark-library.com";
return window.location.href;
}
export function walletDeepLink(
kind: WalletKind,
dappUrl = currentDappUrl(),
): string {
switch (kind) {
case "tokenPocket":
return `tpdapp://open?params=${encodeURIComponent(
JSON.stringify({ url: dappUrl, chain: "ETH" }),
)}`;
case "metaMask":
return `https://metamask.app.link/dapp/${dappUrl.replace(/^https?:\/\//, "")}`;
case "imToken":
return `imtokenv2://navigate/DappView?url=${encodeURIComponent(dappUrl)}`;
default:
return dappUrl;
}
}
export function openWalletDeepLink(kind: WalletKind): void {
if (typeof window === "undefined") return;
window.location.href = walletDeepLink(kind);
}