refactor: 统一中文文案并简化组件结构,提升代码可读性
移除 chrome.i18n 后,将各功能页面、布局与工具模块的 UI 文案改为内联中文; 删除冗余注释与过度抽象(如 ToolCard、StatCard),精简 props 与状态管理; 同步优化 JsonTools、StorageCleaner、Timestamp、TestDataGenerator、Dashboard、 Base64Converter、RightClickRestorer、TextStatistics、TopBar、RouterProvider、 ThemeModeProvider 及生成器库与 utils 工具文件。
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { getFeatureByKey } from '@/config/features';
|
||||
import type { DashboardFeatureItem } from '../useDashboard';
|
||||
import { resolveDashboardFeatures, type DashboardFeatureItem } from '../dashboardFeatures';
|
||||
import Index from '../index';
|
||||
|
||||
const mockNavigateTo = vi.fn();
|
||||
@@ -13,11 +12,7 @@ vi.mock('../useDashboard', () => ({
|
||||
}));
|
||||
|
||||
function buildFeatureItem(key: 'timestamp' | 'jwt'): DashboardFeatureItem {
|
||||
const feature = getFeatureByKey(key)!;
|
||||
return {
|
||||
key,
|
||||
feature: feature as DashboardFeatureItem['feature'],
|
||||
};
|
||||
return resolveDashboardFeatures([key], [key])[0]!;
|
||||
}
|
||||
|
||||
describe('Dashboard 页面', () => {
|
||||
|
||||
@@ -14,10 +14,6 @@ function isDashboardFeature(feature: FeatureConfig): feature is DashboardFeature
|
||||
return feature.icon != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将页面 key 列表解析为 Dashboard 可展示的工具项。
|
||||
* 过滤条件:在 visiblePages 中且 feature 配置了 icon。
|
||||
*/
|
||||
export function resolveDashboardFeatures(
|
||||
keys: PageType[],
|
||||
visiblePages: PageType[],
|
||||
|
||||
@@ -9,7 +9,7 @@ export default function Index() {
|
||||
{showRecent && (
|
||||
<div className="flex flex-col gap-2">
|
||||
<h3 className="text-xs font-semibold text-muted-foreground/80 uppercase tracking-wider">
|
||||
{'最近使用'}
|
||||
最近使用
|
||||
</h3>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{recentFeatures.map(({ key, feature }) => {
|
||||
@@ -37,10 +37,10 @@ export default function Index() {
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
<h3 className="text-xs font-semibold text-muted-foreground/80 uppercase tracking-wider">
|
||||
{'全部工具'}
|
||||
全部工具
|
||||
</h3>
|
||||
{visibleFeatures.length === 0 ? (
|
||||
<p className="text-sm text-muted-foreground py-4 text-center">{'没有可用的工具'}</p>
|
||||
<p className="text-sm text-muted-foreground py-4 text-center">没有可用的工具</p>
|
||||
) : (
|
||||
<div
|
||||
className={cn('grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 gap-2')}
|
||||
|
||||
@@ -3,8 +3,6 @@ import { useRouter } from '@/providers/RouterProvider';
|
||||
import type { PageType } from '@/types/storage';
|
||||
import { resolveDashboardFeatures, type DashboardFeatureItem } from './dashboardFeatures';
|
||||
|
||||
export type { DashboardFeatureItem } from './dashboardFeatures';
|
||||
|
||||
export interface UseDashboardReturn {
|
||||
visibleFeatures: DashboardFeatureItem[];
|
||||
recentFeatures: DashboardFeatureItem[];
|
||||
|
||||
Reference in New Issue
Block a user