feat: 新增信息-文字-新增【渐变文字】组件

feat: 新增信息-文字-新增【渐变文字】组件
This commit is contained in:
Ryker 2022-06-15 01:43:07 +00:00 committed by 奔跑的面条
parent ffa127593a
commit b8d0d1a2ff
5 changed files with 133 additions and 1 deletions

View File

@ -0,0 +1,20 @@
import { publicConfig } from '@/packages/public'
import { CreateComponentType } from '@/packages/index.d'
import { TextGradientConfig } from './index'
import cloneDeep from 'lodash/cloneDeep'
export const option = {
dataset: '我是渐变文本',
size: 20,
gradient: {
from: '#0000FFFF',
to: '#00FF00FF',
deg: 45
}
}
export default class Config extends publicConfig implements CreateComponentType {
public key = TextGradientConfig.key
public chartConfig = cloneDeep(TextGradientConfig)
public option = cloneDeep(option)
}

View File

@ -0,0 +1,45 @@
<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>
</collapse-item>
<collapse-item name="样式" :expanded="true">
<setting-item-box name="文字">
<setting-item name="字体大小">
<n-input-number v-model:value="optionData.size" size="small" placeholder="字体大小"></n-input-number>
</setting-item>
</setting-item-box>
<setting-item-box name="渐变色参数">
<setting-item name="起始值">
<n-color-picker size="small" :modes="['hex']" v-model:value="optionData.gradient.from"></n-color-picker>
</setting-item>
<setting-item name="结束值">
<n-color-picker size="small" :modes="['hex']" v-model:value="optionData.gradient.to"></n-color-picker>
</setting-item>
<setting-item name="偏移角度">
<n-input-number v-model:value="optionData.gradient.deg" size="small" 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,14 @@
import image from '@/assets/images/chart/informations/text_static.png'
import { ConfigType, PackagesCategoryEnum } from '@/packages/index.d'
import { ChatCategoryEnum,ChatCategoryEnumName } from '../../index.d'
export const TextGradientConfig: ConfigType = {
key: 'TextGradient',
chartKey: 'VTextGradient',
conKey: 'VCTextGradient',
title: '渐变文字',
category: ChatCategoryEnum.TEXT,
categoryName: ChatCategoryEnumName.TEXT,
package: PackagesCategoryEnum.INFORMATIONS,
image
}

View File

@ -0,0 +1,52 @@
<template>
<div class="go-text-box">
<n-gradient-text :size="size" :gradient="gradient">
{{ option.dataset }}
</n-gradient-text>
</div>
</template>
<script setup lang="ts">
import { PropType, toRefs, reactive, watch } from 'vue'
import { CreateComponentType } from '@/packages/index.d'
import { useChartDataFetch } from '@/hooks'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
const props = defineProps({
chartConfig: {
type: Object as PropType<CreateComponentType>,
required: true,
},
})
const option = reactive({
dataset: ''
})
const { w, h } = toRefs(props.chartConfig.attr)
const {
size,
gradient
} = toRefs(props.chartConfig.option)
const callback = (newData: string) => {
option.dataset = newData
}
watch(
() => props.chartConfig.option.dataset,
() => {
option.dataset = props.chartConfig.option.dataset
}, { immediate: true }
)
useChartDataFetch(props.chartConfig, useChartEditStore, callback)
</script>
<style lang="scss" scoped>
@include go('text-box') {
display: flex;
align-items: center;
justify-content: center;
}
</style>

View File

@ -1,3 +1,4 @@
import { TextCommonConfig } from './TextCommon/index'
import { TextGradientConfig } from './TextGradient/index'
export default [TextCommonConfig]
export default [TextCommonConfig, TextGradientConfig]