diff --git a/src/custom-border/custom-dv-1/custom-dv-1.scss b/src/custom-border/custom-dv-1/custom-dv-1.scss index 2cc667922df170a61fac0ca34e96dffdd6f2cfaf..876ca0e7f6e1bb17639d654606e234ced0e31dd1 100644 --- a/src/custom-border/custom-dv-1/custom-dv-1.scss +++ b/src/custom-border/custom-dv-1/custom-dv-1.scss @@ -1,8 +1,13 @@ +$style-1: ( + 'offsetY': 0, +); + @include b(custom-border) { + @include set-component-css-var(style-1, $style-1); @include when(style-1) { position: relative; width: 100%; - height: 100%; + height: calc(100% - getCssVar(style-1,'offsetY')); @include e(border-box) { z-index: 100; height: 0; diff --git a/src/custom-border/custom-dv-1/custom-dv-1.tsx b/src/custom-border/custom-dv-1/custom-dv-1.tsx index b6a8717ec73cd6a6f0a3afcee06a3cb5b1f89a27..edb238b6d5d31b09d6e6f4e12c210c9d25d4fda0 100644 --- a/src/custom-border/custom-dv-1/custom-dv-1.tsx +++ b/src/custom-border/custom-dv-1/custom-dv-1.tsx @@ -1,3 +1,4 @@ +/* eslint-disable vue/require-prop-types */ import { defineComponent, onMounted, @@ -19,14 +20,18 @@ import './custom-dv-1.scss'; export const CustomDV1 = defineComponent({ name: 'CustomDV1', props: { + offsetX: { + style: Number, + default: 0, + }, + offsetY: { + style: Number, + default: 0, + }, color: { type: Array as PropType, default: () => [], }, - backgroundColor: { - type: String, - default: 'transparent', - }, }, setup(props) { const ns = useNamespace('custom-border'); @@ -38,35 +43,36 @@ export const CustomDV1 = defineComponent({ const mergedColor = computed(() => { return deepMerge(defaultColor, props.color || []) as string[]; }); + + const backgroundColor = 'var(--ibiz-screen-dashboard-custom-dv-bg)'; /** * 绘制边框svg */ const renderBorder = () => { + const _width = width.value - props.offsetX; + const _height = height.value - props.offsetY; + const padding = 8; return (
- + +
{this.renderBorder()}
{this.$slots.default?.()}
diff --git a/src/custom-border/custom-dv-10/custom-dv-10.scss b/src/custom-border/custom-dv-10/custom-dv-10.scss index 8ab5442c1415c6c1924592f44417d2d200017931..1e513d3e6c4f0d0cdc47617d25e38799f1b3850e 100644 --- a/src/custom-border/custom-dv-10/custom-dv-10.scss +++ b/src/custom-border/custom-dv-10/custom-dv-10.scss @@ -1,13 +1,27 @@ +$style-10: ( + 'offsetY': 0, + 'padding': 0, +); + @include b(custom-border) { + @include set-component-css-var(style-10, $style-10); + @include when(style-10) { position: relative; width: 100%; - height: 100%; - border-radius: 10px; + height: calc(100% - getCssVar(style-10, 'offsetY')); @include e(border-box) { z-index: 100; height: 0; } + @include e(mask) { + position: absolute; + top: getCssVar(style-10, 'padding'); + left: getCssVar(style-10, 'padding'); + width: calc(100% - 2 * getCssVar(style-10, 'padding')); + height: calc(100% - 2 * getCssVar(style-10, 'padding')); + border-radius: 10px; + } @include e(border-svg) { @include m(container) { position: absolute; diff --git a/src/custom-border/custom-dv-10/custom-dv-10.tsx b/src/custom-border/custom-dv-10/custom-dv-10.tsx index 242c8c82337bf7617101392fa82dcf3d44356182..13d10f1fec351f8ef625fd840accbb2cbb2751e7 100644 --- a/src/custom-border/custom-dv-10/custom-dv-10.tsx +++ b/src/custom-border/custom-dv-10/custom-dv-10.tsx @@ -1,3 +1,4 @@ +/* eslint-disable vue/require-prop-types */ import { defineComponent, onMounted, @@ -19,14 +20,18 @@ import './custom-dv-10.scss'; export const CustomDV10 = defineComponent({ name: 'CustomDV10', props: { + offsetX: { + style: Number, + default: 0, + }, + offsetY: { + style: Number, + default: 0, + }, color: { type: Array as PropType, default: () => [], }, - backgroundColor: { - type: String, - default: 'transparent', - }, }, setup(props) { const ns = useNamespace('custom-border'); @@ -38,6 +43,9 @@ export const CustomDV10 = defineComponent({ const mergedColor = computed(() => { return deepMerge(defaultColor, props.color || []) as string[]; }); + const backgroundColor = 'var(--ibiz-screen-dashboard-custom-dv-bg)'; + const offsety = ref(props.offsetY); + const padding = ref(8); /** * 绘制边框svg */ @@ -47,13 +55,22 @@ export const CustomDV10 = defineComponent({ {border.map((item: string) => ( ))} @@ -83,6 +100,9 @@ export const CustomDV10 = defineComponent({ customDv10, mergedColor, renderBorder, + backgroundColor, + padding, + offsety, }; }, render() { @@ -90,9 +110,13 @@ export const CustomDV10 = defineComponent({
{this.renderBorder()} +
{this.$slots.default?.()}
); diff --git a/src/custom-border/custom-dv-11/custom-dv-11.tsx b/src/custom-border/custom-dv-11/custom-dv-11.tsx index a952c61ca51f9b66bf17d6504f1240617cbabea6..3f42f6616d94006f8f78ea485b924f3fb84dc5ed 100644 --- a/src/custom-border/custom-dv-11/custom-dv-11.tsx +++ b/src/custom-border/custom-dv-11/custom-dv-11.tsx @@ -1,3 +1,4 @@ +/* eslint-disable vue/require-prop-types */ import { createUUID } from 'qx-util'; import { defineComponent, @@ -21,6 +22,14 @@ import './custom-dv-11.scss'; export const CustomDV11 = defineComponent({ name: 'CustomDV11', props: { + offsetX: { + style: Number, + default: 0, + }, + offsetY: { + style: Number, + default: 0, + }, color: { type: Array as PropType, default: () => [], @@ -33,10 +42,6 @@ export const CustomDV11 = defineComponent({ type: String, default: '', }, - backgroundColor: { - type: String, - default: 'transparent', - }, }, setup(props) { const ns = useNamespace('custom-border'); @@ -49,15 +54,20 @@ export const CustomDV11 = defineComponent({ const mergedColor = computed(() => { return deepMerge(defaultColor, props.color || []) as string[]; }); + const backgroundColor = 'var(--ibiz-screen-dashboard-custom-dv-bg)'; + /** * 绘制边框svg */ const renderBorder = () => { + const _width = width.value - props.offsetX; + const _height = height.value - props.offsetY; + const padding = 8; return ( @@ -155,12 +162,12 @@ export const CustomDV11 = defineComponent({ stroke={mergedColor.value[0]} fill='transparent' points={` - ${(width.value - props.titleWidth) / 2 + 5}, 30 ${ + ${(width.value - props.titleWidth) / 2 + 5}, ${30 + padding} ${ (width.value - props.titleWidth) / 2 + 22 - }, 49 - ${(width.value - props.titleWidth) / 2 + 28}, 49 ${ + }, ${49 + padding} + ${(width.value - props.titleWidth) / 2 + 28}, ${49 + padding} ${ (width.value - props.titleWidth) / 2 + 8 - }, 26 + }, ${26 + padding} `} /> @@ -169,15 +176,15 @@ export const CustomDV11 = defineComponent({ fill={fade(mergedColor.value[1] || defaultColor[1], 30) || ''} filter={`url(#${filterId.value})`} points={` - ${(width.value + props.titleWidth) / 2 - 11}, 37 ${ + ${(width.value + props.titleWidth) / 2 - 11}, ${37 + padding} ${ (width.value + props.titleWidth) / 2 - 32 - }, 11 - ${(width.value - props.titleWidth) / 2 + 23}, 11 ${ + }, ${11 + padding} + ${(width.value - props.titleWidth) / 2 + 23}, ${11 + padding} ${ (width.value - props.titleWidth) / 2 + 11 - }, 23 - ${(width.value - props.titleWidth) / 2 + 33}, 49 ${ + }, ${23 + padding} + ${(width.value - props.titleWidth) / 2 + 33}, ${49 + padding} ${ (width.value + props.titleWidth) / 2 - 22 - }, 49 + }, ${49 + padding} `} /> @@ -186,12 +193,12 @@ export const CustomDV11 = defineComponent({ fill={mergedColor.value[0]} opacity='1' points={` - ${(width.value - props.titleWidth) / 2 - 10}, 37 ${ + ${(width.value - props.titleWidth) / 2 - 10}, ${37 + padding} ${ (width.value - props.titleWidth) / 2 - 31 - }, 37 - ${(width.value - props.titleWidth) / 2 - 25}, 46 ${ + }, ${37 + padding} + ${(width.value - props.titleWidth) / 2 - 25}, ${46 + padding} ${ (width.value - props.titleWidth) / 2 - 4 - }, 46 + }, ${46 + padding} `} > diff --git a/src/custom-border/custom-dv-12/custom-dv-12.scss b/src/custom-border/custom-dv-12/custom-dv-12.scss index 5473adf3776afef2d01dfe84ecd3e4ae80ba8bb1..e5452d79584ec82daea1073e6abecbc18d7ad9c6 100644 --- a/src/custom-border/custom-dv-12/custom-dv-12.scss +++ b/src/custom-border/custom-dv-12/custom-dv-12.scss @@ -1,4 +1,10 @@ +$style-12: ( + 'offsetY': 0, +); + @include b('custom-border') { + @include set-component-css-var(style-12, $style-12); + @include when(style-12) { position: relative; width: 100%; @@ -11,7 +17,8 @@ top: 0; left: 0; width: 100%; - height: 100%; + height: calc(100% - getCssVar(style-12,'offsetY')); + & > polyline { fill: none; diff --git a/src/custom-border/custom-dv-12/custom-dv-12.tsx b/src/custom-border/custom-dv-12/custom-dv-12.tsx index 2ef6dd3c9c01e2ec5e9e20d383360b282d866b6a..6b91c941ae2bf5af6511292e2c0cd2197e733ae1 100644 --- a/src/custom-border/custom-dv-12/custom-dv-12.tsx +++ b/src/custom-border/custom-dv-12/custom-dv-12.tsx @@ -1,3 +1,4 @@ +/* eslint-disable vue/require-prop-types */ import { ComponentInternalInstance, PropType, @@ -17,14 +18,18 @@ import './custom-dv-12.scss'; export const CustomDV12 = defineComponent({ name: 'CustomDV12', props: { + offsetX: { + style: Number, + default: 0, + }, + offsetY: { + style: Number, + default: 0, + }, color: { type: Array as PropType, default: () => [], }, - backgroundColor: { - type: String, - default: 'transparent', - }, }, setup(props) { const ns = useNamespace('custom-border'); @@ -38,6 +43,7 @@ export const CustomDV12 = defineComponent({ let domObserver: MutationObserver | null; const id = uuid(false); const filterId = `borderr-box-12-filterId-${id}`; + const backgroundColor = 'var(--ibiz-screen-dashboard-custom-dv-bg)'; /** * 初始化宽高 @@ -150,10 +156,16 @@ export const CustomDV12 = defineComponent({ * 绘制边框 */ const renderBorder = () => { - const _width = width.value; - const _height = height.value; + const _width = width.value - props.offsetX; + const _height = height.value - props.offsetY; + const padding = 8; return ( - + {_width && _height ? ( ) : null} @@ -215,18 +225,16 @@ export const CustomDV12 = defineComponent({ stroke-linecap='round' filter={`url(#${filterId})`} stroke={mergedColor.value[1]} - d={`M 20 5 L 15 5 Q 5 5 5 15 L 5 20`} + d={`M ${20 + padding} 5 L ${15 + padding} 5 Q ${5 + padding} 5 ${5 + padding} 15 L ${5 + padding} ${_height - 5 - padding}`} /> ); diff --git a/src/custom-border/custom-dv-13/custom-dv-13.scss b/src/custom-border/custom-dv-13/custom-dv-13.scss index 946a8d1eec488f5c3cc0f1387f61981e24d9e592..8853391d1a83222ade523b15caa090048b7544a5 100644 --- a/src/custom-border/custom-dv-13/custom-dv-13.scss +++ b/src/custom-border/custom-dv-13/custom-dv-13.scss @@ -1,4 +1,9 @@ +$style-13: ( + 'offsetY': 0, +); + @include b(custom-border) { + @include set-component-css-var(style-13, $style-13); @include when(style-13) { position: relative; width: 100%; @@ -9,7 +14,7 @@ top: 0; left: 0; width: 100%; - height: 100%; + height: calc(100% - getCssVar(style-13,'offsetY')); } } } diff --git a/src/custom-border/custom-dv-13/custom-dv-13.tsx b/src/custom-border/custom-dv-13/custom-dv-13.tsx index e92c16147e7147db373a1f30eed0e1349a1dc94b..a0370a4125a17b3e7651b8655caf2eadf8513084 100644 --- a/src/custom-border/custom-dv-13/custom-dv-13.tsx +++ b/src/custom-border/custom-dv-13/custom-dv-13.tsx @@ -1,3 +1,4 @@ +/* eslint-disable vue/require-prop-types */ import { defineComponent, onMounted, @@ -19,14 +20,18 @@ import './custom-dv-13.scss'; export const CustomDV13 = defineComponent({ name: 'CustomDV13', props: { + offsetX: { + style: Number, + default: 0, + }, + offsetY: { + style: Number, + default: 0, + }, color: { type: Array as PropType, default: () => [], }, - backgroundColor: { - type: String, - default: 'transparent', - }, }, setup(props) { const ns = useNamespace('custom-border'); @@ -37,25 +42,32 @@ export const CustomDV13 = defineComponent({ const mergedColor = computed(() => { return deepMerge(defaultColor, props.color || []) as string[]; }); + const backgroundColor = 'var(--ibiz-screen-dashboard-custom-dv-bg)'; + /** * 绘制边框svg */ const renderBorder = () => { + const _width = width.value - props.offsetX; + const _height = height.value - props.offsetY; + const padding = 8; return ( ); diff --git a/src/custom-border/custom-dv-2/custom-dv-2.scss b/src/custom-border/custom-dv-2/custom-dv-2.scss index e891e216b861418996be47a8c9a72170c0528920..65c5a835c5abdfc20da7701f43e9306844e0d91a 100644 --- a/src/custom-border/custom-dv-2/custom-dv-2.scss +++ b/src/custom-border/custom-dv-2/custom-dv-2.scss @@ -1,4 +1,9 @@ +$style-2: ( + 'offsetY': 0, +); + @include b(custom-border) { + @include set-component-css-var(style-2, $style-2); @include when(style-2) { position: relative; z-index: 1; @@ -11,6 +16,7 @@ left: 0; width: 100%; height: 100%; + height: calc(100% - getCssVar(style-2,'offsetY')); & > polyline { fill: none; diff --git a/src/custom-border/custom-dv-2/custom-dv-2.tsx b/src/custom-border/custom-dv-2/custom-dv-2.tsx index 0a8f7e43d1f4ec8c7515fd569f6a14aa898e2c0c..fe95ceadf037ed9378fec3048275eee30665e0b6 100644 --- a/src/custom-border/custom-dv-2/custom-dv-2.tsx +++ b/src/custom-border/custom-dv-2/custom-dv-2.tsx @@ -1,3 +1,4 @@ +/* eslint-disable vue/require-prop-types */ import { defineComponent, onMounted, @@ -19,14 +20,18 @@ import './custom-dv-2.scss'; export const CustomDV2 = defineComponent({ name: 'CustomDV2', props: { + offsetX: { + style: Number, + default: 0, + }, + offsetY: { + style: Number, + default: 0, + }, color: { type: Array as PropType, default: () => [], }, - backgroundColor: { - type: String, - default: 'transparent', - }, }, setup(props) { const ns = useNamespace('custom-border'); @@ -37,54 +42,74 @@ export const CustomDV2 = defineComponent({ const mergedColor = computed(() => { return deepMerge(defaultColor, props.color || []) as string[]; }); + const backgroundColor = 'var(--ibiz-screen-dashboard-custom-dv-bg)'; + /** * 绘制边框svg */ const renderBorder = () => { + const _width = width.value - props.offsetX; + const _height = height.value - props.offsetY; + const padding = 8; return ( + - diff --git a/src/custom-border/custom-dv-3/custom-dv-3.scss b/src/custom-border/custom-dv-3/custom-dv-3.scss index 27c84461a00f279409367b7c2111a7b3db3e330b..532899959ce8c8276d45560f3ecee9fddb189b5d 100644 --- a/src/custom-border/custom-dv-3/custom-dv-3.scss +++ b/src/custom-border/custom-dv-3/custom-dv-3.scss @@ -1,4 +1,10 @@ +$style-3: ( + 'offsetY': 0, +); + @include b(custom-border) { + @include set-component-css-var(style-3, $style-3); + @include when(style-3) { position: relative; z-index: 1; @@ -10,7 +16,8 @@ top: 0; left: 0; width: 100%; - height: 100%; + height: calc(100% - getCssVar(style-3,'offsetY')); + & > polyline { fill: none; diff --git a/src/custom-border/custom-dv-3/custom-dv-3.tsx b/src/custom-border/custom-dv-3/custom-dv-3.tsx index 019835eec80543c92382a3cfea2ab45fb9ed3e22..d426b9e629aa0fdda7909aa16644102de3432913 100644 --- a/src/custom-border/custom-dv-3/custom-dv-3.tsx +++ b/src/custom-border/custom-dv-3/custom-dv-3.tsx @@ -1,3 +1,4 @@ +/* eslint-disable vue/require-prop-types */ import { defineComponent, onMounted, @@ -19,14 +20,18 @@ import './custom-dv-3.scss'; export const CustomDV3 = defineComponent({ name: 'CustomDV3', props: { + offsetX: { + style: Number, + default: 0, + }, + offsetY: { + style: Number, + default: 0, + }, color: { type: Array as PropType, default: () => [], }, - backgroundColor: { - type: String, - default: 'transparent', - }, }, setup(props) { const ns = useNamespace('custom-border'); @@ -37,52 +42,74 @@ export const CustomDV3 = defineComponent({ const mergedColor = computed(() => { return deepMerge(defaultColor, props.color || []) as string[]; }); + const backgroundColor = 'var(--ibiz-screen-dashboard-custom-dv-bg)'; /** * 绘制边框svg */ const renderBorder = () => { + const _width = width.value - props.offsetX; + const _height = height.value - props.offsetY; + const padding = 8; return ( ); diff --git a/src/custom-border/custom-dv-4/custom-dv-4.scss b/src/custom-border/custom-dv-4/custom-dv-4.scss index 3adfa368ad6165760b82204f782a84b3c2ecfb56..4c77d8bb9277d2f9f3f874eed101b6f533b6c2cd 100644 --- a/src/custom-border/custom-dv-4/custom-dv-4.scss +++ b/src/custom-border/custom-dv-4/custom-dv-4.scss @@ -1,5 +1,11 @@ /* stylelint-disable scss/at-extend-no-missing-placeholder */ +$style-4: ( + 'offsetY': 0, +); + @include b('custom-border') { + @include set-component-css-var(style-4, $style-4); + @include when(style-4) { position: relative; width: 100%; @@ -12,7 +18,7 @@ top: 0; left: 0; width: 100%; - height: 100%; + height: calc(100% - getCssVar(style-4,'offsetY')); & > polyline { fill: none; diff --git a/src/custom-border/custom-dv-4/custom-dv-4.tsx b/src/custom-border/custom-dv-4/custom-dv-4.tsx index 1381ca805a0f5dc230d44e0a45da68a2fd97b6ad..9422c460417e98594bd2dc1470da4bb94dfb8de8 100644 --- a/src/custom-border/custom-dv-4/custom-dv-4.tsx +++ b/src/custom-border/custom-dv-4/custom-dv-4.tsx @@ -1,3 +1,4 @@ +/* eslint-disable vue/require-prop-types */ import { ComponentInternalInstance, PropType, @@ -17,6 +18,14 @@ import './custom-dv-4.scss'; export const CustomDV4 = defineComponent({ name: 'CustomDV4', props: { + offsetX: { + style: Number, + default: 0, + }, + offsetY: { + style: Number, + default: 0, + }, color: { type: Array as PropType, default: () => [], @@ -25,10 +34,6 @@ export const CustomDV4 = defineComponent({ type: Boolean, default: false, }, - backgroundColor: { - type: String, - default: 'transparent', - }, }, setup(props) { const ns = useNamespace('custom-border'); @@ -40,7 +45,7 @@ export const CustomDV4 = defineComponent({ | MutationCallback | EventListenerOrEventListenerObject; let domObserver: MutationObserver | null; - + const backgroundColor = 'var(--ibiz-screen-dashboard-custom-dv-bg)'; /** * 初始化宽高 * @param resize @@ -152,78 +157,126 @@ export const CustomDV4 = defineComponent({ * 绘制边框 */ const renderBorder = () => { + const _width = width.value - props.offsetX; + const _height = height.value - props.offsetY; + const padding = 8; return ( ); diff --git a/src/custom-border/custom-dv-5/custom-dv-5.scss b/src/custom-border/custom-dv-5/custom-dv-5.scss index 37a0b05193ab0454ab9a33147f1bc30104e2fdb8..4b9d332d49ffd256757c796571142c6cc7898976 100644 --- a/src/custom-border/custom-dv-5/custom-dv-5.scss +++ b/src/custom-border/custom-dv-5/custom-dv-5.scss @@ -1,4 +1,9 @@ +$style-5: ( + 'offsetY': 0, +); + @include b('custom-border') { + @include set-component-css-var(style-5, $style-5); @include when(style-5) { position: relative; width: 100%; @@ -11,7 +16,7 @@ top: 0; left: 0; width: 100%; - height: 100%; + height: calc(100% - getCssVar(style-5,'offsetY')); & > polyline { fill: none; diff --git a/src/custom-border/custom-dv-5/custom-dv-5.tsx b/src/custom-border/custom-dv-5/custom-dv-5.tsx index 97d15234f4014b04a8aea54fc4be6fa8d77c78e3..1e285e841e5f95ce23cdaa25d6c2e13f8ef1a7a4 100644 --- a/src/custom-border/custom-dv-5/custom-dv-5.tsx +++ b/src/custom-border/custom-dv-5/custom-dv-5.tsx @@ -1,3 +1,4 @@ +/* eslint-disable vue/require-prop-types */ import { ComponentInternalInstance, PropType, @@ -17,6 +18,14 @@ import './custom-dv-5.scss'; export const CustomDV5 = defineComponent({ name: 'CustomDV5', props: { + offsetX: { + style: Number, + default: 0, + }, + offsetY: { + style: Number, + default: 0, + }, color: { type: Array as PropType, default: () => [], @@ -25,10 +34,6 @@ export const CustomDV5 = defineComponent({ type: Boolean, default: false, }, - backgroundColor: { - type: String, - default: 'transparent', - }, }, setup(props) { const ns = useNamespace('custom-border'); @@ -40,7 +45,7 @@ export const CustomDV5 = defineComponent({ | MutationCallback | EventListenerOrEventListenerObject; let domObserver: MutationObserver | null; - + const backgroundColor = 'var(--ibiz-screen-dashboard-custom-dv-bg)'; /** * 初始化宽高 * @param resize @@ -152,66 +157,84 @@ export const CustomDV5 = defineComponent({ * 绘制边框 */ const renderBorder = () => { + const _width = width.value - props.offsetX; + const _height = height.value - props.offsetY; + const padding = 8; return ( ); diff --git a/src/custom-border/custom-dv-6/custom-dv-6.scss b/src/custom-border/custom-dv-6/custom-dv-6.scss index a4fbab6c374d96d735c9cea01fd4455b28188640..784dd023f24f1e92fb543a166fa7939512a5ec14 100644 --- a/src/custom-border/custom-dv-6/custom-dv-6.scss +++ b/src/custom-border/custom-dv-6/custom-dv-6.scss @@ -1,4 +1,8 @@ +$style-6: ( + 'offsetY': 0, +); @include b('custom-border') { + @include set-component-css-var(style-6, $style-6); @include when(style-6) { position: relative; width: 100%; @@ -11,7 +15,7 @@ top: 0; left: 0; width: 100%; - height: 100%; + height: calc(100% - getCssVar(style-6,'offsetY')); & > polyline { fill: none; diff --git a/src/custom-border/custom-dv-6/custom-dv-6.tsx b/src/custom-border/custom-dv-6/custom-dv-6.tsx index da7fa5231dbbf3a0fd256469e3743dc4440d5fe8..984bd68e99567497b87eb9d19c4f7ed18c087bbb 100644 --- a/src/custom-border/custom-dv-6/custom-dv-6.tsx +++ b/src/custom-border/custom-dv-6/custom-dv-6.tsx @@ -1,3 +1,4 @@ +/* eslint-disable vue/require-prop-types */ import { ComponentInternalInstance, PropType, @@ -17,6 +18,14 @@ import './custom-dv-6.scss'; export const CustomDV6 = defineComponent({ name: 'CustomDV6', props: { + offsetX: { + style: Number, + default: 0, + }, + offsetY: { + style: Number, + default: 0, + }, color: { type: Array as PropType, default: () => [], @@ -25,10 +34,6 @@ export const CustomDV6 = defineComponent({ type: Boolean, default: false, }, - backgroundColor: { - type: String, - default: 'transparent', - }, }, setup(props) { const ns = useNamespace('custom-border'); @@ -40,7 +45,7 @@ export const CustomDV6 = defineComponent({ | MutationCallback | EventListenerOrEventListenerObject; let domObserver: MutationObserver | null; - + const backgroundColor = 'var(--ibiz-screen-dashboard-custom-dv-bg)'; /** * 初始化宽高 * @param resize @@ -152,8 +157,9 @@ export const CustomDV6 = defineComponent({ * 绘制边框 */ const renderBorder = () => { - const _width = width.value; - const _height = height.value; + const _width = width.value - props.offsetX; + const _height = height.value - props.offsetY; + const padding = 8; return ( - - + + - + + + + - - ); diff --git a/src/custom-border/custom-dv-7/custom-dv-7.scss b/src/custom-border/custom-dv-7/custom-dv-7.scss index 232d078d874d028ef44275e6ec0b12c3de8c47d1..89c7f4f73429f0b739835ae6f08a082588392088 100644 --- a/src/custom-border/custom-dv-7/custom-dv-7.scss +++ b/src/custom-border/custom-dv-7/custom-dv-7.scss @@ -1,4 +1,8 @@ +$style-7: ( + 'offsetY': 0, +); @include b('custom-border') { + @include set-component-css-var(style-7, $style-7); @include when(style-7) { position: relative; width: 100%; @@ -11,7 +15,7 @@ top: 0; left: 0; width: 100%; - height: 100%; + height: calc(100% - getCssVar(style-7,'offsetY')); & > polyline { fill: none; diff --git a/src/custom-border/custom-dv-7/custom-dv-7.tsx b/src/custom-border/custom-dv-7/custom-dv-7.tsx index 50e59ec37f0adc8d0f74de988afb9b626ec32666..d57d371e9be728fe6f2f863ae554053ad759e28a 100644 --- a/src/custom-border/custom-dv-7/custom-dv-7.tsx +++ b/src/custom-border/custom-dv-7/custom-dv-7.tsx @@ -96,7 +96,12 @@ export const CustomDV7 = defineComponent({ const offset = 25; const minOffset = 10; return ( - + , default: () => [], @@ -26,10 +35,6 @@ export const CustomDV8 = defineComponent({ type: Boolean, default: false, }, - backgroundColor: { - type: String, - default: 'transparent', - }, dur: { // 单次动画时长,单位秒,默认为3秒 type: Number, @@ -51,20 +56,18 @@ export const CustomDV8 = defineComponent({ const path = `border-box-8-path-${id}`; const gradient = `border-box-8-gradient-${id}`; const mask = `border-box-8-mask-${id}`; - + const backgroundColor = 'var(--ibiz-screen-dashboard-custom-dv-bg)'; const length = computed(() => { - return (width.value + height.value - 5) * 2; + return (width.value + height.value - props.offsetY - 5) * 2; }); - const pathD = () => { + const pathD = (padding: number) => { if (props.reverse) { - return `M 2.5, 2.5 L 2.5, ${height.value - 2.5} L ${ - width.value - 2.5 - }, ${height.value - 2.5} L ${width.value - 2.5}, 2.5 L 2.5, 2.5`; + // 当reverse为true时,从左上角开始,逆时针方向绘制 + return `M ${2.5 + padding},${2.5 + padding} L ${2.5 + padding},${height.value - 2.5 - props.offsetY - padding} L ${width.value - 2.5 - padding},${height.value - 2.5 - props.offsetY - padding} L ${width.value - 2.5 - padding},${2.5 + padding} Z`; } - return `M2.5, 2.5 L${width.value - 2.5}, 2.5 L${width.value - 2.5}, ${ - height.value - 2.5 - } L2.5, ${height.value - 2.5} L2.5, 2.5`; + // 当reverse为false时,从左上角开始,顺时针方向绘制 + return `M ${2.5 + padding},${2.5 + padding} L ${width.value - 2.5 - padding},${2.5 + padding} L ${width.value - 2.5 - padding},${height.value - 2.5 - props.offsetY - padding} L ${2.5 + padding},${height.value - 2.5 - props.offsetY - padding} Z`; }; /** @@ -172,19 +175,25 @@ export const CustomDV8 = defineComponent({ * 绘制边框 */ const renderBorder = () => { - const _width = width.value; - const _height = height.value; + const _width = width.value - props.offsetX; + const _height = height.value - props.offsetY; + const padding = 8; return ( - + - + - + , default: () => [], }, - backgroundColor: { - type: String, - default: 'transparent', - }, }, setup(props) { const ns = useNamespace('custom-border'); @@ -40,15 +46,20 @@ export const CustomDV9 = defineComponent({ const mergedColor = computed(() => { return deepMerge(defaultColor, props.color || []) as string[]; }); + const backgroundColor = 'var(--ibiz-screen-dashboard-custom-dv-bg)'; /** * 绘制边框svg */ const renderBorder = () => { + const _width = width.value - props.offsetX; + const _height = height.value - props.offsetY; + const padding = 8; return ( @@ -116,26 +123,26 @@ export const CustomDV9 = defineComponent({ stroke='#fff' stroke-width='3' fill='transparent' - points={`${width.value * 0.5}, 3 ${width.value - 3}, 3, ${ - width.value - 3 - }, ${height.value * 0.25}`} + points={`${width.value * 0.5 - padding}, ${3 + padding} ${width.value - 3 - padding}, ${3 + padding}, ${ + width.value - 3 - padding + }, ${_height * 0.25 + padding}`} /> @@ -143,15 +150,15 @@ export const CustomDV9 = defineComponent({ stroke='#fff' stroke-width='3' fill='transparent' - points={`8, ${height.value * 0.5} 8, ${height.value - 3} ${ + points={`${8 + padding}, ${_height * 0.5} ${8 + padding}, ${_height - 3 - padding} ${ width.value * 0.3 + 7 - }, ${height.value - 3}`} + }, ${_height - 3 - padding}`} /> @@ -159,30 +166,27 @@ export const CustomDV9 = defineComponent({ stroke='#fff' stroke-width='3' fill='transparent' - points={`${width.value * 0.35}, ${height.value - 3} ${ - width.value - 3 - }, ${height.value - 3} ${width.value - 3}, ${ - height.value * 0.35 - }`} + points={`${width.value * 0.35 - padding}, ${_height - 3 - padding} ${ + width.value - 3 - padding + }, ${_height - 3 - padding} ${width.value - 3 - padding}, ${_height * 0.35 - padding}`} /> @@ -209,7 +211,7 @@ export const CustomDV9 = defineComponent({ x='0' y='0' width={width.value} - height={height.value} + height={_height} fill={`url(#${gradientId.value})`} mask={`url(#${maskId.value})`} /> diff --git a/src/custom-decoration/custom-decoration-1/custom-decoration-1.scss b/src/custom-decoration/custom-decoration-1/custom-decoration-1.scss new file mode 100644 index 0000000000000000000000000000000000000000..fbf00971b00a04e30f25ef1f4832c92442d7bbf2 --- /dev/null +++ b/src/custom-decoration/custom-decoration-1/custom-decoration-1.scss @@ -0,0 +1,10 @@ +@include b(custom-decoration-1) { + position: relative; + width: 100%; + height: 100%; + + >svg { + position: absolute; + transform-origin: left top; + } +} diff --git a/src/custom-decoration/custom-decoration-1/custom-decoration-1.tsx b/src/custom-decoration/custom-decoration-1/custom-decoration-1.tsx new file mode 100644 index 0000000000000000000000000000000000000000..f6d156ebb705a869cce820e5cdac6cbf530cc9ab --- /dev/null +++ b/src/custom-decoration/custom-decoration-1/custom-decoration-1.tsx @@ -0,0 +1,190 @@ +/* eslint-disable no-use-before-define */ +import { defineComponent, ref, computed, PropType } from 'vue'; +import { useNamespace } from '@ibiz-template/vue3-util'; +import { deepMerge, getThemeVar } from '../util'; +import { autoResize } from '../util/autoResize'; +import './custom-decoration-1.scss'; + +export const CustomDecoration1 = defineComponent({ + name: 'CustomDecoration1', + props: { + color: { + type: Array as PropType, + default: () => [], + }, + }, + setup(props) { + const ns = useNamespace('custom-decoration-1'); + const customDecoration1 = ref(); + const svgWH = ref<[number, number]>([20, 50]); + const rowNum = ref(4); + const rowPoints = ref(20); + + const pointSideLength = ref(2.5); + const halfPointSideLength = ref(pointSideLength.value / 2); + const defaultColor = [getThemeVar() || '#0095ee', '#95d8f8']; + + const mergedColor = computed(() => { + return deepMerge(defaultColor, props.color || []) as string[]; + }); + + const rects = ref([]); + const points = ref([]); + const svgScale = ref([1, 1]); + + const calcPointsPosition = () => { + const [w, h] = svgWH.value; + const horizontalGap = w / (rowPoints.value + 1); + const verticalGap = h / (rowNum.value + 1); + const newPoints = Array.from({ length: rowNum.value }) + .fill(0) + .map((_foo, i) => + Array.from({ length: rowPoints.value }) + .fill(0) + .map((foo, j) => [horizontalGap * (j + 1), verticalGap * (i + 1)]), + ); + + points.value = newPoints.reduce((all, item) => [...all, ...item], []); + }; + + const calcRectsPosition = () => { + const rect1 = points.value[rowPoints.value * 2 - 1]; + const rect2 = points.value[rowPoints.value * 2 - 3]; + rects.value = [rect1, rect2]; + }; + + const onResize = () => { + calcSVGData(); + }; + + const afterAutoResizeMixinInit = () => { + calcSVGData(); + }; + + const { width, height } = autoResize( + customDecoration1, + onResize, + afterAutoResizeMixinInit, + ); + + const calcScale = () => { + const [w, h] = svgWH.value; + svgScale.value = [width.value / w, height.value / h]; + }; + + const calcSVGData = () => { + calcPointsPosition(); + calcRectsPosition(); + calcScale(); + }; + + /** + * 绘制边框svg + */ + const renderBorder = () => { + return ( + + {points.value.map(point => { + if (Math.random() > 0.6) { + return ( + + {Math.random() > 0.6 ? ( + + ) : null} + + ); + } + return null; + })} + {rects.value[0] ? ( + + + + + + + ) : null} + {rects.value[1] ? ( + + + + + ) : null} + + ); + }; + + return { + ns, + customDecoration1, + renderBorder, + }; + }, + render() { + return ( +
+ {this.renderBorder()} + {this.$slots.default?.()} +
+ ); + }, +}); diff --git a/src/custom-decoration/custom-decoration-1/index.ts b/src/custom-decoration/custom-decoration-1/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..0e84a69a130275f71bedc66a7c98b27cc46ea283 --- /dev/null +++ b/src/custom-decoration/custom-decoration-1/index.ts @@ -0,0 +1,12 @@ +import { App } from 'vue'; +import { withInstall } from '@ibiz-template/vue3-util'; +import { CustomDecoration1 } from './custom-decoration-1'; + +export const IBizCustomDecoration1 = withInstall( + CustomDecoration1, + function (v: App) { + v.component(CustomDecoration1.name, CustomDecoration1); + }, +); + +export default IBizCustomDecoration1; diff --git a/src/custom-decoration/custom-decoration-2/custom-decoration-2.scss b/src/custom-decoration/custom-decoration-2/custom-decoration-2.scss new file mode 100644 index 0000000000000000000000000000000000000000..01c43c3d6730e8481f16aa9c966df935d6531194 --- /dev/null +++ b/src/custom-decoration/custom-decoration-2/custom-decoration-2.scss @@ -0,0 +1,12 @@ +@include b(custom-decoration-2) { + display: flex; + align-items: center; + justify-content: center; + width: 100%; + height: 100%; + + >svg{ + position: absolute; + top: 50%; + } +} diff --git a/src/custom-decoration/custom-decoration-2/custom-decoration-2.tsx b/src/custom-decoration/custom-decoration-2/custom-decoration-2.tsx new file mode 100644 index 0000000000000000000000000000000000000000..672ccc2e491a368b16b3efe16e6a09aaf5bb22f3 --- /dev/null +++ b/src/custom-decoration/custom-decoration-2/custom-decoration-2.tsx @@ -0,0 +1,151 @@ +import { + defineComponent, + onMounted, + onUnmounted, + ref, + nextTick, + computed, + PropType, + watch, +} from 'vue'; +import { useNamespace } from '@ibiz-template/vue3-util'; +import { + deepMerge, + getThemeVar, + bindDomResizeCallback, + unbindDomResizeCallback, +} from '../util'; +import './custom-decoration-2.scss'; + +export const CustomDecoration2 = defineComponent({ + name: 'CustomDecoration2', + props: { + color: { + type: Array as PropType, + default: () => [], + }, + reverse: { + type: Boolean, + default: false, + }, + dur: { + type: Number, + default: 2, + }, + }, + setup(props) { + const ns = useNamespace('custom-decoration-2'); + const defaultColor = [getThemeVar() || '#0095ee', '#95d8f8']; + const customDecoration2 = ref(); + + const x = ref(0); + const y = ref(0); + const w = ref(0); + const h = ref(0); + + const width = ref(0); + const height = ref(0); + const mergedColor = computed(() => { + return deepMerge(defaultColor, props.color || []) as string[]; + }); + + const calcSVGData = () => { + if (props.reverse) { + w.value = 1; + h.value = height.value; + x.value = width.value / 2; + y.value = 0; + } else { + w.value = width.value; + h.value = 1; + x.value = 0; + y.value = height.value / 2; + } + }; + + watch( + () => props.reverse, + () => { + calcSVGData(); + }, + { immediate: true }, + ); + /** + * 绘制边框svg + */ + const renderBorder = () => { + return ( + + + + + + + + + + ); + }; + const initWH = () => { + nextTick(() => { + const dom = customDecoration2.value as Element; + if (dom) { + width.value = dom.clientWidth; + height.value = dom.clientHeight; + } + }); + }; + onMounted(() => { + initWH(); + bindDomResizeCallback(customDecoration2.value, initWH); + window.addEventListener('resize', initWH); + }); + onUnmounted(() => { + unbindDomResizeCallback(customDecoration2.value); + window.removeEventListener('resize', initWH); + }); + return { + ns, + customDecoration2, + renderBorder, + }; + }, + render() { + return ( +
+ {this.renderBorder()} + {this.$slots.default?.()} +
+ ); + }, +}); diff --git a/src/custom-decoration/custom-decoration-2/index.ts b/src/custom-decoration/custom-decoration-2/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..1275a9ed8567ce1e07b2ef19ce8807882822641c --- /dev/null +++ b/src/custom-decoration/custom-decoration-2/index.ts @@ -0,0 +1,12 @@ +import { App } from 'vue'; +import { withInstall } from '@ibiz-template/vue3-util'; +import { CustomDecoration2 } from './custom-decoration-2'; + +export const IBizCustomDecoration2 = withInstall( + CustomDecoration2, + function (v: App) { + v.component(CustomDecoration2.name, CustomDecoration2); + }, +); + +export default IBizCustomDecoration2; diff --git a/src/custom-decoration/custom-decoration-3/custom-decoration-3.scss b/src/custom-decoration/custom-decoration-3/custom-decoration-3.scss new file mode 100644 index 0000000000000000000000000000000000000000..b44820331ede341acbe46bbe9c26a58b84d47128 --- /dev/null +++ b/src/custom-decoration/custom-decoration-3/custom-decoration-3.scss @@ -0,0 +1,10 @@ +@include b(custom-decoration-3) { + position: relative; + width: 100%; + height: 100%; + + > svg { + position: absolute; + transform-origin: left top; + } +} diff --git a/src/custom-decoration/custom-decoration-3/custom-decoration-3.tsx b/src/custom-decoration/custom-decoration-3/custom-decoration-3.tsx new file mode 100644 index 0000000000000000000000000000000000000000..d306d7baac323e980ccdd6daf7d1ae48ea721718 --- /dev/null +++ b/src/custom-decoration/custom-decoration-3/custom-decoration-3.tsx @@ -0,0 +1,132 @@ +/* eslint-disable no-use-before-define */ +/* eslint-disable no-shadow */ +import { defineComponent, ref, computed, PropType } from 'vue'; +import { useNamespace } from '@ibiz-template/vue3-util'; +import { deepMerge, getThemeVar } from '../util'; +import './custom-decoration-3.scss'; +import autoResize from '../util/autoResize'; + +export const CustomDecoration3 = defineComponent({ + name: 'CustomDecoration3', + props: { + color: { + type: Array as PropType, + default: () => [], + }, + dur: { + type: Number, + default: 1.2, + }, + }, + setup(props) { + const ns = useNamespace('custom-decoration-3'); + + const pointSideLength = ref(7); + const svgWH = ref<[number, number]>([300, 35]); + const svgScale = ref<[number, number]>([1, 1]); + const rowNum = ref(2); + const rowPoints = ref(25); + + const halfPointSideLength = ref(pointSideLength.value / 2); + + const points = ref([]); + + const defaultColor = [getThemeVar() || '#0095ee', '#95d8f8']; + const customDecoration3 = ref(); + const mergedColor = computed(() => { + return deepMerge(defaultColor, props.color || []) as string[]; + }); + + const calcPointsPosition = () => { + const [w, h] = svgWH.value; + + const horizontalGap = w / (rowPoints.value + 1); + const verticalGap = h / (rowNum.value + 1); + + const points1 = Array.from({ length: rowNum.value }) + .fill(0) + .map((_foo, i) => + Array.from({ length: rowPoints.value }) + .fill(0) + .map((_foo, j) => [horizontalGap * (j + 1), verticalGap * (i + 1)]), + ); + + points.value = points1.reduce((all, item) => [...all, ...item], []); + }; + + /** + * 绘制边框svg + */ + const renderBorder = () => { + return ( + + {points.value.map(point => { + return ( + + {Math.random() > 0.6 ? ( + + ) : null} + + ); + })} + + ); + }; + + const afterAutoResizeMixinInit = () => { + calcSVGData(); + }; + + const calcSVGData = () => { + calcPointsPosition(); + + calcScale(); + }; + + const onResize = () => { + calcSVGData(); + }; + + const { width, height } = autoResize( + customDecoration3, + onResize, + afterAutoResizeMixinInit, + ); + const calcScale = () => { + const [w, h] = svgWH.value; + + svgScale.value = [width.value / w, height.value / h]; + }; + + return { + ns, + customDecoration3, + renderBorder, + }; + }, + render() { + return ( +
+ {this.renderBorder()} + {this.$slots.default?.()} +
+ ); + }, +}); diff --git a/src/custom-decoration/custom-decoration-3/index.ts b/src/custom-decoration/custom-decoration-3/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..58659f4c93326c4f2a0accb8b567fbfbe56571a7 --- /dev/null +++ b/src/custom-decoration/custom-decoration-3/index.ts @@ -0,0 +1,12 @@ +import { App } from 'vue'; +import { withInstall } from '@ibiz-template/vue3-util'; +import { CustomDecoration3 } from './custom-decoration-3'; + +export const IBizCustomDecoration3 = withInstall( + CustomDecoration3, + function (v: App) { + v.component(CustomDecoration3.name, CustomDecoration3); + }, +); + +export default IBizCustomDecoration3; diff --git a/src/custom-decoration/custom-decoration-4/custom-decoration-4.scss b/src/custom-decoration/custom-decoration-4/custom-decoration-4.scss new file mode 100644 index 0000000000000000000000000000000000000000..992eff65950faf8d3f09ce6df04e8561da0aca0a --- /dev/null +++ b/src/custom-decoration/custom-decoration-4/custom-decoration-4.scss @@ -0,0 +1,56 @@ +@include b(custom-decoration-4) { + position: relative; + width: 100%; + height: 100%; + + .container { + position: absolute; + display: flex; + flex: 1; + overflow: hidden; + } + + .normal { + left: 50%; + margin-left: -2px; + animation: ani-height ease-in-out infinite; + } + + .reverse { + top: 50%; + margin-top: -2px; + animation: ani-width ease-in-out infinite; + } + + @keyframes ani-height { + 0% { + height: 0%; + } + + 70% { + height: 100%; + } + + 100% { + height: 100%; + } + } + + @keyframes ani-width { + 0% { + width: 0%; + } + + 70% { + width: 100%; + } + + 100% { + width: 100%; + } + } + + >svg { + position: absolute; + } +} diff --git a/src/custom-decoration/custom-decoration-4/custom-decoration-4.tsx b/src/custom-decoration/custom-decoration-4/custom-decoration-4.tsx new file mode 100644 index 0000000000000000000000000000000000000000..c2a123c85b72081ee5ce8d3fa962a7c0b6a07fb9 --- /dev/null +++ b/src/custom-decoration/custom-decoration-4/custom-decoration-4.tsx @@ -0,0 +1,117 @@ +import { + defineComponent, + onMounted, + onUnmounted, + ref, + nextTick, + computed, + PropType, +} from 'vue'; +import { useNamespace } from '@ibiz-template/vue3-util'; +import { + deepMerge, + getThemeVar, + bindDomResizeCallback, + unbindDomResizeCallback, +} from '../util'; +import './custom-decoration-4.scss'; + +export const CustomDecoration4 = defineComponent({ + name: 'CustomDecoration4', + props: { + color: { + type: Array as PropType, + default: () => [], + }, + reverse: { + type: Boolean, + default: false, + }, + dur: { + type: Number, + default: 1.2, + }, + }, + setup(props) { + const ns = useNamespace('custom-decoration-4'); + const defaultColor = [getThemeVar() || '#0095ee', '#95d8f8']; + const customDecoration4 = ref(); + const width = ref(0); + const height = ref(0); + const mergedColor = computed(() => { + return deepMerge(defaultColor, props.color || []) as string[]; + }); + /** + * 绘制边框svg + */ + const renderBorder = () => { + return ( +
+ + + + +
+ ); + }; + const initWH = () => { + nextTick(() => { + const dom = customDecoration4.value as Element; + if (dom) { + width.value = dom.clientWidth; + height.value = dom.clientHeight; + } + }); + }; + onMounted(() => { + initWH(); + bindDomResizeCallback(customDecoration4.value, initWH); + window.addEventListener('resize', initWH); + }); + onUnmounted(() => { + unbindDomResizeCallback(customDecoration4.value); + window.removeEventListener('resize', initWH); + }); + return { + ns, + customDecoration4, + renderBorder, + }; + }, + render() { + return ( +
+ {this.renderBorder()} + {this.$slots.default?.()} +
+ ); + }, +}); diff --git a/src/custom-decoration/custom-decoration-4/index.ts b/src/custom-decoration/custom-decoration-4/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..c7dd37f86ce336aff26527e963b6d64249e1541a --- /dev/null +++ b/src/custom-decoration/custom-decoration-4/index.ts @@ -0,0 +1,12 @@ +import { App } from 'vue'; +import { withInstall } from '@ibiz-template/vue3-util'; +import { CustomDecoration4 } from './custom-decoration-4'; + +export const IBizCustomDecoration4 = withInstall( + CustomDecoration4, + function (v: App) { + v.component(CustomDecoration4.name, CustomDecoration4); + }, +); + +export default IBizCustomDecoration4; diff --git a/src/custom-decoration/custom-decoration-6/custom-decoration-6.scss b/src/custom-decoration/custom-decoration-6/custom-decoration-6.scss new file mode 100644 index 0000000000000000000000000000000000000000..348f7cd789a4d64ce556bfef7d6eeacf53d85d25 --- /dev/null +++ b/src/custom-decoration/custom-decoration-6/custom-decoration-6.scss @@ -0,0 +1,9 @@ +@include b(custom-decoration-6) { + position: relative; + width: 100%; + height: 100%; + + >svg { + transform-origin: left top; + } +} diff --git a/src/custom-decoration/custom-decoration-6/custom-decoration-6.tsx b/src/custom-decoration/custom-decoration-6/custom-decoration-6.tsx new file mode 100644 index 0000000000000000000000000000000000000000..0a9dd38f79b961c317a531685d90ac68ca4b7d0e --- /dev/null +++ b/src/custom-decoration/custom-decoration-6/custom-decoration-6.tsx @@ -0,0 +1,171 @@ +/* eslint-disable no-use-before-define */ +/* eslint-disable no-multi-assign */ +import { defineComponent, ref, computed, PropType } from 'vue'; +import { useNamespace } from '@ibiz-template/vue3-util'; +import { deepMerge, getThemeVar } from '../util'; +import './custom-decoration-6.scss'; +import autoResize from '../util/autoResize'; + +export const CustomDecoration6 = defineComponent({ + name: 'CustomDecoration6', + props: { + color: { + type: Array as PropType, + default: () => [], + }, + }, + setup(props) { + const ns = useNamespace('custom-decoration-6'); + + const rectWidth = ref(7); + + const svgWH = ref<[number, number]>([300, 35]); + const svgScale = ref<[number, number]>([1, 1]); + const rowNum = ref(1); + const rowPoints = ref(40); + const halfRectWidth = ref(rectWidth.value / 2); + + const points = ref([]); + const heights = ref([]); + const minHeights = ref([]); + const randoms = ref([]); + + const customDecoration6 = ref(); + const defaultColor = [getThemeVar() || '#0095ee', '#95d8f8']; + const mergedColor = computed(() => { + return deepMerge(defaultColor, props.color || []) as string[]; + }); + + const randomExtend = (minNum: number, maxNum: number) => { + if (arguments.length === 1) + return Number.parseInt((Math.random() * minNum + 1).toString(), 10); + return Number.parseInt( + (Math.random() * (maxNum - minNum + 1) + minNum).toString(), + 10, + ); + }; + + const calcPointsPosition = () => { + const [w, h] = svgWH.value; + + const horizontalGap = w / (rowPoints.value + 1); + const verticalGap = h / (rowNum.value + 1); + + const points1 = Array.from({ length: rowNum.value }) + .fill(0) + .map((foo, i) => + Array.from({ length: rowPoints.value }) + .fill(0) + .map((foo, j) => [horizontalGap * (j + 1), verticalGap * (i + 1)]), + ); + + points.value = points1.reduce((all, item) => [...all, ...item], []); + const heights1 = Array.from({ + length: rowNum.value * rowPoints.value, + }) + .fill(0) + .map(() => + Math.random() > 0.8 + ? randomExtend(0.7 * h, h) + : randomExtend(0.2 * h, 0.5 * h), + ); + + heights.value = heights1; + + minHeights.value = Array.from({ length: rowNum.value * rowPoints.value }) + .fill(0) + .map((foo, i) => heights1[i] * Math.random()); + + randoms.value = Array.from({ length: rowNum.value * rowPoints.value }) + .fill(0) + .map(() => Math.random() + 1.5); + }; + + const calcSVGData = () => { + calcPointsPosition(); + + calcScale(); + }; + + const onResize = () => { + calcSVGData(); + }; + + const afterAutoResizeMixinInit = () => { + calcSVGData(); + }; + + const { width, height } = autoResize( + customDecoration6, + onResize, + afterAutoResizeMixinInit, + ); + + const calcScale = () => { + const [w, h] = svgWH.value; + + svgScale.value = [width.value / w, height.value / h]; + }; + + /** + * 绘制边框svg + */ + const renderBorder = () => { + return ( + + {points.value.map((point, i) => { + return ( + 0.5 ? 0 : 1]} + x={point[0] - halfRectWidth.value} + y={point[1] - heights.value[i] / 2} + width={rectWidth.value} + height={heights.value[i]} + > + + + + ); + })} + + ); + }; + + return { + ns, + customDecoration6, + renderBorder, + }; + }, + render() { + return ( +
+ {this.renderBorder()} + {this.$slots.default?.()} +
+ ); + }, +}); diff --git a/src/custom-decoration/custom-decoration-6/index.ts b/src/custom-decoration/custom-decoration-6/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..d3dc2ae603ecabd9c422ccc3565664d713132f2b --- /dev/null +++ b/src/custom-decoration/custom-decoration-6/index.ts @@ -0,0 +1,12 @@ +import { App } from 'vue'; +import { withInstall } from '@ibiz-template/vue3-util'; +import { CustomDecoration6 } from './custom-decoration-6'; + +export const IBizCustomDecoration6 = withInstall( + CustomDecoration6, + function (v: App) { + v.component(CustomDecoration6.name, CustomDecoration6); + }, +); + +export default IBizCustomDecoration6; diff --git a/src/custom-decoration/index.ts b/src/custom-decoration/index.ts index 3e8dcda49fb47b6dd408c5460db18ee50f7b85d8..c18b4977051701cd452d3880c88d893e8f8bbb46 100644 --- a/src/custom-decoration/index.ts +++ b/src/custom-decoration/index.ts @@ -1,2 +1,7 @@ +export * from './custom-decoration-1'; +export * from './custom-decoration-2'; +export * from './custom-decoration-3'; +export * from './custom-decoration-4'; export * from './custom-decoration-5'; +export * from './custom-decoration-6'; export * from './custom-decoration-11'; diff --git a/src/custom-decoration/util/autoResize.ts b/src/custom-decoration/util/autoResize.ts new file mode 100644 index 0000000000000000000000000000000000000000..d4a82925bce7e82a3efa379dfcc7ab613b133863 --- /dev/null +++ b/src/custom-decoration/util/autoResize.ts @@ -0,0 +1,100 @@ +import type { ComponentInternalInstance, Ref } from 'vue'; +import { + getCurrentInstance, + nextTick, + onActivated, + onDeactivated, + onMounted, + onUnmounted, + ref, +} from 'vue'; +import { debounce, observerDomResize } from './index'; + +export function autoResize( + dom: Ref, + onResize?: () => void, + afterAutoResizeMixinInit?: () => void, +) { + const width = ref(0); + const height = ref(0); + + let debounceInitWHFun: () => void; + let domObserver: MutationObserver | null = null; + let domHtml: HTMLElement | null = null; + + const initWH = (resize = true) => { + return new Promise(resolve => { + nextTick(() => { + domHtml = dom.value; + width.value = dom.value ? dom.value.clientWidth : 0; + height.value = dom.value ? dom.value.clientHeight : 0; + + if (!dom.value) + console.warn( + 'DataV: Failed to get dom node, component rendering may be abnormal!', + ); + else if (!width.value || !height.value) + console.warn( + 'DataV: Component width or height is 0px, rendering abnormality may occur!', + ); + + if (typeof onResize === 'function' && resize) onResize(); + resolve(true); + }); + }); + }; + const getDebounceInitWHFun = () => { + debounceInitWHFun = debounce( + 200, + initWH, + getCurrentInstance() as ComponentInternalInstance, + null, + ); + }; + const bindDomResizeCallback = () => { + domObserver = observerDomResize(domHtml!, debounceInitWHFun); + + window.addEventListener( + 'resize', + debounceInitWHFun as EventListenerOrEventListenerObject, + ); + }; + const unbindDomResizeCallback = () => { + if (!domObserver) return; + + domObserver.disconnect(); + domObserver.takeRecords(); + domObserver = null; + }; + + const autoResizeMixinInit = async () => { + await initWH(false); + + getDebounceInitWHFun(); + + bindDomResizeCallback(); + + if (typeof afterAutoResizeMixinInit === 'function') + afterAutoResizeMixinInit(); + }; + + onMounted(() => { + autoResizeMixinInit(); + }); + + onUnmounted(() => { + unbindDomResizeCallback(); + }); + + onActivated(autoResizeMixinInit); + + onDeactivated(unbindDomResizeCallback); + + return { + width, + height, + initWH, + }; +} + +export default autoResize; diff --git a/src/index.ts b/src/index.ts index f19e4023e19d25412cb5955fdd6a70e648110ae3..6d434c13c776b34ac41f3c93506d8a3bcea26706 100644 --- a/src/index.ts +++ b/src/index.ts @@ -29,7 +29,12 @@ import { } from './custom-border'; // 装饰器 import { + IBizCustomDecoration1, + IBizCustomDecoration2, + IBizCustomDecoration3, + IBizCustomDecoration4, IBizCustomDecoration5, + IBizCustomDecoration6, IBizCustomDecoration11, } from './custom-decoration'; @@ -63,7 +68,12 @@ export default { _app.use(IBizCustomDV12); _app.use(IBizCustomDV13); // 装饰器 + _app.use(IBizCustomDecoration1); + _app.use(IBizCustomDecoration2); + _app.use(IBizCustomDecoration3); + _app.use(IBizCustomDecoration4); _app.use(IBizCustomDecoration5); + _app.use(IBizCustomDecoration6); _app.use(IBizCustomDecoration11); }, }; diff --git a/src/screen-dashboard/screen-dashboard.scss b/src/screen-dashboard/screen-dashboard.scss index 5231a2ed9e604b9a931e5914d4e13300d76c8a95..9100d86ab80ea566df8b9153989c283231ade3a8 100644 --- a/src/screen-dashboard/screen-dashboard.scss +++ b/src/screen-dashboard/screen-dashboard.scss @@ -7,6 +7,7 @@ $screen-dashboard: ( 'light-text-color': transparent, 'border-color': #18a9d9, 'border-radius': 0, + 'custom-dv-bg':transparent, ); @include b(screen-dashboard) { @include set-component-css-var('screen-dashboard', $screen-dashboard); diff --git a/src/screen-portlet/screen-portlet.controller.ts b/src/screen-portlet/screen-portlet.controller.ts index 188ef1c39b69d2603bfca43e859c53f01eb55f48..a49815220a91f7b505d35a9f306b4cdc376d6a68 100644 --- a/src/screen-portlet/screen-portlet.controller.ts +++ b/src/screen-portlet/screen-portlet.controller.ts @@ -1,5 +1,5 @@ /* eslint-disable no-useless-constructor */ -import { IControlParam, IDBPortletPart } from '@ibiz/model-core'; +import { IAppPortlet, IControlParam, IDBPortletPart } from '@ibiz/model-core'; import { IDashboardController, IPortletContainerController, @@ -35,6 +35,9 @@ export class ScreenPortletController extends PortletPartController x.codeName === this.model.codeName, + ); + if (porltlet && porltlet.portletParams) { + this.controlParam = porltlet.portletParams as IControlParam; + if (porltlet.portletParams?.BORDERSTYLE) { + this.borderStyle = porltlet.portletParams?.BORDERSTYLE; + } + if (porltlet.portletParams?.ICONTYPE) { + this.iconType = porltlet.portletParams?.ICONTYPE; + } + } } } diff --git a/src/screen-portlet/screen-portlet.scss b/src/screen-portlet/screen-portlet.scss index b7203e1ee0d8833b7cc2f8f3a2b51f65be60dd5b..84248ac9dc6aa675c8af9d24505b8971464dbc3f 100644 --- a/src/screen-portlet/screen-portlet.scss +++ b/src/screen-portlet/screen-portlet.scss @@ -1,42 +1,78 @@ @include b(screen-portlet) { + width: 100%; + height: 100%; + @include when('full-icon') { + .#{bem(portlet-layout-header)} { + position: relative; + } + + .#{bem(portlet-layout-header, left)} { + position: unset; + } + + .#{bem(portlet-layout, caption)} { + &::before { + display: none; + } + } + + .#{bem(portlet-layout, caption-icon)} { + position: absolute; + top: 0; + left: 0; + z-index: -1; + width: 100%; + height: 100%; + } + } +} + +@include b('custom-border') { + @include e('content') { + position: relative; width: 100%; height: 100%; - @include when('full-icon') { - .#{bem(portlet-layout-header)} { - position: relative; + } + @include when(full-border) { + > svg { + transform: translateY(50px); + } + + &.is-style-1 { + .#{bem(custom-border,left-top)} { + transform: translateY(50px); } - .#{bem(portlet-layout-header, left)} { - position: unset; + .#{bem(custom-border,right-top)} { + transform: translateY(50px) rotateY(180deg); } - .#{bem(portlet-layout, caption)} { - &::before { - display: none; - } + .#{bem(custom-border,left-bottom)} { + transform: translateY(50px) rotateX(180deg); } - .#{bem(portlet-layout, caption-icon)} { - position: absolute; - top: 0; - left: 0; - z-index: -1; - width: 100%; - height: 100%; + .#{bem(custom-border,right-bottom)} { + transform: translateY(50px) rotateX(180deg) rotateY(180deg); } } -} - -@include b('custom-border') { - @include e('content') { - position: relative; - width: 100%; - height: 100%; + &.is-style-10 { + transform: translateY(50px); + .#{bem(custom-border,content)} { + transform: translateY(-50px); + } } - @include when(full-border) { - >svg { - transform: translateY(50px); + + &.is-style-11 { + > svg { + transform: translateY(0); + } + .#{bem(portlet-layout-header,left)} { + position: absolute; + top: 12%; + left: 49%; + transform: translate(-50%, -50%); } } -} \ No newline at end of file + } +} diff --git a/src/screen-real-time/screen-real-time.controller.ts b/src/screen-real-time/screen-real-time.controller.ts index 2f024198e437c895a078cd710e1bc837900c58ba..7c293fa223537d8b9746156fc2ea598c928a7c09 100644 --- a/src/screen-real-time/screen-real-time.controller.ts +++ b/src/screen-real-time/screen-real-time.controller.ts @@ -40,16 +40,40 @@ export class ScreenRealTimeController extends EditorController { */ protected async onInit(): Promise { super.onInit(); - if (this.model.editorParams) { - const { SHOWWEEK, LEFTTIME, RIGHTTIME } = this.model.editorParams; - if (SHOWWEEK) { - this.showWeek = JSON.parse(SHOWWEEK); - } - if (LEFTTIME) { - this.leftTime = LEFTTIME; - } - if (RIGHTTIME) { - this.rightTime = RIGHTTIME; + if (this.parent.valueFormat) { + const arr = this.parent.valueFormat.split(','); + const index = arr.findIndex(w => w === 'week'); // 找到week + + if (index > -1) { + this.showWeek = true; + if (index === 0) { + // 左侧没配 0 1 + this.leftTime = ''; + this.rightTime = arr[1]; + } + if (index === 1) { + // 左侧配了 0 1 , 0 1 2 + arr.splice(index, 1); + arr.forEach((str, i) => { + if (i === 0) { + this.leftTime = str; + } + if (i === 1) { + this.rightTime = str; + } + }); + } + } else { + this.showWeek = false; + // 按顺序赋值 0 2 + arr.forEach((str, i) => { + if (i === 0) { + this.leftTime = str; + } + if (i === 1) { + this.rightTime = str; + } + }); } } }