From ad228d53b710a6c4aa3da4065a7a0abd115dc818 Mon Sep 17 00:00:00 2001
From: GyDi <zzzgydi@gmail.com>
Date: Sat, 9 Sep 2023 16:52:00 +0800
Subject: [PATCH] feat: add paste and clear icon

---
 src/pages/profiles.tsx | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/pages/profiles.tsx b/src/pages/profiles.tsx
index 0c48d15..9d70468 100644
--- a/src/pages/profiles.tsx
+++ b/src/pages/profiles.tsx
@@ -4,6 +4,8 @@ import { useLockFn } from "ahooks";
 import { useSetRecoilState } from "recoil";
 import { Box, Button, Grid, IconButton, Stack, TextField } from "@mui/material";
 import {
+  ClearRounded,
+  ContentCopyRounded,
   LocalFireDepartmentRounded,
   RefreshRounded,
   TextSnippetOutlined,
@@ -194,6 +196,11 @@ const ProfilePage = () => {
     });
   });
 
+  const onCopyLink = async () => {
+    const text = await navigator.clipboard.readText();
+    if (text) setUrl(text);
+  };
+
   return (
     <BasePage
       title={t("Profiles")}
@@ -240,6 +247,28 @@ const ProfilePage = () => {
           onChange={(e) => setUrl(e.target.value)}
           sx={{ input: { py: 0.65, px: 1.25 } }}
           placeholder={t("Profile URL")}
+          InputProps={{
+            sx: { pr: 1 },
+            endAdornment: !url ? (
+              <IconButton
+                size="small"
+                sx={{ p: 0.5 }}
+                title={t("Paste")}
+                onClick={onCopyLink}
+              >
+                <ContentCopyRounded fontSize="inherit" />
+              </IconButton>
+            ) : (
+              <IconButton
+                size="small"
+                sx={{ p: 0.5 }}
+                title={t("Clear")}
+                onClick={() => setUrl("")}
+              >
+                <ClearRounded fontSize="inherit" />
+              </IconButton>
+            ),
+          }}
         />
         <Button
           disabled={!url || disabled}
-- 
GitLab