kagg886 1 月之前
父节点
当前提交
d0856d7ad7
共有 2 个文件被更改,包括 9 次插入2 次删除
  1. 8 1
      src/components/assistant/ComponentLibrary.vue
  2. 1 1
      src/components/assistant/DashboardDesigner.vue

+ 8 - 1
src/components/assistant/ComponentLibrary.vue

@@ -5,6 +5,7 @@ import Markdown from '/@/components/markdown/Markdown.vue'
 import type { ComponentLibraryItem, Content } from './types'
 import { MarkdownPlugin } from '/@/components/markdown/type/markdown'
 import EChartsPlugin from '/@/components/markdown/plugins/echarts'
+import VueCharts from '/@/components/markdown/plugins/impl/VueCharts.vue'
 
 const plugin: Array<MarkdownPlugin<any>> = [EChartsPlugin()]
 
@@ -25,7 +26,8 @@ const handleDragStart = (event: DragEvent, component: any) => {
 
 	event.dataTransfer.setData('text/plain', JSON.stringify({
 		title: component.title,
-		data: component.data
+		data: component.data,
+		type: component.type
 	}))
 
 	event.dataTransfer.effectAllowed = 'copy'
@@ -81,11 +83,14 @@ const openPreview = (component: any) => {
 					</div>
 
 					<div class="component-preview">
+
 						<Markdown
+							v-if="component.type === 'markdown'"
 							:content="component.preview"
 							:plugins="plugin"
 							class="preview-content"
 						/>
+						<vue-charts style="width: 100%;height: 200px" :data="component.data" v-if="component.type === 'echarts'"/>
 					</div>
 
 					<div class="component-actions">
@@ -131,7 +136,9 @@ const openPreview = (component: any) => {
 			v-if="previewComponent"
 		>
 			<div class="preview-dialog-content">
+				<vue-charts style="width: 100%;height: 400px" :data="previewComponent.data" v-if="previewComponent.type === 'echarts'"/>
 				<Markdown
+					v-if="previewComponent.type === 'markdown'"
 					:content="previewComponent.data"
 					:plugins="plugin"
 					class="full-preview-content"

+ 1 - 1
src/components/assistant/DashboardDesigner.vue

@@ -61,7 +61,7 @@ const handleDrop = (event: DragEvent) => {
 			// 限制在画布范围内
 			const constrainedX = Math.max(0, Math.min(70, x)) // 预留30%宽度
 			const constrainedY = Math.max(0, Math.min(75, y)) // 预留25%高度
-
+			debugger
 			emit('addCard', {
 				...componentData,
 				x: constrainedX,