Commit ea3e3802ffd512088c311d41d21d9d9abde0ccef

Authored by fengwotao
1 parent 0d8ef193

feat(packages/external): 自定义标签选择器

... ... @@ -27,7 +27,16 @@ export const option = {
27 27 label: '选项3',
28 28 value: '3'
29 29 }
30   - ]
  30 + ],
  31 + //自定义样式
  32 + tabStyleOptions: {
  33 + textColor: 'green',
  34 + textActiveColor: 'black',
  35 + textBackgroundColor: '#ffffff',
  36 + tabBarColor: 'green',
  37 + segmentBackgroundColor: 'grey',
  38 + segmentActiveColor: 'white'
  39 + }
31 40 }
32 41
33 42 export default class Config extends PublicConfigClass implements CreateComponentType {
... ...
1 1 <template>
2 2 <collapse-item name="标签页配置" :expanded="true">
3 3 <setting-item-box name="默认值" :alone="true">
4   - <n-select size="small" v-model:value="optionData.tabType" :options="tabTypeOptions" />
  4 + <n-select @change="handleSelect" size="small" v-model:value="optionData.tabType" :options="tabTypeOptions" />
  5 + </setting-item-box>
  6 + <setting-item-box name="未激活文字颜色" :alone="true">
  7 + <SettingItem name="颜色">
  8 + <n-color-picker
  9 + size="small"
  10 + :modes="['hex']"
  11 + v-model:value="optionData.tabStyleOptions.textColor"
  12 + ></n-color-picker>
  13 + </SettingItem>
  14 + <SettingItem>
  15 + <n-button size="small" @click="optionData.tabStyleOptions.textColor = 'green'"> 恢复默认 </n-button>
  16 + </SettingItem>
  17 + </setting-item-box>
  18 + <setting-item-box name="激活文字颜色" :alone="true">
  19 + <SettingItem name="颜色">
  20 + <n-color-picker
  21 + size="small"
  22 + :modes="['hex']"
  23 + v-model:value="optionData.tabStyleOptions.textActiveColor"
  24 + ></n-color-picker>
  25 + </SettingItem>
  26 + <SettingItem>
  27 + <n-button size="small" @click="optionData.tabStyleOptions.textActiveColor = 'black'"> 恢复默认 </n-button>
  28 + </SettingItem>
  29 + </setting-item-box>
  30 + <setting-item-box v-if="optionData.tabType === 'bar'" name="导航条颜色" :alone="true">
  31 + <SettingItem name="颜色">
  32 + <n-color-picker
  33 + size="small"
  34 + :modes="['hex']"
  35 + v-model:value="optionData.tabStyleOptions.tabBarColor"
  36 + ></n-color-picker>
  37 + </SettingItem>
  38 + <SettingItem>
  39 + <n-button size="small" @click="optionData.tabStyleOptions.tabBarColor = 'green'"> 恢复默认 </n-button>
  40 + </SettingItem>
  41 + </setting-item-box>
  42 + <setting-item-box v-if="optionData.tabType === 'segment'" name="分段背景色" :alone="true">
  43 + <SettingItem name="颜色">
  44 + <n-color-picker
  45 + size="small"
  46 + :modes="['hex']"
  47 + v-model:value="optionData.tabStyleOptions.segmentBackgroundColor"
  48 + ></n-color-picker>
  49 + </SettingItem>
  50 + <SettingItem>
  51 + <n-button size="small" @click="optionData.tabStyleOptions.segmentBackgroundColor = 'grey'"> 恢复默认 </n-button>
  52 + </SettingItem>
  53 + </setting-item-box>
  54 + <setting-item-box v-if="optionData.tabType === 'segment'" name="分段激活背景色" :alone="true">
  55 + <SettingItem name="颜色">
  56 + <n-color-picker
  57 + size="small"
  58 + :modes="['hex']"
  59 + v-model:value="optionData.tabStyleOptions.segmentActiveColor"
  60 + ></n-color-picker>
  61 + </SettingItem>
  62 + <SettingItem>
  63 + <n-button size="small" @click="optionData.tabStyleOptions.segmentActiveColor = 'white'"> 恢复默认 </n-button>
  64 + </SettingItem>
5 65 </setting-item-box>
6 66 </collapse-item>
7 67 </template>
... ... @@ -11,7 +71,7 @@ import { PropType } from 'vue'
11 71 import { CollapseItem, SettingItemBox } from '@/components/Pages/ChartItemSetting'
12 72 import { option } from './config'
13 73
14   -defineProps({
  74 +const props = defineProps({
15 75 optionData: {
16 76 type: Object as PropType<typeof option>,
17 77 required: true
... ... @@ -28,4 +88,11 @@ const tabTypeOptions = [
28 88 value: 'segment'
29 89 }
30 90 ]
  91 +
  92 +const handleSelect = (e: string) => {
  93 + if (e === 'bar') {
  94 + props.optionData.tabStyleOptions.segmentActiveColor = ''
  95 + props.optionData.tabStyleOptions.segmentBackgroundColor = ''
  96 + }
  97 +}
31 98 </script>
... ...
... ... @@ -21,6 +21,9 @@ const props = defineProps({
21 21 })
22 22
23 23 const { w, h } = toRefs(props.chartConfig.attr)
  24 +
  25 +const { tabStyleOptions } = toRefs(props.chartConfig.option)
  26 +
24 27 const option = shallowReactive({
25 28 value: cloneDeep(props.chartConfig.option)
26 29 })
... ... @@ -57,3 +60,22 @@ watch(
57 60 }
58 61 )
59 62 </script>
  63 +
  64 +<style lang="scss" scoped>
  65 +@include deep() {
  66 + .n-tabs-tab {
  67 + color: v-bind('tabStyleOptions.textColor') !important;
  68 + background: v-bind('tabStyleOptions.segmentBackgroundColor') !important;
  69 + }
  70 + .n-tabs-tab--active {
  71 + color: v-bind('tabStyleOptions.textActiveColor') !important;
  72 + background: v-bind('tabStyleOptions.segmentActiveColor') !important;
  73 + }
  74 + .n-tabs-bar {
  75 + background-color: v-bind('tabStyleOptions.tabBarColor') !important;
  76 + }
  77 + .n-tabs-tab-wrapper {
  78 + background-color: v-bind('tabStyleOptions.segmentBackgroundColor') !important;
  79 + }
  80 +}
  81 +</style>
... ...