mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-25 00:33:00 +08:00
perf: 优化iframe
This commit is contained in:
parent
cb54b1f51f
commit
ed93fe7818
BIN
src/assets/images/chart/informations/iframe.png
Normal file
BIN
src/assets/images/chart/informations/iframe.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.7 KiB |
@ -1,11 +1,12 @@
|
|||||||
import { PublicConfigClass } from '@/packages/public'
|
import { PublicConfigClass } from '@/packages/public'
|
||||||
import { CreateComponentType } from '@/packages/index.d'
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
|
import { chartInitConfig } from '@/settings/designSetting'
|
||||||
import { IframeConfig } from './index'
|
import { IframeConfig } from './index'
|
||||||
import cloneDeep from 'lodash/cloneDeep'
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
|
|
||||||
export const option = {
|
export const option = {
|
||||||
// 网站路径
|
// 网站路径
|
||||||
dataset: "https://www.bilibili.com/",
|
dataset: "http://www.mtruning.club:81/",
|
||||||
// 圆角
|
// 圆角
|
||||||
borderRadius: 10
|
borderRadius: 10
|
||||||
}
|
}
|
||||||
@ -13,6 +14,7 @@ export const option = {
|
|||||||
export default class Config extends PublicConfigClass implements CreateComponentType
|
export default class Config extends PublicConfigClass implements CreateComponentType
|
||||||
{
|
{
|
||||||
public key = IframeConfig.key
|
public key = IframeConfig.key
|
||||||
|
public attr = { ...chartInitConfig, w: 800, h: 800, zIndex: -1 }
|
||||||
public chartConfig = cloneDeep(IframeConfig)
|
public chartConfig = cloneDeep(IframeConfig)
|
||||||
public option = cloneDeep(option)
|
public option = cloneDeep(option)
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import image from '@/assets/images/chart/informations/photo.png'
|
import image from '@/assets/images/chart/informations/iframe.png'
|
||||||
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
|
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
|
||||||
import { ChatCategoryEnum,ChatCategoryEnumName } from '../../index.d'
|
import { ChatCategoryEnum,ChatCategoryEnumName } from '../../index.d'
|
||||||
|
|
||||||
@ -6,7 +6,7 @@ export const IframeConfig: ConfigType = {
|
|||||||
key: 'Iframe',
|
key: 'Iframe',
|
||||||
chartKey: 'VIframe',
|
chartKey: 'VIframe',
|
||||||
conKey: 'VCIframe',
|
conKey: 'VCIframe',
|
||||||
title: 'Iframe',
|
title: '远程网页',
|
||||||
category: ChatCategoryEnum.MORE,
|
category: ChatCategoryEnum.MORE,
|
||||||
categoryName: ChatCategoryEnumName.MORE,
|
categoryName: ChatCategoryEnumName.MORE,
|
||||||
package: PackagesCategoryEnum.INFORMATIONS,
|
package: PackagesCategoryEnum.INFORMATIONS,
|
||||||
|
@ -1,50 +1,49 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :style="getStyle(borderRadius)">
|
<div :style="getStyle(borderRadius)">
|
||||||
<iframe :src="option.dataset" :width="w" :height="h"></iframe>
|
<iframe :src="option.dataset" :width="w" :height="h" 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 } 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'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
chartConfig: {
|
chartConfig: {
|
||||||
type: Object as PropType<CreateComponentType>,
|
type: Object as PropType<CreateComponentType>,
|
||||||
required: true,
|
required: true
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
const { w, h } = toRefs(props.chartConfig.attr);
|
const { w, h } = toRefs(props.chartConfig.attr)
|
||||||
const { dataset, borderRadius } = toRefs(props.chartConfig.option);
|
const { borderRadius } = toRefs(props.chartConfig.option)
|
||||||
|
|
||||||
const option = shallowReactive({
|
const option = shallowReactive({
|
||||||
dataset: "",
|
dataset: ''
|
||||||
});
|
})
|
||||||
|
|
||||||
const getStyle = (radius: number) => {
|
const getStyle = (radius: number) => {
|
||||||
return {
|
return {
|
||||||
borderRadius: `${radius}px`,
|
borderRadius: `${radius}px`,
|
||||||
overflow: "hidden",
|
overflow: 'hidden'
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
// 编辑更新
|
// 编辑更新
|
||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option.dataset,
|
() => props.chartConfig.option.dataset,
|
||||||
(newData: any) => {
|
(newData: string) => {
|
||||||
option.dataset = newData;
|
option.dataset = newData
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true
|
||||||
deep: false,
|
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
|
|
||||||
// 预览更新
|
// 预览更新
|
||||||
useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
|
useChartDataFetch(props.chartConfig, useChartEditStore, (newData: string) => {
|
||||||
option.dataset = newData;
|
option.dataset = newData
|
||||||
});
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -46,8 +46,7 @@ watch(
|
|||||||
option.dataset = newData
|
option.dataset = newData
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true
|
||||||
deep: false
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -10,6 +10,6 @@ export const VideoConfig: ConfigType = {
|
|||||||
category: ChatCategoryEnum.MORE,
|
category: ChatCategoryEnum.MORE,
|
||||||
categoryName: ChatCategoryEnumName.MORE,
|
categoryName: ChatCategoryEnumName.MORE,
|
||||||
package: PackagesCategoryEnum.INFORMATIONS,
|
package: PackagesCategoryEnum.INFORMATIONS,
|
||||||
chartFrame: ChartFrameEnum.ECHARTS,
|
chartFrame: ChartFrameEnum.COMMON,
|
||||||
image
|
image
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,4 @@ import { IframeConfig } from './Iframe/index'
|
|||||||
import { VideoConfig } from './Video/index'
|
import { VideoConfig } from './Video/index'
|
||||||
import { WordCloudConfig } from './WordCloud/index'
|
import { WordCloudConfig } from './WordCloud/index'
|
||||||
|
|
||||||
export default [ImageConfig, VideoConfig, WordCloudConfig,IframeConfig]
|
export default [WordCloudConfig, ImageConfig, VideoConfig, IframeConfig]
|
||||||
|
Loading…
Reference in New Issue
Block a user