diff --git a/assets/icons.tsx b/assets/icons.tsx
index 2f50bbc..ebd15e7 100644
--- a/assets/icons.tsx
+++ b/assets/icons.tsx
@@ -16,6 +16,12 @@ export function IconBili() {
);
}
+export function IconSay() {
+ return (
+
+ );
+}
+
export function IconBack() {
return (
diff --git a/background/messages/say.ts b/background/messages/say.ts
new file mode 100644
index 0000000..f4ddf61
--- /dev/null
+++ b/background/messages/say.ts
@@ -0,0 +1,26 @@
+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 === "addSay") {
+ const { values } = req.body;
+ const formData = new FormData();
+
+ Object.keys(values).forEach((item) => {
+ formData.append(item, String(values[item]));
+ });
+
+ const addReq = await fetch(`${siteUrl}/api/say/add`, {
+ method: "POST",
+ body: formData,
+ headers: {
+ "paul-token-code": token,
+ },
+ }).then((res) => res.json());
+
+ res.send(addReq);
+ }
+}
+
+export default handler;
diff --git a/components/biz/say/index.tsx b/components/biz/say/index.tsx
new file mode 100644
index 0000000..3cc4ade
--- /dev/null
+++ b/components/biz/say/index.tsx
@@ -0,0 +1,74 @@
+import { useEffect, useRef } from "react";
+import { sendToBackground } from "@plasmohq/messaging";
+import useForm from "~hooks/useForm";
+import Tab from "~components/ui/tab";
+import Form from "~components/ui/form";
+import { add } from "~components/ui/message/utils";
+
+interface FormValue {
+ content: string;
+ author: string;
+ origin: string;
+ links: string;
+ is_comment: boolean;
+}
+
+const submitForm = (body: FormValue) => {
+ sendToBackground({
+ name: "say",
+ body: {
+ action: "addSay",
+ values: body,
+ },
+ }).then((res) => {
+ add({
+ content: res.msg,
+ });
+ }).catch((e) => {
+ if (e instanceof Error) {
+ add({
+ content: e.message,
+ });
+ }
+ });
+}
+
+function Say() {
+ const formRef = useRef();
+
+ const { bindInput, onSubmit } = useForm({
+ initialValues: {
+ is_comment: true,
+ },
+ });
+
+ return (
+
+
+
+
+
+
+
+
+ );
+}
+
+export default Say;
diff --git a/popup/menu.tsx b/popup/menu.tsx
index 2bee551..89d9fd2 100644
--- a/popup/menu.tsx
+++ b/popup/menu.tsx
@@ -1,4 +1,4 @@
-import { IconBili, IconPaul, IconRead, IconSetting } from "~assets/icons";
+import { IconBili, IconPaul, IconRead, IconSay, IconSetting } from "~assets/icons";
import styles from "./popup.module.less";
const items = [
@@ -8,10 +8,15 @@ const items = [
value: "read",
},
{
- name: "增加手办",
+ name: "手办",
icon: ,
value: "toy",
},
+ {
+ name: "语录",
+ icon: ,
+ value: "say",
+ },
{
name: "访问网站",
icon: ,
diff --git a/sidepanel/index.tsx b/sidepanel/index.tsx
index 12ab15d..fb1db06 100644
--- a/sidepanel/index.tsx
+++ b/sidepanel/index.tsx
@@ -1,6 +1,7 @@
import { useState } from "react";
import Read from "~components/biz/read";
import Toy from "~components/biz/toy";
+import Say from "~components/biz/say";
import Message from "~components/ui/message";
import { clsn } from "~utils";
@@ -10,7 +11,7 @@ import styles from "./sidepanel.module.less";
const initialType = new URLSearchParams(location.search).get("type") || "read";
const tabItems = [
- { title: "在读", value: "read" },
+ { title: "在看", value: "read" },
{ title: "手办", value: "toy" },
{ title: "语录", value: "say" },
];
@@ -22,7 +23,8 @@ function SidePanel() {
);