From f273be61d405b99cb62cf3dea10e3fb76e3f113a Mon Sep 17 00:00:00 2001 From: expdsn <18111002318@163.com> Date: Mon, 17 Feb 2025 18:17:12 +0800 Subject: [PATCH] clear --- app/(main)/article/[id]/page.tsx | 6 +-- app/_lib/data/link.ts | 1 - app/_lib/data/search.ts | 1 - app/_lib/mongodb.ts | 2 +- app/_lib/request.ts | 3 +- app/_lib/session.ts | 2 +- app/_lib/test/oss.ts | 20 ------- app/_mannual/data.tsx | 52 ------------------- app/_ui/ImageUpload.tsx | 2 +- app/_ui/LinkListBox.tsx | 10 ++-- app/_ui/MarkdownView.tsx | 2 +- app/_ui/PosterBox.tsx | 2 + app/_ui/Search.tsx | 6 +-- app/_ui/SiderNav.tsx | 8 +-- app/admin/(default)/dashboard/LinkTable.tsx | 4 +- app/admin/(default)/dashboard/ad/page.tsx | 2 +- .../dashboard/article/detail/AddOrEdit.tsx | 10 ++-- .../(default)/dashboard/article/page.tsx | 2 +- app/admin/(default)/dashboard/page.tsx | 27 +++------- .../dashboard/search/SearchSelect.tsx | 2 +- app/admin/(default)/dashboard/search/page.tsx | 4 +- app/api/article/[id]/route.ts | 2 +- app/api/article/route.ts | 4 +- app/api/link/[id]/route.ts | 6 +-- app/api/link/route.ts | 11 ++-- app/api/linkType/[id]/route.ts | 6 +-- app/api/linkType/route.ts | 6 +-- app/api/search/[id]/route.ts | 8 +-- app/api/search/route.ts | 8 +-- app/api/searchType/[id]/route.ts | 6 +-- app/api/searchType/route.ts | 6 +-- eslint.config.mjs | 2 +- next.config.ts | 11 ++++ 33 files changed, 79 insertions(+), 165 deletions(-) delete mode 100644 app/_lib/test/oss.ts delete mode 100644 app/_mannual/data.tsx diff --git a/app/(main)/article/[id]/page.tsx b/app/(main)/article/[id]/page.tsx index e3cf830..9fe9a0e 100644 --- a/app/(main)/article/[id]/page.tsx +++ b/app/(main)/article/[id]/page.tsx @@ -2,7 +2,7 @@ import { getArticle } from "@/app/_lib/data/article" import MarkdownView from "@/app/_ui/MarkdownView" import { faArrowRight } from "@fortawesome/free-solid-svg-icons" import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" -import { MdEditor } from "md-editor-rt" +import Image from "next/image" import Link from "next/link" export default async function Page({ params }: { params: Promise<{ id: string }> }) { @@ -14,8 +14,8 @@ export default async function Page({ params }: { params: Promise<{ id: string }>
- - + +

{article.title}

diff --git a/app/_lib/data/link.ts b/app/_lib/data/link.ts index fc9e432..e27b77b 100644 --- a/app/_lib/data/link.ts +++ b/app/_lib/data/link.ts @@ -1,7 +1,6 @@ "use server"; import { getCollection } from "../mongodb"; -import { ReactNode } from "react"; export type Link = { name: string; diff --git a/app/_lib/data/search.ts b/app/_lib/data/search.ts index 26189c8..6283513 100644 --- a/app/_lib/data/search.ts +++ b/app/_lib/data/search.ts @@ -1,7 +1,6 @@ "use server"; import { ObjectId } from "mongodb"; -import { verifySession } from "../dal"; import { getCollection } from "../mongodb"; export type SearchTypeItem = { diff --git a/app/_lib/mongodb.ts b/app/_lib/mongodb.ts index 3416c9f..dfca694 100644 --- a/app/_lib/mongodb.ts +++ b/app/_lib/mongodb.ts @@ -1,5 +1,5 @@ // lib/mongodb.ts -import { MongoClient, Db } from 'mongodb'; +import { MongoClient } from 'mongodb'; const uri = process.env.MONGODB_URI; diff --git a/app/_lib/request.ts b/app/_lib/request.ts index 208df4d..af65436 100644 --- a/app/_lib/request.ts +++ b/app/_lib/request.ts @@ -1,4 +1,3 @@ -import { message } from "antd" /** * 发送请求 @@ -13,7 +12,7 @@ export async function mRequest( data?: any, responseType: 'json' | 'text' | 'blob' = 'json' ): Promise { - let options: RequestInit = { + const options: RequestInit = { method: method, headers: { 'Content-Type': 'application/json' diff --git a/app/_lib/session.ts b/app/_lib/session.ts index 180a810..e81b6b2 100644 --- a/app/_lib/session.ts +++ b/app/_lib/session.ts @@ -23,7 +23,7 @@ export async function decrypt(session: string | undefined = '') { algorithms: ['HS256'], }) return payload - } catch (error) { + } catch { console.log('Failed to verify session') } } diff --git a/app/_lib/test/oss.ts b/app/_lib/test/oss.ts deleted file mode 100644 index f828d01..0000000 --- a/app/_lib/test/oss.ts +++ /dev/null @@ -1,20 +0,0 @@ -const OSS = require('ali-oss'); - -// 创建OSS实例 -const client = new OSS({ - accessKeyId: 'LTAI5tNzopZHJFa2Q9vqr1u5', - accessKeySecret: 'qPu7fyft0KJ1l6SGqbS71IW0vDbRlr' - // 先不指定region和bucket,以便后续查询 -}); - -// 列出所有Bucket -client.listBuckets().then((result) => { - console.log('所有的Bucket:', result.buckets); - // 打印每个Bucket的信息 - result.buckets.forEach((bucket) => { - console.log('Bucket名称:', bucket.name); - console.log('Bucket所在区域:', bucket.location); - }); -}).catch((error) => { - console.error('列出Bucket失败:', error); -}); \ No newline at end of file diff --git a/app/_mannual/data.tsx b/app/_mannual/data.tsx deleted file mode 100644 index e0ee517..0000000 --- a/app/_mannual/data.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { LinkTypeItem } from "../_lib/types"; -import { faPenClip, faThumbsUp } from "@fortawesome/free-solid-svg-icons"; - -const defaultLinkList = [ - { - label: 'AI应用集', - icon: , - href: '/ai-apps', - id: 1, - }, - { - label: 'AI写作工具', - icon: , - id: 2, - }, - { - label: 'AI写作工具', - icon: , - id: 3, - }, - { - label: 'AI写作工具', - icon: , - id: 4, - }, - { - label: 'AI写作工具', - icon: , - id: 5, - }, - { - label: 'AI写作工具', - icon: , - id: 6, - }, - { - label: 'AI写作工具', - icon: , - id: 7, - }, - { - label: 'AI写作工具', - icon: , - id: 8, - }, - { - label: 'AI写作工具', - icon: , - id: 9, - } -] as LinkTypeItem[]; \ No newline at end of file diff --git a/app/_ui/ImageUpload.tsx b/app/_ui/ImageUpload.tsx index e9cb150..a2a1914 100644 --- a/app/_ui/ImageUpload.tsx +++ b/app/_ui/ImageUpload.tsx @@ -24,7 +24,7 @@ export default function ImageUpload(props: { if (url) { props.onChange?.(url) } - } catch (e) { + } catch { setLoading(false) } diff --git a/app/_ui/LinkListBox.tsx b/app/_ui/LinkListBox.tsx index a7fa95e..e973c6c 100644 --- a/app/_ui/LinkListBox.tsx +++ b/app/_ui/LinkListBox.tsx @@ -4,7 +4,7 @@ import { LinkType } from "../_lib/data/linkType"; import { Link as _Link } from "../_lib/data/link"; import { useEffect, useMemo } from "react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { faClock, faFire, faTimeline, faTimesCircle, faTimesRectangle, faVolumeTimes } from "@fortawesome/free-solid-svg-icons"; +import { faClock, faFire } from "@fortawesome/free-solid-svg-icons"; import { useAtom } from "jotai"; import { linkTypeAtom } from "../_lib/atom"; import Image from "next/image"; @@ -12,7 +12,7 @@ import Image from "next/image"; const LinkBlock = ({ val }: { val: _Link }) => { return - + image
{val.name} {val.description} @@ -20,8 +20,8 @@ const LinkBlock = ({ val }: { val: _Link }) => { } export default function LinkListBox({ linkTypeList, linkList, showHot, showRecent }: { linkTypeList: LinkType[]; linkList: _Link[]; showHot: boolean; showRecent: boolean }) { - const hotList = useMemo(() => linkList.filter((val, index) => val.isHot && index < 12), []) - const recentList = useMemo(() => linkList.map(val => val).sort((a, b) => b.addTime - a.addTime).filter((_, idx) => idx < 12), []) + const hotList = useMemo(() => linkList.filter((val, index) => val.isHot && index < 12), [linkList]) + const recentList = useMemo(() => linkList.map(val => val).sort((a, b) => b.addTime - a.addTime).filter((_, idx) => idx < 12), [linkList]) const [currentId] = useAtom(linkTypeAtom) useEffect(() => { console.log(currentId); @@ -72,7 +72,7 @@ export default function LinkListBox({ linkTypeList, linkList, showHot, showRecen linkTypeList.map(item => (
- + {item.label}
diff --git a/app/_ui/MarkdownView.tsx b/app/_ui/MarkdownView.tsx index 205df2c..aa8577f 100644 --- a/app/_ui/MarkdownView.tsx +++ b/app/_ui/MarkdownView.tsx @@ -1,5 +1,5 @@ "use client"; -import { MdPreview, MdCatalog } from 'md-editor-rt'; +import { MdPreview} from 'md-editor-rt'; export default function MarkdownView({ value = '' }: { value?: string }) { return ( diff --git a/app/_ui/PosterBox.tsx b/app/_ui/PosterBox.tsx index 40dd3b7..7e1a79e 100644 --- a/app/_ui/PosterBox.tsx +++ b/app/_ui/PosterBox.tsx @@ -1,4 +1,6 @@ export default function PosterBox({ posterList }: { posterList: string[] }) { + console.log('posterList', posterList); + return (
diff --git a/app/_ui/Search.tsx b/app/_ui/Search.tsx index a3c277b..53d47b8 100644 --- a/app/_ui/Search.tsx +++ b/app/_ui/Search.tsx @@ -6,10 +6,8 @@ import clsx from "clsx"; import { useEffect, useMemo, useState } from "react"; import Logo from "./Logo"; import { useRequest } from "ahooks"; -import { mRequest } from "../_lib/request"; -import { getSearchTypeList, getSearchWayList, SearchTypeItem, SearchWayItemType } from "../_lib/data/search"; +import { getSearchTypeList, getSearchWayList, SearchWayItemType } from "../_lib/data/search"; import { doSearch } from "../_lib/utils"; -import { log } from "node:console"; const defaultSearchEngine: SearchWayItemType = { @@ -61,7 +59,7 @@ export default function Search() { if (filterSeachList.length > 0) { setActiveSearchKey(filterSeachList[0]._id) } - }, [selectKey]) + }, [filterSeachList, selectKey]) return (
diff --git a/app/_ui/SiderNav.tsx b/app/_ui/SiderNav.tsx index 6ef4fef..cae790c 100644 --- a/app/_ui/SiderNav.tsx +++ b/app/_ui/SiderNav.tsx @@ -1,17 +1,17 @@ "use client"; import Link from "next/link"; -import { LinkTypeItem } from "../_lib/types"; import Logo from "./Logo"; import clsx from "clsx"; import { usePathname, useRouter } from "next/navigation"; import { useAtom } from "jotai"; import { linkTypeAtom } from "../_lib/atom"; import { LinkType } from "../_lib/data/linkType"; - +import Image from "next/image"; export default function SiderNav({ linkList }: { linkList: LinkType[] }) { const pathname = usePathname() const router = useRouter() const [, setSelectType] = useAtom(linkTypeAtom) + return (
@@ -32,14 +32,14 @@ export default function SiderNav({ linkList }: { linkList: LinkType[] }) { :
{ - + if (pathname !== '/') { router.replace('/') } setSelectType(item._id) }} > - + {item.label}
diff --git a/app/admin/(default)/dashboard/LinkTable.tsx b/app/admin/(default)/dashboard/LinkTable.tsx index 2ecc9a2..333a1cb 100644 --- a/app/admin/(default)/dashboard/LinkTable.tsx +++ b/app/admin/(default)/dashboard/LinkTable.tsx @@ -25,7 +25,7 @@ import { useState } from "react" export default function LinkTable(props: { id: string }) { - const [loading, setLoading] = useState(false) + const [loading] = useState(false) const { data: LinkTypeList } = useRequest(async () => mRequest<{ list: LinkType[] }>('GET', '/api/linkType')) @@ -83,7 +83,7 @@ export default function LinkTable(props: { id: string }) { title: "图标", dataIndex: "logoLink", render: (_, row) => ( - + ) }, { diff --git a/app/admin/(default)/dashboard/ad/page.tsx b/app/admin/(default)/dashboard/ad/page.tsx index df0338c..6bc3709 100644 --- a/app/admin/(default)/dashboard/ad/page.tsx +++ b/app/admin/(default)/dashboard/ad/page.tsx @@ -20,7 +20,7 @@ export default function Page() { }, { title: '操作', - render: (_, row) => ( + render: () => ( diff --git a/app/admin/(default)/dashboard/article/detail/AddOrEdit.tsx b/app/admin/(default)/dashboard/article/detail/AddOrEdit.tsx index 83932a3..f1c1a1f 100644 --- a/app/admin/(default)/dashboard/article/detail/AddOrEdit.tsx +++ b/app/admin/(default)/dashboard/article/detail/AddOrEdit.tsx @@ -2,14 +2,10 @@ import { ArticleType } from '@/app/_lib/data/article'; import ImageUpload from '@/app/_ui/ImageUpload'; -import { faArrowLeft, faRibbon } from '@fortawesome/free-solid-svg-icons'; +import { faArrowLeft } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { BackTop, Button, Card, Col, DatePicker, Form, Grid, Input, InputNumber, message, Row, Select, Space, Upload } from 'antd'; -import dynamic from 'next/dynamic'; -import { useParams, useRouter } from 'next/navigation' - -import { useState } from 'react'; -// const MDEditor = dynamic(() => import('@uiw/react-md-editor'), { ssr: false }); +import { Button, Card, Col, DatePicker, Form, Input, InputNumber, message, Row, Select, Space } from 'antd'; +import { useRouter } from 'next/navigation' import { MdEditor } from 'md-editor-rt'; import 'md-editor-rt/lib/style.css'; import '@ant-design/v5-patch-for-react-19'; diff --git a/app/admin/(default)/dashboard/article/page.tsx b/app/admin/(default)/dashboard/article/page.tsx index b7131c7..9cdd697 100644 --- a/app/admin/(default)/dashboard/article/page.tsx +++ b/app/admin/(default)/dashboard/article/page.tsx @@ -41,7 +41,7 @@ export default function Page() { dataIndex: "content", render: (_, item) => ( <> - + ) }, diff --git a/app/admin/(default)/dashboard/page.tsx b/app/admin/(default)/dashboard/page.tsx index a19292f..f02f2fe 100644 --- a/app/admin/(default)/dashboard/page.tsx +++ b/app/admin/(default)/dashboard/page.tsx @@ -1,31 +1,16 @@ "use client"; -import { Button, Card, Drawer, Form, Image, Input, InputNumber, message, Modal, Popconfirm, Space, Table } from "antd"; -import { useRef, useState } from "react"; +import { Button, Card, Drawer, Form, Image, Input, InputNumber, message, Popconfirm, Space, Table } from "antd"; +import { useState } from "react"; import { useAntdTable } from "ahooks"; import { mRequest } from "@/app/_lib/request"; -import { LinkTypeItem } from "@/app/_lib/types"; import LinkTable from "./LinkTable"; import ImageUpload from "@/app/_ui/ImageUpload"; -import { useForm } from "antd/es/form/Form"; -import { LinkType } from "@/app/_lib/data/linkType"; +import { getLinkTypeList, LinkType } from "@/app/_lib/data/linkType"; import '@ant-design/v5-patch-for-react-19'; export default function Page() { const { tableProps, refresh } = useAntdTable( - async ({ current, pageSize }) => { - return mRequest<{ - total: number; - data: LinkTypeItem[] - }>( - "GET", - `/api/linkType?page=${current}&pageSize=${pageSize}` - ).then((res: any) => { - return { - total: res?.total || 0, - list: res?.list || [], - } - }) - }, + async ({ current, pageSize }) => getLinkTypeList({ page: current, pageSize }), ) const [selectedType, setSelectedType] = useState( @@ -69,7 +54,7 @@ export default function Page() { dataIndex: "icon", render: (_, item) => ( <> - + ) }, @@ -187,7 +172,7 @@ export default function Page() { - + {/* void }) { diff --git a/app/admin/(default)/dashboard/search/page.tsx b/app/admin/(default)/dashboard/search/page.tsx index a587f68..8f57ea9 100644 --- a/app/admin/(default)/dashboard/search/page.tsx +++ b/app/admin/(default)/dashboard/search/page.tsx @@ -66,7 +66,7 @@ export default function Page() { // mRequest('DELETE', `/api/search/${row._id}`).then(res => { // refresh() // }) - deleteSearchWay(row._id).then(res => { + deleteSearchWay(row._id).then(() => { refresh() message.success('删除成功') }) @@ -132,7 +132,7 @@ export default function Page() { okText="确定" cancelText="取消" onConfirm={() => { - mRequest('DELETE', `/api/searchType/${row._id}`).then(res => { + mRequest('DELETE', `/api/searchType/${row._id}`).then(() => { refreshTypeList() message.success('删除成功') }) diff --git a/app/api/article/[id]/route.ts b/app/api/article/[id]/route.ts index 7d2ef0c..4807811 100644 --- a/app/api/article/[id]/route.ts +++ b/app/api/article/[id]/route.ts @@ -19,7 +19,7 @@ export async function DELETE(req: NextRequest, { params }: { params: Promise<{ i _id: new ObjectId(slug) }) return Response.json({ message: '删除成功' }) - } catch (e) { + } catch { return Response.error() } } diff --git a/app/api/article/route.ts b/app/api/article/route.ts index 95c9416..902082d 100644 --- a/app/api/article/route.ts +++ b/app/api/article/route.ts @@ -15,7 +15,7 @@ export async function POST(request: NextRequest) { const collection = await getCollection('article'); const data = await collection.insertOne(body); return Response.json(data) - } catch (e) { + } catch { return Response.error() } } @@ -25,7 +25,7 @@ export async function PUT(request: NextRequest) { const collection = await getCollection('article'); const data = await collection.updateOne({ _id: body._id }, { $set: body }); return Response.json(data) - } catch (e) { + } catch { return Response.error() } } diff --git a/app/api/link/[id]/route.ts b/app/api/link/[id]/route.ts index 20d0242..5a0f41f 100644 --- a/app/api/link/[id]/route.ts +++ b/app/api/link/[id]/route.ts @@ -1,4 +1,4 @@ -import { getCollection, getDb } from "@/app/_lib/mongodb"; +import { getCollection } from "@/app/_lib/mongodb"; import { ObjectId } from "mongodb"; import { NextRequest } from "next/server"; import { verifySession } from "@/app/_lib/dal"; @@ -26,7 +26,7 @@ export async function GET(req: NextRequest) { total, list: data, }) - } catch (e) { + } catch { return Response.error() } } @@ -46,7 +46,7 @@ export async function DELETE(req: NextRequest, { params }: { params: Promise<{ i _id: new ObjectId(slug) }) return Response.json({ message: '删除成功' }) - } catch (e) { + } catch { return Response.error() } } diff --git a/app/api/link/route.ts b/app/api/link/route.ts index 0778504..7b8f060 100644 --- a/app/api/link/route.ts +++ b/app/api/link/route.ts @@ -1,9 +1,6 @@ import { verifySession } from "@/app/_lib/dal"; import { Link } from "@/app/_lib/data/link"; -import { User } from "@/app/_lib/data/user"; -import { getCollection, getDb } from "@/app/_lib/mongodb"; -import { message } from "antd"; -import bcrypt from 'bcrypt'; +import { getCollection } from "@/app/_lib/mongodb"; import { ObjectId } from "mongodb"; import { NextRequest } from "next/server"; @@ -29,7 +26,7 @@ export async function GET(req: NextRequest) { total, list: data, }) - } catch (e) { + } catch { return Response.error() } } @@ -48,7 +45,7 @@ export async function POST(req: NextRequest) { const collection = await getCollection('link') await collection.insertOne(link) return Response.json({ message: '成功' }) - } catch (e) { + } catch { return Response.error() } } @@ -67,7 +64,7 @@ export async function PUT(req: NextRequest) { const collection = await getCollection('link') await collection.replaceOne({ _id: new ObjectId(link._id) }, { ...link, _id: new ObjectId(link._id) }) return Response.json({ message: '成功' }) - } catch (e) { + } catch { return Response.error() } } \ No newline at end of file diff --git a/app/api/linkType/[id]/route.ts b/app/api/linkType/[id]/route.ts index 1382d21..fbac986 100644 --- a/app/api/linkType/[id]/route.ts +++ b/app/api/linkType/[id]/route.ts @@ -1,5 +1,5 @@ import { verifySession } from "@/app/_lib/dal"; -import { getCollection, getDb } from "@/app/_lib/mongodb"; +import { getCollection} from "@/app/_lib/mongodb"; import { ObjectId } from "mongodb"; import { NextRequest } from "next/server"; import { getLinkList } from "@/app/_lib/data/link"; @@ -19,7 +19,7 @@ export async function GET(req: NextRequest) { const res = await getLinkList({ page, pageSize }) return Response.json(res) - } catch (e) { + } catch { return Response.error() } } @@ -40,7 +40,7 @@ export async function DELETE(req: NextRequest, { params }: { params: Promise<{ i _id: new ObjectId(slug) }) return Response.json({ message: '删除成功' }) - } catch (e) { + } catch { return Response.error() } } diff --git a/app/api/linkType/route.ts b/app/api/linkType/route.ts index a3c4aa6..3dde7e5 100644 --- a/app/api/linkType/route.ts +++ b/app/api/linkType/route.ts @@ -1,6 +1,6 @@ import { verifySession } from "@/app/_lib/dal"; import { getLinkTypeList, LinkType } from "@/app/_lib/data/linkType"; -import { getCollection, getDb } from "@/app/_lib/mongodb"; +import { getCollection } from "@/app/_lib/mongodb"; import { ObjectId } from "mongodb"; import { NextRequest } from "next/server"; @@ -11,7 +11,7 @@ export async function GET(req: NextRequest) { const pageSize = parseInt(req.nextUrl.searchParams.get('pageSize') || '10') || 10; const res = await getLinkTypeList({ page, pageSize }) return Response.json(res) - } catch (e) { + } catch { return Response.error() } } @@ -29,7 +29,7 @@ export async function POST(req: NextRequest) { const collection = await getCollection('link-type') await collection.insertOne(link) return Response.json({ message: '成功' }) - } catch (e) { + } catch { return Response.error() } } diff --git a/app/api/search/[id]/route.ts b/app/api/search/[id]/route.ts index 8ab7b4f..707635e 100644 --- a/app/api/search/[id]/route.ts +++ b/app/api/search/[id]/route.ts @@ -1,9 +1,9 @@ -import { getCollection, getDb } from "@/app/_lib/mongodb"; +import { getCollection } from "@/app/_lib/mongodb"; import { ObjectId } from "mongodb"; import { NextRequest } from "next/server"; import { verifySession } from "@/app/_lib/dal"; -import { getLinkList, Link } from "@/app/_lib/data/link"; +import { getLinkList } from "@/app/_lib/data/link"; export async function GET(req: NextRequest) { try { @@ -13,7 +13,7 @@ export async function GET(req: NextRequest) { const res = await getLinkList({ page, pageSize, typeId }) return Response.json(res) - } catch (e) { + } catch { return Response.error() } } @@ -34,7 +34,7 @@ export async function DELETE(req: NextRequest, { params }: { params: Promise<{ i _id: new ObjectId(slug) }) return Response.json({ message: '删除成功' }) - } catch (e) { + } catch { return Response.error() } } diff --git a/app/api/search/route.ts b/app/api/search/route.ts index db39129..c1a9855 100644 --- a/app/api/search/route.ts +++ b/app/api/search/route.ts @@ -1,7 +1,7 @@ import { verifySession } from "@/app/_lib/dal"; import { Link } from "@/app/_lib/data/link"; import { getSearchWayList } from "@/app/_lib/data/search"; -import { getCollection, getDb } from "@/app/_lib/mongodb"; +import { getCollection } from "@/app/_lib/mongodb"; import { ObjectId } from "mongodb"; import { NextRequest } from "next/server"; @@ -14,7 +14,7 @@ export async function GET(req: NextRequest) { const res = await getSearchWayList({ page, pageSize }) return Response.json(res) - } catch (e) { + } catch { return Response.error() } } @@ -33,7 +33,7 @@ export async function POST(req: NextRequest) { const collection = await getCollection('search') await collection.insertOne(link) return Response.json({ message: '成功' }) - } catch (e) { + } catch { return Response.error() } } @@ -56,7 +56,7 @@ export async function PUT(req: NextRequest) { return Response.json({ message: '成功' }) - } catch (e) { + } catch { return Response.error() } } \ No newline at end of file diff --git a/app/api/searchType/[id]/route.ts b/app/api/searchType/[id]/route.ts index 868350d..ddb1c8b 100644 --- a/app/api/searchType/[id]/route.ts +++ b/app/api/searchType/[id]/route.ts @@ -1,4 +1,4 @@ -import { getCollection, getDb } from "@/app/_lib/mongodb"; +import { getCollection } from "@/app/_lib/mongodb"; import { ObjectId } from "mongodb"; import { NextRequest } from "next/server"; import { verifySession } from "@/app/_lib/dal"; @@ -6,7 +6,7 @@ import { verifySession } from "@/app/_lib/dal"; export async function DELETE(req: NextRequest, { params }: { params: Promise<{ id: string }> }) { try { const session = await verifySession() - + // Check if the user is authenticated if (!session) { // User is not authenticated @@ -19,7 +19,7 @@ export async function DELETE(req: NextRequest, { params }: { params: Promise<{ i _id: new ObjectId(slug) }) return Response.json({ message: '删除成功' }) - } catch (e) { + } catch { return Response.error() } } diff --git a/app/api/searchType/route.ts b/app/api/searchType/route.ts index 086e3a9..43502c3 100644 --- a/app/api/searchType/route.ts +++ b/app/api/searchType/route.ts @@ -13,7 +13,7 @@ export async function GET(req: NextRequest) { const res = await getSearchTypeList({ page, pageSize }) return Response.json(res) - } catch (e) { + } catch { return Response.error() } } @@ -31,7 +31,7 @@ export async function POST(req: NextRequest) { const res = collection.insertOne(item) return Response.json(res) - } catch (e) { + } catch { return Response.error() } } @@ -50,7 +50,7 @@ export async function PUT(req: NextRequest) { const item = await req.json() as SearchTypeItem const res = await collection.replaceOne({ _id: new ObjectId(item._id) }, { ...item, _id: new ObjectId(item._id) }) return Response.json(res) - } catch (e) { + } catch { return Response.error() } } \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs index aef6f2d..71cd777 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -13,7 +13,7 @@ const eslintConfig = [ ...compat.extends("next/core-web-vitals", "next/typescript"), { rules: { - "@typescript-eslint/no-explicit-any": "", + "@typescript-eslint/no-explicit-any": "off", // 禁用对显式 any 类型的检查 }, }, ]; diff --git a/next.config.ts b/next.config.ts index 2d437ae..89ccf78 100644 --- a/next.config.ts +++ b/next.config.ts @@ -14,6 +14,17 @@ const nextConfig: NextConfig = { ] }, + images: { + remotePatterns: [ + { + protocol: 'https', + hostname: 'aihlp.com.cn', + port: '', + pathname: '/**', + search: '', + }, + ], + }, }; export default nextConfig;