From 9f6df6bbd8478ba2d2b905875288380131568a68 Mon Sep 17 00:00:00 2001 From: cheney Date: Fri, 17 Apr 2026 13:34:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Readme.md | 3 +- src/App.tsx | 474 +++++++++++++++++++++++++++++++++++++++++-------- src/version.js | 2 +- 3 files changed, 401 insertions(+), 78 deletions(-) diff --git a/Readme.md b/Readme.md index 610c7b3..c750ad5 100644 --- a/Readme.md +++ b/Readme.md @@ -1,4 +1,5 @@ # TODO -- [ ] CI 集成,将 dist 传输到指定服务器指定目录。 +- [x] CI 集成,将 dist 传输到指定服务器指定目录。 +- [x] 添加 SM2 算法 diff --git a/src/App.tsx b/src/App.tsx index 4d730da..e1e16d2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react' +import { useState, useEffect } from 'react' import { VERSION } from './version' import { sm3Digest, sm3Hmac } from './utils/algorithm/sm3' @@ -7,9 +7,36 @@ import { hexToUtf8, utf8ToHex } from './utils/convert' function App() { const [activeTab, setActiveTab] = useState('sm3') + const [isMobile, setIsMobile] = useState(false) + const [mobileTab, setMobileTab] = useState('sm3') + + // 检测是否为移动设备 + useEffect(() => { + const checkMobile = () => { + setIsMobile(window.innerWidth < 768) + } + + checkMobile() + window.addEventListener('resize', checkMobile) + + return () => { + window.removeEventListener('resize', checkMobile) + } + }, []) + + // 处理移动设备的 tab 切换 + const handleMobileTabChange = (e: React.ChangeEvent) => { + setMobileTab(e.target.value) + setActiveTab(e.target.value) + } + + // 处理桌面端的 tab 切换 + const handleTabChange = (tab: string) => { + setActiveTab(tab) + } - + // SM3 状态 const [sm3Message, setSm3Message] = useState('') const [sm3Result, setSm3Result] = useState('') @@ -92,113 +119,280 @@ function App() { } return ( -
-

安全算法计算工具

+
+

安全算法计算工具

-
- - - -
+ {/* 桌面端 Tab 选择 */} + {!isMobile && ( +
+ + + +
+ )} + + {/* 移动端下拉选择 */} + {isMobile && ( +
+ +
+ )} {/* SM3 面板 */} {activeTab === 'sm3' && ( -
-

SM3 算法

+
+

SM3 算法

-
- +
+