Showing
11 changed files
with
403 additions
and
6 deletions
... | ... | @@ -2,6 +2,7 @@ import { PublicConfigClass } from '@/packages/public' |
2 | 2 | import { CreateComponentType } from '@/packages/index.d' |
3 | 3 | import { OverrideTextCommonConfig } from './index' |
4 | 4 | import cloneDeep from 'lodash/cloneDeep' |
5 | +import { chartInitConfig } from '@/settings/designSetting' | |
5 | 6 | |
6 | 7 | export enum WritingModeEnum { |
7 | 8 | HORIZONTAL = '水平', |
... | ... | @@ -50,6 +51,7 @@ export const option = { |
50 | 51 | |
51 | 52 | export default class Config extends PublicConfigClass implements CreateComponentType { |
52 | 53 | public key = OverrideTextCommonConfig.key |
54 | + public attr = { ...chartInitConfig, w: 150, h: 40, zIndex: -1 } | |
53 | 55 | public chartConfig = cloneDeep(OverrideTextCommonConfig) |
54 | 56 | public option = cloneDeep(option) |
55 | 57 | } | ... | ... |
1 | +import { PublicConfigClass } from '@/packages/public' | |
2 | +import { CreateComponentType } from '@/packages/index.d' | |
3 | +import { OverrideTextBarrageConfig } from './index' | |
4 | +import { chartInitConfig } from '@/settings/designSetting' | |
5 | +import cloneDeep from 'lodash/cloneDeep' | |
6 | + | |
7 | +export enum FontWeightEnum { | |
8 | + NORMAL = '常规', | |
9 | + BOLD = '加粗', | |
10 | +} | |
11 | + | |
12 | +export const FontWeightObject = { | |
13 | + [FontWeightEnum.NORMAL]: 'normal', | |
14 | + [FontWeightEnum.BOLD]: 'bold', | |
15 | +} | |
16 | + | |
17 | +export const option = { | |
18 | + dataset: '让数字化看得见', | |
19 | + fontSize: 32, | |
20 | + fontColor: '#ffffff', | |
21 | + fontWeight: 'normal', | |
22 | + // 字间距 | |
23 | + letterSpacing: 5, | |
24 | + //阴影 | |
25 | + showShadow: true, | |
26 | + boxShadow: 'none', | |
27 | + hShadow: 0, | |
28 | + vShadow: 0, | |
29 | + blurShadow: 8, | |
30 | + colorShadow: '#0075ff', | |
31 | + //动画 | |
32 | + animationTime: 0, | |
33 | + animationSpeed: 50, | |
34 | +} | |
35 | + | |
36 | +export default class Config extends PublicConfigClass implements CreateComponentType { | |
37 | + public key = OverrideTextBarrageConfig.key | |
38 | + public attr = { ...chartInitConfig, w: 260, h: 40, zIndex: -1 } | |
39 | + public chartConfig = cloneDeep(OverrideTextBarrageConfig) | |
40 | + public option = cloneDeep(option) | |
41 | + public preview = { overFlowHidden: true } | |
42 | +} | ... | ... |
1 | +<template> | |
2 | + <collapse-item name="信息" :expanded="true"> | |
3 | + <setting-item-box name="文字" :alone="true"> | |
4 | + <setting-item> | |
5 | + <n-input v-model:value="optionData.dataset" size="small"></n-input> | |
6 | + </setting-item> | |
7 | + </setting-item-box> | |
8 | + </collapse-item> | |
9 | + | |
10 | + <collapse-item name="样式" :expanded="true"> | |
11 | + <setting-item-box name="文字"> | |
12 | + <setting-item name="颜色"> | |
13 | + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.fontColor"></n-color-picker> | |
14 | + </setting-item> | |
15 | + <setting-item name="字体大小"> | |
16 | + <n-input-number v-model:value="optionData.fontSize" size="small" placeholder="字体大小"></n-input-number> | |
17 | + </setting-item> | |
18 | + <setting-item name="字体粗细"> | |
19 | + <n-select v-model:value="optionData.fontWeight" size="small" :options="fontWeightOptions" /> | |
20 | + </setting-item> | |
21 | + | |
22 | + <setting-item name="字间距"> | |
23 | + <n-input-number v-model:value="optionData.letterSpacing" size="small" placeholder="输入字间距"></n-input-number> | |
24 | + </setting-item> | |
25 | + </setting-item-box> | |
26 | + <setting-item-box name="阴影"> | |
27 | + <setting-item> | |
28 | + <n-space> | |
29 | + <n-switch v-model:value="optionData.showShadow" size="small" /> | |
30 | + <n-text>展示阴影</n-text> | |
31 | + </n-space> | |
32 | + </setting-item> | |
33 | + <setting-item name="颜色"> | |
34 | + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.colorShadow"></n-color-picker | |
35 | + ></setting-item> | |
36 | + <setting-item name="x"> | |
37 | + <n-input-number v-model:value="optionData.hShadow" size="small"></n-input-number | |
38 | + ></setting-item> | |
39 | + <setting-item name="y"> | |
40 | + <n-input-number v-model:value="optionData.vShadow" size="small"></n-input-number | |
41 | + ></setting-item> | |
42 | + <setting-item name="模糊"> | |
43 | + <n-input-number v-model:value="optionData.blurShadow" size="small"></n-input-number | |
44 | + ></setting-item> | |
45 | + </setting-item-box> | |
46 | + | |
47 | + <setting-item-box name="动画"> | |
48 | + <setting-item name="动画速度"> | |
49 | + <n-input-number | |
50 | + v-model:value="optionData.animationSpeed" | |
51 | + size="small" | |
52 | + placeholder="动画速度" | |
53 | + :min="0" | |
54 | + ></n-input-number> | |
55 | + </setting-item> | |
56 | + <setting-item name="动画间隔"> | |
57 | + <n-input-number | |
58 | + v-model:value="optionData.animationTime" | |
59 | + size="small" | |
60 | + placeholder="动画间隔" | |
61 | + :min="0" | |
62 | + ></n-input-number> | |
63 | + </setting-item> | |
64 | + </setting-item-box> | |
65 | + </collapse-item> | |
66 | +</template> | |
67 | + | |
68 | +<script setup lang="ts"> | |
69 | +import { PropType } from 'vue' | |
70 | +import { option, FontWeightEnum, FontWeightObject } from './config' | |
71 | +import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' | |
72 | +const props = defineProps({ | |
73 | + optionData: { | |
74 | + type: Object as PropType<typeof option>, | |
75 | + required: true | |
76 | + } | |
77 | +}) | |
78 | + | |
79 | +const fontWeightOptions = [ | |
80 | + { | |
81 | + label: FontWeightEnum.NORMAL, | |
82 | + value: FontWeightObject[FontWeightEnum.NORMAL] | |
83 | + }, | |
84 | + { | |
85 | + label: FontWeightEnum.BOLD, | |
86 | + value: FontWeightObject[FontWeightEnum.BOLD] | |
87 | + } | |
88 | +] | |
89 | +</script> | ... | ... |
1 | +import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d' | |
2 | +import { ChatCategoryEnum, ChatCategoryEnumName } from '@/packages/components/Informations/index.d' | |
3 | +import { useWidgetKey } from '@/packages/external/useWidgetKey' | |
4 | + | |
5 | +const { key, conKey, chartKey } = useWidgetKey('OverrideTextBarrage', true) | |
6 | + | |
7 | +export const OverrideTextBarrageConfig: ConfigType = { | |
8 | + key, | |
9 | + chartKey, | |
10 | + conKey, | |
11 | + title: '自定义弹幕文字', | |
12 | + category: ChatCategoryEnum.TEXT, | |
13 | + categoryName: ChatCategoryEnumName.TEXT, | |
14 | + package: PackagesCategoryEnum.INFORMATIONS, | |
15 | + chartFrame: ChartFrameEnum.COMMON, | |
16 | + image: 'text_barrage.png' | |
17 | +} | ... | ... |
1 | +<template> | |
2 | + <div class="go-text-box"> | |
3 | + <div class="content"> | |
4 | + <span> | |
5 | + {{ option.dataset }} | |
6 | + </span> | |
7 | + </div> | |
8 | + </div> | |
9 | +</template> | |
10 | + | |
11 | +<script setup lang="ts"> | |
12 | +import { PropType, toRefs, shallowReactive, watch, computed, ref } from 'vue' | |
13 | +import { CreateComponentType } from '@/packages/index.d' | |
14 | +import { useChartDataFetch } from '@/hooks' | |
15 | +import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' | |
16 | +import { option as configOption } from './config' | |
17 | +import { values } from 'lodash' | |
18 | + | |
19 | +const props = defineProps({ | |
20 | + chartConfig: { | |
21 | + type: Object as PropType<CreateComponentType & typeof option>, | |
22 | + required: true | |
23 | + } | |
24 | +}) | |
25 | + | |
26 | +const { w } = toRefs(props.chartConfig.attr) | |
27 | + | |
28 | +const { fontColor, fontSize, letterSpacing, fontWeight, animationTime, animationSpeed, boxShadow } = toRefs( | |
29 | + props.chartConfig.option | |
30 | +) | |
31 | + | |
32 | +const option = shallowReactive({ | |
33 | + dataset: configOption.dataset | |
34 | +}) | |
35 | + | |
36 | +// 手动更新 | |
37 | +watch( | |
38 | + () => props.chartConfig.option.dataset, | |
39 | + (newData: any) => { | |
40 | + option.dataset = newData | |
41 | + }, | |
42 | + { | |
43 | + immediate: true, | |
44 | + deep: false | |
45 | + } | |
46 | +) | |
47 | + | |
48 | +//阴影 | |
49 | +watch( | |
50 | + props.chartConfig.option, | |
51 | + () => { | |
52 | + try { | |
53 | + if (props.chartConfig.option.showShadow) { | |
54 | + boxShadow.value = `${props.chartConfig.option.hShadow}px ${props.chartConfig.option.vShadow}px ${props.chartConfig.option.blurShadow}px ${props.chartConfig.option.colorShadow}` | |
55 | + } else { | |
56 | + boxShadow.value = 'none' | |
57 | + } | |
58 | + } catch (error) { | |
59 | + console.log(error) | |
60 | + } | |
61 | + }, | |
62 | + { | |
63 | + immediate: true | |
64 | + } | |
65 | +) | |
66 | + | |
67 | +const transitionDuration = computed(() => { | |
68 | + return Math.floor((w.value as any) / (animationSpeed.value as any)) | |
69 | +}) | |
70 | + | |
71 | +// 预览更新 | |
72 | +useChartDataFetch(props.chartConfig, useChartEditStore, (newData: string) => { | |
73 | + option.dataset = newData | |
74 | +}) | |
75 | +</script> | |
76 | + | |
77 | +<style lang="scss" scoped> | |
78 | +@include go('text-box') { | |
79 | + display: flex; | |
80 | + align-items: center; | |
81 | + .content { | |
82 | + width: 100%; | |
83 | + color: v-bind('fontColor'); | |
84 | + font-size: v-bind('fontSize + "px"'); | |
85 | + letter-spacing: v-bind('letterSpacing + "px"'); | |
86 | + font-weight: v-bind('fontWeight'); | |
87 | + text-shadow: v-bind('boxShadow'); | |
88 | + position: absolute; | |
89 | + animation: barrage v-bind('transitionDuration + "s"') linear v-bind('animationTime + "s"') infinite; | |
90 | + } | |
91 | + @keyframes barrage { | |
92 | + from { | |
93 | + left: 100%; | |
94 | + transform: translateX(0); | |
95 | + } | |
96 | + to { | |
97 | + left: 0; | |
98 | + transform: translateX(-100%); | |
99 | + } | |
100 | + } | |
101 | +} | |
102 | +</style> | ... | ... |
1 | +import { PublicConfigClass } from '@/packages/public' | |
2 | +import { CreateComponentType } from '@/packages/index.d' | |
3 | +import { OverrideTextGradientConfig } from './index' | |
4 | +import cloneDeep from 'lodash/cloneDeep' | |
5 | +import { chartInitConfig } from '@/settings/designSetting' | |
6 | + | |
7 | +export const option = { | |
8 | + dataset: '我是渐变文本', | |
9 | + size: 20, | |
10 | + gradient: { | |
11 | + from: '#0000FFFF', | |
12 | + to: '#00FF00FF', | |
13 | + deg: 45 | |
14 | + } | |
15 | +} | |
16 | + | |
17 | +export default class Config extends PublicConfigClass implements CreateComponentType { | |
18 | + public key = OverrideTextGradientConfig.key | |
19 | + public attr = { ...chartInitConfig, w: 150, h: 40, zIndex: -1 } | |
20 | + public chartConfig = cloneDeep(OverrideTextGradientConfig) | |
21 | + public option = cloneDeep(option) | |
22 | +} | ... | ... |
1 | +<template> | |
2 | + <collapse-item name="信息" :expanded="true"> | |
3 | + <setting-item-box name="文字" :alone="true"> | |
4 | + <setting-item> | |
5 | + <n-input v-model:value="optionData.dataset" size="small"></n-input> | |
6 | + </setting-item> | |
7 | + </setting-item-box> | |
8 | + </collapse-item> | |
9 | + <collapse-item name="样式" :expanded="true"> | |
10 | + <setting-item-box name="文字"> | |
11 | + <setting-item name="字体大小"> | |
12 | + <n-input-number v-model:value="optionData.size" size="small" placeholder="字体大小"></n-input-number> | |
13 | + </setting-item> | |
14 | + </setting-item-box> | |
15 | + <setting-item-box name="渐变色参数"> | |
16 | + <setting-item name="起始值"> | |
17 | + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.gradient.from"></n-color-picker> | |
18 | + </setting-item> | |
19 | + <setting-item name="结束值"> | |
20 | + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.gradient.to"></n-color-picker> | |
21 | + </setting-item> | |
22 | + <setting-item name="偏移角度"> | |
23 | + <n-input-number v-model:value="optionData.gradient.deg" size="small" placeholder="颜色旋转"></n-input-number> | |
24 | + </setting-item> | |
25 | + </setting-item-box> | |
26 | + | |
27 | + </collapse-item> | |
28 | +</template> | |
29 | + | |
30 | +<script setup lang="ts"> | |
31 | +import { PropType } from 'vue' | |
32 | +import { option } from './config' | |
33 | +import { | |
34 | + CollapseItem, | |
35 | + SettingItemBox, | |
36 | + SettingItem | |
37 | +} from '@/components/Pages/ChartItemSetting' | |
38 | + | |
39 | +const props = defineProps({ | |
40 | + optionData: { | |
41 | + type: Object as PropType<typeof option>, | |
42 | + required: true | |
43 | + } | |
44 | +}) | |
45 | +</script> | ... | ... |
1 | +import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d' | |
2 | +import { ChatCategoryEnum, ChatCategoryEnumName } from '@/packages/components/Informations/index.d' | |
3 | +import { useWidgetKey } from '@/packages/external/useWidgetKey' | |
4 | + | |
5 | +const { key, conKey, chartKey } = useWidgetKey('OverrideTextGradient', true) | |
6 | + | |
7 | +export const OverrideTextGradientConfig: ConfigType = { | |
8 | + key, | |
9 | + chartKey, | |
10 | + conKey, | |
11 | + title: '自定义渐变文字', | |
12 | + category: ChatCategoryEnum.TEXT, | |
13 | + categoryName: ChatCategoryEnumName.TEXT, | |
14 | + package: PackagesCategoryEnum.INFORMATIONS, | |
15 | + chartFrame: ChartFrameEnum.COMMON, | |
16 | + image: 'text_gradient.png' | |
17 | +} | ... | ... |
1 | +<template> | |
2 | + <div class="go-text-box"> | |
3 | + <n-gradient-text :size="size" :gradient="gradient"> | |
4 | + {{ option.dataset }} | |
5 | + </n-gradient-text> | |
6 | + </div> | |
7 | +</template> | |
8 | +<script setup lang="ts"> | |
9 | +import { PropType, toRefs, shallowReactive, watch } from 'vue' | |
10 | +import { CreateComponentType } from '@/packages/index.d' | |
11 | +import { useChartDataFetch } from '@/hooks' | |
12 | +import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' | |
13 | +import { option as configOption } from './config' | |
14 | + | |
15 | +const props = defineProps({ | |
16 | + chartConfig: { | |
17 | + type: Object as PropType<CreateComponentType>, | |
18 | + required: true | |
19 | + } | |
20 | +}) | |
21 | + | |
22 | +const option = shallowReactive({ | |
23 | + dataset: configOption.dataset | |
24 | +}) | |
25 | + | |
26 | +const { w, h } = toRefs(props.chartConfig.attr) | |
27 | +const { size, gradient } = toRefs(props.chartConfig.option) | |
28 | + | |
29 | +watch( | |
30 | + () => props.chartConfig.option.dataset, | |
31 | + (newData: any) => { | |
32 | + option.dataset = newData | |
33 | + }, | |
34 | + { | |
35 | + immediate: true, | |
36 | + deep: false | |
37 | + } | |
38 | +) | |
39 | + | |
40 | +useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => { | |
41 | + option.dataset = newData | |
42 | +}) | |
43 | +</script> | |
44 | + | |
45 | +<style lang="scss" scoped> | |
46 | +@include go('text-box') { | |
47 | + display: flex; | |
48 | + align-items: center; | |
49 | + justify-content: center; | |
50 | + .n-gradient-text { | |
51 | + white-space: initial; | |
52 | + } | |
53 | +} | |
54 | +</style> | ... | ... |
... | ... | @@ -11,12 +11,13 @@ import { OverrideInputsTabConfig } from '@/packages/components/external/Informat |
11 | 11 | import { OverrideTextCommonConfig } from '@/packages/components/external/Informations/Mores/OverrideTextCommon' |
12 | 12 | import { OverrideIframeConfig } from '@/packages/components/external/Informations/Mores/OverrideIframe' |
13 | 13 | import { ButtonConfig } from '@/packages/components/external/Informations/Mores/Button' |
14 | +import { OverrideTextBarrageConfig } from '@/packages/components/external/Informations/Texts/OverrideTextBarrage' | |
15 | +import { OverrideTextGradientConfig } from '@/packages/components/external/Informations/Texts/OverrideTextGradient' | |
14 | 16 | import { OverrideBarCommonConfig } from '@/packages/components/external/Charts/Bars/OverrideBarCommon' |
15 | 17 | import { OverrideLineCommonConfig } from '@/packages/components/external/Charts/Lines/OverrideLineCommon' |
16 | 18 | import { OverrideLineGradientsConfig } from '@/packages/components/external/Charts/Lines/OverrideLineGradients' |
17 | 19 | |
18 | 20 | export function useInjectLib(packagesList: EPackagesType) { |
19 | - | |
20 | 21 | packagesList[EPackagesCategoryEnum.COMPOSES] = ComposesList |
21 | 22 | |
22 | 23 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.DECORATES, PickIconConfig) |
... | ... | @@ -29,17 +30,23 @@ export function useInjectLib(packagesList: EPackagesType) { |
29 | 30 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideTextCommonConfig) |
30 | 31 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, ButtonConfig) |
31 | 32 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideIframeConfig) |
33 | + addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideTextBarrageConfig) | |
34 | + addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideTextGradientConfig) | |
32 | 35 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideBarCommonConfig) |
33 | 36 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideLineCommonConfig) |
34 | 37 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideLineGradientsConfig) |
35 | 38 | } |
36 | 39 | |
37 | 40 | /** |
38 | - * | |
39 | - * @param packagesList | |
40 | - * @param categoryName | |
41 | - * @param config | |
41 | + * | |
42 | + * @param packagesList | |
43 | + * @param categoryName | |
44 | + * @param config | |
42 | 45 | */ |
43 | -function addWidgetToCategoryByCategoryName(packagesList: EPackagesType, categoryName: PackagesCategoryEnum, config: ConfigType) { | |
46 | +function addWidgetToCategoryByCategoryName( | |
47 | + packagesList: EPackagesType, | |
48 | + categoryName: PackagesCategoryEnum, | |
49 | + config: ConfigType | |
50 | +) { | |
44 | 51 | packagesList[categoryName].push(config) |
45 | 52 | } | ... | ... |