Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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}
Expand Down
5 changes: 5 additions & 0 deletions .vitepress/theme/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading