MCPcopy Index your code
hub / github.com/andurils/vue-code-view

github.com/andurils/vue-code-view @v0.6.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.6.1 ↗ · + Follow
49 symbols 100 edges 15 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Vue Code View(VCV)

Build Status GitHub license npm npm bundle size npm

English | 简体中文# Vue Code View

一个基于 vue 2.x的轻量代码交互组件,在网页中可以编辑、运行并实时预览代码效果展示。

当阅读包含大量代码的文档时,很多项目文档通过 markdown loader 实现了示例代码的 render 展示,但它是静态的。当我们想调试代码时,一般需要打开本地IDE或者打开 codepencodesandbox等在线编辑器网站,也会受制于电脑是否安装开发环境或者网络连接是否顺畅。

那么能不能有这么一个组件能支持在页面中编辑代码,在网页中可以编辑、运行并实时预览代码效果展示?

特别感谢组件 react-code-view,基于此编写了vue 版本的组件!使用此组件在 vue 页面还是 markdown 文档中的多示例代码,都可以实时编辑运行代码、预览效果。

⚡ 在线预览

示例

在线预览: https://andurils.github.io/vue-code-view/#/demo

codesandbox 示例: vue-code-view-example

✨ 特性

  • 💻 代码可以在线编辑,实时预览效果。
  • 🎨 支持示例代码高亮,配置主题。
  • 🌈 支持 <style> 解析渲染。
  • 📑 支持 Markdown 文件示例渲染。

📦 安装

npm i vue-code-view
# or
yarn add vue-code-view

🔨 配置

使用vue cli需要在vue.config.js文件进行配置,支持使用包含运行时编译器的 Vue 构建版本。

module.exports = {
  runtimeCompiler: true,
  // or
  chainWebpack: (config) => { 
    config.resolve.alias
      .set("vue$", "vue/dist/vue.esm.js");
  },
}; 

💻 示例

入口文件 main.js 中引入组件,不需要手动引入样式。

import Vue from "vue";
import App from "./App.vue";
import CodeView from "vue-code-view";

Vue.use(CodeView);

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");

📚 API

Props

参数 说明 类型 默认值 版本
themeMode 主题theme mode,默认light,支持 dark \| `dark` |
showCode 是否显示代码编辑器,只有在layout值为top生效 boolean false
source 运行示例源码 string -
layout render 视图布局 top | right | left top 0.4.0

📋 更新日志

每个版本的详细更改记录在发行说明

💡 灵感

灵感来自源于以下分享

💳 License

VCV is licensed under the terms of the MIT License .

Copyright (c) 2021-present Anduril

Extension points exported contracts — how you extend this code

Store (Interface)
(no doc) [1 implementers]
src/store.ts
StoreState (Interface)
(no doc)
src/store.ts
SFCOptions (Interface)
(no doc)
src/store.ts
StoreOptions (Interface)
(no doc)
src/store.ts

Core symbols most depended-on inside this repo

defineExport
called by 4
src/output/moduleCompiler.ts
forceSandboxReset
called by 3
src/store.ts
transformTS
called by 3
src/transform.ts
compileFile
called by 3
src/transform.ts
defineImport
called by 3
src/output/moduleCompiler.ts
setActive
called by 2
src/store.ts
initImportMap
called by 2
src/store.ts
getImportMap
called by 2
src/store.ts

Shape

Method 22
Function 17
Class 6
Interface 4

Languages

TypeScript100%

Modules by API surface

src/store.ts23 symbols
src/output/PreviewProxy.ts9 symbols
src/output/moduleCompiler.ts7 symbols
src/transform.ts5 symbols
src/utils.ts3 symbols
test/main.ts1 symbols
src/monaco/userWorker.ts1 symbols

For agents

$ claude mcp add vue-code-view \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact