Showing
5 changed files
with
191 additions
and
1 deletions
1 | +import { PublicConfigClass } from '@/packages/public' | |
2 | +import { CreateComponentType } from '@/packages/index.d' | |
3 | +import { TitleConfig } from './index' | |
4 | +import cloneDeep from 'lodash/cloneDeep' | |
5 | + | |
6 | +export const option = { | |
7 | + dataset:'我是标题', | |
8 | + attribute:{ | |
9 | + titleColor:'#fff', | |
10 | + titleSize:'16', | |
11 | + svg_7:'blue', | |
12 | + svg_8:'red', | |
13 | + svg_16:'red', | |
14 | + svg_14:'red', | |
15 | + svg_21:'red', | |
16 | + svg_7_opacity:1, | |
17 | + svg_8_opacity:1, | |
18 | + svg_16_opacity:1, | |
19 | + svg_14_opacity:1, | |
20 | + linearGradient:{ | |
21 | + stop_color1:'#447799', | |
22 | + stop_color2:'#224488', | |
23 | + svg_21_opacity1:1, | |
24 | + svg_21_opacity2:1, | |
25 | + } | |
26 | + } | |
27 | +} | |
28 | + | |
29 | +export default class Config extends PublicConfigClass implements CreateComponentType { | |
30 | + public key = TitleConfig.key | |
31 | + public chartConfig = cloneDeep(TitleConfig) | |
32 | + public option = cloneDeep(option) | |
33 | +} | ... | ... |
1 | +<template> | |
2 | + <CollapseItem name="配置" :expanded="true"> | |
3 | + <SettingItemBox name="文字"> | |
4 | + <SettingItem name="内容"> | |
5 | + <n-input size="small" v-model:value="optionData.dataset"></n-input> | |
6 | + </SettingItem> | |
7 | + <SettingItem name="颜色"> | |
8 | + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.titleColor"></n-color-picker> | |
9 | + </SettingItem> | |
10 | + <SettingItem> | |
11 | + <n-button size="small" @click="optionData.attribute.titleColor ='#fff'"> 恢复默认 </n-button> | |
12 | + </SettingItem> | |
13 | + <SettingItem name="大小"> | |
14 | + <n-input-number v-model:value="optionData.attribute.titleSize" size="small" placeholder="大小"></n-input-number> | |
15 | + </SettingItem> | |
16 | + </SettingItemBox> | |
17 | + <SettingItemBox name="左边装饰"> | |
18 | + <SettingItem name="颜色"> | |
19 | + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.svg_16"></n-color-picker> | |
20 | + </SettingItem> | |
21 | + <SettingItem name="透明度"> | |
22 | + <n-input-number :min="0" :max="1" v-model:value="optionData.attribute.svg_16_opacity" size="small" placeholder="透明度1"></n-input-number> | |
23 | + </SettingItem> | |
24 | + </SettingItemBox> | |
25 | + <SettingItemBox name="三角装饰"> | |
26 | + <SettingItem name="颜色"> | |
27 | + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.svg_14"></n-color-picker> | |
28 | + </SettingItem> | |
29 | + <SettingItem name="透明度"> | |
30 | + <n-input-number :min="0" :max="1" v-model:value="optionData.attribute.svg_14_opacity" size="small" placeholder="透明度1"></n-input-number> | |
31 | + </SettingItem> | |
32 | + </SettingItemBox> | |
33 | + <SettingItemBox name="右边装饰"> | |
34 | + <SettingItem name="颜色1"> | |
35 | + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.svg_7"></n-color-picker> | |
36 | + </SettingItem> | |
37 | + <SettingItem name="颜色2"> | |
38 | + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.svg_8"></n-color-picker> | |
39 | + </SettingItem> | |
40 | + <SettingItem name="透明度1"> | |
41 | + <n-input-number :min="0" :max="1" v-model:value="optionData.attribute.svg_7_opacity" size="small" placeholder="透明度1"></n-input-number> | |
42 | + </SettingItem> | |
43 | + <SettingItem name="透明度2"> | |
44 | + <n-input-number :min="0" :max="1" v-model:value="optionData.attribute.svg_8_opacity" size="small" placeholder="透明度2"></n-input-number> | |
45 | + </SettingItem> | |
46 | + </SettingItemBox> | |
47 | + <SettingItemBox name="装饰渐变"> | |
48 | + <SettingItem name="渐变颜色1"> | |
49 | + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.linearGradient.stop_color1"></n-color-picker> | |
50 | + </SettingItem> | |
51 | + <SettingItem name="渐变颜色2"> | |
52 | + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.linearGradient.stop_color2"></n-color-picker> | |
53 | + </SettingItem> | |
54 | + <SettingItem name="透明度1"> | |
55 | + <n-input-number :min="0" :max="1" v-model:value="optionData.attribute.linearGradient.svg_21_opacity1" size="small" placeholder="透明度1"></n-input-number> | |
56 | + </SettingItem> | |
57 | + <SettingItem name="透明度2"> | |
58 | + <n-input-number :min="0" :max="1" v-model:value="optionData.attribute.linearGradient.svg_21_opacity2" size="small" placeholder="透明度1"></n-input-number> | |
59 | + </SettingItem> | |
60 | + </SettingItemBox> | |
61 | + </CollapseItem> | |
62 | +</template> | |
63 | + | |
64 | +<script setup lang="ts"> | |
65 | +import { PropType } from 'vue' | |
66 | +import { option } from './config' | |
67 | +import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' | |
68 | + | |
69 | +defineProps({ | |
70 | + optionData: { | |
71 | + type: Object as PropType<typeof option>, | |
72 | + required: true | |
73 | + } | |
74 | +}) | |
75 | +</script> | ... | ... |
1 | +import { ChartFrameEnum, ConfigType } from '@/packages/index.d' | |
2 | +import { EPackagesCategoryEnum } from '@/packages/components/external/types' | |
3 | +import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' | |
4 | +import { useWidgetKey } from '@/packages/external/useWidgetKey' | |
5 | + | |
6 | +const { key, chartKey, conKey } = useWidgetKey('Title') | |
7 | +export const TitleConfig: ConfigType = { | |
8 | + key, | |
9 | + chartKey, | |
10 | + conKey, | |
11 | + title: '标题', | |
12 | + category: ChatCategoryEnum.MORE, | |
13 | + categoryName: ChatCategoryEnumName.MORE, | |
14 | + package: EPackagesCategoryEnum.COMPOSES, | |
15 | + chartFrame: ChartFrameEnum.NAIVE_UI, | |
16 | + image: 'dateTime.png', | |
17 | +} | ... | ... |
1 | +<template> | |
2 | + <div class="go-content-box" > | |
3 | +<svg xmlns="http://www.w3.org/2000/svg" width="782" height="600"> | |
4 | + <defs> | |
5 | + <defs> | |
6 | + <linearGradient id="my-cool-gradient" x1="0%" y1="0%" x2="100%" y2="0%"> | |
7 | + <stop offset="0%" :style="{stopColor:attribute.linearGradient.stop_color1,stopOpacity:attribute.linearGradient.svg_21_opacity1 }"/> | |
8 | + <stop offset="100%" :style="{stopColor:attribute.linearGradient.stop_color2,stopOpacity:attribute.linearGradient.svg_21_opacity2}"/> | |
9 | + </linearGradient> | |
10 | + </defs> | |
11 | + </defs> | |
12 | + <g> | |
13 | + <rect stroke="#000" id="svg_6" height="0" width="2" y="189.5" x="523" fill="#fff"/> | |
14 | + <path :opacity="attribute.svg_7_opacity" transform="rotate(-137 422.766 284.992)" stroke="#000" id="svg_7" d="m412.87465,287.39672l3.95636,-4.80932l15.82545,0l-3.95636,4.80932l-15.82545,0z" :fill="attribute.svg_7"/> | |
15 | + <path :opacity="attribute.svg_8_opacity" transform="rotate(44 444.883 283.871)" stroke="#000" id="svg_8" d="m435.52609,286.39738l3.74294,-5.0534l14.97175,0l-3.74294,5.0534l-14.97175,0z" :fill="attribute.svg_8"/> | |
16 | + <rect id="svg_10" height="0" width="1" y="242.5" x="235" stroke="#000" fill="#fff"/> | |
17 | + <text xml:space="preserve" text-anchor="start" font-family="Noto Sans JP" :font-size="attribute.titleSize" stroke-width="0" id="svg_12" y="290.5" x="214" stroke="#000" :fill="attribute.titleColor">{{ dataset }}</text> | |
18 | + <path :opacity="attribute.svg_14_opacity" transform="rotate(90 198.922 284.168)" stroke="#000" id="svg_14" d="m193.42189,288.16843l5.50043,-8.00001l5.50043,8.00001l-11.00085,0z" stroke-width="0" :fill="attribute.svg_14"/> | |
19 | + <path id="svg_15" d="m259.7,311.34437l0.5,-1.00001l0.5,1.00001l-1.00001,0z" stroke-width="0" stroke="#000" fill="#000000"/> | |
20 | + <rect stroke="#000" id="svg_16" height="33" width="4" y="269" x="181" :fill="attribute.svg_16" :opacity="attribute.svg_16_opacity"/> | |
21 | + <rect id="svg_17" height="0" width="2" y="368.5" x="187" stroke="#000" fill="#6D97AB"/> | |
22 | + <rect id="svg_18" height="13" width="0" y="290.5" x="167" stroke="#000" fill="#6D97AB"/> | |
23 | + <rect id="svg_20" height="0" width="1" y="193.5" x="281" stroke="#000" fill="#6D97AB"/> | |
24 | + <path stroke="#000" id="svg_21" d="m184,269l299.00001,0l0,33l-299.00001,0l0,-33z" opacity="0.35" fill="url(#my-cool-gradient)"/> | |
25 | + </g> | |
26 | + | |
27 | +</svg> | |
28 | + </div> | |
29 | +</template> | |
30 | +<script setup lang="ts"> | |
31 | +import { PropType, toRefs } from 'vue' | |
32 | +import { CreateComponentType } from '@/packages/index.d' | |
33 | + | |
34 | +const props = defineProps({ | |
35 | + chartConfig: { | |
36 | + type: Object as PropType<CreateComponentType>, | |
37 | + required: true | |
38 | + } | |
39 | +}) | |
40 | + | |
41 | +//修改默认宽高距离位置 | |
42 | +props.chartConfig.attr.w = 600 | |
43 | +props.chartConfig.attr.h = 100 | |
44 | +props.chartConfig.attr.x = 200 | |
45 | +props.chartConfig.attr.y = 200 | |
46 | + | |
47 | +const { dataset,attribute }= toRefs(props.chartConfig.option) | |
48 | + | |
49 | +const { w, h } = toRefs(props.chartConfig.attr) | |
50 | + | |
51 | + | |
52 | +</script> | |
53 | + | |
54 | +<style lang="scss" scoped> | |
55 | +.go-content-box { | |
56 | + display: flex; | |
57 | + align-items: center; | |
58 | + justify-content: center; | |
59 | + .content{ | |
60 | + width:v-bind('w + "px"'); | |
61 | + height:v-bind('h + "px"'); | |
62 | + } | |
63 | +} | |
64 | +</style> | ... | ... |