深色模式
Runtime API Examples
This page demonstrates usage of some of the runtime APIs provided by VitePress.
The main useData() API can be used to access site, theme, and page data for the current page. It works in both .md and .vue files:
md
<script setup>
import { useData } from 'vitepress'
const { theme, page, frontmatter } = useData()
</script>
## Results
### Theme Data
<pre>{{ theme }}</pre>
### Page Data
<pre>{{ page }}</pre>
### Page Frontmatter
<pre>{{ frontmatter }}</pre>Results
Theme Data
{
"nav": [
{
"text": "首页",
"link": "/"
},
{
"text": "接入教程",
"link": "/tutorials/apijianjie"
},
{
"text": "进入控制台",
"link": "https://docs.juheq.cn/admin"
}
],
"sidebar": [
{
"text": "开始",
"collapsed": false,
"items": [
{
"text": "Z-API简介",
"link": "/tutorials/apijianjie"
}
]
},
{
"text": "快速开始",
"collapsed": false,
"items": [
{
"text": "使用指南",
"link": "/tutorials/使用指南"
}
]
},
{
"text": "客户端配置",
"collapsed": false,
"items": [
{
"text": "Claude Desktop桌面端配置",
"link": "/tutorials/claude-desktop"
},
{
"text": "CC-Switch接入Codex客户端教程",
"link": "/tutorials/cc-switch-codex"
},
{
"text": "CC-Switch接入Claude客户端教程",
"link": "/tutorials/cc-switch-claude-code"
},
{
"text": "Codex客户端切换中转站同步会话教程",
"link": "/tutorials/codex-session-sync"
},
{
"text": "Codex 桌面端配置教程",
"link": "/tutorials/codex-desktop"
},
{
"text": "测试",
"link": "/tutorials/测试"
}
]
},
{
"text": "常见问题",
"collapsed": false,
"items": [
{
"text": "常见 API 错误码说明",
"link": "/tutorials/api-error-codes"
}
]
}
],
"search": {
"provider": "local",
"options": {
"translations": {
"button": {
"buttonText": "搜索文档",
"buttonAriaLabel": "搜索文档"
},
"modal": {
"noResultsText": "没有找到相关内容",
"resetButtonTitle": "清除搜索",
"footer": {
"selectText": "选择",
"navigateText": "切换",
"closeText": "关闭"
}
}
}
}
},
"outline": {
"level": [
2,
3
],
"label": "本页目录"
},
"docFooter": {
"prev": "上一篇",
"next": "下一篇"
},
"lastUpdatedText": "最后更新",
"returnToTopLabel": "返回顶部",
"sidebarMenuLabel": "文档菜单",
"darkModeSwitchLabel": "深色模式",
"lightModeSwitchTitle": "切换到浅色模式",
"darkModeSwitchTitle": "切换到深色模式",
"externalLinkIcon": true,
"footer": {
"message": "Z-API Documentation",
"copyright": "Copyright © 2026 Z-API"
}
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "api-examples.md",
"filePath": "api-examples.md",
"lastUpdated": 1786527869000
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.