ui(autoMate):Content页面添加自动获取焦点功能及文本框placeholder提示

📝 ui(autoMate):ContentListAction页面重构,添加逻辑处理并重定向
🔧 ui(autoMate):ContentList样式表调整,修改链接边距及样式
♻️ ui(autoMate):ContentList页面重构,修改NavLink类名及布局样式
This commit is contained in:
ruotongyu 2024-06-18 22:07:54 +08:00
parent 08b33ca439
commit 65ea1214d4
4 changed files with 12 additions and 9 deletions

View File

@ -6,10 +6,10 @@ export const Content = () => {
return (
<Form method="PUT">
<main className="content-page" key={content.id}>
<input defaultValue={content.title} name="title" onChange={(e) => {
<input autoFocus defaultValue={content.title} name="title" onChange={(e) => {
submit(e.target.form)
}}/>
<textarea defaultValue={content.content} name="content" onChange={(e) => {
<textarea placeholder="请输入内容..." defaultValue={content.content} name="content" onChange={(e) => {
submit(e.target.form)
}}/>
</main>

View File

@ -1,12 +1,15 @@
import { redirect } from "react-router-dom"
export default async ({request, params}) => {
const formData = await request.formData()
const cid = params.cid || 0
switch(formData.get("action")){
case "add":
await window.api.sql(
case "add": {
const id = await window.api.sql(
`insert into contents (title, content, category_id, created_at) values ('未命名', '', ${cid}, datetime())`,
"create")
break
return redirect(`content/${id}`)
}
}
return {}

View File

@ -6,10 +6,10 @@
@apply border-r overflow-y-auto;
grid-area: list;
a {
@apply truncate py-1 px-1 cursor-pointer flex items-center gap-1 border-b mx-2;
@apply truncate py-1 px-1 cursor-pointer flex items-center gap-1 border-b mx-2 my-1;
&.active{
// mx-1 外边距
@apply bg-blue-700 text-white mx-1 rounded-md;
@apply bg-blue-700 text-white rounded-md;
}
}
}

View File

@ -35,7 +35,7 @@ export const ContentList = () => {
<NavLink
key={content.id}
to={`/config/category/contentList/${content.category_id}/content/${content.id}`}
className={({ isActive }) => `${isActive ? "active" : ""}`}>
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>
</NavLink>