From bdbb399ddcdeb627731251f6c88f25e83ca24994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E8=88=AA=E5=AE=87?= <3364451258@qq.com> Date: Tue, 26 May 2026 08:13:17 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=B8=85=E7=90=86=20LOW=20?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20=E2=80=94=20=E6=A0=B7=E5=BC=8F=E5=8E=BB?= =?UTF-8?q?=E9=87=8D=E3=80=81=E6=AD=BB=E4=BB=A3=E7=A0=81=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E3=80=81=E5=91=BD=E5=90=8D=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 抽取 buttons.ts 共享按钮样式,消除 3 个组件的重复定义 - store 删除未调用的 canUndo/canRedo 方法 - importFromContent 变量 ext→lower 修正确性 - CSV 导出修复 BOM 重复(exportToCsv 自带 BOM) - Rust error.rs 添加 allow(dead_code) 消除编译警告 Co-Authored-By: Claude Opus 4.7 --- src-tauri/src/error.rs | 3 ++- src/components/toolbar/ActionButtons.tsx | 9 +------ src/components/toolbar/ToolBar.tsx | 31 +++++++++------------- src/components/toolbar/UndoRedoButtons.tsx | 9 +------ src/components/ui/buttons.ts | 7 +++++ src/core/import-export.ts | 6 ++--- src/hooks/use-app-actions.ts | 2 +- src/store/app-store.ts | 5 ---- 8 files changed, 27 insertions(+), 45 deletions(-) create mode 100644 src/components/ui/buttons.ts diff --git a/src-tauri/src/error.rs b/src-tauri/src/error.rs index ec8950c..97ca0e5 100644 --- a/src-tauri/src/error.rs +++ b/src-tauri/src/error.rs @@ -1,6 +1,7 @@ use serde::Serialize; -/// 传给前端的统一错误类型(保留供未来使用,当前命令返回 Result) +/// 传给前端的统一错误类型(保留供未来迁移使用,届时所有命令改为返回 Result) +#[allow(dead_code)] #[derive(Debug, Serialize)] pub struct AppError { pub message: String, diff --git a/src/components/toolbar/ActionButtons.tsx b/src/components/toolbar/ActionButtons.tsx index ccfb686..535c35c 100644 --- a/src/components/toolbar/ActionButtons.tsx +++ b/src/components/toolbar/ActionButtons.tsx @@ -1,5 +1,6 @@ import { useTranslation } from 'react-i18next'; import { useAppStore } from '@/store/app-store'; +import { btnClass, btnStyle } from '@/components/ui/buttons'; interface ActionButtonsProps { onNew: () => void; @@ -24,14 +25,6 @@ export function ActionButtons({ const isAdmin = useAppStore((s) => s.isAdmin); const disabled = !isAdmin; - const btnClass = - 'px-3 py-1 text-sm rounded border transition-colors disabled:opacity-40 disabled:cursor-not-allowed'; - const btnStyle = { - backgroundColor: 'var(--app-bg)', - color: 'var(--app-fg)', - borderColor: 'var(--app-border)', - }; - return (
- - - - -
diff --git a/src/components/toolbar/UndoRedoButtons.tsx b/src/components/toolbar/UndoRedoButtons.tsx index dcb007b..9a977fd 100644 --- a/src/components/toolbar/UndoRedoButtons.tsx +++ b/src/components/toolbar/UndoRedoButtons.tsx @@ -1,5 +1,6 @@ import { useTranslation } from 'react-i18next'; import { useAppStore } from '@/store/app-store'; +import { btnClass, btnStyle } from '@/components/ui/buttons'; export function UndoRedoButtons() { const { t } = useTranslation(); @@ -8,14 +9,6 @@ export function UndoRedoButtons() { const undo = useAppStore((s) => s.undo); const redo = useAppStore((s) => s.redo); - const btnClass = - 'px-3 py-1 text-sm rounded border transition-colors disabled:opacity-40 disabled:cursor-not-allowed'; - const btnStyle = { - backgroundColor: 'var(--app-bg)', - color: 'var(--app-fg)', - borderColor: 'var(--app-border)', - }; - return (