优化用户体验

This commit is contained in:
宇阳
2024-10-15 13:27:54 +08:00
parent 91301c6172
commit dbad8712d6
2 changed files with 61 additions and 51 deletions

View File

@@ -11,9 +11,13 @@ import type { Tag as ArticleTag } from '@/types/app/tag';
import type { Cate } from '@/types/app/cate';
import type { Article, FilterArticle, FilterForm } from '@/types/app/article';
import { useWebStore } from '@/stores';
import dayjs from 'dayjs';
const ArticlePage = () => {
const web = useWebStore(state => state.web)
const [loading, setLoading] = useState<boolean>(false);
const [articleList, setArticleList] = useState<Article[]>([]);
@@ -34,7 +38,7 @@ const ArticlePage = () => {
const delArticleData = async (id: number) => {
setLoading(true);
await delArticleDataAPI(id);
notification.success({ message: '🎉 删除文章成功' })
getArticleList();
@@ -59,7 +63,7 @@ const ArticlePage = () => {
key: 'title',
align: 'center',
width: 300,
render: (text: string) => <div className='line-clamp-1'>{text}</div>,
render: (text: string, record: Article) => <a href={`${web.url}/article/${record.id}`} target='_blank' className='hover:text-primary line-clamp-1'>{text}</a>,
},
{
title: '摘要',

View File

@@ -14,6 +14,8 @@ import dayjs from 'dayjs';
import RandomAvatar from "@/components/RandomAvatar";
import Empty from "@/components/Empty";
import { useWebStore } from '@/stores';
type Menu = "comment" | "link" | "wall";
interface ListItemProps {
@@ -23,60 +25,64 @@ interface ListItemProps {
handleRejection: (id: number, type: Menu) => void;
}
const ListItem = ({ item, type, handleApproval, handleRejection }: ListItemProps) => (
<div key={item.id}>
<div className="text-center text-xs text-[#e0e0e0] mb-4">
{dayjs(+item.createTime!).format('YYYY-MM-DD HH:mm:ss')}
</div>
const ListItem = ({ item, type, handleApproval, handleRejection }: ListItemProps) => {
const web = useWebStore(state => state.web)
<div className="flex justify-between p-7 rounded-md transition-colors">
<div className="flex mr-10">
{type !== "wall" ? (
<img src={item.avatar || item.image} alt="" className="w-13 h-13 border border-[#eee] rounded-full" />
) : <RandomAvatar className="w-13 h-13 border border-[#eee] rounded-full" />}
return (
<div key={item.id}>
<div className="text-center text-xs text-[#e0e0e0] mb-4">
{dayjs(+item.createTime!).format('YYYY-MM-DD HH:mm:ss')}
</div>
<div className="flex flex-col justify-center ml-4 px-4 py-2 bg-[#F9F9FD] rounded-md">
{type === "link" ? (
<>
<div>{item.title}</div>
<div>{item.description}</div>
<div>{item.type.name}</div>
<div>{item.email || '暂无'}</div>
<div>{item.url || '暂无'}</div>
</>
) : type === "comment" ? (
<>
<div>{item.name}</div>
<div>{item.content}</div>
<div>{item.email || '暂无'}</div>
<div>{item.url || '暂无'}</div>
<div><a href={`/article/${item.articleId}`} className="hover:text-primary">{item.articleTitle || '暂无'}</a></div>
</>
) : (
<>
<div>{item.name}</div>
<div>{item.content}</div>
</>
)}
<div className="flex justify-between p-7 rounded-md transition-colors">
<div className="flex mr-10">
{type !== "wall" ? (
<img src={item.avatar || item.image} alt="" className="w-13 h-13 border border-[#eee] rounded-full" />
) : <RandomAvatar className="w-13 h-13 border border-[#eee] rounded-full" />}
<div className="flex flex-col justify-center ml-4 px-4 py-2 bg-[#F9F9FD] rounded-md">
{type === "link" ? (
<>
<div>{item.title}</div>
<div>{item.description}</div>
<div>{item.type.name}</div>
<div>{item.email || '暂无'}</div>
<div>{item.url || '暂无'}</div>
</>
) : type === "comment" ? (
<>
<div>{item.name}</div>
<div>{item.content}</div>
<div>{item.email || '暂无'}</div>
<div>{item.url || '暂无'}</div>
<div><a href={`${web.url}/article/${item.articleId}`} target='_blank' className="hover:text-primary">{item.articleTitle || '暂无'}</a></div>
</>
) : (
<>
<div>{item.name}</div>
<div>{item.content}</div>
</>
)}
</div>
</div>
<div className="flex items-end">
<Dropdown menu={{
items: [
{ key: 'ok', label: "通过", onClick: () => handleApproval(item.id, type) },
{ key: 'no', label: "拒审", onClick: () => handleRejection(item.id, type) }
]
}}>
<div className="flex justify-evenly items-center bg-[#F9F9FD] w-11 h-5 rounded-md cursor-pointer">
<span className="inline-block w-2 h-2 bg-[#b5c2d3] rounded-full"></span>
<span className="inline-block w-2 h-2 bg-[#b5c2d3] rounded-full"></span>
</div>
</Dropdown>
</div>
</div>
<div className="flex items-end">
<Dropdown menu={{
items: [
{ key: 'ok', label: "通过", onClick: () => handleApproval(item.id, type) },
{ key: 'no', label: "拒审", onClick: () => handleRejection(item.id, type) }
]
}}>
<div className="flex justify-evenly items-center bg-[#F9F9FD] w-11 h-5 rounded-md cursor-pointer">
<span className="inline-block w-2 h-2 bg-[#b5c2d3] rounded-full"></span>
<span className="inline-block w-2 h-2 bg-[#b5c2d3] rounded-full"></span>
</div>
</Dropdown>
</div>
</div>
</div>
);
)
}
const WorkPage = () => {
const activeSty = "bg-[#f9f9ff] text-primary";