Commit 2cb17843940d6e7ebcbb89cd8c317a623bbb86e0
1 parent
79eaef0a
feat(packages/external): 重写远程网页,新增全屏按钮
Showing
5 changed files
with
169 additions
and
0 deletions
1 | +import { PublicConfigClass } from '@/packages/public' | ||
2 | +import { CreateComponentType } from '@/packages/index.d' | ||
3 | +import { chartInitConfig } from '@/settings/designSetting' | ||
4 | +import { OverrideIframeConfig } from './index' | ||
5 | +import cloneDeep from 'lodash/cloneDeep' | ||
6 | + | ||
7 | +export const option = { | ||
8 | + // 网站路径 | ||
9 | + dataset: "https://www.thingskit.com/", | ||
10 | + // 圆角 | ||
11 | + borderRadius: 10 | ||
12 | +} | ||
13 | + | ||
14 | +export default class Config extends PublicConfigClass implements CreateComponentType | ||
15 | +{ | ||
16 | + public key = OverrideIframeConfig.key | ||
17 | + public attr = { ...chartInitConfig, w: 1200, h: 800, zIndex: -1 } | ||
18 | + public chartConfig = cloneDeep(OverrideIframeConfig) | ||
19 | + public option = cloneDeep(option) | ||
20 | +} |
1 | +<template> | ||
2 | + <collapse-item name="属性" :expanded="true"> | ||
3 | + <setting-item-box name="路径" :alone="true"> | ||
4 | + <setting-item name="请填写 https 协议的网址"> | ||
5 | + <n-input v-model:value="optionData.dataset" size="small"></n-input> | ||
6 | + </setting-item> | ||
7 | + </setting-item-box> | ||
8 | + <setting-item-box name="样式"> | ||
9 | + <setting-item name="圆角"> | ||
10 | + <n-input-number | ||
11 | + v-model:value="optionData.borderRadius" | ||
12 | + size="small" | ||
13 | + :min="0" | ||
14 | + placeholder="圆角" | ||
15 | + ></n-input-number> | ||
16 | + </setting-item> | ||
17 | + </setting-item-box> | ||
18 | + </collapse-item> | ||
19 | +</template> | ||
20 | + | ||
21 | +<script setup lang="ts"> | ||
22 | +import { PropType } from "vue"; | ||
23 | +import { option } from "./config"; | ||
24 | +import { | ||
25 | + CollapseItem, | ||
26 | + SettingItemBox, | ||
27 | + SettingItem, | ||
28 | +} from "@/components/Pages/ChartItemSetting"; | ||
29 | + | ||
30 | +const props = defineProps({ | ||
31 | + optionData: { | ||
32 | + type: Object as PropType<typeof option>, | ||
33 | + required: true, | ||
34 | + }, | ||
35 | +}); | ||
36 | +</script> |
1 | +import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d' | ||
2 | +import { ChatCategoryEnum, ChatCategoryEnumName } from '@/packages/components/Informations/index.d' | ||
3 | +import { useWidgetKey } from '@/packages/external/useWidgetKey' | ||
4 | + | ||
5 | +const { key, conKey, chartKey } = useWidgetKey('OverrideIframe', true) | ||
6 | + | ||
7 | +export const OverrideIframeConfig: ConfigType = { | ||
8 | + key, | ||
9 | + chartKey, | ||
10 | + conKey, | ||
11 | + title: '自定义远程网页', | ||
12 | + category: ChatCategoryEnum.MORE, | ||
13 | + categoryName: ChatCategoryEnumName.MORE, | ||
14 | + package: PackagesCategoryEnum.INFORMATIONS, | ||
15 | + chartFrame: ChartFrameEnum.COMMON, | ||
16 | + image: 'iframe.png' | ||
17 | +} |
1 | +<template> | ||
2 | + <div :style="getStyle(borderRadius)"> | ||
3 | + <div v-show="isShowSvg" @click="handleFullScreen" class="fullscreen-button"> | ||
4 | + <svg | ||
5 | + focusable="false" | ||
6 | + class="" | ||
7 | + data-icon="fullscreen" | ||
8 | + width="1em" | ||
9 | + height="1em" | ||
10 | + fill="currentColor" | ||
11 | + aria-hidden="true" | ||
12 | + viewBox="64 64 896 896" | ||
13 | + > | ||
14 | + <path | ||
15 | + d="M290 236.4l43.9-43.9a8.01 8.01 0 00-4.7-13.6L169 160c-5.1-.6-9.5 3.7-8.9 8.9L179 329.1c.8 6.6 8.9 9.4 13.6 4.7l43.7-43.7L370 423.7c3.1 3.1 8.2 3.1 11.3 0l42.4-42.3c3.1-3.1 3.1-8.2 0-11.3L290 236.4zm352.7 187.3c3.1 3.1 8.2 3.1 11.3 0l133.7-133.6 43.7 43.7a8.01 8.01 0 0013.6-4.7L863.9 169c.6-5.1-3.7-9.5-8.9-8.9L694.8 179c-6.6.8-9.4 8.9-4.7 13.6l43.9 43.9L600.3 370a8.03 8.03 0 000 11.3l42.4 42.4zM845 694.9c-.8-6.6-8.9-9.4-13.6-4.7l-43.7 43.7L654 600.3a8.03 8.03 0 00-11.3 0l-42.4 42.3a8.03 8.03 0 000 11.3L734 787.6l-43.9 43.9a8.01 8.01 0 004.7 13.6L855 864c5.1.6 9.5-3.7 8.9-8.9L845 694.9zm-463.7-94.6a8.03 8.03 0 00-11.3 0L236.3 733.9l-43.7-43.7a8.01 8.01 0 00-13.6 4.7L160.1 855c-.6 5.1 3.7 9.5 8.9 8.9L329.2 845c6.6-.8 9.4-8.9 4.7-13.6L290 787.6 423.7 654c3.1-3.1 3.1-8.2 0-11.3l-42.4-42.4z" | ||
16 | + ></path> | ||
17 | + </svg> | ||
18 | + </div> | ||
19 | + <iframe | ||
20 | + @mouseenter="handleMouseenter" | ||
21 | + @mouseleave="handleMouseleave" | ||
22 | + id="iframe-content" | ||
23 | + :src="option.dataset" | ||
24 | + :width="w" | ||
25 | + :height="h" | ||
26 | + style="border-width: 0" | ||
27 | + ></iframe> | ||
28 | + </div> | ||
29 | +</template> | ||
30 | + | ||
31 | +<script setup lang="ts"> | ||
32 | +import { PropType, shallowReactive, watch, toRefs, ref } from 'vue' | ||
33 | +import { useChartDataFetch } from '@/hooks' | ||
34 | +import { CreateComponentType } from '@/packages/index.d' | ||
35 | +import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' | ||
36 | +import { useFullScreen } from '@/packages/components/external/Charts/utls/fullScreen' | ||
37 | + | ||
38 | +const props = defineProps({ | ||
39 | + chartConfig: { | ||
40 | + type: Object as PropType<CreateComponentType>, | ||
41 | + required: true | ||
42 | + } | ||
43 | +}) | ||
44 | + | ||
45 | +const isShowSvg = ref(false) | ||
46 | + | ||
47 | +const { w, h } = toRefs(props.chartConfig.attr) | ||
48 | +const { borderRadius } = toRefs(props.chartConfig.option) | ||
49 | + | ||
50 | +const option = shallowReactive({ | ||
51 | + dataset: '' | ||
52 | +}) | ||
53 | + | ||
54 | +const getStyle = (radius: number) => { | ||
55 | + return { | ||
56 | + borderRadius: `${radius}px`, | ||
57 | + overflow: 'hidden' | ||
58 | + } | ||
59 | +} | ||
60 | + | ||
61 | +// 编辑更新 | ||
62 | +watch( | ||
63 | + () => props.chartConfig.option.dataset, | ||
64 | + (newData: string) => { | ||
65 | + option.dataset = newData | ||
66 | + }, | ||
67 | + { | ||
68 | + immediate: true | ||
69 | + } | ||
70 | +) | ||
71 | + | ||
72 | +// 预览更新 | ||
73 | +useChartDataFetch(props.chartConfig, useChartEditStore, (newData: string) => { | ||
74 | + option.dataset = newData | ||
75 | +}) | ||
76 | + | ||
77 | +const handleFullScreen = () => { | ||
78 | + const domName = document.getElementById('iframe-content') as HTMLElement | ||
79 | + const htmlName = document.querySelector('html') as HTMLHtmlElement | ||
80 | + useFullScreen(domName, htmlName) | ||
81 | +} | ||
82 | + | ||
83 | +const handleMouseenter = () => (isShowSvg.value = true) | ||
84 | +const handleMouseleave = () => (isShowSvg.value = false) | ||
85 | +</script> | ||
86 | + | ||
87 | +<style lang="scss" scoped> | ||
88 | +.fullscreen-button { | ||
89 | + cursor: pointer; | ||
90 | + position: absolute; | ||
91 | + right: 0; | ||
92 | + top: 0; | ||
93 | +} | ||
94 | +</style> |
@@ -9,6 +9,7 @@ import { OverrideSelectConfig } from '@/packages/components/external/Information | @@ -9,6 +9,7 @@ import { OverrideSelectConfig } from '@/packages/components/external/Information | ||
9 | import { OverrideInputsDateConfig } from '@/packages/components/external/Informations/Mores/OverrideInputsDate' | 9 | import { OverrideInputsDateConfig } from '@/packages/components/external/Informations/Mores/OverrideInputsDate' |
10 | import { OverrideInputsTabConfig } from '@/packages/components/external/Informations/Mores/OverrideInputsTab' | 10 | import { OverrideInputsTabConfig } from '@/packages/components/external/Informations/Mores/OverrideInputsTab' |
11 | import { OverrideTextCommonConfig } from '@/packages/components/external/Informations/Mores/OverrideTextCommon' | 11 | import { OverrideTextCommonConfig } from '@/packages/components/external/Informations/Mores/OverrideTextCommon' |
12 | +import { OverrideIframeConfig } from '@/packages/components/external/Informations/Mores/OverrideIframe' | ||
12 | import { ButtonConfig } from '@/packages/components/external/Informations/Mores/Button' | 13 | import { ButtonConfig } from '@/packages/components/external/Informations/Mores/Button' |
13 | import { OverrideBarCommonConfig } from '@/packages/components/external/Charts/Bars/OverrideBarCommon' | 14 | import { OverrideBarCommonConfig } from '@/packages/components/external/Charts/Bars/OverrideBarCommon' |
14 | import { OverrideLineCommonConfig } from '@/packages/components/external/Charts/Lines/OverrideLineCommon' | 15 | import { OverrideLineCommonConfig } from '@/packages/components/external/Charts/Lines/OverrideLineCommon' |
@@ -27,6 +28,7 @@ export function useInjectLib(packagesList: EPackagesType) { | @@ -27,6 +28,7 @@ export function useInjectLib(packagesList: EPackagesType) { | ||
27 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideInputsTabConfig) | 28 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideInputsTabConfig) |
28 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideTextCommonConfig) | 29 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideTextCommonConfig) |
29 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, ButtonConfig) | 30 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, ButtonConfig) |
31 | + addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideIframeConfig) | ||
30 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideBarCommonConfig) | 32 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideBarCommonConfig) |
31 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideLineCommonConfig) | 33 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideLineCommonConfig) |
32 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideLineGradientsConfig) | 34 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideLineGradientsConfig) |