Skip to content

Commit 9b15009

Browse files
committed
fix: correct spelling errors in action types
1 parent 82a90a6 commit 9b15009

File tree

11 files changed

+43
-34
lines changed

11 files changed

+43
-34
lines changed

src/background/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ chrome.tabs.onRemoved.addListener((tabId) => {
6464
let currentSyncData: SyncData | null = null;
6565
let currentPublishPopup: chrome.windows.Window | null = null;
6666
const defaultMessageHandler = (request, sender, sendResponse) => {
67-
if (request.action === 'MUTLIPOST_EXTENSION_CHECK_SERVICE_STATUS') {
67+
if (request.action === 'MULTIPOST_EXTENSION_CHECK_SERVICE_STATUS') {
6868
sendResponse({ extensionId: chrome.runtime.id });
6969
}
70-
if (request.action === 'MUTLIPOST_EXTENSION_PUBLISH') {
70+
if (request.action === 'MULTIPOST_EXTENSION_PUBLISH') {
7171
const data = request.data as SyncData;
7272
currentSyncData = data;
7373
(async () => {
@@ -79,21 +79,21 @@ const defaultMessageHandler = (request, sender, sendResponse) => {
7979
});
8080
})();
8181
}
82-
if (request.action === 'MUTLIPOST_EXTENSION_PLATFORMS') {
82+
if (request.action === 'MULTIPOST_EXTENSION_PLATFORMS') {
8383
getPlatformInfos().then((platforms) => {
8484
sendResponse({ platforms });
8585
});
8686
}
87-
if (request.action === 'MUTLIPOST_EXTENSION_GET_ACCOUNT_INFOS') {
87+
if (request.action === 'MULTIPOST_EXTENSION_GET_ACCOUNT_INFOS') {
8888
getAllAccountInfo().then((accountInfo) => {
8989
sendResponse({ accountInfo });
9090
});
9191
}
92-
if (request.action === 'MUTLIPOST_EXTENSION_OPEN_OPTIONS') {
92+
if (request.action === 'MULTIPOST_EXTENSION_OPEN_OPTIONS') {
9393
chrome.runtime.openOptionsPage();
9494
sendResponse({ extensionId: chrome.runtime.id });
9595
}
96-
if (request.action === 'MUTLIPOST_EXTENSION_REFRESH_ACCOUNT_INFOS') {
96+
if (request.action === 'MULTIPOST_EXTENSION_REFRESH_ACCOUNT_INFOS') {
9797
chrome.windows.create({
9898
url: chrome.runtime.getURL(`tabs/refresh-accounts.html`),
9999
type: 'popup',
@@ -102,10 +102,10 @@ const defaultMessageHandler = (request, sender, sendResponse) => {
102102
focused: request.data.isFocused || false,
103103
});
104104
}
105-
if (request.action === 'MUTLIPOST_EXTENSION_PUBLISH_REQUEST_SYNC_DATA') {
105+
if (request.action === 'MULTIPOST_EXTENSION_PUBLISH_REQUEST_SYNC_DATA') {
106106
sendResponse({ syncData: currentSyncData });
107107
}
108-
if (request.action === 'MUTLIPOST_EXTENSION_PUBLISH_NOW') {
108+
if (request.action === 'MULTIPOST_EXTENSION_PUBLISH_NOW') {
109109
const data = request.data as SyncData;
110110
if (Array.isArray(data.platforms) && data.platforms.length > 0) {
111111
(async () => {

src/background/services/api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ export const ping = async (withPlatforms: boolean = false) => {
5353
};
5454

5555
export const linkExtensionMessageHandler = async (request, sender, sendResponse) => {
56-
if (request.action === 'MUTLIPOST_EXTENSION_LINK_EXTENSION') {
56+
if (request.action === 'MULTIPOST_EXTENSION_LINK_EXTENSION') {
5757
console.log('request', request);
5858
const params = {
59-
action: 'MUTLIPOST_EXTENSION_LINK_EXTENSION',
59+
action: 'MULTIPOST_EXTENSION_LINK_EXTENSION',
6060
apiKey: request.data.apiKey,
6161
};
6262

@@ -71,7 +71,7 @@ export const linkExtensionMessageHandler = async (request, sender, sendResponse)
7171
});
7272

7373
const linkExtensionListener = (message, authSender, authSendResponse) => {
74-
if (message.type === 'MUTLIPOST_EXTENSION_LINK_EXTENSION_CONFIRM') {
74+
if (message.type === 'MULTIPOST_EXTENSION_LINK_EXTENSION_CONFIRM') {
7575
const { confirm } = message;
7676
sendResponse({ confirm });
7777
authSendResponse('success');

src/background/services/tabs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const tabsManagerHandleTabUpdated = handleTabUpdated;
3737
export const tabsManagerHandleTabRemoved = handleTabRemoved;
3838

3939
export const tabsManagerMessageHandler = (request, sender, sendResponse) => {
40-
if (request.type === 'MUTLIPOST_EXTENSION_REQUEST_PUBLISH_RELOAD') {
40+
if (request.type === 'MULTIPOST_EXTENSION_REQUEST_PUBLISH_RELOAD') {
4141
const { tabId } = request.data;
4242
const info = tabsManagerMessages.find((group) => group.tabs.some((t) => t.tab.id === tabId));
4343
const tabInfo = info?.tabs.find((t) => t.tab.id === tabId);
@@ -54,10 +54,10 @@ export const tabsManagerMessageHandler = (request, sender, sendResponse) => {
5454

5555
sendResponse('success');
5656
}
57-
if (request.type === 'MUTLIPOST_EXTENSION_TABS_MANAGER_REQUEST_TABS') {
57+
if (request.type === 'MULTIPOST_EXTENSION_TABS_MANAGER_REQUEST_TABS') {
5858
sendResponse(getTabsManagerMessages());
5959
}
60-
if (request.type === 'MUTLIPOST_EXTENSION_TABS_MANAGER_REQUEST_ADD_TABS') {
60+
if (request.type === 'MULTIPOST_EXTENSION_TABS_MANAGER_REQUEST_ADD_TABS') {
6161
const { data, tabs } = request;
6262
addTabsManagerMessages({
6363
syncData: data,

src/background/services/trust-domain.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ const storage = new Storage({ area: 'local' });
44

55
export const trustDomainMessageHandler = async (request, sender, sendResponse) => {
66
// 获取信任域名列表
7-
if (request.action === 'MUTLIPOST_EXTENSION_GET_TRUSTED_DOMAINS') {
7+
if (request.action === 'MULTIPOST_EXTENSION_GET_TRUSTED_DOMAINS') {
88
const trustedDomains = (await storage.get<Array<{ id: string; domain: string }>>('trustedDomains')) || [];
99
return sendResponse({ trustedDomains });
1010
}
1111

1212
// 删除特定信任域名
13-
if (request.action === 'MUTLIPOST_EXTENSION_DELETE_TRUSTED_DOMAIN') {
13+
if (request.action === 'MULTIPOST_EXTENSION_DELETE_TRUSTED_DOMAIN') {
1414
const { domainId } = request.data;
1515

1616
console.log('request', request);
@@ -27,7 +27,7 @@ export const trustDomainMessageHandler = async (request, sender, sendResponse) =
2727
return sendResponse({ success: true, trustedDomains: updatedDomains });
2828
}
2929

30-
if (request.action === 'MUTLIPOST_EXTENSION_REQUEST_TRUST_DOMAIN') {
30+
if (request.action === 'MULTIPOST_EXTENSION_REQUEST_TRUST_DOMAIN') {
3131
// 检查域名是否已经被信任
3232
const trustedDomains = (await storage.get<Array<{ domain: string }>>('trustedDomains')) || [];
3333
const hostname = new URL(sender.origin).hostname;
@@ -45,7 +45,7 @@ export const trustDomainMessageHandler = async (request, sender, sendResponse) =
4545
}
4646

4747
const params = {
48-
action: 'MUTLIPOST_EXTENSION_REQUEST_TRUST_DOMAIN',
48+
action: 'MULTIPOST_EXTENSION_REQUEST_TRUST_DOMAIN',
4949
origin: hostname,
5050
};
5151

@@ -60,7 +60,7 @@ export const trustDomainMessageHandler = async (request, sender, sendResponse) =
6060
});
6161

6262
const trustDomainListener = (message, authSender, authSendResponse) => {
63-
if (message.type === 'MUTLIPOST_EXTENSION_TRUST_DOMAIN_CONFIRM') {
63+
if (message.type === 'MULTIPOST_EXTENSION_TRUST_DOMAIN_CONFIRM') {
6464
const { trusted, status } = message;
6565
sendResponse({ trusted, status });
6666
authSendResponse('success');

src/components/Sidepanel/Tabs/TabsManager.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function TabsManager() {
88

99
useEffect(() => {
1010
const interval = setInterval(() => {
11-
chrome.runtime.sendMessage({ type: 'MUTLIPOST_EXTENSION_TABS_MANAGER_REQUEST_TABS' }).then((data) => {
11+
chrome.runtime.sendMessage({ type: 'MULTIPOST_EXTENSION_TABS_MANAGER_REQUEST_TABS' }).then((data) => {
1212
setTabGroup(data);
1313
});
1414
}, 1000);
@@ -46,7 +46,7 @@ function TabsManager() {
4646
};
4747

4848
const handleReloadTab = (tabGroup: TabManagerMessage, tabId: number) => {
49-
chrome.runtime.sendMessage({ type: 'MUTLIPOST_EXTENSION_REQUEST_PUBLISH_RELOAD', data: { tabId, tabGroup } });
49+
chrome.runtime.sendMessage({ type: 'MULTIPOST_EXTENSION_REQUEST_PUBLISH_RELOAD', data: { tabId, tabGroup } });
5050
};
5151

5252
// 过滤掉没有标签的组

src/contents/extension.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const storage = new Storage({
1212
area: 'local',
1313
});
1414

15-
const ACTIONS_NOT_NEED_TRUST_DOMAIN = ['MUTLIPOST_EXTENSION_REQUEST_TRUST_DOMAIN'];
15+
const ACTIONS_NOT_NEED_TRUST_DOMAIN = ['MULTIPOST_EXTENSION_REQUEST_TRUST_DOMAIN'];
1616

1717
async function isOriginTrusted(origin: string, action: string): Promise<boolean> {
1818
if (ACTIONS_NOT_NEED_TRUST_DOMAIN.includes(action)) {
@@ -37,6 +37,11 @@ window.addEventListener('message', async (event) => {
3737
return;
3838
}
3939

40+
// 修正action中的拼写错误
41+
if (request.action.startsWith('MUTLIPOST')) {
42+
request.action = request.action.replace(/^MUTLIPOST/, 'MULTIPOST');
43+
}
44+
4045
// 验证来源是否可信
4146
const isTrusted = await isOriginTrusted(new URL(event.origin).hostname, request.action);
4247
if (!isTrusted) {

src/contents/scraper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const config: PlasmoCSConfig = {
88
};
99

1010
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
11-
if (message.type === 'MUTLIPOST_EXTENSION_REQUEST_SCRAPER_START') {
11+
if (message.type === 'MULTIPOST_EXTENSION_REQUEST_SCRAPER_START') {
1212
const scrapeFunc = async () => {
1313
const articleData = await scrapeContent();
1414
await new Promise((resolve) => setTimeout(resolve, 1000));

src/options/index_old.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const Options = () => {
100100

101101
// Notify tabs manager about new tabs
102102
chrome.runtime.sendMessage({
103-
type: 'MUTLIPOST_EXTENSION_TABS_MANAGER_REQUEST_ADD_TABS',
103+
type: 'MULTIPOST_EXTENSION_TABS_MANAGER_REQUEST_ADD_TABS',
104104
data: data,
105105
tabs: tabs,
106106
});
@@ -149,7 +149,7 @@ const Options = () => {
149149
if (tabId === newTab.id && info.status === 'complete') {
150150
chrome.tabs.onUpdated.removeListener(listener);
151151
chrome.tabs
152-
.sendMessage(newTab.id!, { type: 'MUTLIPOST_EXTENSION_REQUEST_SCRAPER_START' })
152+
.sendMessage(newTab.id!, { type: 'MULTIPOST_EXTENSION_REQUEST_SCRAPER_START' })
153153
.then(async (scraperResult) => {
154154
if (currentTab?.id) {
155155
await chrome.tabs.update(currentTab.id, { active: true });

src/tabs/link-extension.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const LinkExtension = () => {
8383
}
8484

8585
chrome.runtime.sendMessage({
86-
type: 'MUTLIPOST_EXTENSION_LINK_EXTENSION_CONFIRM',
86+
type: 'MULTIPOST_EXTENSION_LINK_EXTENSION_CONFIRM',
8787
confirm: confirm,
8888
});
8989

src/tabs/publish.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ export default function Publish() {
7171
const autoCloseTimerRef = useRef<number>();
7272
const countdownTimerRef = useRef<number>();
7373
const sysnCloseTabsRef = useRef<boolean>(false);
74-
const publishedTabsRef = useRef<Array<{
75-
tab: chrome.tabs.Tab;
76-
platformInfo: SyncDataPlatform;
77-
}>>([]);
74+
const publishedTabsRef = useRef<
75+
Array<{
76+
tab: chrome.tabs.Tab;
77+
platformInfo: SyncDataPlatform;
78+
}>
79+
>([]);
7880

7981
async function processArticle(data: SyncData): Promise<SyncData> {
8082
setNotice(chrome.i18n.getMessage('processingContent'));
@@ -274,7 +276,9 @@ export default function Publish() {
274276

275277
// 更新本地状态
276278
setPublishedTabs((prev) => prev.map((item) => (item.tab.id === tabId ? { ...item, tab: updatedTab } : item)));
277-
publishedTabsRef.current = publishedTabsRef.current.map((t) => (t.tab.id === tabId ? { ...t, tab: updatedTab } : t));
279+
publishedTabsRef.current = publishedTabsRef.current.map((t) =>
280+
t.tab.id === tabId ? { ...t, tab: updatedTab } : t,
281+
);
278282
} catch (error) {
279283
console.error('重新加载标签页失败:', error);
280284
setErrors((prev) => [...prev, chrome.i18n.getMessage('errorReloadTab', [error.message || '未知错误'])]);
@@ -505,7 +509,7 @@ export default function Publish() {
505509
useEffect(() => {
506510
chrome.tabs.onUpdated.addListener(handleTabUpdated);
507511
chrome.tabs.onRemoved.addListener(handleTabRemoved);
508-
chrome.runtime.sendMessage({ action: 'MUTLIPOST_EXTENSION_PUBLISH_REQUEST_SYNC_DATA' }, async (response) => {
512+
chrome.runtime.sendMessage({ action: 'MULTIPOST_EXTENSION_PUBLISH_REQUEST_SYNC_DATA' }, async (response) => {
509513
console.log(response);
510514
const data = response.syncData as SyncData;
511515
if (!data) return setNotice(chrome.i18n.getMessage('errorGetSyncData'));
@@ -539,7 +543,7 @@ export default function Publish() {
539543
setTimeout(async () => {
540544
await focusMainWindow();
541545
chrome.runtime.sendMessage(
542-
{ action: 'MUTLIPOST_EXTENSION_PUBLISH_NOW', data: processedData },
546+
{ action: 'MULTIPOST_EXTENSION_PUBLISH_NOW', data: processedData },
543547
handlePublishComplete,
544548
);
545549
}, 1000 * 1);

0 commit comments

Comments
 (0)