初始化

This commit is contained in:
李琦
2026-07-08 15:04:42 +08:00
commit 70264153e5
129 changed files with 13797 additions and 0 deletions

View File

@@ -0,0 +1,612 @@
<template>
<div class="home-page">
<!-- Hero Section -->
<section class="hero">
<div class="hero-bg"></div>
<div class="hero-content">
<div class="hero-badge">技术文档</div>
<h1 class="hero-title">XK 项目文档</h1>
<p class="hero-subtitle">萧康新医疗系统</p>
<p class="hero-desc">互联网中医诊疗 · 药品供应链 · 监管合规</p>
<div class="hero-actions">
<a href="/guide/introduction" class="btn btn-primary">
<component :is="BookOpen" :size="18" />
项目介绍
</a>
<a href="/guide/architecture" class="btn btn-secondary">
<component :is="GitBranch" :size="18" />
系统架构
</a>
<a href="/database/overview" class="btn btn-secondary">
<component :is="Database" :size="18" />
数据库总览
</a>
</div>
</div>
</section>
<!-- Stats Section -->
<section class="stats">
<div class="stats-grid">
<div class="stat-card" v-for="stat in stats" :key="stat.label">
<div class="stat-icon">
<component :is="stat.icon" :size="24" />
</div>
<div class="stat-value">{{ stat.value }}</div>
<div class="stat-label">{{ stat.label }}</div>
</div>
</div>
</section>
<!-- Projects Section -->
<section class="projects">
<h2 class="section-title">项目总览</h2>
<p class="section-desc">XK 系统由 7 个核心子项目组成,覆盖完整的互联网中医诊疗业务链</p>
<div class="projects-grid">
<a
v-for="project in projects"
:key="project.name"
:href="project.link"
class="project-card"
>
<div class="project-header">
<div class="project-icon-box" :style="{ background: project.color + '15', color: project.color }">
<component :is="project.icon" :size="22" />
</div>
<span class="project-status" :class="project.status">{{ project.statusText }}</span>
</div>
<h3 class="project-name">{{ project.name }}</h3>
<p class="project-desc">{{ project.desc }}</p>
<div class="project-tech">
<span v-for="tech in project.tech" :key="tech" class="tech-tag">{{ tech }}</span>
</div>
</a>
</div>
</section>
<!-- Tech Stack Section -->
<section class="tech-stack">
<h2 class="section-title">技术栈</h2>
<div class="stack-grid">
<div class="stack-item" v-for="item in techStack" :key="item.name">
<div class="stack-icon" :style="{ color: item.color }">
<component :is="item.icon" :size="20" />
</div>
<span class="stack-name">{{ item.name }}</span>
</div>
</div>
</section>
</div>
</template>
<script setup>
import {
BookOpen,
GitBranch,
Database,
Folder,
Table2,
Plug,
Zap,
LayoutDashboard,
Server,
History,
Smartphone,
Stethoscope,
BarChart3,
Link,
CircleDot,
Code,
Cpu,
HardDrive,
Wifi,
Cloud,
} from '@lucide/vue'
const stats = [
{ icon: Folder, value: '7', label: '子项目' },
{ icon: Table2, value: '167+', label: '数据表' },
{ icon: Plug, value: '50+', label: 'API 接口' },
{ icon: Zap, value: '8', label: '消息队列任务' },
]
const projects = [
{
name: 'xk-admin',
icon: LayoutDashboard,
color: '#2563EB',
desc: '管理后台 — Vue 3 + Vben Admin Pro,总后台 / 门店端管理界面',
tech: ['Vue 3', 'Vben Admin', 'TypeScript'],
status: 'active',
statusText: '活跃',
link: '/projects/xk-admin/overview',
},
{
name: 'xk-api',
icon: Server,
color: '#0077B6',
desc: '新 API 服务 — Laravel 12,核心业务逻辑、支付、处方、监管上报',
tech: ['Laravel 12', 'PHP 8.4', 'MySQL'],
status: 'active',
statusText: '活跃',
link: '/projects/xk-api/overview',
},
{
name: 'xk-api-yii',
icon: History,
color: '#D97706',
desc: '旧 API 服务 — Yii2 Advanced,遗留系统,部分接口仍在使用',
tech: ['Yii2', 'PHP', 'MySQL'],
status: 'legacy',
statusText: '遗留',
link: '/projects/xk-api-yii/overview',
},
{
name: 'xk-client-wx',
icon: Smartphone,
color: '#16A34A',
desc: '用户端小程序 — uni-app,患者问诊、购药、挂号、转诊',
tech: ['uni-app', 'Vue 3', '微信小程序'],
status: 'active',
statusText: '活跃',
link: '/projects/xk-client-wx/overview',
},
{
name: 'xk-doctor-wx',
icon: Stethoscope,
color: '#7C3AED',
desc: '医生端小程序 — uni-app,医生接诊、开方、药师审方、门店管理',
tech: ['uni-app', 'Vue 3', '微信小程序'],
status: 'active',
statusText: '活跃',
link: '/projects/xk-doctor-wx/overview',
},
{
name: 'xk-data',
icon: BarChart3,
color: '#DC2626',
desc: '数据大屏 — Vue 3 + ECharts,业务数据可视化',
tech: ['Vue 3', 'ECharts', 'DataV'],
status: 'active',
statusText: '活跃',
link: '/projects/xk-data/overview',
},
{
name: 'xk-hy-forward-go',
icon: Link,
color: '#0891B2',
desc: '监管转发服务 — Go,内网双通道转发至浙江省政务云',
tech: ['Go', 'HTTP Proxy', 'AES'],
status: 'active',
statusText: '活跃',
link: '/projects/xk-hy-forward-go/overview',
},
]
const techStack = [
{ icon: CircleDot, name: 'Laravel 12', color: '#FF2D20' },
{ icon: Code, name: 'Vue 3', color: '#42B883' },
{ icon: Smartphone, name: 'uni-app', color: '#2B9939' },
{ icon: Cpu, name: 'Go', color: '#00ADD8' },
{ icon: Database, name: 'MySQL', color: '#4479A1' },
{ icon: HardDrive, name: 'Redis', color: '#DC382D' },
{ icon: Wifi, name: 'RabbitMQ', color: '#FF6600' },
{ icon: Cloud, name: '阿里云 OSS', color: '#FF6A00' },
]
</script>
<style scoped>
.home-page {
max-width: 1100px;
margin: 0 auto;
padding: 0 24px;
font-family: 'Noto Sans SC', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
/* Hero */
.hero {
position: relative;
text-align: center;
padding: 72px 0 48px;
overflow: hidden;
}
.hero-bg {
position: absolute;
top: -60%;
left: -20%;
width: 140%;
height: 200%;
background: radial-gradient(ellipse at 50% 0%, #0077B6 0%, transparent 60%);
opacity: 0.06;
pointer-events: none;
}
.hero-content {
position: relative;
z-index: 1;
}
.hero-badge {
display: inline-block;
padding: 6px 16px;
background: linear-gradient(135deg, #0077B608, #0077B615);
color: #0077B6;
border: 1px solid #0077B625;
border-radius: 20px;
font-size: 13px;
font-weight: 600;
margin-bottom: 20px;
letter-spacing: 0.5px;
}
.hero-title {
font-size: 52px;
font-weight: 800;
margin: 0 0 12px;
line-height: 1.15;
color: #0F172A;
letter-spacing: -1px;
}
.hero-subtitle {
font-size: 26px;
font-weight: 600;
color: #334155;
margin: 0 0 10px;
}
.hero-desc {
font-size: 16px;
color: #64748B;
margin: 0 0 36px;
}
.hero-actions {
display: flex;
gap: 14px;
justify-content: center;
flex-wrap: wrap;
}
.btn {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 12px 28px;
border-radius: 10px;
font-size: 15px;
font-weight: 600;
text-decoration: none;
transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
cursor: pointer;
position: relative;
overflow: hidden;
}
.btn-primary {
background: linear-gradient(135deg, #0077B6, #0096D6);
color: white;
box-shadow: 0 2px 8px rgba(0, 119, 182, 0.25);
}
.btn-primary:hover {
background: linear-gradient(135deg, #005F8F, #0077B6);
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(0, 119, 182, 0.35);
}
.btn-primary:active {
transform: translateY(0);
box-shadow: 0 2px 8px rgba(0, 119, 182, 0.25);
}
.btn-secondary {
background: white;
color: #334155;
border: 1px solid #E2E8F0;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.btn-secondary:hover {
border-color: #0077B6;
color: #0077B6;
background: #F0F9FF;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 119, 182, 0.12);
}
.btn-secondary:active {
transform: translateY(0);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
/* Stats */
.stats {
padding: 32px 0;
}
.stats-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 16px;
}
.stat-card {
text-align: center;
padding: 28px 16px;
background: linear-gradient(180deg, #FFFFFF, #F8FAFC);
border-radius: 14px;
border: 1px solid #E2E8F0;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.stat-card:hover {
border-color: #0077B630;
box-shadow: 0 8px 24px rgba(0, 119, 182, 0.1);
transform: translateY(-4px);
}
.stat-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 48px;
height: 48px;
border-radius: 12px;
background: linear-gradient(135deg, #0077B610, #0077B608);
color: #0077B6;
margin-bottom: 12px;
transition: all 0.3s ease;
}
.stat-card:hover .stat-icon {
background: linear-gradient(135deg, #0077B620, #0077B615);
transform: scale(1.08);
}
.stat-value {
font-size: 36px;
font-weight: 800;
color: #0F172A;
margin-bottom: 4px;
letter-spacing: -0.5px;
}
.stat-label {
font-size: 13px;
color: #64748B;
font-weight: 500;
}
/* Section Title */
.section-title {
font-size: 28px;
font-weight: 700;
text-align: center;
margin: 56px 0 10px;
color: #0F172A;
letter-spacing: -0.5px;
}
.section-desc {
text-align: center;
color: #64748B;
margin: 0 0 36px;
font-size: 15px;
}
/* Projects */
.projects-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 16px;
}
.project-card {
display: block;
padding: 24px;
background: linear-gradient(180deg, #FFFFFF, #FAFBFC);
border: 1px solid #E2E8F0;
border-left: 3px solid transparent;
border-radius: 12px;
text-decoration: none;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
cursor: pointer;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.project-card:hover {
border-color: #E2E8F0;
border-left-color: #0077B6;
box-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
transform: translateY(-4px);
}
.project-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 14px;
}
.project-icon-box {
width: 44px;
height: 44px;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
}
.project-card:hover .project-icon-box {
transform: scale(1.08);
}
.project-status {
font-size: 12px;
font-weight: 600;
padding: 4px 12px;
border-radius: 14px;
}
.project-status.active {
background: linear-gradient(135deg, #DCFCE7, #BBF7D0);
color: #15803D;
}
.project-status.legacy {
background: linear-gradient(135deg, #FEF3C7, #FDE68A);
color: #B45309;
}
.project-name {
font-size: 18px;
font-weight: 700;
color: #0F172A;
margin: 0 0 8px;
}
.project-desc {
font-size: 14px;
color: #64748B;
margin: 0 0 16px;
line-height: 1.6;
}
.project-tech {
display: flex;
gap: 6px;
flex-wrap: wrap;
}
.tech-tag {
font-size: 12px;
padding: 5px 10px;
background: linear-gradient(135deg, #F1F5F9, #E2E8F0);
border: none;
border-radius: 6px;
color: #475569;
font-weight: 500;
}
/* Tech Stack */
.tech-stack {
padding: 32px 0 72px;
}
.stack-grid {
display: flex;
justify-content: center;
gap: 12px;
flex-wrap: wrap;
}
.stack-item {
display: flex;
align-items: center;
gap: 10px;
padding: 12px 20px;
background: linear-gradient(135deg, #FFFFFF, #F8FAFC);
border: 1px solid #E2E8F0;
border-radius: 10px;
font-size: 14px;
font-weight: 500;
color: #334155;
transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
cursor: default;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.stack-item:hover {
border-color: #0077B630;
box-shadow: 0 4px 12px rgba(0, 119, 182, 0.08);
transform: translateY(-2px);
}
.stack-icon {
display: flex;
align-items: center;
transition: transform 0.25s ease;
}
.stack-item:hover .stack-icon {
transform: scale(1.12);
}
.stack-name {
white-space: nowrap;
}
/* Responsive */
@media (max-width: 768px) {
.hero-title {
font-size: 34px;
}
.hero-subtitle {
font-size: 20px;
}
.stats-grid {
grid-template-columns: repeat(2, 1fr);
}
.projects-grid {
grid-template-columns: 1fr;
}
}
/* Dark mode */
:root.dark .home-page {
color: #E2E8F0;
}
:root.dark .hero-title {
color: #F1F5F9;
}
:root.dark .hero-subtitle {
color: #CBD5E1;
}
:root.dark .hero-badge {
background: linear-gradient(135deg, #38BDF808, #38BDF815);
color: #38BDF8;
border-color: #38BDF825;
}
:root.dark .btn-secondary {
background: #1E293B;
border-color: #334155;
color: #E2E8F0;
}
:root.dark .btn-secondary:hover {
border-color: #38BDF8;
color: #38BDF8;
background: #1E3A5F;
}
:root.dark .stat-card,
:root.dark .project-card,
:root.dark .stack-item {
background: linear-gradient(180deg, #1E293B, #1A2332);
border-color: #334155;
}
:root.dark .stat-card:hover,
:root.dark .project-card:hover,
:root.dark .stack-item:hover {
border-color: #38BDF840;
box-shadow: 0 8px 24px rgba(56, 189, 248, 0.08);
}
:root.dark .stat-icon {
background: linear-gradient(135deg, #38BDF810, #38BDF808);
color: #38BDF8;
}
:root.dark .stat-value,
:root.dark .project-name {
color: #F1F5F9;
}
:root.dark .stat-label,
:root.dark .project-desc {
color: #94A3B8;
}
:root.dark .tech-tag {
background: linear-gradient(135deg, #0F172A, #1E293B);
color: #94A3B8;
}
</style>

View File

@@ -0,0 +1,237 @@
<template>
<Teleport to="body">
<Transition name="preview">
<div v-if="visible" class="image-preview-overlay" @click.self="close">
<div class="image-preview-toolbar">
<button @click="zoomIn" title="放大">
<component :is="ZoomIn" :size="16" />
</button>
<button @click="zoomOut" title="缩小">
<component :is="ZoomOut" :size="16" />
</button>
<button @click="reset" title="重置">
<component :is="RotateCcw" :size="16" />
</button>
<span class="zoom-level">{{ Math.round(scale * 100) }}%</span>
<button class="close-btn" @click="close" title="关闭">
<component :is="X" :size="16" />
</button>
</div>
<div
class="image-preview-canvas"
ref="canvasRef"
@wheel.prevent="onWheel"
@mousedown="onMouseDown"
@mousemove="onMouseMove"
@mouseup="onMouseUp"
@mouseleave="onMouseUp"
>
<div
class="image-preview-content"
ref="contentRef"
:style="contentStyle"
></div>
</div>
</div>
</Transition>
</Teleport>
</template>
<script setup>
import { ref, computed, watch, nextTick, onUnmounted } from 'vue'
import { ZoomIn, ZoomOut, RotateCcw, X } from '@lucide/vue'
const props = defineProps({
visible: Boolean,
html: String,
})
const emit = defineEmits(['close'])
const canvasRef = ref(null)
const contentRef = ref(null)
const scale = ref(1)
const translateX = ref(0)
const translateY = ref(0)
const isDragging = ref(false)
const lastX = ref(0)
const lastY = ref(0)
const contentStyle = computed(() => ({
transform: `translate(${translateX.value}px, ${translateY.value}px) scale(${scale.value})`,
transformOrigin: '0 0',
}))
watch(() => props.visible, (val) => {
if (val) {
scale.value = 1
translateX.value = 0
translateY.value = 0
nextTick(() => {
if (contentRef.value && props.html) {
contentRef.value.innerHTML = props.html
centerContent()
}
})
document.body.style.overflow = 'hidden'
} else {
document.body.style.overflow = ''
}
})
function centerContent() {
if (!canvasRef.value || !contentRef.value) return
const cw = canvasRef.value.clientWidth
const ch = canvasRef.value.clientHeight
const iw = contentRef.value.scrollWidth
const ih = contentRef.value.scrollHeight
const fitScale = Math.min(cw / iw, ch / ih, 1) * 0.85
scale.value = fitScale
translateX.value = (cw - iw * fitScale) / 2
translateY.value = (ch - ih * fitScale) / 2
}
function zoomIn() {
scale.value = Math.min(scale.value * 1.25, 5)
}
function zoomOut() {
scale.value = Math.max(scale.value * 0.8, 0.1)
}
function reset() {
centerContent()
}
function close() {
emit('close')
}
function onWheel(e) {
const delta = e.deltaY > 0 ? 0.9 : 1.1
const newScale = Math.min(Math.max(scale.value * delta, 0.1), 5)
const rect = canvasRef.value.getBoundingClientRect()
const cx = e.clientX - rect.left
const cy = e.clientY - rect.top
translateX.value = cx - (cx - translateX.value) * (newScale / scale.value)
translateY.value = cy - (cy - translateY.value) * (newScale / scale.value)
scale.value = newScale
}
function onMouseDown(e) {
if (e.button !== 0) return
isDragging.value = true
lastX.value = e.clientX
lastY.value = e.clientY
}
function onMouseMove(e) {
if (!isDragging.value) return
translateX.value += e.clientX - lastX.value
translateY.value += e.clientY - lastY.value
lastX.value = e.clientX
lastY.value = e.clientY
}
function onMouseUp() {
isDragging.value = false
}
function onKeydown(e) {
if (e.key === 'Escape') close()
if (e.key === '+' || e.key === '=') zoomIn()
if (e.key === '-') zoomOut()
if (e.key === '0') reset()
}
if (typeof window !== 'undefined') {
window.addEventListener('keydown', onKeydown)
onUnmounted(() => window.removeEventListener('keydown', onKeydown))
}
</script>
<style scoped>
.image-preview-overlay {
position: fixed;
inset: 0;
z-index: 9999;
background: rgba(0, 0, 0, 0.85);
display: flex;
flex-direction: column;
cursor: default;
}
.image-preview-toolbar {
display: flex;
align-items: center;
gap: 2px;
padding: 8px 12px;
background: rgba(0, 0, 0, 0.6);
backdrop-filter: blur(8px);
z-index: 1;
}
.image-preview-toolbar button {
display: inline-flex;
align-items: center;
justify-content: center;
width: 30px;
height: 30px;
border: none;
border-radius: 6px;
background: transparent;
color: #fff;
cursor: pointer;
transition: background 0.15s;
}
.image-preview-toolbar button:hover {
background: rgba(255, 255, 255, 0.15);
}
.close-btn {
margin-left: auto;
}
.zoom-level {
font-size: 13px;
color: rgba(255, 255, 255, 0.7);
min-width: 48px;
text-align: center;
font-variant-numeric: tabular-nums;
}
.image-preview-canvas {
flex: 1;
overflow: hidden;
cursor: grab;
position: relative;
}
.image-preview-canvas:active {
cursor: grabbing;
}
.image-preview-content {
position: absolute;
color: #fff;
}
.image-preview-content :deep(svg) {
max-width: none;
height: auto;
}
/* Transition */
.preview-enter-active,
.preview-leave-active {
transition: opacity 0.25s ease;
}
.preview-enter-from,
.preview-leave-to {
opacity: 0;
}
</style>

View File

@@ -0,0 +1,221 @@
<template>
<div class="mermaid-wrapper" ref="wrapperRef">
<div class="mermaid svg-mermaid" ref="mermaidRef" :data-graph="graph" @click="openPreview"></div>
<button class="mermaid-expand" @click.stop="openPreview" title="全屏预览">
<Maximize2 :size="8" />
</button>
<ImagePreview :visible="showPreview" :html="renderedHtml" @close="showPreview = false" />
</div>
</template>
<script setup>
import { ref, onMounted, onUnmounted } from 'vue'
import { Maximize2 } from '@lucide/vue'
import ImagePreview from './ImagePreview.vue'
const props = defineProps({
graph: {
type: String,
default: '',
},
id: {
type: String,
default: () => `mermaid-${Math.random().toString(36).slice(2, 9)}`,
},
})
const wrapperRef = ref(null)
const mermaidRef = ref(null)
const showPreview = ref(false)
const renderedHtml = ref('')
let mut = null
// Zoom/pan state
let scale = 1
let translateX = 0
let translateY = 0
let isDragging = false
let lastX = 0
let lastY = 0
const updateTransform = () => {
if (!mermaidRef.value) return
mermaidRef.value.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scale})`
mermaidRef.value.style.transformOrigin = '0 0'
}
const onWheel = (e) => {
e.preventDefault()
const delta = e.deltaY > 0 ? 0.9 : 1.1
const newScale = Math.min(Math.max(scale * delta, 0.2), 5)
const rect = wrapperRef.value.getBoundingClientRect()
const cx = e.clientX - rect.left
const cy = e.clientY - rect.top
translateX = cx - (cx - translateX) * (newScale / scale)
translateY = cy - (cy - translateY) * (newScale / scale)
scale = newScale
updateTransform()
}
const onMouseDown = (e) => {
if (e.button !== 0) return
isDragging = true
lastX = e.clientX
lastY = e.clientY
wrapperRef.value.style.cursor = 'grabbing'
}
const onMouseMove = (e) => {
if (!isDragging) return
translateX += e.clientX - lastX
translateY += e.clientY - lastY
lastX = e.clientX
lastY = e.clientY
updateTransform()
}
const onMouseUp = () => {
isDragging = false
if (wrapperRef.value) wrapperRef.value.style.cursor = 'grab'
}
const onDblClick = () => {
scale = 1
translateX = 0
translateY = 0
updateTransform()
}
function openPreview() {
if (mermaidRef.value && mermaidRef.value.innerHTML) {
renderedHtml.value = mermaidRef.value.innerHTML
showPreview.value = true
}
}
const renderMermaid = async () => {
if (!mermaidRef.value) return
try {
const mermaid = (await import('mermaid')).default
mermaid.initialize({
startOnLoad: false,
theme: document.documentElement.classList.contains('dark') ? 'dark' : 'default',
securityLevel: 'loose',
})
const graphData = props.graph || mermaidRef.value.getAttribute('data-graph') || ''
if (!graphData) return
const decoded = decodeURIComponent(graphData)
const { svg } = await mermaid.render(props.id, decoded)
mermaidRef.value.innerHTML = svg
// Reset zoom/pan on re-render
scale = 1
translateX = 0
translateY = 0
updateTransform()
} catch (error) {
console.error('Mermaid render error:', error)
mermaidRef.value.innerHTML = `<pre style="color: red;">Mermaid Error: ${error.message}</pre>`
}
}
onMounted(() => {
renderMermaid()
mut = new MutationObserver(() => renderMermaid())
mut.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] })
const el = wrapperRef.value
if (el) {
el.addEventListener('wheel', onWheel, { passive: false })
el.addEventListener('mousedown', onMouseDown)
window.addEventListener('mousemove', onMouseMove)
window.addEventListener('mouseup', onMouseUp)
el.addEventListener('dblclick', onDblClick)
}
})
onUnmounted(() => {
if (mut) mut.disconnect()
const el = wrapperRef.value
if (el) {
el.removeEventListener('wheel', onWheel)
el.removeEventListener('mousedown', onMouseDown)
el.removeEventListener('dblclick', onDblClick)
}
window.removeEventListener('mousemove', onMouseMove)
window.removeEventListener('mouseup', onMouseUp)
})
</script>
<style scoped>
.mermaid-wrapper {
overflow: hidden;
cursor: grab;
border: 1px solid var(--vp-c-divider);
border-radius: 8px;
padding: 24px;
margin: 24px 0;
position: relative;
width: 100%;
min-height: 200px;
}
.mermaid-wrapper:active {
cursor: grabbing;
}
.mermaid {
width: 100%;
text-align: center;
}
.mermaid :deep(.svg-mermaid) {
width: 100%;
height: auto;
min-width: 600px;
}
.mermaid-expand {
position: absolute;
top: 8px;
right: 8px;
width: 28px !important;
height: 28px !important;
min-width: 28px !important;
min-height: 28px !important;
max-width: 28px !important;
max-height: 28px !important;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid var(--vp-c-divider);
border-radius: 6px;
background: var(--vp-c-bg);
color: var(--vp-c-text-2);
cursor: pointer;
/* opacity: 0;
transition: opacity 0.2s;*/
z-index: 2;
flex-shrink: 0;
padding: 0;
margin: 0;
line-height: 1;
}
/*
.mermaid-wrapper:hover .mermaid-expand {
opacity: 1;
}*/
.mermaid-expand:hover {
border-color: var(--vp-c-brand-1);
color: var(--vp-c-brand-1);
}
</style>

View File

@@ -0,0 +1,13 @@
import DefaultTheme from 'vitepress/theme'
import Mermaid from './Mermaid.vue'
import HomePage from './HomePage.vue'
import type { Theme } from 'vitepress'
export default {
extends: DefaultTheme,
enhanceApp({ app }) {
app.component('Mermaid', Mermaid)
app.component('HomePage', HomePage)
},
setup() {},
} satisfies Theme

View File

@@ -0,0 +1,18 @@
import type { MarkdownRenderer } from 'vitepress'
export function mermaidPlugin(md: MarkdownRenderer) {
const defaultFence = md.renderer.rules.fence.bind(md.renderer.rules)
md.renderer.rules.fence = (tokens, idx, options, env, self) => {
const token = tokens[idx]
const info = token.info.trim()
if (info === 'mermaid') {
const id = `mermaid-${idx}`
const encoded = encodeURIComponent(token.content)
return `<Mermaid graph="${encoded}" id="${id}"></Mermaid>`
}
return defaultFence(tokens, idx, options, env, self)
}
}