Skip to content

Commit 796dc45

Browse files
committed
feat: added the function of clearing platform selection
1 parent be76d42 commit 796dc45

File tree

5 files changed

+77
-7
lines changed

5 files changed

+77
-7
lines changed

locales/en/messages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,10 @@
521521
"optionsClearAll": {
522522
"message": "Clear All"
523523
},
524+
"optionsClearPlatforms": {
525+
"message": "Clear Platforms",
526+
"description": "Button text to clear all selected platforms"
527+
},
524528
"aboutDescription": {
525529
"message": "MultiPost Extension helps you publish content to multiple platforms simultaneously, improving your content distribution efficiency."
526530
},

locales/zh_CN/messages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,10 @@
527527
"optionsClearAll": {
528528
"message": "清空"
529529
},
530+
"optionsClearPlatforms": {
531+
"message": "清空平台",
532+
"description": "清空所有已选择平台的按钮文本"
533+
},
530534
"aboutDescription": {
531535
"message": "MultiPost Extension 帮助您同时将内容发布到多个平台,提高内容分发效率。"
532536
},

src/components/Sync/ArticleTab.tsx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ const ArticleTab: React.FC<ArticleTabProps> = ({ funcPublish, funcScraper }) =>
5757
await storage.set('articlePlatforms', newSelectedPlatforms);
5858
};
5959

60+
const clearSelectedPlatforms = async () => {
61+
setSelectedPlatforms([]);
62+
await storage.set('articlePlatforms', []);
63+
};
64+
6065
const loadPlatforms = async () => {
6166
const platforms = await storage.get<string[]>("articlePlatforms");
6267
setSelectedPlatforms(platforms as string[] || []);
@@ -344,7 +349,7 @@ const ArticleTab: React.FC<ArticleTabProps> = ({ funcPublish, funcScraper }) =>
344349
isIconOnly
345350
size="sm"
346351
color="danger"
347-
className="absolute top-0 right-0 z-50 m-1 opacity-0 transition-opacity group-hover:opacity-100"
352+
className="absolute top-0 right-0 z-50 m-1 transition-opacity opacity-0 group-hover:opacity-100"
348353
onPress={handleDeleteCover}>
349354
<XIcon className="size-4" />
350355
</Button>
@@ -383,9 +388,24 @@ const ArticleTab: React.FC<ArticleTabProps> = ({ funcPublish, funcScraper }) =>
383388
</CardBody>
384389
</Card>
385390

386-
<div className="flex flex-col gap-4 bg-default-50 p-4 rounded-lg">
391+
<div className="flex flex-col gap-4 p-4 rounded-lg bg-default-50">
387392
<div className="flex flex-col gap-2">
388-
<p className="text-sm font-medium">{chrome.i18n.getMessage('optionsSelectPublishPlatforms')}</p>
393+
<div className="flex items-center justify-between">
394+
<div className="flex items-center gap-2">
395+
<p className="text-sm font-medium">{chrome.i18n.getMessage('optionsSelectPublishPlatforms')}</p>
396+
</div>
397+
{selectedPlatforms.length > 0 && (
398+
<Button
399+
size="sm"
400+
variant="light"
401+
color="danger"
402+
onPress={clearSelectedPlatforms}
403+
className="text-xs"
404+
>
405+
{chrome.i18n.getMessage('optionsClearPlatforms') || chrome.i18n.getMessage('optionsClearAll') || '清空平台'}
406+
</Button>
407+
)}
408+
</div>
389409
<div className="grid grid-cols-2 gap-3">
390410
{getPlatformInfos('ARTICLE').map((platform) => (
391411
<PlatformCheckbox
@@ -403,7 +423,7 @@ const ArticleTab: React.FC<ArticleTabProps> = ({ funcPublish, funcScraper }) =>
403423
onPress={handlePublish}
404424
color="primary"
405425
disabled={!title || selectedPlatforms.length === 0}
406-
className="px-4 py-2 w-full font-bold">
426+
className="w-full px-4 py-2 font-bold">
407427
{chrome.i18n.getMessage('optionsSyncArticle')}
408428
</Button>
409429

@@ -423,7 +443,7 @@ const ArticleTab: React.FC<ArticleTabProps> = ({ funcPublish, funcScraper }) =>
423443
<h4 className="mb-2 font-semibold">{importedContent.title}</h4>
424444
<p className="mb-4 text-sm">{importedContent.digest}</p>
425445
<div
426-
className="max-w-none prose"
446+
className="prose max-w-none"
427447
dangerouslySetInnerHTML={{ __html: importedContent.content }}
428448
/>
429449
</CardBody>

src/components/Sync/DynamicTab.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ const DynamicTab: React.FC<DynamicTabProps> = ({ funcPublish }) => {
162162
setSelectedPlatforms(newSelectedPlatforms);
163163
await storage.set('dynamicPlatforms', newSelectedPlatforms);
164164
};
165+
166+
const clearSelectedPlatforms = async () => {
167+
setSelectedPlatforms([]);
168+
await storage.set('dynamicPlatforms', []);
169+
};
170+
165171
const loadPlatforms = async () => {
166172
const platforms = await storage.get<string[]>('dynamicPlatforms');
167173
setSelectedPlatforms((platforms as string[]) || []);
@@ -348,7 +354,22 @@ const DynamicTab: React.FC<DynamicTabProps> = ({ funcPublish }) => {
348354
</Switch>
349355

350356
<div className="flex flex-col gap-2">
351-
<p className="text-sm font-medium">{chrome.i18n.getMessage('optionsSelectPublishPlatforms')}</p>
357+
<div className="flex justify-between items-center">
358+
<div className="flex items-center gap-2">
359+
<p className="text-sm font-medium">{chrome.i18n.getMessage('optionsSelectPublishPlatforms')}</p>
360+
</div>
361+
{selectedPlatforms.length > 0 && (
362+
<Button
363+
size="sm"
364+
variant="light"
365+
color="danger"
366+
onPress={clearSelectedPlatforms}
367+
className="text-xs"
368+
>
369+
{chrome.i18n.getMessage('optionsClearPlatforms') || chrome.i18n.getMessage('optionsClearAll') || '清空平台'}
370+
</Button>
371+
)}
372+
</div>
352373
<div className="grid grid-cols-2 gap-3">
353374
{getPlatformInfos('DYNAMIC').map((platform) => (
354375
<PlatformCheckbox

src/components/Sync/VideoTab.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ const VideoTab: React.FC<VideoTabProps> = ({ funcPublish }) => {
5454
setSelectedPlatforms(newSelectedPlatforms);
5555
await storage.set('videoPlatforms', newSelectedPlatforms);
5656
};
57+
58+
const clearSelectedPlatforms = async () => {
59+
setSelectedPlatforms([]);
60+
await storage.set('videoPlatforms', []);
61+
};
62+
5763
const loadPlatforms = async () => {
5864
const platforms = await storage.get<string[]>('videoPlatforms');
5965
setSelectedPlatforms((platforms as string[]) || []);
@@ -195,7 +201,22 @@ const VideoTab: React.FC<VideoTabProps> = ({ funcPublish }) => {
195201

196202
<div className="flex flex-col gap-4 p-4 rounded-lg bg-default-50">
197203
<div className="flex flex-col gap-2">
198-
<p className="text-sm font-medium">{chrome.i18n.getMessage('optionsSelectPublishPlatforms')}</p>
204+
<div className="flex justify-between items-center">
205+
<div className="flex items-center gap-2">
206+
<p className="text-sm font-medium">{chrome.i18n.getMessage('optionsSelectPublishPlatforms')}</p>
207+
</div>
208+
{selectedPlatforms.length > 0 && (
209+
<Button
210+
size="sm"
211+
variant="light"
212+
color="danger"
213+
onPress={clearSelectedPlatforms}
214+
className="text-xs"
215+
>
216+
{chrome.i18n.getMessage('optionsClearPlatforms') || chrome.i18n.getMessage('optionsClearAll') || '清空平台'}
217+
</Button>
218+
)}
219+
</div>
199220
<div className="grid grid-cols-2 gap-3">
200221
{getPlatformInfos('VIDEO').map((platform) => (
201222
<PlatformCheckbox

0 commit comments

Comments
 (0)