mirror of
https://github.com/yuruotong1/autoMate.git
synced 2025-12-26 05:16:21 +08:00
✨ ui/autoMate:为内容页面添加隐藏的id输入框
✅ ui/autoMate:更新内容操作模块以适应新表单数据结构 ♻️ ui/autoMate:更新内容列表页中显示时间的格式
This commit is contained in:
parent
3c0bbf834d
commit
eb3643d5f7
@ -9,6 +9,7 @@ export const Content = () => {
|
||||
return (
|
||||
<Form method="PUT">
|
||||
<main className="content-page" key={content.id}>
|
||||
<input name="id" type="text" defaultValue={content.id} hidden></input>
|
||||
<input autoFocus defaultValue={content.title} name="title" onChange={(e) => {
|
||||
submit(e.target.form)
|
||||
}}/>
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
export default async({request, params}) => {
|
||||
import { redirect } from "react-router-dom"
|
||||
|
||||
export default async({request}) => {
|
||||
// params 接收路由中传递过来的数据
|
||||
const data = await request.formData()
|
||||
const res = window.api.sql(
|
||||
const formData = await request.formData()
|
||||
const data = Object.fromEntries(formData)
|
||||
await window.api.sql(
|
||||
`update contents set title=@title, content=@content, category_id=@category_id where id=@id`,
|
||||
"update",
|
||||
{title: data.get("title"),
|
||||
content: data.get("content"),
|
||||
category_id: data.get("category_id"),
|
||||
id: params.id}
|
||||
data
|
||||
)
|
||||
return res
|
||||
return redirect(`/config/category/contentList/${data.category_id}/content/${data.id}`)
|
||||
}
|
||||
@ -37,7 +37,7 @@ export const ContentList = () => {
|
||||
to={`/config/category/contentList/${content.category_id}/content/${content.id}`}
|
||||
className="flex justify-between items-center">
|
||||
<div className="truncate">{content.title}</div>
|
||||
<div className="text-[10px] opacity-80 ">{dayjs(content.created_at).format("YYYY/MM/DD")}</div>
|
||||
<div className="text-[10px] opacity-80 ">{dayjs(content.created_at).format("YY/MM/DD")}</div>
|
||||
</NavLink>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user