diff --git a/package.json b/package.json index 53467b7..ceb28d9 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ "dependencies": { "@midwayjs/hooks": "^3.0.0", "@midwayjs/hooks-kit": "^3.0.0", + "@midwayjs/jwt": "^3.3.5", "@midwayjs/koa": "^3.3.0", + "@midwayjs/passport": "^3.3.5", "@midwayjs/redis": "^3.3.2", "@midwayjs/rpc": "^3.0.0", "@prisma/client": "^3.12.0", @@ -18,6 +20,8 @@ "dotenv": "^16.0.0", "isomorphic-unfetch": "^3.1.0", "lodash": "^4.17.21", + "passport": "^0.5.2", + "passport-jwt": "^4.0.0", "prismjs": "^1.27.0", "react": "^17.0.2", "react-dom": "^17.0.2", @@ -27,6 +31,7 @@ "@midwayjs/mock": "^3.3.0", "@types/ioredis": "^4.28.10", "@types/lodash": "^4.14.181", + "@types/passport-jwt": "^3.0.6", "@types/prismjs": "^1.26.0", "@types/react": "^17.0.44", "@types/react-dom": "^17.0.15", diff --git a/public/assets/bili.css b/public/assets/bili.css index 6e0fa10..d4fe839 100644 --- a/public/assets/bili.css +++ b/public/assets/bili.css @@ -107,7 +107,7 @@ a{ .bili-info p{ -webkit-line-clamp: 1; } - + .bili-box .bili-img{ flex: 1; max-width: none; diff --git a/src/components/ArticleSnippet.tsx b/src/components/ArticleSnippet.tsx index 92f9b24..2f8e196 100644 --- a/src/components/ArticleSnippet.tsx +++ b/src/components/ArticleSnippet.tsx @@ -26,15 +26,15 @@ export const Donate = () => {

赞助我:

本服务将长期免费提供,运行至今暂无任何打赏记录,故不进行展示。如您能为本站献上微薄之力,就是对我的最大支持了~ 记得备注「支持保罗的 API」噢!

-
+
支付宝

支付宝

-
+
微信支付

微信支付

-
+
QQ 钱包

QQ 钱包

diff --git a/src/components/GlobalContext.tsx b/src/components/GlobalContext.tsx new file mode 100644 index 0000000..84e8422 --- /dev/null +++ b/src/components/GlobalContext.tsx @@ -0,0 +1,14 @@ +import { createContext } from "react"; + +import { IGlobalData } from "@/types/GlobalData"; + +import { initalState, IAction } from "@/hooks/useGlobalData"; + +const GlobalContext = createContext<{ globalData: IGlobalData, setGlobalData: React.Dispatch }>({ + globalData: initalState, + setGlobalData() {} +}); + +GlobalContext.displayName = "GlobalContext"; + +export default GlobalContext; diff --git a/src/components/Layout/Aside.tsx b/src/components/Layout/Aside.tsx index f1e0375..0de4d45 100644 --- a/src/components/Layout/Aside.tsx +++ b/src/components/Layout/Aside.tsx @@ -1,25 +1,36 @@ // React import React, { useState } from "react"; +import useGlobalContext from "@/hooks/useGlobalContext"; // UI import { Link } from "react-router-dom"; -import Avatar from "../../images/avatar.jpg"; +import Avatar from "@/images/avatar.jpg"; + + +// Interface +import { MouseEvent } from "react"; // Components function Aside() { - + const { globalData: { profile } } = useGlobalContext(); const [sideOpen, setSideOpen] = useState(false); - const toggleClick = () => { + const onMenuClick = (ev: MouseEvent) => { + let el = ev.target as HTMLElement; + + el.tagName === "A" && setSideOpen(!sideOpen); + } + + const onToggleClick = () => { setSideOpen(!sideOpen); } return ( -