diff --git a/.vitepress/theme/index.ts b/.vitepress/theme/index.ts index f33951d..a026131 100644 --- a/.vitepress/theme/index.ts +++ b/.vitepress/theme/index.ts @@ -9,7 +9,7 @@ import MermaidBlock from './components/MermaidBlock.vue' import '@opentiny/tiny-robot-style' import {nextTick, watch} from 'vue'; import {useRoute} from 'vitepress'; -import mediumZoom from 'medium-zoom'; +import mediumZoom, { Zoom } from 'medium-zoom'; import { insertFurion } from './insert-furion' // 引入样式文件 import './medium-zoom.css'; @@ -43,17 +43,22 @@ export default { }, Layout, setup() { - // 为img元素添加点击放大功能 + // 为img元素添加点击放大功能并根据路由隐藏 playground 图标 const route = useRoute(); - let zomm: any = null; + let zoom: Zoom | null = null; watch( () => route.path, () => nextTick(() => { - if (zomm) { - zomm.detach(); + if (zoom) { + zoom.detach(); } if (typeof window !== 'undefined'){ - zomm = mediumZoom('.main img', {background: 'var(--vp-c-bg)'}) + zoom = mediumZoom('.main img', {background: 'var(--vp-c-bg)'}) + if (route.path.includes('tiny-robot')) { + document.body.classList.remove('hide-code-playground'); + } else { + document.body.classList.add('hide-code-playground'); + } } }), {immediate: true} diff --git a/.vitepress/theme/style.css b/.vitepress/theme/style.css index 4b70b73..c219ed2 100644 --- a/.vitepress/theme/style.css +++ b/.vitepress/theme/style.css @@ -177,6 +177,11 @@ body, .VPContent { padding-top: 0 !important; } + +/* 隐藏代码 playground 图标,在除了 tiny-robot 路由下启用 */ +body.hide-code-playground .lucide.lucide-play-icon.lucide-play { + display: none !important; +} .VPHome .container { max-width: 92rem; }