import React, {useEffect, useState} from "react"; import Popup from "@components/Popup"; import styles from "./styles.module.scss"; import SvgIcon from "@components/SvgIcon"; import {CopyToClipboard} from "react-copy-to-clipboard"; import {toast} from "react-toastify"; import {stringFormat} from "@utils/helpers"; import html2canvas from "html2canvas"; import Fade from "@mui/material/Fade"; import Grow from "@mui/material/Grow"; import Modal from "@mui/material/Modal"; import {ReactComponent as CloseIcon} from "@assets/singlesvg/btnclose.svg"; const i18n=global.i18n; const WSaveAccount = () => { const [isShow, setIsShow] = useState(false); const [account, setAccount] = useState(""); const [password, setPassword] = useState(""); const show=(info)=>{ if (info.account!=null)setAccount(info.account); if (info.password!=null)setPassword(info.password); setIsShow(true); } const hide=()=>{ setIsShow(false); } const handleScreenshot = () => { const style = document.createElement('style'); document.head.appendChild(style); style.sheet?.insertRule('body > div:last-child img { display: inline-block; }'); // 获取需要截图的元素 const element = document.getElementById('saveAccount'); // 使用 html2canvas 捕获元素并生成图片 html2canvas(element,{ }).then(canvas => { // 创建一个链接元素 const link = document.createElement('a'); link.href = canvas.toDataURL('image/png'); // 获取图片数据 URL link.download = 'accountInfo.png'; // 设置下载的文件名 link.click(); // 触发下载 toast.success(i18n.t("saveAccount.save_success")); }); }; useEffect(()=>{ const saveAccount={ show, hide }; global.saveAccount=saveAccount; return ()=>{ } },[]) return (
{i18n.t("saveAccount.title")}
{i18n.t("saveAccount.account")}
{account} { toast.success(i18n.t("copy_success")); }}>
{i18n.t("saveAccount.password")}
{password} { toast.success(i18n.t("copy_success")); }}>
{i18n.t("saveAccount.tips")}
) } export default WSaveAccount;