feat: 完善颜色选择

This commit is contained in:
奔跑的面条 2024-12-17 21:35:37 +08:00
parent 844b95987e
commit 5d6850b47d
2 changed files with 103 additions and 37 deletions

View File

@ -2,7 +2,7 @@
"name": "go-view", "name": "go-view",
"version": "1.1.11", "version": "1.1.11",
"engines": { "engines": {
"node": ">=16.14 <18.0.0" "node": ">=16.14"
}, },
"scripts": { "scripts": {
"dev": "vite --host", "dev": "vite --host",
@ -39,7 +39,7 @@
"keymaster": "^1.6.2", "keymaster": "^1.6.2",
"mitt": "^3.0.0", "mitt": "^3.0.0",
"monaco-editor": "^0.33.0", "monaco-editor": "^0.33.0",
"naive-ui": "2.34.3", "naive-ui": "2.40.3",
"pinia": "^2.0.13", "pinia": "^2.0.13",
"screenfull": "^6.0.1", "screenfull": "^6.0.1",
"three": "^0.145.0", "three": "^0.145.0",

View File

@ -1,27 +1,72 @@
<template> <template>
<n-grid :x-gap="8" :y-gap="8" :cols="2"> <n-grid :x-gap="8" :y-gap="8" :cols="2">
<n-gi v-for="item in list" :key="item.value"> <n-gi v-for="item in list" :key="item.value">
<n-card class="theme-item" size="small" @click="selectThemeHandle(item)"> <div
{{ item.name }} class="theme-item"
</n-card> :class="{ active: item.value === vChartThemeName }"
size="small"
@click="selectThemeHandle(item)"
>
<div class="go-flex-items-center">
<n-ellipsis style="text-align: left; width: 72px">{{ item.name }} </n-ellipsis>
<n-space :wrap-item="false" :size="2">
<span
class="theme-color-item"
v-for="colorItem in item.colors"
:key="colorItem"
:style="{ backgroundColor: colorItem }"
></span>
</n-space>
</div>
</div>
</n-gi> </n-gi>
</n-grid> </n-grid>
<div class="go-my-4">行业模板</div> <div class="go-my-4">行业模板</div>
<n-grid :x-gap="8" :y-gap="8" :cols="2"> <n-grid :x-gap="8" :y-gap="8" :cols="2">
<n-gi v-for="item in industryList" :key="item.value"> <n-gi v-for="item in industryList" :key="item.value">
<n-card class="theme-item-industry" size="small" @click="selectThemeHandle(item)"> <div
{{ item.name }} class="theme-item"
</n-card> :class="{ active: item.value === vChartThemeName }"
size="small"
@click="selectThemeHandle(item)"
>
<div class="go-flex-items-center">
<n-ellipsis style="text-align: left; width: 72px">{{ item.name }} </n-ellipsis>
<n-space :wrap-item="false" :size="2">
<span
class="theme-color-item"
v-for="colorItem in item.colors"
:key="colorItem"
:style="{ backgroundColor: colorItem }"
></span>
</n-space>
</div>
</div>
</n-gi> </n-gi>
</n-grid> </n-grid>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { ref, computed } from 'vue'
import { useVCharts } from '@/hooks' import { useVCharts } from '@/hooks'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { EditCanvasConfigEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
import { useDesignStore } from '@/store/modules/designStore/designStore'
const chartEditStore = useChartEditStore()
const designStore = useDesignStore()
const vCharts = useVCharts() const vCharts = useVCharts()
const themeMap = vCharts.getThemeMap() const themeMap = vCharts.getThemeMap()
const vChartThemeName = computed(() => {
return chartEditStore.getEditCanvasConfig.vChartThemeName
})
//
const themeColor = computed(() => {
return designStore.getAppTheme
})
const list = ref< const list = ref<
Array<{ Array<{
name: string name: string
@ -32,52 +77,52 @@ const list = ref<
{ {
name: '火山蓝(默认)', name: '火山蓝(默认)',
value: 'vScreenVolcanoBlue', value: 'vScreenVolcanoBlue',
colors: [] colors: ['#2D64DD', '#284588', '#58B4B6']
}, },
{ {
name: '党建红', name: '党建红',
value: 'vScreenPartyRed', value: 'vScreenPartyRed',
colors: [] colors: ['#d3d3d4', '#d68a46', '#d74f3c']
}, },
{ {
name: '清新蜡笔', name: '清新蜡笔',
value: 'vScreenClean', value: 'vScreenClean',
colors: [] colors: ['#94AF60', '#7696B8', '#d6837a']
}, },
{ {
name: '郊外', name: '郊外',
value: 'vScreenOutskirts', value: 'vScreenOutskirts',
colors: [] colors: ['#A7C4E6', '#e1bf99', '#c0bcbb']
}, },
{ {
name: '汽车蓝橙', name: '汽车蓝橙',
value: 'vScreenBlueOrange', value: 'vScreenBlueOrange',
colors: [] colors: ['#acd5fa', '#cc896b', '#5ea4dd']
}, },
{ {
name: '金融黄', name: '金融黄',
value: 'vScreenFinanceYellow', value: 'vScreenFinanceYellow',
colors: [] colors: ['#d7d7d7', '#f09761', '#f7d177']
}, },
{ {
name: '文旅青', name: '文旅青',
value: 'vScreenWenLvCyan', value: 'vScreenWenLvCyan',
colors: [] colors: ['#63c6ba', '#dcb974', '#a34440']
}, },
{ {
name: '电力绿', name: '电力绿',
value: 'vScreenElectricGreen', value: 'vScreenElectricGreen',
colors: [] colors: ['#75faf2', '#ee813e', '#f4ce7f']
}, },
{ {
name: '电商紫', name: '电商紫',
value: 'vScreenECommercePurple', value: 'vScreenECommercePurple',
colors: [] colors: ['#6d4cf6', '#ed7266', '#5f83f7']
}, },
{ {
name: '红蓝', name: '红蓝',
value: 'vScreenRedBlue', value: 'vScreenRedBlue',
colors: [] colors: ['#2e6cf6', '#bc4741', '#c1e4fb']
} }
]) ])
@ -92,93 +137,114 @@ const industryList = ref<
{ {
name: '明亮(适用白背景)', name: '明亮(适用白背景)',
value: 'light', value: 'light',
colors: [] colors: ['#3063f6', '#5dc3f9', '#f1f2f5']
}, },
{ {
name: '暗黑(适用黑背景)', name: '暗黑(适用黑背景)',
value: 'dark', value: 'dark',
colors: [] colors: ['#3063f6', '#5dc3f9', '#414348']
}, },
{ {
name: '亮-金融行业', name: '亮-金融行业',
value: 'veODesignLightFinance', value: 'veODesignLightFinance',
colors: [] colors: ['#dbba95', '#314b5e', '#f1f2f5']
}, },
{ {
name: '暗-金融行业', name: '暗-金融行业',
value: 'veODesignDarkFinance', value: 'veODesignDarkFinance',
colors: [] colors: ['#dbba95', '#314b5e', '#414348']
}, },
{ {
name: '亮-政府行业', name: '亮-政府行业',
value: 'veODesignLightGovernment', value: 'veODesignLightGovernment',
colors: [] colors: ['#c0403a', '#f6c552', '#f1f2f5']
}, },
{ {
name: '暗-政府行业', name: '暗-政府行业',
value: 'veODesignDarkGovernment', value: 'veODesignDarkGovernment',
colors: [] colors: ['#c0403a', '#f6c552', '#414348']
}, },
{ {
name: '亮-消费行业', name: '亮-消费行业',
value: 'veODesignLightConsumer', value: 'veODesignLightConsumer',
colors: [] colors: ['#3f36ab', '#eb4854', '#f1f2f5']
}, },
{ {
name: '暗-消费行业', name: '暗-消费行业',
value: 'veODesignDarkConsumer', value: 'veODesignDarkConsumer',
colors: [] colors: ['#3f36ab', '#eb4854', '#414348']
}, },
{ {
name: '亮-汽车行业', name: '亮-汽车行业',
value: 'veODesignLightAutomobile', value: 'veODesignLightAutomobile',
colors: [] colors: ['#1515d1', '#abb6cd', '#f1f2f5']
}, },
{ {
name: '暗-汽车行业', name: '暗-汽车行业',
value: 'veODesignDarkAutomobile', value: 'veODesignDarkAutomobile',
colors: [] colors: ['#1515d1', '#abb6cd', '#414348']
}, },
{ {
name: '亮-文旅行业', name: '亮-文旅行业',
value: 'veODesignLightCulturalTourism', value: 'veODesignLightCulturalTourism',
colors: [] colors: ['#77b897', '#3c5a4b', '#f1f2f5']
}, },
{ {
name: '暗-文旅行业', name: '暗-文旅行业',
value: 'veODesignDarkCulturalTourism', value: 'veODesignDarkCulturalTourism',
colors: [] colors: ['#77b897', '#3c5a4b', '#414348']
}, },
{ {
name: '亮-医疗行业', name: '亮-医疗行业',
value: 'veODesignLightMedical', value: 'veODesignLightMedical',
colors: [] colors: ['#76d0d1', '#314787', '#f1f2f5']
}, },
{ {
name: '暗-医疗行业', name: '暗-医疗行业',
value: 'veODesignDarkMedical', value: 'veODesignDarkMedical',
colors: [] colors: ['#76d0d1', '#314787', '#414348']
}, },
{ {
name: '亮-新能源行业', name: '亮-新能源行业',
value: 'veODesignLightNewEnergy', value: 'veODesignLightNewEnergy',
colors: [] colors: ['#64d886', '#1f3b76', '#f1f2f5']
}, },
{ {
name: '暗-新能源行业', name: '暗-新能源行业',
value: 'veODesignDarkNewEnergy', value: 'veODesignDarkNewEnergy',
colors: [] colors: ['#64d886', '#1f3b76', '#414348']
} }
]) ])
const selectThemeHandle = (item: { name: string; value: keyof typeof themeMap; colors: string[] }) => { const selectThemeHandle = (item: { name: string; value: keyof typeof themeMap; colors: string[] }) => {
vCharts.setTheme(item.value) vCharts.setTheme(item.value)
chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.VCHART_THEME_NAME, item.value)
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.theme-item, $radius: 6px;
.theme-item-industry { $itemRadius: 2px;
.theme-item {
display: flex;
align-items: center;
height: 34px;
padding: 0 16px;
overflow: hidden;
cursor: pointer; cursor: pointer;
font-size: 13px;
border-radius: $radius;
@include fetch-bg-color('background-color4-shallow');
&.active {
/* border: 1px solid v-bind('themeColor'); */
/* border-bottom: 1px solid rgba(0, 0, 0, 0); */
color: v-bind('themeColor');
}
.theme-color-item {
display: inline-block;
width: 16px;
height: 16px;
border-radius: $itemRadius;
}
} }
</style> </style>