| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <template>
- <div class="go-text-box">
- <div
- :style="`
- color: ${fontColor};
- padding: ${paddingY}px ${paddingX}px;
- font-size: ${fontSize}px;
- letter-spacing: ${letterSpacing}px;
- writing-mode: ${writingMode};
- border-style: solid;
- border-width: ${borderWidth}px;
- border-radius: ${borderRadius}px;
- border-color: ${borderColor};
- background-color:${backgroundColor}`"
- >
- <n-button v-if="link" @click="click" text>
- {{ dataset }}
- </n-button>
- <span v-else>{{ dataset }}</span>
- </div>
- </div>
- </template>
- <script setup lang="ts">
- import { PropType, toRefs, shallowReactive, watch } from 'vue'
- import { CreateComponentType } from '@/packages/index.d'
- import { useChartDataFetch } from '@/hooks'
- import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
- import { option as configOption } from './config'
- const props = defineProps({
- chartConfig: {
- type: Object as PropType<CreateComponentType>,
- required: true
- }
- })
- const { w, h } = toRefs(props.chartConfig.attr)
- const {
- link,
- dataset,
- fontColor,
- fontSize,
- letterSpacing,
- paddingY,
- paddingX,
- borderWidth,
- borderColor,
- borderRadius,
- writingMode,
- backgroundColor
- } = toRefs(props.chartConfig.option)
- const option = shallowReactive({
- dataset: configOption.dataset
- })
- // 手动更新
- watch(
- () => props.chartConfig.option.dataset,
- (newData: any) => {
- option.dataset = newData
- },
- {
- immediate: true,
- deep: false
- }
- )
- // 预览更新
- useChartDataFetch(props.chartConfig, useChartEditStore, (newData: string) => {
- option.dataset = newData
- })
- //打开链接
- const click = () => {
- window.open(link.value)
- }
- </script>
- <style lang="scss" scoped>
- @include go('text-box') {
- display: flex;
- align-items: center;
- justify-content: center;
- }
- </style>
|