!92 新增Iframe组件

Merge pull request !92 from 自由/dev-wu-20221027
This commit is contained in:
奔跑的面条 2022-10-29 09:27:15 +00:00 committed by Gitee
commit cb54b1f51f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 121 additions and 1 deletions

View File

@ -0,0 +1,18 @@
import { PublicConfigClass } from '@/packages/public'
import { CreateComponentType } from '@/packages/index.d'
import { IframeConfig } from './index'
import cloneDeep from 'lodash/cloneDeep'
export const option = {
// 网站路径
dataset: "https://www.bilibili.com/",
// 圆角
borderRadius: 10
}
export default class Config extends PublicConfigClass implements CreateComponentType
{
public key = IframeConfig.key
public chartConfig = cloneDeep(IframeConfig)
public option = cloneDeep(option)
}

View File

@ -0,0 +1,36 @@
<template>
<collapse-item name="属性" :expanded="true">
<setting-item-box name="路径" :alone="true">
<setting-item>
<n-input v-model:value="optionData.dataset" size="small"></n-input>
</setting-item>
</setting-item-box>
<setting-item-box name="样式">
<setting-item name="圆角">
<n-input-number
v-model:value="optionData.borderRadius"
size="small"
:min="0"
placeholder="圆角"
></n-input-number>
</setting-item>
</setting-item-box>
</collapse-item>
</template>
<script setup lang="ts">
import { PropType } from "vue";
import { option } from "./config";
import {
CollapseItem,
SettingItemBox,
SettingItem,
} from "@/components/Pages/ChartItemSetting";
const props = defineProps({
optionData: {
type: Object as PropType<typeof option>,
required: true,
},
});
</script>

View File

@ -0,0 +1,15 @@
import image from '@/assets/images/chart/informations/photo.png'
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
import { ChatCategoryEnum,ChatCategoryEnumName } from '../../index.d'
export const IframeConfig: ConfigType = {
key: 'Iframe',
chartKey: 'VIframe',
conKey: 'VCIframe',
title: 'Iframe',
category: ChatCategoryEnum.MORE,
categoryName: ChatCategoryEnumName.MORE,
package: PackagesCategoryEnum.INFORMATIONS,
chartFrame: ChartFrameEnum.COMMON,
image
}

View File

@ -0,0 +1,50 @@
<template>
<div :style="getStyle(borderRadius)">
<iframe :src="option.dataset" :width="w" :height="h"></iframe>
</div>
</template>
<script setup lang="ts">
import { PropType, shallowReactive, watch, toRefs } from "vue";
import { useChartDataFetch } from "@/hooks";
import { CreateComponentType } from "@/packages/index.d";
import { useChartEditStore } from "@/store/modules/chartEditStore/chartEditStore";
const props = defineProps({
chartConfig: {
type: Object as PropType<CreateComponentType>,
required: true,
},
});
const { w, h } = toRefs(props.chartConfig.attr);
const { dataset, borderRadius } = toRefs(props.chartConfig.option);
const option = shallowReactive({
dataset: "",
});
const getStyle = (radius: number) => {
return {
borderRadius: `${radius}px`,
overflow: "hidden",
};
};
//
watch(
() => props.chartConfig.option.dataset,
(newData: any) => {
option.dataset = newData;
},
{
immediate: true,
deep: false,
}
);
//
useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
option.dataset = newData;
});
</script>

View File

@ -1,5 +1,6 @@
import { ImageConfig } from './Image/index'
import { IframeConfig } from './Iframe/index'
import { VideoConfig } from './Video/index'
import { WordCloudConfig } from './WordCloud/index'
export default [ImageConfig, VideoConfig, WordCloudConfig]
export default [ImageConfig, VideoConfig, WordCloudConfig,IframeConfig]