mirror of
https://github.com/yuruotong1/autoMate.git
synced 2026-03-22 04:57:18 +08:00
✨ 添加(FooterMenu): 添加了点击事件处理程序以提交POST请求
新增(Category): 新增了CategoryAction文件来处理创建新分类的数据库操作 ♻️ 重构(CategoryLoader): 优化了获取分类数据的SQL查询语句 🚀 部署(router): 添加了CategoryAction到路由配置中
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import { Add, DatabaseConfig } from '@icon-park/react'
|
||||
import { useSubmit } from 'react-router-dom'
|
||||
|
||||
export const FooterMenu = () => {
|
||||
const submit = useSubmit()
|
||||
return (
|
||||
<>
|
||||
<div className="nav">
|
||||
<Add theme="outline" size="20" fill="#333"/>
|
||||
<Add theme="outline" size="20" fill="#333" onClick={(_e)=>
|
||||
submit(null, {method:'POST'})
|
||||
}/>
|
||||
<DatabaseConfig theme="outline" size="20" fill="#333"/>
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
export default async({request}) =>{
|
||||
await window.api.sql(
|
||||
"insert into categories (name, created_at) values('未命名', datetime())",
|
||||
"create",
|
||||
)
|
||||
return {}
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
@@ -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: <Category />,
|
||||
loader: CategoryLoader,
|
||||
action: CategoryAction,
|
||||
children: [
|
||||
{
|
||||
path: "contentList/:cid?",
|
||||
|
||||
Reference in New Issue
Block a user