Commit f58186a62deb45d6a4a9beefe4780683fc8a28ba

Authored by fengwotao
1 parent 90872f02

perf(external/Componse): 新增组合下的小标题2

  1 +import { PublicConfigClass } from '@/packages/public'
  2 +import { CreateComponentType } from '@/packages/index.d'
  3 +import { Title2Config } from './index'
  4 +import cloneDeep from 'lodash/cloneDeep'
  5 +
  6 +export const option = {
  7 + dataset: '我是标题',
  8 + attribute: {
  9 + linearColors: ['#21649C', '#060F1E', '#2AFFFF', '#000000', '#ffcc33', '#ffcc33'],
  10 + fontSize: 20,
  11 + fontPos: {
  12 + x: 0,
  13 + y: 20
  14 + },
  15 + fontColor: '#2AFFFF'
  16 + }
  17 +}
  18 +
  19 +export default class Config extends PublicConfigClass implements CreateComponentType {
  20 + public key = Title2Config.key
  21 + public chartConfig = cloneDeep(Title2Config)
  22 + public option = cloneDeep(option)
  23 +}
... ...
  1 +<template>
  2 + <CollapseItem name="配置" :expanded="true">
  3 + <SettingItemBox name="标题">
  4 + <SettingItem name="内容">
  5 + <n-input v-model:value="optionData.dataset" />
  6 + </SettingItem>
  7 + <SettingItem name="大小">
  8 + <n-input-number v-model:value="optionData.attribute.fontSize" />
  9 + </SettingItem>
  10 + <SettingItem name="颜色">
  11 + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.fontColor"></n-color-picker>
  12 + </SettingItem>
  13 + <SettingItem name="x轴位置">
  14 + <n-input-number v-model:value="optionData.attribute.fontPos.x" />
  15 + </SettingItem>
  16 + <SettingItem name="y轴位置">
  17 + <n-input-number v-model:value="optionData.attribute.fontPos.y" />
  18 + </SettingItem>
  19 + </SettingItemBox>
  20 + <SettingItemBox
  21 + :name="`装饰颜色-${index + 1}`"
  22 + v-for="(item, index) in optionData.attribute.linearColors"
  23 + :key="index"
  24 + >
  25 + <SettingItem name="颜色">
  26 + <n-color-picker
  27 + size="small"
  28 + :modes="['hex']"
  29 + v-model:value="optionData.attribute.linearColors[index]"
  30 + ></n-color-picker>
  31 + </SettingItem>
  32 + <SettingItem>
  33 + <n-button
  34 + size="small"
  35 + @click="optionData.attribute.linearColors[index] = option.attribute.linearColors[index]"
  36 + >
  37 + 恢复默认
  38 + </n-button>
  39 + </SettingItem>
  40 + </SettingItemBox>
  41 + </CollapseItem>
  42 +</template>
  43 +
  44 +<script setup lang="ts">
  45 +import { PropType } from 'vue'
  46 +import { option } from './config'
  47 +import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
  48 +
  49 +
  50 +defineProps({
  51 + optionData: {
  52 + type: Object as PropType<typeof option>,
  53 + required: true
  54 + }
  55 +})
  56 +</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('Title2')
  7 +export const Title2Config: ConfigType = {
  8 + key,
  9 + chartKey,
  10 + conKey,
  11 + title: '小标题2',
  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 :width="w" :height="h" fill="none">
  4 + <defs xmlns="http://www.w3.org/2000/svg">
  5 + <linearGradient id="linear_title2_u" x1="0%" y1="50%" x2="100%" y2="50%" gradientUnits="objectBoundingBox">
  6 + <stop offset="0" :stop-color="attribute.linearColors[0]" stop-opacity="1" />
  7 + <stop offset="1" :stop-color="attribute.linearColors[1]" stop-opacity="1" />
  8 + </linearGradient>
  9 + <linearGradient id="linear_title2_d" x1="0%" y1="50%" x2="100%" y2="50%" gradientUnits="objectBoundingBox">
  10 + <stop offset="0" :stop-color="attribute.linearColors[3]" stop-opacity="1" />
  11 + <stop offset="1" :stop-color="attribute.linearColors[4]" stop-opacity="0" />
  12 + </linearGradient>
  13 + </defs>
  14 + <g opacity="1" transform="translate(0 0) rotate(0 160 15)">
  15 + <path
  16 + id="矩形 title2_u"
  17 + fill-rule="evenodd"
  18 + fill="url(#linear_title2_u)"
  19 + transform="translate(0 0) rotate(0 160 15)"
  20 + opacity="1"
  21 + :d="`M2.77,${h} L${w},${h} L${w},0 L${
  22 + w - 11.44
  23 + },0 C10.58,0 9.81,0.55 9.54,1.37 L0.88,27.37 C0.68,27.98 0.78,28.65 1.15,29.17 C1.53,29.69 2.13,30 2.77,30 Z `"
  24 + />
  25 + <path
  26 + id="矩形 title2_u"
  27 + style="stroke: url(#linear_title2_d); stroke-width: 1; stroke-opacity: 100; stroke-dasharray: 0 0"
  28 + transform="translate(0 0) rotate(0 160 15)"
  29 + :d="`M2.77,${h} L${w},${h} L${w},0 L11.44,0 C10.58,0 9.81,0.55 9.54,1.37 L0.88,27.37 C0.68,27.98 0.78,28.65 1.15,29.17 C1.53,29.69 2.13,30 2.77,30 Z `"
  30 + />
  31 + <g opacity="1" :transform="`translate(24 ${h / 2 - 26 / 2}) rotate(0 46 13)`">
  32 + <text>
  33 + <tspan
  34 + :x="attribute.fontPos.x"
  35 + :y="attribute.fontPos.y"
  36 + :font-size="attribute.fontSize"
  37 + line-height="0"
  38 + :fill="attribute.fontColor"
  39 + opacity="1"
  40 + font-family="YouSheBiaoTiHei"
  41 + letter-spacing="0"
  42 + >
  43 + {{ dataset }}
  44 + </tspan>
  45 + </text>
  46 + </g>
  47 + <path
  48 + id="矩形 title2_d"
  49 + fill-rule="evenodd"
  50 + :style="{ fill: attribute.linearColors[4] }"
  51 + :transform="`translate(9 ${h / 2 - 15 / 2}) rotate(0 3.5 7.5)`"
  52 + opacity="1"
  53 + d="M0,15L2,15L7,0L5,0L0,15Z "
  54 + />
  55 + <path
  56 + id="矩形 title2_d"
  57 + fill-rule="evenodd"
  58 + :style="{ fill: attribute.linearColors[5] }"
  59 + :transform="`translate(15 ${h / 2 - 15 / 2}) rotate(0 3.5 7.5)`"
  60 + opacity="1"
  61 + d="M0,15L2,15L7,0L5,0L0,15Z "
  62 + />
  63 + </g>
  64 + </svg>
  65 + </div>
  66 +</template>
  67 +<script setup lang="ts">
  68 +import { PropType, toRefs } from 'vue'
  69 +import { CreateComponentType } from '@/packages/index.d'
  70 +
  71 +const props = defineProps({
  72 + chartConfig: {
  73 + type: Object as PropType<CreateComponentType>,
  74 + required: true
  75 + }
  76 +})
  77 +
  78 +const { dataset, attribute } = toRefs(props.chartConfig.option)
  79 +
  80 +const { w, h } = toRefs(props.chartConfig.attr)
  81 +</script>
  82 +
  83 +<style lang="scss" scoped>
  84 +.go-content-box {
  85 + width: v-bind('w+"px"');
  86 + height: v-bind('h+"px"');
  87 + display: flex;
  88 + align-items: center;
  89 + justify-content: center;
  90 +}
  91 +</style>
... ...
1 1 import { ButtonConfig } from './Button/index'
2 2 import { Title1Config } from './Title1/index'
  3 +import { Title2Config } from './Title2/index'
3 4 import { CameraConfig } from './Camera/index'
4 5
5   -export default [ButtonConfig, Title1Config, CameraConfig]
  6 +export default [ButtonConfig, Title1Config, CameraConfig,Title2Config]
... ...