upnav
parent
952ff8f2ab
commit
774b52fca9
|
@ -99,6 +99,8 @@ module.exports = {
|
||||||
'@typescript-eslint/no-unsafe-argument': 0,
|
'@typescript-eslint/no-unsafe-argument': 0,
|
||||||
'@typescript-eslint/ban-ts-comment': 0,
|
'@typescript-eslint/ban-ts-comment': 0,
|
||||||
'@typescript-eslint/naming-convention': 0,
|
'@typescript-eslint/naming-convention': 0,
|
||||||
|
"@typescript-eslint/lines-between-class-members": "error",
|
||||||
|
"@typescript-eslint/no-throw-literal": "error",
|
||||||
|
|
||||||
/* ********************************** React and Hooks ********************************** */
|
/* ********************************** React and Hooks ********************************** */
|
||||||
'react/jsx-uses-react': 1,
|
'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-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">
|
<div className=" tw-relative tw-w-full tw-h-64 tw-overflow-hidden">
|
||||||
<Image
|
<Image
|
||||||
className=" tw-rounded-t-lg tw-opacity-50"
|
className=" tw-rounded-t-lg tw-opacity-50 tw-object-cover"
|
||||||
src={post.thumb}
|
src={post.thumb}
|
||||||
alt={post.title}
|
alt={post.title}
|
||||||
priority
|
priority
|
||||||
fill
|
fill
|
||||||
objectFit="cover"
|
|
||||||
layout="fill"
|
|
||||||
sizes="100%"
|
sizes="100%"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className=" tw-my-2">
|
<div className=" tw-my-2 ">
|
||||||
<header>
|
<header className="tw-text-center tw-mb-5">
|
||||||
<h1 className=" tw-font-bold">{post.title}</h1>
|
<h1 className=" tw-font-bold">{post.title}</h1>
|
||||||
</header>
|
</header>
|
||||||
<div>
|
<div>
|
||||||
<div className=" tw-mx-auto tw-justify-center tw-flex tw-mb-5">
|
<div className="tw-text-center">
|
||||||
<time className="tw-ellips tw-mx-auto" dateTime="2024-08-10">
|
<span className=" tw-text-black tw-font-bold tw-text-md">作者:</span>
|
||||||
{post.updatedAt.toString()}
|
<span className="tw-text-black tw-ml-3 ">
|
||||||
</time>
|
{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>
|
||||||
</div>
|
</div>
|
||||||
<MarkdownPreview text={post.body} previewTheme="arknights" />
|
<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';
|
import { User } from './user';
|
||||||
|
|
||||||
|
const myFont = localFont({
|
||||||
|
src: '../../fonts/lhzt.ttf',
|
||||||
|
display: 'swap',
|
||||||
|
});
|
||||||
export const Header = () => {
|
export const Header = () => {
|
||||||
return (
|
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 />
|
<User />
|
||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
|
|
|
@ -11,29 +11,24 @@ import { Button } from '../ui/button';
|
||||||
|
|
||||||
export const User = () => {
|
export const User = () => {
|
||||||
const { data } = useSession();
|
const { data } = useSession();
|
||||||
if (!data) return null;
|
if (!data)
|
||||||
|
return (
|
||||||
|
<Link href="/auth/login">
|
||||||
|
<p className="tw-text-white">登录</p>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<div className=" tw-flex tw-justify-center tw-items-center tw-space-x-6 tw-mr-36">
|
<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 ">
|
||||||
{data.user && (
|
<Avatar>
|
||||||
<Avatar className="tw-h-12 tw-w-12">
|
<AvatarImage width={160} height={160} src={data?.user.image} />
|
||||||
<AvatarImage width={160} height={160} src={data?.user.image} />
|
<AvatarFallback>
|
||||||
<AvatarFallback>
|
<p className="">暂无</p>
|
||||||
<p className="">暂无</p>
|
</AvatarFallback>
|
||||||
</AvatarFallback>
|
</Avatar>
|
||||||
</Avatar>
|
<div>
|
||||||
)}
|
|
||||||
{data?.user?.name ? (
|
|
||||||
<p className="tw-text-lg tw-font-bold tw-text-white">{data?.user?.name}</p>
|
<p className="tw-text-lg tw-font-bold tw-text-white">{data?.user?.name}</p>
|
||||||
) : (
|
</div>
|
||||||
<></>
|
<Button onClick={() => logout()}>退出</Button>
|
||||||
)}
|
|
||||||
{data?.user ? (
|
|
||||||
<Button onClick={() => logout()}>退出</Button>
|
|
||||||
) : (
|
|
||||||
<Link href="/auth/login">
|
|
||||||
<p className="tw-text-white">登录</p>
|
|
||||||
</Link>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,10 +41,17 @@ export const queryPostTotalPages = async (limit = 8): Promise<number> => {
|
||||||
* 根据ID查询文章信息
|
* 根据ID查询文章信息
|
||||||
* @param 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('数据加载错误,请稍后重试!');
|
// throw new Error('数据加载错误,请稍后重试!');
|
||||||
const item = await db.post.findFirst({ where: { OR: [{ id }, { slug: id }] } });
|
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:*",
|
"@3rapp/core": "workspace:*",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
"rimraf": "^6.0.1",
|
"rimraf": "^6.0.1",
|
||||||
"turbo": "^2.0.12",
|
"turbo": "^2.2.3",
|
||||||
"typescript": "^5.5.4"
|
"typescript": "^5.5.4"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@9.7.0",
|
"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