From 6e5f6f32287da304463bee20f6ef0324d12b32c1 Mon Sep 17 00:00:00 2001 From: yuruo Date: Thu, 20 Jun 2024 08:52:00 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E6=B7=BB=E5=8A=A0(FooterMenu):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E7=82=B9=E5=87=BB=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=A4=84=E7=90=86=E7=A8=8B=E5=BA=8F=E4=BB=A5=E6=8F=90=E4=BA=A4?= =?UTF-8?q?POST=E8=AF=B7=E6=B1=82=20=E6=96=B0=E5=A2=9E(Category):=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=86CategoryAction=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=9D=A5=E5=A4=84=E7=90=86=E5=88=9B=E5=BB=BA=E6=96=B0=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E7=9A=84=E6=95=B0=E6=8D=AE=E5=BA=93=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=20=E2=99=BB=EF=B8=8F=20=E9=87=8D=E6=9E=84(CategoryLoader):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E8=8E=B7=E5=8F=96=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9A=84SQL=E6=9F=A5=E8=AF=A2=E8=AF=AD?= =?UTF-8?q?=E5=8F=A5=20=F0=9F=9A=80=20=E9=83=A8=E7=BD=B2(router):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86CategoryAction=E5=88=B0=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E9=85=8D=E7=BD=AE=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/renderer/src/components/FooterMenu/index.tsx | 6 +++++- .../src/renderer/src/pages/Category/CategoryAction.ts | 7 +++++++ .../src/renderer/src/pages/Category/CategoryLoader.ts | 2 +- ui/autoMate/src/renderer/src/router/index.tsx | 2 ++ 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 ui/autoMate/src/renderer/src/pages/Category/CategoryAction.ts diff --git a/ui/autoMate/src/renderer/src/components/FooterMenu/index.tsx b/ui/autoMate/src/renderer/src/components/FooterMenu/index.tsx index 0faf415..23c1610 100644 --- a/ui/autoMate/src/renderer/src/components/FooterMenu/index.tsx +++ b/ui/autoMate/src/renderer/src/components/FooterMenu/index.tsx @@ -1,10 +1,14 @@ import { Add, DatabaseConfig } from '@icon-park/react' +import { useSubmit } from 'react-router-dom' export const FooterMenu = () => { + const submit = useSubmit() return ( <>
- + + submit(null, {method:'POST'}) + }/>
diff --git a/ui/autoMate/src/renderer/src/pages/Category/CategoryAction.ts b/ui/autoMate/src/renderer/src/pages/Category/CategoryAction.ts new file mode 100644 index 0000000..55d4a05 --- /dev/null +++ b/ui/autoMate/src/renderer/src/pages/Category/CategoryAction.ts @@ -0,0 +1,7 @@ +export default async({request}) =>{ + await window.api.sql( + "insert into categories (name, created_at) values('未命名', datetime())", + "create", + ) + return {} +} diff --git a/ui/autoMate/src/renderer/src/pages/Category/CategoryLoader.ts b/ui/autoMate/src/renderer/src/pages/Category/CategoryLoader.ts index 8f9672d..dbe6feb 100644 --- a/ui/autoMate/src/renderer/src/pages/Category/CategoryLoader.ts +++ b/ui/autoMate/src/renderer/src/pages/Category/CategoryLoader.ts @@ -1,3 +1,3 @@ export default () => { - return window.api.sql("SELECT * FROM categories", "findAll") + return window.api.sql("SELECT * FROM categories order by id desc", "findAll") } \ No newline at end of file diff --git a/ui/autoMate/src/renderer/src/router/index.tsx b/ui/autoMate/src/renderer/src/router/index.tsx index a004c13..105cb10 100644 --- a/ui/autoMate/src/renderer/src/router/index.tsx +++ b/ui/autoMate/src/renderer/src/router/index.tsx @@ -10,6 +10,7 @@ import { Content } from "@renderer/pages/Content/Content"; import ContentAction from "@renderer/pages/Content/ContentAction"; import { Welcome } from "@renderer/pages/Welcome"; import ContentListAction from "@renderer/pages/ContentList/ContentListAction"; +import CategoryAction from "@renderer/pages/Category/CategoryAction"; const router = createHashRouter([ { @@ -25,6 +26,7 @@ const router = createHashRouter([ // 界面第一次打开时,默认显示的页面 element: , loader: CategoryLoader, + action: CategoryAction, children: [ { path: "contentList/:cid?",