feat: Add platform adapters for various content publishing platforms
- Implemented Dongchedi adapter for user detection and publishing. - Implemented Jianshu adapter for user detection and publishing. - Implemented Juejin adapter for user detection and publishing. - Implemented Qiehao adapter for user detection and publishing. - Implemented Smzdm adapter for user detection and publishing. - Implemented Sohuhao adapter for user detection and publishing. - Implemented Toutiaohao adapter for user detection and publishing. - Implemented Wangyihao adapter for user detection and publishing. - Implemented Weixin Gzh adapter for user detection and publishing. - Implemented Zol adapter for user detection and publishing. - Added documentation for manual testing of media publishing.
This commit is contained in:
@@ -4,6 +4,16 @@ import { defineBackground } from "wxt/utils/define-background";
|
||||
import { handlePublisherAction } from "../src/runtime";
|
||||
import { getExtensionState } from "../src/storage";
|
||||
|
||||
type BackgroundSuccessResponse = {
|
||||
ok: true;
|
||||
data: Awaited<ReturnType<typeof handlePublisherAction>>;
|
||||
};
|
||||
|
||||
type BackgroundErrorResponse = {
|
||||
ok: false;
|
||||
error: string;
|
||||
};
|
||||
|
||||
export default defineBackground(() => {
|
||||
void getExtensionState();
|
||||
|
||||
@@ -21,11 +31,25 @@ export default defineBackground(() => {
|
||||
await getExtensionState();
|
||||
});
|
||||
|
||||
browser.runtime.onMessage.addListener((message) => {
|
||||
chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
||||
if (!message || message.type !== "geo.publisher.request") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return handlePublisherAction(message.action, message.payload);
|
||||
void handlePublisherAction(message.action, message.payload)
|
||||
.then((data) => {
|
||||
sendResponse({
|
||||
ok: true,
|
||||
data,
|
||||
} satisfies BackgroundSuccessResponse);
|
||||
})
|
||||
.catch((error: unknown) => {
|
||||
sendResponse({
|
||||
ok: false,
|
||||
error: error instanceof Error ? error.message : "publisher_plugin_unknown_error",
|
||||
} satisfies BackgroundErrorResponse);
|
||||
});
|
||||
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user