Update background message name

This commit is contained in:
2024-04-24 13:14:30 +08:00
parent 8bf22edbda
commit 46d7d4b26f
6 changed files with 37 additions and 38 deletions
+22
View File
@@ -0,0 +1,22 @@
import type { PlasmoMessaging } from "@plasmohq/messaging";
const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
const { token, siteUrl } = await chrome.storage.local.get(["token", "siteUrl"]);
// 更新追番进度
if (req.body.action === "updateBangumiProgress") {
const { values } = req.body;
const updateRequest = await fetch(`${siteUrl}/api/bangumi/update`, {
method: "POST",
body: JSON.stringify(values),
headers: {
"paul-token-code": token,
},
}).then((res) => res.json());
res.send(updateRequest);
}
}
export default handler;
+1 -1
View File
@@ -3,7 +3,7 @@ import type { PlasmoMessaging } from "@plasmohq/messaging";
const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
const { token, siteUrl } = await chrome.storage.local.get(["token", "siteUrl"]);
if (req.body.action === "submitAddForm") {
if (req.body.action === "addRead") {
const { values } = req.body;
const formData = new FormData();
@@ -4,7 +4,7 @@ const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
const { token, siteUrl } = await chrome.storage.local.get(["token", "siteUrl"]);
// 添加手办
if (req.body.action === "submitAddForm") {
if (req.body.action === "addToy") {
const { values } = req.body;
let imageBlob: Blob | undefined;
@@ -33,21 +33,6 @@ const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
res.send(addReq);
}
// 更新追番进度
if (req.body.action === "updateBangumiProgress") {
const { values } = req.body;
const updateRequest = await fetch(`${siteUrl}/api/bangumi/update`, {
method: "POST",
body: JSON.stringify(values),
headers: {
"paul-token-code": token,
},
}).then((res) => res.json());
res.send(updateRequest);
}
}
export default handler;