From d7c97d4d3475953d5a2caba455f43e7200706f7f Mon Sep 17 00:00:00 2001 From: t0ng7u Date: Sun, 22 Jun 2025 16:49:44 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(tokens-table):=20add=20selecta?= =?UTF-8?q?ble=20copy=20modes=20for=20bulk=20token=20copy=20action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit enhances the “Copy Selected Tokens to Clipboard” feature in `TokensTable.js` by introducing a user-friendly modal that lets users choose how they want to copy tokens. Changes made • Replaced direct copy logic with a `Modal.info` dialog. • Modal displays the prompt “Please choose your copy mode”. • Added two buttons in a custom footer: – **Name + Secret**: copies `tokenName sk-tokenKey`. – **Secret Only**: copies `sk-tokenKey`. • Each button triggers the copy operation and closes the dialog. • Maintains existing validations (e.g., selection check, clipboard feedback). Benefits • Gives users clear control over copy format, reducing manual editing. • Aligns UI with Semi UI’s best practices via custom modal footer. No backend/API changes are involved; all updates are limited to the front-end UI logic. --- web/src/components/table/TokensTable.js | 49 +++++++++++++++++++++---- web/src/i18n/locales/en.json | 5 ++- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/web/src/components/table/TokensTable.js b/web/src/components/table/TokensTable.js index d49a344d..0a049c39 100644 --- a/web/src/components/table/TokensTable.js +++ b/web/src/components/table/TokensTable.js @@ -639,20 +639,53 @@ const TokensTable = () => { type="warning" icon={} className="!rounded-full flex-1 md:flex-initial" - onClick={async () => { + onClick={() => { if (selectedKeys.length === 0) { showError(t('请至少选择一个令牌!')); return; } - let keys = ''; - for (let i = 0; i < selectedKeys.length; i++) { - keys += - selectedKeys[i].name + ' sk-' + selectedKeys[i].key + '\n'; - } - await copyText(keys); + Modal.info({ + title: t('复制令牌'), + icon: null, + content: t('请选择你的复制方式'), + footer: ( + + + + + ), + }); }} > - {t('复制所选令牌到剪贴板')} + {t('复制所选令牌')}