refactor(storageCleaner): simplify architecture and improve type semantics

- Remove RELOAD_TAB message chain, use chrome.tabs.reload() directly
- Rename IndexedDB label to '站点存储' for accuracy
- Introduce StorageSizeInfo type to distinguish bytes vs count
- Rename totalSize to totalBytes for clarity
- Merge runCleanScript into runScript to reduce duplication
- Rename CleaningResult.success to overallSuccess to avoid confusion
- Remove unused domain state and setDomain call

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
雨霖铃
2026-05-29 21:59:54 +08:00
parent 1b9f6d044d
commit f9fbc79612
11 changed files with 149 additions and 151 deletions
+11 -11
View File
@@ -1,5 +1,6 @@
import React from 'react';
import type { StorageCleanerOptions } from '@/types/storage';
import type { StorageSizeInfo } from './useStorageCleaner';
import OptionItem from './OptionItem';
import { useI18n } from '@/utils/chromeI18n';
import { cn } from '@/lib/utils';
@@ -8,7 +9,7 @@ import { Label } from '@/components/ui/label';
interface StorageOptionsGridProps extends React.HTMLAttributes<HTMLDivElement> {
options: StorageCleanerOptions;
sizes: Record<string, number>;
sizes: Record<string, StorageSizeInfo>;
allSelected: boolean;
someSelected: boolean;
onOptionChange: (key: keyof StorageCleanerOptions) => void;
@@ -27,13 +28,13 @@ export default function StorageOptionsGrid({
}: StorageOptionsGridProps) {
const { t } = useI18n('storageCleaner');
const optionKeys: { key: keyof StorageCleanerOptions; isCount?: boolean }[] = [
{ key: 'localStorage' },
{ key: 'sessionStorage' },
{ key: 'indexedDB' },
{ key: 'cookies' },
{ key: 'cacheStorage', isCount: true },
{ key: 'serviceWorkers', isCount: true },
const optionKeys: (keyof StorageCleanerOptions)[] = [
'localStorage',
'sessionStorage',
'indexedDB',
'cookies',
'cacheStorage',
'serviceWorkers',
];
const handleToggleAll = () => {
@@ -44,13 +45,12 @@ export default function StorageOptionsGrid({
<div className={cn('w-full overflow-hidden', className)} {...props}>
<div className="px-3.5 pt-3.5 pb-2">
<div className="grid grid-cols-2 gap-2 items-stretch">
{optionKeys.map(({ key, isCount }) => (
{optionKeys.map((key) => (
<OptionItem
key={key}
labelKey={`storageCleaner:options.${key}`}
checked={options[key]}
size={sizes[key]}
isCount={isCount}
sizeInfo={sizes[key]}
onChange={() => onOptionChange(key)}
/>
))}