d38bafe237
移除 chrome.i18n 后,将各功能页面、布局与工具模块的 UI 文案改为内联中文; 删除冗余注释与过度抽象(如 ToolCard、StatCard),精简 props 与状态管理; 同步优化 JsonTools、StorageCleaner、Timestamp、TestDataGenerator、Dashboard、 Base64Converter、RightClickRestorer、TextStatistics、TopBar、RouterProvider、 ThemeModeProvider 及生成器库与 utils 工具文件。
35 lines
862 B
TypeScript
35 lines
862 B
TypeScript
import { getFeatureByKey, type FeatureConfig } from '@/config/features';
|
|
import type { PageType } from '@/types/storage';
|
|
|
|
export type DashboardFeature = FeatureConfig & {
|
|
icon: NonNullable<FeatureConfig['icon']>;
|
|
};
|
|
|
|
export interface DashboardFeatureItem {
|
|
key: PageType;
|
|
feature: DashboardFeature;
|
|
}
|
|
|
|
function isDashboardFeature(feature: FeatureConfig): feature is DashboardFeature {
|
|
return feature.icon != null;
|
|
}
|
|
|
|
export function resolveDashboardFeatures(
|
|
keys: PageType[],
|
|
visiblePages: PageType[],
|
|
): DashboardFeatureItem[] {
|
|
const visibleSet = new Set(visiblePages);
|
|
const items: DashboardFeatureItem[] = [];
|
|
|
|
for (const key of keys) {
|
|
if (!visibleSet.has(key)) continue;
|
|
|
|
const feature = getFeatureByKey(key);
|
|
if (!feature || !isDashboardFeature(feature)) continue;
|
|
|
|
items.push({ key, feature });
|
|
}
|
|
|
|
return items;
|
|
}
|