mirror of
https://github.com/yuruotong1/autoMate.git
synced 2026-03-22 04:57:18 +08:00
✨ ui(autoMate): 添加选中样式以及自动跳转至第一个内容页
📝 ui(autoMate): 引入react的useEffect和useNavigate功能
This commit is contained in:
@@ -7,6 +7,10 @@
|
||||
grid-area: list;
|
||||
a {
|
||||
@apply block truncate py-1 px-1 cursor-pointer;
|
||||
&.active{
|
||||
// mx-1 外边距
|
||||
@apply bg-blue-700 text-white mx-1 rounded-md;
|
||||
}
|
||||
}
|
||||
}
|
||||
.content{
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
import { NavLink, Outlet, useLoaderData } from "react-router-dom"
|
||||
import { NavLink, Outlet, useLoaderData, useNavigate } from "react-router-dom"
|
||||
import "./content.scss"
|
||||
import { useEffect } from "react"
|
||||
|
||||
export const ContentList = () => {
|
||||
const contentList = useLoaderData() as ContentType[]
|
||||
const navigate = useNavigate()
|
||||
useEffect(() => {
|
||||
if (contentList) {
|
||||
navigate(`/config/category/contentList/${contentList[0].category_id}/content/${contentList[0].id}`)
|
||||
}
|
||||
}, [contentList])
|
||||
return (<main className="content-page">
|
||||
<div className="list">
|
||||
{contentList.map(content => (
|
||||
|
||||
Reference in New Issue
Block a user