diff --git a/.env b/.env new file mode 100644 index 0000000..da03b7a --- /dev/null +++ b/.env @@ -0,0 +1,7 @@ +DB_NAME=paul_api_next +DB_USER=root +DB_PASS=233456 +DB_PORT=8889 +DB_LINK=localhost + +PAUL_SITENAME="保罗 API Next" diff --git a/midway.config.ts b/midway.config.ts index 9609c40..b54050e 100644 --- a/midway.config.ts +++ b/midway.config.ts @@ -14,5 +14,6 @@ export default defineConfig({ } ] }, + envPrefix: "PAUL_" }, }); diff --git a/src/components/Layout/Footer.tsx b/src/components/Layout/Footer.tsx index f207735..96e43bb 100644 --- a/src/components/Layout/Footer.tsx +++ b/src/components/Layout/Footer.tsx @@ -17,6 +17,7 @@ function Footer() {

+ 作者主页 使用约定 维护记录

diff --git a/src/components/Layout/FrontWrapper.tsx b/src/components/Layout/FrontWrapper.tsx new file mode 100644 index 0000000..3676f60 --- /dev/null +++ b/src/components/Layout/FrontWrapper.tsx @@ -0,0 +1,46 @@ +// React +import React, { useEffect, useLayoutEffect } from "react"; +import { useLocation } from "react-router-dom"; + + +// Components +import Aside from "@/components/Layout/Aside"; +import Footer from "@/components/Layout/Footer"; + + +// Interface +interface FrontWrapperProps { + title?: string + element: JSX.Element +} + + +// Components +function FrontWrapper(props: FrontWrapperProps) { + const location = useLocation(); + + useEffect(() => { + const name = import.meta.env.PAUL_SITENAME; + + if (props.title) { + document.title = `${props.title} - ${name}`; + } + else if (name) { + document.title = String(name); + } + }, []); + + useLayoutEffect(() => { + window.scrollTo({ top: 0, left: 0 }); + }, [location.pathname]); + + return ( + <> +