diff --git a/themes/example/LayoutBase.js b/themes/example/LayoutBase.js index 90ec3ff9..9ca0eb5e 100644 --- a/themes/example/LayoutBase.js +++ b/themes/example/LayoutBase.js @@ -7,6 +7,7 @@ import { Title } from './components/Title' import { SideBar } from './components/SideBar' import JumpToTopButton from './components/JumpToTopButton' import BLOG from '@/blog.config' +import { useGlobal } from '@/lib/global' /** * 基础布局 采用左右两侧布局,移动端使用顶部导航栏 @@ -15,6 +16,14 @@ import BLOG from '@/blog.config' */ const LayoutBase = props => { const { children, meta } = props + const { onLoading } = useGlobal() + + const LoadingCover =
+
+ +
+
+ return (
@@ -31,7 +40,7 @@ const LayoutBase = props => {
-
{children}
+
{onLoading ? LoadingCover : children}
diff --git a/themes/fukasawa/LayoutBase.js b/themes/fukasawa/LayoutBase.js index a99dea5d..2c6d030e 100644 --- a/themes/fukasawa/LayoutBase.js +++ b/themes/fukasawa/LayoutBase.js @@ -4,6 +4,7 @@ import AsideLeft from './components/AsideLeft' import Live2D from '@/components/Live2D' import BLOG from '@/blog.config' import { isBrowser, loadExternalResource } from '@/lib/utils' +import { useGlobal } from '@/lib/global' /** * 基础布局 采用左右两侧布局,移动端使用顶部导航栏 @@ -20,17 +21,21 @@ import { isBrowser, loadExternalResource } from '@/lib/utils' * @constructor */ const LayoutBase = (props) => { - const { - children, - headerSlot, - meta - } = props + const { children, headerSlot, meta } = props const leftAreaSlot = if (isBrowser()) { loadExternalResource('/css/theme-fukasawa.css', 'css') } + const { onLoading } = useGlobal() + + const LoadingCover =
+
+ +
+
+ return (
@@ -41,7 +46,7 @@ const LayoutBase = (props) => {
{headerSlot}
-
{children}
+
{onLoading ? LoadingCover : children}
diff --git a/themes/medium/LayoutBase.js b/themes/medium/LayoutBase.js index 34f90c96..9d3a9eff 100644 --- a/themes/medium/LayoutBase.js +++ b/themes/medium/LayoutBase.js @@ -25,6 +25,13 @@ const LayoutBase = props => { const { locale } = useGlobal() const router = useRouter() const [tocVisible, changeTocVisible] = useState(false) + const { onLoading } = useGlobal() + + const LoadingCover =
+
+ +
+
return ( @@ -42,7 +49,8 @@ const LayoutBase = props => {
{slotTop} - {children} + + {onLoading ? LoadingCover : children} {/* 回顶按钮 */}
{ const { children, meta, post } = props const fullWidth = post?.fullWidth ?? false + const { onLoading } = useGlobal() + const LoadingCover =
+
+ +
+
return (
@@ -22,11 +29,9 @@ const LayoutBase = props => { {/* 顶部导航栏 */}