1a92e88934
- 添加类型定义 (FieldConfig, DataRule, GeneratorDefinition 等) - 实现 21 个数据生成器 (个人信息/业务数据/技术数据/基础类型) - 实现 Web Worker 后台数据生成引擎 - 实现规则存储与管理功能 - 实现 JSON/CSV 数据导出功能 - 开发完整 UI 组件 (字段管理/生成器选择/数据预览/导出面板等) - 集成到应用功能配置,添加国际化支持 功能特性: - 实时预览生成的数据 - 字段配置 (名称/描述/必填/空值率/唯一性约束) - 规则管理 (保存/加载/搜索/导入导出) - Web Worker 后台生成,支持进度显示和取消 - 响应式布局,支持多种设备 docs: 更新 TASKS.md 所有子任务复选框为已完成状态
201 lines
5.2 KiB
TypeScript
201 lines
5.2 KiB
TypeScript
import { type ComponentType, lazy } from 'react';
|
|
import type { LucideProps } from 'lucide-react';
|
|
import type { PageType } from '@/types/storage';
|
|
import {
|
|
Clock,
|
|
Database,
|
|
QrCode,
|
|
FileText,
|
|
Key,
|
|
GitCompareArrows,
|
|
ArrowLeftRight,
|
|
MousePointerClick,
|
|
FileSpreadsheet,
|
|
} from 'lucide-react';
|
|
|
|
export type PaletteColorKey = 'primary' | 'success' | 'warning' | 'error' | 'secondary' | 'info';
|
|
|
|
// 懒加载页面组件
|
|
const DashboardPage = lazy(() => import('@/pages/Dashboard'));
|
|
const TimestampPage = lazy(() => import('@/pages/Timestamp'));
|
|
const StorageCleanerPage = lazy(() => import('@/pages/StorageCleaner'));
|
|
const QrCodePage = lazy(() => import('@/pages/QrCode'));
|
|
const TextStatisticsPage = lazy(() => import('@/pages/TextStatistics'));
|
|
const JwtPage = lazy(() => import('@/pages/Jwt'));
|
|
const JsonToolsPage = lazy(() => import('@/pages/JsonTools'));
|
|
const Base64ConverterPage = lazy(() => import('@/pages/Base64Converter'));
|
|
const RightClickRestorerPage = lazy(() => import('@/pages/RightClickRestorer'));
|
|
const TestDataGeneratorPage = lazy(() => import('@/pages/TestDataGenerator'));
|
|
|
|
export interface FeatureConfig {
|
|
key: PageType;
|
|
labelKey: string;
|
|
descriptionKey: string;
|
|
themeColorKey?: PaletteColorKey;
|
|
icon?: ComponentType<LucideProps>;
|
|
defaultVisible: boolean;
|
|
components: {
|
|
popup: ComponentType;
|
|
sidepanel: ComponentType;
|
|
tab: ComponentType;
|
|
};
|
|
}
|
|
|
|
export const FEATURES: FeatureConfig[] = [
|
|
{
|
|
key: 'dashboard',
|
|
labelKey: 'dashboard_title',
|
|
descriptionKey: '',
|
|
defaultVisible: true,
|
|
components: {
|
|
popup: DashboardPage,
|
|
sidepanel: DashboardPage,
|
|
tab: DashboardPage,
|
|
},
|
|
},
|
|
{
|
|
key: 'timestamp',
|
|
labelKey: 'timestamp_title',
|
|
descriptionKey: 'timestamp_description',
|
|
themeColorKey: 'primary',
|
|
icon: Clock,
|
|
defaultVisible: true,
|
|
components: {
|
|
popup: TimestampPage,
|
|
sidepanel: TimestampPage,
|
|
tab: TimestampPage,
|
|
},
|
|
},
|
|
{
|
|
key: 'storageCleaner',
|
|
labelKey: 'storageCleaner_title',
|
|
descriptionKey: 'storageCleaner_description',
|
|
themeColorKey: 'warning',
|
|
icon: Database,
|
|
defaultVisible: true,
|
|
components: {
|
|
popup: StorageCleanerPage,
|
|
sidepanel: StorageCleanerPage,
|
|
tab: StorageCleanerPage,
|
|
},
|
|
},
|
|
{
|
|
key: 'qrCode',
|
|
labelKey: 'qrCode_title',
|
|
descriptionKey: 'qrCode_description',
|
|
themeColorKey: 'success',
|
|
icon: QrCode,
|
|
defaultVisible: true,
|
|
components: {
|
|
popup: QrCodePage,
|
|
sidepanel: QrCodePage,
|
|
tab: QrCodePage,
|
|
},
|
|
},
|
|
{
|
|
key: 'textStatistics',
|
|
labelKey: 'textStatistics_title',
|
|
descriptionKey: 'textStatistics_description',
|
|
themeColorKey: 'secondary',
|
|
icon: FileText,
|
|
defaultVisible: true,
|
|
components: {
|
|
popup: TextStatisticsPage,
|
|
sidepanel: TextStatisticsPage,
|
|
tab: TextStatisticsPage,
|
|
},
|
|
},
|
|
{
|
|
key: 'jwt',
|
|
labelKey: 'jwt_title',
|
|
descriptionKey: 'jwt_description',
|
|
themeColorKey: 'info',
|
|
icon: Key,
|
|
defaultVisible: true,
|
|
components: {
|
|
popup: JwtPage,
|
|
sidepanel: JwtPage,
|
|
tab: JwtPage,
|
|
},
|
|
},
|
|
{
|
|
key: 'jsonDiff',
|
|
labelKey: 'jsonDiff_title',
|
|
descriptionKey: 'jsonDiff_description',
|
|
themeColorKey: 'primary',
|
|
icon: GitCompareArrows,
|
|
defaultVisible: true,
|
|
components: {
|
|
popup: JsonToolsPage,
|
|
sidepanel: JsonToolsPage,
|
|
tab: JsonToolsPage,
|
|
},
|
|
},
|
|
{
|
|
key: 'base64Converter',
|
|
labelKey: 'base64Converter_title',
|
|
descriptionKey: 'base64Converter_description',
|
|
themeColorKey: 'info',
|
|
icon: ArrowLeftRight,
|
|
defaultVisible: true,
|
|
components: {
|
|
popup: Base64ConverterPage,
|
|
sidepanel: Base64ConverterPage,
|
|
tab: Base64ConverterPage,
|
|
},
|
|
},
|
|
{
|
|
key: 'rightClickRestorer',
|
|
labelKey: 'rightClickRestorer_title',
|
|
descriptionKey: 'rightClickRestorer_description',
|
|
themeColorKey: 'success',
|
|
icon: MousePointerClick,
|
|
defaultVisible: true,
|
|
components: {
|
|
popup: RightClickRestorerPage,
|
|
sidepanel: RightClickRestorerPage,
|
|
tab: RightClickRestorerPage,
|
|
},
|
|
},
|
|
{
|
|
key: 'testDataGenerator',
|
|
labelKey: 'testDataGenerator_title',
|
|
descriptionKey: 'testDataGenerator_description',
|
|
themeColorKey: 'warning',
|
|
icon: FileSpreadsheet,
|
|
defaultVisible: true,
|
|
components: {
|
|
popup: TestDataGeneratorPage,
|
|
sidepanel: TestDataGeneratorPage,
|
|
tab: TestDataGeneratorPage,
|
|
},
|
|
},
|
|
];
|
|
|
|
export function getFeatureByKey(key: PageType): FeatureConfig | undefined {
|
|
return FEATURES.find((f) => f.key === key);
|
|
}
|
|
|
|
export function getDefaultVisibleFeatureKeys(): PageType[] {
|
|
return FEATURES.filter((f) => f.defaultVisible).map((f) => f.key);
|
|
}
|
|
|
|
export function getAllFeatureKeys(): PageType[] {
|
|
return FEATURES.map((f) => f.key);
|
|
}
|
|
|
|
export function getDefaultPageOrder(): PageType[] {
|
|
return FEATURES.filter((f) => f.key !== 'dashboard').map((f) => f.key);
|
|
}
|
|
|
|
export function getEntryPointType(): 'popup' | 'sidepanel' | 'tab' {
|
|
const pathname = window.location.pathname;
|
|
if (pathname.includes('sidepanel')) {
|
|
return 'sidepanel';
|
|
}
|
|
if (new URLSearchParams(window.location.search).get('mode') === 'tab') {
|
|
return 'tab';
|
|
}
|
|
return 'popup';
|
|
}
|