mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-06 03:58:04 +08:00
feat: 新增渐变文本组件
This commit is contained in:
parent
749c0a2f39
commit
5d803e3fa6
BIN
src/assets/images/chart/informations/text_gradient.png
Normal file
BIN
src/assets/images/chart/informations/text_gradient.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 44 KiB |
@ -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)
|
||||||
|
}
|
@ -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>
|
@ -0,0 +1,14 @@
|
|||||||
|
import image from '@/assets/images/chart/informations/text_gradient.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
|
||||||
|
}
|
@ -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>
|
@ -1,3 +1,4 @@
|
|||||||
import { TextCommonConfig } from './TextCommon/index'
|
import { TextCommonConfig } from './TextCommon/index'
|
||||||
|
import { TextGradientConfig } from './TextGradient/index'
|
||||||
|
|
||||||
export default [TextCommonConfig]
|
export default [TextCommonConfig, TextGradientConfig]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user