feat: 新增iframe组件

This commit is contained in:
huanghao1412 2024-03-07 17:41:01 +08:00
parent d07f25045c
commit ae1219dea7
6 changed files with 39 additions and 24 deletions

2
.gitignore vendored
View File

@ -1,6 +1,6 @@
node_modules node_modules
.DS_Store .DS_Store
dist customLargeScreen
dist-ssr dist-ssr
*.local *.local
.vscode .vscode

View File

@ -1,5 +1,5 @@
import path from 'path' import path from 'path'
export const OUTPUT_DIR = 'dist' export const OUTPUT_DIR = 'customLargeScreen'
// monaco-editor 路径 // monaco-editor 路径
export const prefix = `monaco-editor/esm/vs` export const prefix = `monaco-editor/esm/vs`

View File

@ -6,7 +6,7 @@ import cloneDeep from 'lodash/cloneDeep'
export const option = { export const option = {
// 网站路径 // 网站路径
dataset: "https://www.mtruning.club/", dataset: "",
// 圆角 // 圆角
borderRadius: 10 borderRadius: 10
} }

View File

@ -1,14 +1,15 @@
<template> <template>
<div :style="getStyle(borderRadius)"> <div :style="getStyle(borderRadius)">
<iframe :src="option.dataset" :width="w" :height="h" style="border-width: 0"></iframe> <iframe :src="src" :width="w" :height="h" allowfullscreen style="border-width: 0"></iframe>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { PropType, shallowReactive, watch, toRefs } from 'vue' import { PropType, shallowReactive, watch, toRefs, ref, computed } from 'vue'
import { useChartDataFetch } from '@/hooks' import { useChartDataFetch } from '@/hooks'
import { CreateComponentType } from '@/packages/index.d' import { CreateComponentType } from '@/packages/index.d'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import {debounce} from 'lodash'
const props = defineProps({ const props = defineProps({
chartConfig: { chartConfig: {
@ -20,9 +21,23 @@ const props = defineProps({
const { w, h } = toRefs(props.chartConfig.attr) const { w, h } = toRefs(props.chartConfig.attr)
const { borderRadius } = toRefs(props.chartConfig.option) const { borderRadius } = toRefs(props.chartConfig.option)
const option = shallowReactive({ // const option = shallowReactive({
dataset: '' // dataset: ''
}) // })
let src = ref('')
const setValue = debounce((v: string) => {
src.value = v
}, 1000)
watch(
() => props.chartConfig.option.dataset,
(v: string) => {
setValue(v)
},
{
immediate: true
}
)
const getStyle = (radius: number) => { const getStyle = (radius: number) => {
return { return {
@ -31,19 +46,19 @@ const getStyle = (radius: number) => {
} }
} }
// // //
watch( // watch(
() => props.chartConfig.option.dataset, // () => props.chartConfig.option.dataset,
(newData: string) => { // (newData: string) => {
option.dataset = newData // option.dataset = newData
}, // },
{ // {
immediate: true // immediate: true
} // }
) // )
// // //
useChartDataFetch(props.chartConfig, useChartEditStore, (newData: string) => { // useChartDataFetch(props.chartConfig, useChartEditStore, (newData: string) => {
option.dataset = newData // option.dataset = newData
}) // })
</script> </script>

View File

@ -5,4 +5,4 @@ import { VideoConfig } from './Video/index'
import { WordCloudConfig } from './WordCloud/index' import { WordCloudConfig } from './WordCloud/index'
// export default [VideoConfig] // export default [VideoConfig]
export default [] export default [IframeConfig]

View File

@ -14,7 +14,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { PropType } from "vue/dist/vue"; import { PropType } from "vue";
import { option } from './config' import { option } from './config'
import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'