upnav
parent
952ff8f2ab
commit
774b52fca9
|
@ -99,6 +99,8 @@ module.exports = {
|
|||
'@typescript-eslint/no-unsafe-argument': 0,
|
||||
'@typescript-eslint/ban-ts-comment': 0,
|
||||
'@typescript-eslint/naming-convention': 0,
|
||||
"@typescript-eslint/lines-between-class-members": "error",
|
||||
"@typescript-eslint/no-throw-literal": "error",
|
||||
|
||||
/* ********************************** React and Hooks ********************************** */
|
||||
'react/jsx-uses-react': 1,
|
||||
|
|
|
@ -30,25 +30,28 @@ const PostItemPage: FC<{ params: { item: string } }> = async ({ params }) => {
|
|||
<div className="tw-bg-white/80 tw-flex-auto tw-w-full tw-drop-shadow-lg tw-rounded-md tw-flex tw-flex-col">
|
||||
<div className=" tw-relative tw-w-full tw-h-64 tw-overflow-hidden">
|
||||
<Image
|
||||
className=" tw-rounded-t-lg tw-opacity-50"
|
||||
className=" tw-rounded-t-lg tw-opacity-50 tw-object-cover"
|
||||
src={post.thumb}
|
||||
alt={post.title}
|
||||
priority
|
||||
fill
|
||||
objectFit="cover"
|
||||
layout="fill"
|
||||
sizes="100%"
|
||||
/>
|
||||
</div>
|
||||
<div className=" tw-my-2">
|
||||
<header>
|
||||
<div className=" tw-my-2 ">
|
||||
<header className="tw-text-center tw-mb-5">
|
||||
<h1 className=" tw-font-bold">{post.title}</h1>
|
||||
</header>
|
||||
<div>
|
||||
<div className=" tw-mx-auto tw-justify-center tw-flex tw-mb-5">
|
||||
<time className="tw-ellips tw-mx-auto" dateTime="2024-08-10">
|
||||
{post.updatedAt.toString()}
|
||||
</time>
|
||||
<div className="tw-text-center">
|
||||
<span className=" tw-text-black tw-font-bold tw-text-md">作者:</span>
|
||||
<span className="tw-text-black tw-ml-3 ">
|
||||
{post.name ? post.name : '佚名'}
|
||||
</span>
|
||||
</div>
|
||||
<div className=" tw-mb-2 tw-text-right tw-pr-10">
|
||||
<span>发布于:</span>
|
||||
<time>{post.updatedAt.toLocaleString('zh')}</time>
|
||||
</div>
|
||||
</div>
|
||||
<MarkdownPreview text={post.body} previewTheme="arknights" />
|
||||
|
|
|
@ -1,8 +1,26 @@
|
|||
import { HomeIcon } from '@radix-ui/react-icons';
|
||||
import localFont from 'next/font/local';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
import { User } from './user';
|
||||
|
||||
const myFont = localFont({
|
||||
src: '../../fonts/lhzt.ttf',
|
||||
display: 'swap',
|
||||
});
|
||||
export const Header = () => {
|
||||
return (
|
||||
<header className=" tw-flex tw-flex-row-reverse tw-pt-6 tw-max-h-24 tw-flex-auto">
|
||||
<header className="tw-flex tw-py-4 tw-max-h-24 tw-flex-auto tw-w-5/6 tw-mx-auto tw-bg-orange-200 tw-rounded-lg tw-mt-4 tw-shadow-nylg">
|
||||
<div className=" tw-w-40">
|
||||
<p className={cn(myFont.className, ' tw-text-4xl tw-text-gray-800')}>一昧書屋</p>
|
||||
</div>
|
||||
<div className=" tw-rounded-full tw-h-14 tw-w-14 tw-flex tw-items-center tw-justify-center tw-flex-col tw-bg-violet-500 tw-text-white ">
|
||||
<HomeIcon className=" tw-h-6 tw-w-6" />
|
||||
<p className="tw-text-sm tw-font-bold">首页</p>
|
||||
</div>
|
||||
<div className="tw-flex-1"> </div>
|
||||
<div className="tw-w-48">搜索</div>
|
||||
<User />
|
||||
</header>
|
||||
);
|
||||
|
|
|
@ -11,29 +11,24 @@ import { Button } from '../ui/button';
|
|||
|
||||
export const User = () => {
|
||||
const { data } = useSession();
|
||||
if (!data) return null;
|
||||
if (!data)
|
||||
return (
|
||||
<div className=" tw-flex tw-justify-center tw-items-center tw-space-x-6 tw-mr-36">
|
||||
{data.user && (
|
||||
<Avatar className="tw-h-12 tw-w-12">
|
||||
<Link href="/auth/login">
|
||||
<p className="tw-text-white">登录</p>
|
||||
</Link>
|
||||
);
|
||||
return (
|
||||
<div className=" tw-flex tw-items-center tw-space-x-6 tw-mr-36 tw-h-14 tw-border-teal-100 tw-border-2 tw-border-opacity-50 ">
|
||||
<Avatar>
|
||||
<AvatarImage width={160} height={160} src={data?.user.image} />
|
||||
<AvatarFallback>
|
||||
<p className="">暂无</p>
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
)}
|
||||
{data?.user?.name ? (
|
||||
<div>
|
||||
<p className="tw-text-lg tw-font-bold tw-text-white">{data?.user?.name}</p>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
{data?.user ? (
|
||||
</div>
|
||||
<Button onClick={() => logout()}>退出</Button>
|
||||
) : (
|
||||
<Link href="/auth/login">
|
||||
<p className="tw-text-white">登录</p>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -41,10 +41,17 @@ export const queryPostTotalPages = async (limit = 8): Promise<number> => {
|
|||
* 根据ID查询文章信息
|
||||
* @param id
|
||||
*/
|
||||
export const queryPostItemByIdOrSlug = async (id: string): Promise<Post | null> => {
|
||||
export const queryPostItemByIdOrSlug = async (
|
||||
id: string,
|
||||
): Promise<(Post & { name: string }) | null> => {
|
||||
// throw new Error('数据加载错误,请稍后重试!');
|
||||
const item = await db.post.findFirst({ where: { OR: [{ id }, { slug: id }] } });
|
||||
return item;
|
||||
if (isNil(item)) {
|
||||
return null;
|
||||
}
|
||||
const { name } = await db.user.findUnique({ where: { id: item.userId } });
|
||||
|
||||
return { ...item, name };
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Binary file not shown.
|
@ -27,7 +27,7 @@
|
|||
"@3rapp/core": "workspace:*",
|
||||
"prettier": "^3.3.3",
|
||||
"rimraf": "^6.0.1",
|
||||
"turbo": "^2.0.12",
|
||||
"turbo": "^2.2.3",
|
||||
"typescript": "^5.5.4"
|
||||
},
|
||||
"packageManager": "pnpm@9.7.0",
|
||||
|
|
6964
pnpm-lock.yaml
6964
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue