+ {/* eslint-disable-next-line @next/next/no-img-element */} - - + + {post?.title} + {post?.category && + + {post?.category} + + } ) diff --git a/themes/plog/components/BottomNav.js b/themes/plog/components/BottomNav.js index 186f2741..5567e3dc 100644 --- a/themes/plog/components/BottomNav.js +++ b/themes/plog/components/BottomNav.js @@ -15,7 +15,7 @@ const BottomNav = props => { const { navBarTitle, siteInfo } = props return <> - + diff --git a/themes/plog/components/Modal.js b/themes/plog/components/Modal.js new file mode 100644 index 00000000..51424a44 --- /dev/null +++ b/themes/plog/components/Modal.js @@ -0,0 +1,83 @@ +import { Fragment, useRef, useState } from 'react' +import { Dialog, Transition } from '@headlessui/react' +import { usePlogGlobal } from '..' +import { ArrowPath } from '@/components/HeroIcons' +import Link from 'next/link' + +/** + * 弹出框 + */ +export default function Modal(props) { + const { showModal, setShowModal, modalContent } = usePlogGlobal() + const { siteInfo } = props + const cancelButtonRef = useRef(null) + const img = modalContent?.pageCover || siteInfo?.pageCover + const imgRef = useRef(null) + + // 添加loading状态 + const [loading, setLoading] = useState(true) + + // 在图片加载完成时设置loading为false + async function handleImageLoad() { + setLoading(false) + } + + // 关闭弹窗 + function handleClose() { + setShowModal(false) + setLoading(true) + } + return ( + + + {/* 遮罩 */} + + + + + + + + + {/* 添加loading状态 */} + + + + {/* 添加onLoad事件处理函数 */} + {/* eslint-disable-next-line @next/next/no-img-element */} + + {!loading && + + {modalContent?.title} + + {modalContent?.summary} + {modalContent?.category && + + {modalContent?.category} + + } + } + + + + + + + ) +} diff --git a/themes/plog/index.js b/themes/plog/index.js index c7da235d..cf156034 100644 --- a/themes/plog/index.js +++ b/themes/plog/index.js @@ -1,6 +1,6 @@ import CONFIG from './config' import CommonHead from '@/components/CommonHead' -import React, { useEffect } from 'react' +import React, { createContext, useContext, useEffect, useState } from 'react' import Nav from './components/Nav' import { useGlobal } from '@/lib/global' @@ -24,6 +24,11 @@ import Link from 'next/link' import { Transition } from '@headlessui/react' import BottomNav from './components/BottomNav' import { saveDarkModeToCookies } from '@/themes/theme' +import Modal from './components/Modal' + +// 主题全局状态 +const ThemeGlobalPlog = createContext() +export const usePlogGlobal = () => useContext(ThemeGlobalPlog) /** * 基础布局 采用左右两侧布局,移动端使用顶部导航栏 @@ -34,6 +39,8 @@ import { saveDarkModeToCookies } from '@/themes/theme' const LayoutBase = props => { const { children, meta, topSlot } = props const { onLoading, updateDarkMode } = useGlobal() + const [showModal, setShowModal] = useState(false) + const [modalContent, setModalContent] = useState(null) // 用户手动设置主题 const setDarkMode = () => { @@ -52,6 +59,7 @@ const LayoutBase = props => { }, []) return ( + {/* SEO相关 */} @@ -60,7 +68,7 @@ const LayoutBase = props => { {/* 主区 */} - + { + {/* 弹出框 */} + + {/* 桌面端底部导航栏 */} + ) }
{/* eslint-disable-next-line @next/next/no-img-element */} - - + + {post?.title} + {post?.category && + + {post?.category} + + }