Skip to content

Commit

Permalink
feat:reload some miss
Browse files Browse the repository at this point in the history
delete:load something wrong just  now
  • Loading branch information
YuChanGongzhu committed Oct 25, 2024
1 parent 8fa90b5 commit f031812
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
2 changes: 1 addition & 1 deletion components/MainUI/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default function Main({
onClick={() => switchTo("user")}
/>
</div>
<div className="flex justify-between items-center mt-8">
<div className="flex justify-between items-center">
{/* 左侧图标 */}
<Image
src={WalletIcon}
Expand Down
54 changes: 49 additions & 5 deletions components/MainUI/Wallet.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { DynamicConnectButton, DynamicWidget } from "@dynamic-labs/sdk-react-core";
import PopUp from "./PopUp";
import { useState } from 'react';
import { WalletTgSdk } from '@uxuycom/web3-tg-sdk';
import { Button } from '@telegram-apps/telegram-ui'; // TelegramUI组件
import PopUp from './PopUp'; // 假设PopUp是自定义的弹窗组件
import { ConnectButton } from "@ant-design/web3"
import type { Account } from '@ant-design/web3';
import { ConfigProvider } from 'antd';


interface WalletProps {
Expand All @@ -9,10 +14,49 @@ interface WalletProps {
export default function Wallet({
onClose,
}: WalletProps) {
const { solana } = new WalletTgSdk({
injected: true,
metaData: {
hostname: 'your-app.com',
name: 'Your DApp Name',
icon: 'https://example.com/icon.png',
},
});

const [address, setAddress] = useState<Account | undefined>(undefined);

const solanaProvider = solana

// 处理钱包连接
const handleConnect = async () => {
await solanaProvider.connect({}, false);
const walletAddress = solanaProvider.publicKey?.toString();
setAddress({ "address": walletAddress }); // 设置钱包地址
};

return (
<PopUp title="Wallet" onClose={onClose}>
<div className="flex grow items-center justify-center">
<DynamicWidget />
<PopUp onClose={onClose}>
<div className="flex justify-center items-center">
<ConfigProvider
theme={{
token: {
colorPrimary: '#8442ff', // 主要颜色
colorBgBase: '#000000', // 背景颜色设置为黑色
colorTextBase: '#ffffff', // 文字颜色设置为白色
colorBorder: '#444444', // 边框颜色设置为灰色
},
}}
>
<ConnectButton
type="primary"
account={address}
onConnectClick={handleConnect}
onDisconnectClick={() => {
setAddress(undefined);
solanaProvider.disconnect()
}}
/>
</ConfigProvider>
</div>
</PopUp>
);
Expand Down
Empty file removed components/MainUI/test3.tsx
Empty file.

0 comments on commit f031812

Please sign in to comment.