From ba3f43ba33afa2f2dee06e65022f07bb957e472b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E7=A7=98=E4=BA=BA?= <3311118881@qq.com> Date: Fri, 4 Jul 2025 12:25:57 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E9=A1=B9=E7=9B=AE=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=EF=BC=8C=E7=A7=BB=E9=99=A4=E8=BF=87=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E9=A1=B9=E7=9B=AEAPI=EF=BC=8C=E6=9B=BF=E6=8D=A2=E4=B8=BA?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E9=85=8D=E7=BD=AEAPI=EF=BC=8C=E7=A1=AE?= =?UTF-8?q?=E4=BF=9D=E4=BB=A3=E7=A0=81=E4=B8=80=E8=87=B4=E6=80=A7=E5=92=8C?= =?UTF-8?q?=E5=8F=AF=E7=BB=B4=E6=8A=A4=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/config.ts | 11 +++++++++++ src/api/project.ts | 12 ------------ src/app/api/rss/route.ts | 6 +++--- src/app/footprint/page.tsx | 6 +++--- src/app/friend/page.tsx | 6 +++--- src/app/layout.tsx | 6 +++--- src/app/my/component/Map/index.tsx | 4 ++-- src/app/page.tsx | 6 +++--- src/app/record/page.tsx | 6 +++--- src/components/ArticleLayout/Card/index.tsx | 6 +++--- src/components/ArticleLayout/Classics/index.tsx | 6 +++--- src/components/ArticleLayout/index.tsx | 6 +++--- src/components/Footer/index.tsx | 6 +++--- src/components/Header/index.tsx | 8 ++++---- src/components/Sidebar/Author/index.tsx | 6 +++--- src/components/Sidebar/HotArticle/index.tsx | 6 +++--- src/components/Sidebar/index.tsx | 6 +++--- src/components/Slide/index.tsx | 6 +++--- src/components/Tools/components/Rss/index.tsx | 2 +- src/stores/modules/config.ts | 2 +- src/types/app/{project.d.ts => config.d.ts} | 0 21 files changed, 61 insertions(+), 62 deletions(-) create mode 100755 src/api/config.ts delete mode 100755 src/api/project.ts rename src/types/app/{project.d.ts => config.d.ts} (100%) diff --git a/src/api/config.ts b/src/api/config.ts new file mode 100755 index 0000000..1bf48fa --- /dev/null +++ b/src/api/config.ts @@ -0,0 +1,11 @@ +import Request from "@/utils/request"; + +// 获取网站配置 +export const getWebConfigDataAPI = (type: string) => Request("GET", `/web_config/list/${type}`) + +// 修改网站配置 +export const editWebConfigDataAPI = (type: string, data: object) => Request<{ [string: string]: string }>("PATCH", `/web_config/${type}`, { data }) + + +// 获取高德地图配置 +export const getGaodeMapConfigDataAPI = () => Request("GET", `/env_config/gaode_map`) \ No newline at end of file diff --git a/src/api/project.ts b/src/api/project.ts deleted file mode 100755 index 26aaeee..0000000 --- a/src/api/project.ts +++ /dev/null @@ -1,12 +0,0 @@ -import Request from "@/utils/request"; -import { EnvConfig, EnvConfigName } from "@/types/app/project"; - -// 获取项目配置 -export const getConfigDataAPI = (type: string) => Request("GET", `/config/list/${type}`) - -// 修改项目配置 -export const editConfigDataAPI = (type: string, data: object) => Request<{ [string: string]: string }>("PATCH", `/config/${type}`, { data }) - - -// 获取环境配置 -export const getEnvConfigDataAPI = () => Request("GET", `/env_config/gaode_map`) \ No newline at end of file diff --git a/src/app/api/rss/route.ts b/src/app/api/rss/route.ts index 30779a5..50dea9d 100755 --- a/src/app/api/rss/route.ts +++ b/src/app/api/rss/route.ts @@ -1,18 +1,18 @@ import { Feed } from 'feed'; import { NextResponse } from 'next/server'; -import { Web } from '@/types/app/project'; +import { Web } from '@/types/app/config'; import { User } from '@/types/app/user'; import { Article } from '@/types/app/article'; import { Record } from '@/types/app/record' import { getArticlePagingAPI } from '@/api/article' -import { getConfigDataAPI } from '@/api/project' +import { getWebConfigDataAPI } from '@/api/config' import { getUserDataAPI } from '@/api/user' import { getRecordPagingAPI } from '@/api/record'; export async function GET() { - const { data: web } = await getConfigDataAPI("web") || { data: {} as Web } + const { data: web } = await getWebConfigDataAPI("web") || { data: {} as Web } const { data: user } = await getUserDataAPI() || { data: {} as User } const { data: article } = await getArticlePagingAPI({ pagination: { page: 1, size: 8 } }) || { data: {} as Paginate } const { data: record } = await getRecordPagingAPI({ pagination: { page: 1, size: 8 } }) || { data: {} as Paginate } diff --git a/src/app/footprint/page.tsx b/src/app/footprint/page.tsx index 4bb0a20..6671ff7 100755 --- a/src/app/footprint/page.tsx +++ b/src/app/footprint/page.tsx @@ -9,8 +9,8 @@ import 'react-photo-view/dist/react-photo-view.css'; import dayjs from 'dayjs' import Masonry from "react-masonry-css"; import "./page.scss"; -import { getEnvConfigDataAPI } from "@/api/project"; -import { EnvConfig } from "@/types/app/project"; +import { getGaodeMapConfigDataAPI } from "@/api/config"; +import { EnvConfig } from "@/types/app/config"; const breakpointColumnsObj = { default: 4, @@ -40,7 +40,7 @@ export default function MapContainer() { // 确保代码仅在客户端执行 import('@amap/amap-jsapi-loader').then(async AMapLoader => { - const { data } = await getEnvConfigDataAPI() || { data: {} } + const { data } = await getGaodeMapConfigDataAPI() || { data: {} } const { key_code, security_code } = data as { key_code: string, security_code: string } // @ts-ignore diff --git a/src/app/friend/page.tsx b/src/app/friend/page.tsx index 17850bf..5a6bf0a 100755 --- a/src/app/friend/page.tsx +++ b/src/app/friend/page.tsx @@ -1,7 +1,7 @@ import Link from "next/link"; import { Metadata } from "next"; -import { getConfigDataAPI } from "@/api/project"; +import { getWebConfigDataAPI } from "@/api/config"; import { getWebListAPI, getWebTypeListAPI } from '@/api/web' import { Web as WebLink, WebType } from "@/types/app/web"; @@ -13,7 +13,7 @@ import CopyableText from "./components/CopyableText"; import { ToastContainer } from "react-toastify"; import { getUserDataAPI } from "@/api/user"; import { User } from "@/types/app/user"; -import { Web } from "@/types/app/project"; +import { Web } from "@/types/app/config"; export const metadata: Metadata = { title: "😇 朋友圈", @@ -22,7 +22,7 @@ export const metadata: Metadata = { export default async () => { const { data: user } = await getUserDataAPI() || { data: {} as User } - const { data: web } = await getConfigDataAPI("web") || { data: {} as Web } + const { data: web } = await getWebConfigDataAPI("web") || { data: {} as Web } const { data: linkList } = await getWebListAPI() || { data: [] as WebLink[] } const { data: typeList } = await getWebTypeListAPI() || { data: [] as WebType[] } diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 51a8888..06589ec 100755 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -8,8 +8,8 @@ import Tools from '@/components/Tools'; import Confetti from '@/components/Confetti'; import RouteChangeHandler from '@/components/RouteChangeHandler' -import { getConfigDataAPI } from '@/api/project' -import { Web } from '@/types/app/project'; +import { getWebConfigDataAPI } from '@/api/config' +import { Web } from '@/types/app/config'; // 加载样式文件 import "@/styles/index.scss"; @@ -25,7 +25,7 @@ const LXGWWenKai = localFont({ }) export default async function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) { - const { data } = (await getConfigDataAPI("web")) || { data: {} as Web }; + const { data } = (await getWebConfigDataAPI("web")) || { data: {} as Web }; // 尊重开源,禁止删除此版权信息!!! console.log("🚀 欢迎使用 ThriveX 现代化博客管理系统") diff --git a/src/app/my/component/Map/index.tsx b/src/app/my/component/Map/index.tsx index c773752..85fac5a 100755 --- a/src/app/my/component/Map/index.tsx +++ b/src/app/my/component/Map/index.tsx @@ -5,7 +5,7 @@ import { useEffect } from "react"; import AOS from 'aos'; import 'aos/dist/aos.css'; -import { getEnvConfigDataAPI } from "@/api/project"; +import { getGaodeMapConfigDataAPI } from "@/api/config"; export default function MapContainer() { let map: any; @@ -15,7 +15,7 @@ export default function MapContainer() { // 确保代码仅在客户端执行 import('@amap/amap-jsapi-loader').then(async AMapLoader => { - const { data } = await getEnvConfigDataAPI() || { data: {} } + const { data } = await getGaodeMapConfigDataAPI() || { data: {} } const { key_code, security_code } = data as { key_code: string, security_code: string } // @ts-ignore diff --git a/src/app/page.tsx b/src/app/page.tsx index bb14b00..0f77cc8 100755 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -5,8 +5,8 @@ import Container from "@/components/Container"; import ArticleLayout from "@/components/ArticleLayout"; import Sidebar from "@/components/Sidebar"; -import { getConfigDataAPI } from '@/api/project' -import { Theme } from "@/types/app/project"; +import { getWebConfigDataAPI } from '@/api/config' +import { Theme } from "@/types/app/config"; interface Props { searchParams: Promise<{ page: number }>; @@ -15,7 +15,7 @@ interface Props { export default async (props: Props) => { const searchParams = await props.searchParams; const page = searchParams.page || 1; - const { data } = (await getConfigDataAPI("layout")) || { data: {} as Theme } + const { data } = (await getWebConfigDataAPI("layout")) || { data: {} as Theme } return ( <> diff --git a/src/app/record/page.tsx b/src/app/record/page.tsx index f9fde36..02a19b0 100755 --- a/src/app/record/page.tsx +++ b/src/app/record/page.tsx @@ -7,8 +7,8 @@ import { dayFormat } from '@/utils' import Pagination from "@/components/Pagination"; import Empty from "@/components/Empty"; import Show from "@/components/Show"; -import { getConfigDataAPI } from "@/api/project"; -import { Theme } from "@/types/app/project"; +import { getWebConfigDataAPI } from "@/api/config"; +import { Theme } from "@/types/app/config"; import Editor from "./components/Editor"; interface Props { @@ -21,7 +21,7 @@ export default async (props: Props) => { const { data: user } = (await getUserDataAPI()) || { data: {} as User } const { data: record } = (await getRecordPagingAPI({ pagination: { page, size: 8 } })) || { data: {} as Paginate } - const { data: theme } = (await getConfigDataAPI("layout")) || { data: {} as Theme } + const { data: theme } = (await getWebConfigDataAPI("layout")) || { data: {} as Theme } return ( <> diff --git a/src/components/ArticleLayout/Card/index.tsx b/src/components/ArticleLayout/Card/index.tsx index 08d76ca..65c432b 100755 --- a/src/components/ArticleLayout/Card/index.tsx +++ b/src/components/ArticleLayout/Card/index.tsx @@ -9,15 +9,15 @@ import { GoTag } from "react-icons/go"; import Empty from '@/components/Empty'; import Show from '@/components/Show'; -import { getConfigDataAPI } from '@/api/project' -import { Theme } from '@/types/app/project'; +import { getWebConfigDataAPI } from '@/api/config' +import { Theme } from '@/types/app/config'; interface CardProps { data: Paginate; } const Card = async ({ data }: CardProps) => { - const { data: theme } = await getConfigDataAPI("layout") || { data: {} as Theme } + const { data: theme } = await getWebConfigDataAPI("layout") || { data: {} as Theme } const covers = JSON.parse(theme.covers || '[]') diff --git a/src/components/ArticleLayout/Classics/index.tsx b/src/components/ArticleLayout/Classics/index.tsx index 1c00cca..e3f13bd 100755 --- a/src/components/ArticleLayout/Classics/index.tsx +++ b/src/components/ArticleLayout/Classics/index.tsx @@ -9,15 +9,15 @@ import { GoTag } from "react-icons/go"; import Empty from '@/components/Empty'; import Show from '@/components/Show'; -import { getConfigDataAPI } from '@/api/project' -import { Theme } from '@/types/app/project'; +import { getWebConfigDataAPI } from '@/api/config' +import { Theme } from '@/types/app/config'; interface ClassicsProps { data: Paginate; } const Classics = async ({ data }: ClassicsProps) => { - const { data: theme } = await getConfigDataAPI("layout") || { data: {} as Theme } + const { data: theme } = await getWebConfigDataAPI("layout") || { data: {} as Theme } const covers = JSON.parse(theme.covers || '[]') diff --git a/src/components/ArticleLayout/index.tsx b/src/components/ArticleLayout/index.tsx index 8bdcbf9..bdb13e8 100755 --- a/src/components/ArticleLayout/index.tsx +++ b/src/components/ArticleLayout/index.tsx @@ -6,15 +6,15 @@ import Card from './Card' import Pagination from "../Pagination" import { getArticlePagingAPI } from '@/api/article' -import { getConfigDataAPI } from '@/api/project' -import { Theme } from '@/types/app/project' +import { getWebConfigDataAPI } from '@/api/config' +import { Theme } from '@/types/app/config' import { Article } from '@/types/app/article' import { Swiper as SwiperType } from '@/types/app/swiper' import { getSwiperListAPI } from '@/api/swiper' export default async ({ page }: { page: number }) => { const { data: swiper } = await getSwiperListAPI() || { data: [] as SwiperType[] } - const { data: theme } = await getConfigDataAPI("layout") || { data: {} as Theme } + const { data: theme } = await getWebConfigDataAPI("layout") || { data: {} as Theme } const sidebar: string[] = JSON.parse(theme?.right_sidebar || '[]') // 如果是瀑布流布局就显示28条数据,否则显示8条 diff --git a/src/components/Footer/index.tsx b/src/components/Footer/index.tsx index a8d62c1..1987bb3 100755 --- a/src/components/Footer/index.tsx +++ b/src/components/Footer/index.tsx @@ -1,9 +1,9 @@ import Link from 'next/link'; import Image from 'next/image'; -import { getConfigDataAPI } from '@/api/project'; +import { getWebConfigDataAPI } from '@/api/config'; import { getUserDataAPI } from '@/api/user'; import { User } from '@/types/app/user'; -import { Web } from '@/types/app/project'; +import { Web } from '@/types/app/config'; import Tooltip from './components/Tooltip'; import animals from './images/animals.webp'; @@ -11,7 +11,7 @@ import ICP from './images/ICP.png'; export default async () => { const { data: user } = (await getUserDataAPI()) || { data: {} as User } - const { data: web } = (await getConfigDataAPI("web")) || { data: {} as Web } + const { data: web } = (await getWebConfigDataAPI("web")) || { data: {} as Web } return ( <> diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index 191575b..aa1744d 100755 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -14,10 +14,10 @@ import { BsFillMoonStarsFill, BsTextIndentLeft } from "react-icons/bs"; import { Cate } from '@/types/app/cate'; import { getCateListAPI } from '@/api/cate'; -import { getConfigDataAPI } from '@/api/project'; +import { getWebConfigDataAPI } from '@/api/config'; import { useConfigStore } from '@/stores'; -import { Theme, Web } from '@/types/app/project'; +import { Theme, Web } from '@/types/app/config'; const Header = () => { // 是否暗黑模式 @@ -25,10 +25,10 @@ const Header = () => { // 获取项目配置 const getConfigData = async () => { - const { data: web } = (await getConfigDataAPI("web")) || { data: {} as Web }; + const { data: web } = (await getWebConfigDataAPI("web")) || { data: {} as Web }; setWeb(web) - const { data: theme } = (await getConfigDataAPI("layout")) || { data: {} as Theme }; + const { data: theme } = (await getWebConfigDataAPI("layout")) || { data: {} as Theme }; setTheme(theme) } diff --git a/src/components/Sidebar/Author/index.tsx b/src/components/Sidebar/Author/index.tsx index a7f57b7..3d3e129 100755 --- a/src/components/Sidebar/Author/index.tsx +++ b/src/components/Sidebar/Author/index.tsx @@ -10,13 +10,13 @@ import QQ from '@/assets/svg/socializing/QQ.svg' import Weixin from '@/assets/svg/socializing/Weixin.svg' import { getUserDataAPI } from '@/api/user'; -import { getConfigDataAPI } from '@/api/project' +import { getWebConfigDataAPI } from '@/api/config' import { User } from '@/types/app/user'; -import { Social, Theme } from '@/types/app/project'; +import { Social, Theme } from '@/types/app/config'; const Author = async () => { const { data: user } = await getUserDataAPI() || { data: {} as User } - const { data: { social } } = await getConfigDataAPI("layout") || { data: {} as Theme } + const { data: { social } } = await getWebConfigDataAPI("layout") || { data: {} as Theme } const socialList = JSON.parse(social || '[]')?.map((item: string) => JSON.parse(item)) diff --git a/src/components/Sidebar/HotArticle/index.tsx b/src/components/Sidebar/HotArticle/index.tsx index 9735546..b3fbd36 100755 --- a/src/components/Sidebar/HotArticle/index.tsx +++ b/src/components/Sidebar/HotArticle/index.tsx @@ -1,15 +1,15 @@ import Link from 'next/link'; import Image from 'next/image'; -import { getConfigDataAPI } from '@/api/project' +import { getWebConfigDataAPI } from '@/api/config' import { getArticleListAPI } from '@/api/article'; import { IoIosArrowForward } from "react-icons/io"; import fire from '@/assets/svg/other/fire.svg'; import "./index.scss"; -import { Theme } from '@/types/app/project'; +import { Theme } from '@/types/app/config'; import { Article } from '@/types/app/article'; const RandomArticle = async () => { - const { data: theme } = await getConfigDataAPI("layout") || { data: {} as Theme } + const { data: theme } = await getWebConfigDataAPI("layout") || { data: {} as Theme } const { data: article } = await getArticleListAPI() || { data: [] as Article[] } const ids = JSON.parse(theme.reco_article ? theme.reco_article : '[]') diff --git a/src/components/Sidebar/index.tsx b/src/components/Sidebar/index.tsx index 785781c..9dc5550 100755 --- a/src/components/Sidebar/index.tsx +++ b/src/components/Sidebar/index.tsx @@ -3,11 +3,11 @@ import HotArticle from "./HotArticle" import RandomArticle from "./RandomArticle" import Comment from "./Comment" import RunTime from "./RunTime" -import { getConfigDataAPI } from '@/api/project' -import { Theme } from "@/types/app/project" +import { getWebConfigDataAPI } from '@/api/config' +import { Theme } from "@/types/app/config" export default async () => { - const { data: theme } = await getConfigDataAPI("layout") || { data: {} as Theme } + const { data: theme } = await getWebConfigDataAPI("layout") || { data: {} as Theme } const sidebar: string[] = JSON.parse(theme?.right_sidebar || '[]') return ( diff --git a/src/components/Slide/index.tsx b/src/components/Slide/index.tsx index 2a17e34..ee91907 100755 --- a/src/components/Slide/index.tsx +++ b/src/components/Slide/index.tsx @@ -1,8 +1,8 @@ import { ReactNode } from 'react' import Ripple from '@/components/Ripple' import { getRandom } from '@/utils' -import { getConfigDataAPI } from '@/api/project' -import { Theme } from '@/types/app/project' +import { getWebConfigDataAPI } from '@/api/config' +import { Theme } from '@/types/app/config' interface Props { src?: string, // 图片列表 @@ -11,7 +11,7 @@ interface Props { } export default async ({ src, isRipple = true, children }: Props) => { - const { data } = await getConfigDataAPI("layout") || { data: {} as Theme } + const { data } = await getWebConfigDataAPI("layout") || { data: {} as Theme } const covers = JSON.parse(data.covers || '[]') const sty = { diff --git a/src/components/Tools/components/Rss/index.tsx b/src/components/Tools/components/Rss/index.tsx index 6aeaf4e..63c0967 100755 --- a/src/components/Tools/components/Rss/index.tsx +++ b/src/components/Tools/components/Rss/index.tsx @@ -1,6 +1,6 @@ "use client" -import { Web } from "@/types/app/project"; +import { Web } from "@/types/app/config"; import { Modal, ModalContent, ModalHeader, ModalBody, UseDisclosureProps, Snippet } from "@heroui/react" interface Props { diff --git a/src/stores/modules/config.ts b/src/stores/modules/config.ts index 31c15b1..ff259de 100755 --- a/src/stores/modules/config.ts +++ b/src/stores/modules/config.ts @@ -1,6 +1,6 @@ import { create } from 'zustand' import { persist, createJSONStorage } from 'zustand/middleware' -import { Theme, Web } from '@/types/app/project'; +import { Theme, Web } from '@/types/app/config'; interface ConfigState { // 是否暗黑模式 diff --git a/src/types/app/project.d.ts b/src/types/app/config.d.ts similarity index 100% rename from src/types/app/project.d.ts rename to src/types/app/config.d.ts