/** * @Author: aric 1290657123@qq.com * @Date: 2025-10-18 07:09:31 * @LastEditors: aric 1290657123@qq.com * @LastEditTime: 2025-10-25 07:32:18 */ import { ArrowLeftOutlined, BulbOutlined, CheckOutlined, CloseOutlined, CopyOutlined, DownloadOutlined, EditOutlined, EyeOutlined, ImportOutlined, PlusOutlined, RedoOutlined, ReloadOutlined, SaveOutlined, SyncOutlined, } from '@ant-design/icons'; import { Button, ButtonProps } from 'antd'; import React, { FC } from 'react'; import type { AppLocale } from './types'; type ActionType = | 'create' | 'edit' | 'del' | 'view' | 'preview' | 'save' | 'export' | 'imp' | 'refresh' | 'back' | 'submit' | 'cancel' | 'sync' | 'copy'; // 文案 const locals: Record> = { 'zh-CN': { create: '添加', edit: '编辑', del: '删除', view: '查看', preview: '预览', save: '保存', export: '导出', imp: '导入', refresh: '刷新', back: '返回', submit: '提交', cancel: '取消', sync: '同步', copy: '复制', }, 'en-US': { create: 'Create', edit: 'Edit', del: 'Delete', view: 'View', preview: 'Preview', save: 'Save', export: 'Export', imp: 'Import', refresh: 'Refresh', back: 'Back', submit: 'Submit', cancel: 'Cancel', sync: 'Sync', copy: 'Copy', }, }; // 图标映射 const iconMap: Record = { create: , edit: , del: , view: , preview: , save: , export: , imp: , refresh: , back: , submit: , cancel: , sync: , copy: , }; // 国际化工具函数 const t = (locale: AppLocale, key: ActionType): string => { return locals[locale]?.[key] ?? key; }; // 通用按钮组件 interface ActionButtonProps extends ButtonProps { action: ActionType; lang?: AppLocale; } const ActionButton: FC = ({ action, lang = 'zh-CN', size = 'small', children, ...props }) => { const text = children ?? t(lang, action); const icon = iconMap[action]; return ( ); }; // 导出具体命名的按钮(保持 API 兼容) export const BtnCreate = (props: ButtonProps & { lang?: AppLocale }) => ( ); export const BtnEdit = (props: ButtonProps & { lang?: AppLocale }) => ( ); export const BtnDelete = (props: ButtonProps & { lang?: AppLocale }) => ( ); export const BtnView = (props: ButtonProps & { lang?: AppLocale }) => ( ); export const BtnPreview = (props: ButtonProps & { lang?: AppLocale }) => ( ); export const BtnSave = (props: ButtonProps & { lang?: AppLocale }) => ( ); export const BtnExport = (props: ButtonProps & { lang?: AppLocale }) => ( ); export const BtnImport = (props: ButtonProps & { lang?: AppLocale }) => ( ); export const BtnRefresh = (props: ButtonProps & { lang?: AppLocale }) => ( ); export const BtnBack = (props: ButtonProps & { lang?: AppLocale }) => ( ); export const BtnSubmit = (props: ButtonProps & { lang?: AppLocale }) => ( ); export const BtnCancel = (props: ButtonProps & { lang?: AppLocale }) => ( ); export const BtnSync = (props: ButtonProps & { lang?: AppLocale }) => ( ); export const BtnCopy = (props: ButtonProps & { lang?: AppLocale }) => ( );