Compare commits

..

36 Commits

Author SHA1 Message Date
奔跑的面条
e841d3db17 Merge branch 'master-fetch-dev' into master-fetch 2023-02-27 19:04:38 +08:00
奔跑的面条
800a0141a5 build: 升级版本到2.1.8 2023-02-27 19:04:05 +08:00
奔跑的面条
c92d7cab97 Merge branch 'dev' into master-fetch-dev 2023-02-27 13:07:05 +08:00
奔跑的面条
dc458ea88e fix: 解决删除颜色之后自动选择的错误 2023-02-27 13:06:27 +08:00
奔跑的面条
86de4e105e Merge branch 'dev' into master-fetch-dev 2023-02-27 12:53:44 +08:00
奔跑的面条
6f4e967b49 perf: 优化自定义颜色组件交互 2023-02-27 12:46:36 +08:00
奔跑的面条
62a2ed2b4a feat: 新增颜色自定义功能 2023-02-27 00:29:47 +08:00
奔跑的面条
97899f275a perf: 优化自定义颜色交互 2023-02-27 00:24:19 +08:00
奔跑的面条
8b6c616a15 perf: 处理渐变色和自定义色的交互 2023-02-26 23:34:40 +08:00
奔跑的面条
87386e69a3 feat: 对接全局颜色和自定义组件交互 2023-02-26 18:36:15 +08:00
奔跑的面条
196df94aee perf: 优化颜色组件展示 2023-02-26 13:08:22 +08:00
奔跑的面条
a407d118fa perf: 优化 UI 控件交互 2023-02-26 01:43:46 +08:00
奔跑的面条
0fc7bde348 perf: 优化数据 2023-02-25 23:44:03 +08:00
奔跑的面条
9a8899ae40 feat: 优化颜色选择器页面 2023-02-25 22:28:09 +08:00
奔跑的面条
8cb711b892 feat: 新增自定义颜色弹窗 2023-02-25 22:00:55 +08:00
奔跑的面条
49d8c35747 perf: 优化主题颜色UI 2023-02-24 21:42:27 +08:00
奔跑的面条
125856677a fix: 处理 deep 失效的问题 2023-02-24 21:34:15 +08:00
奔跑的面条
e8e05033cd Merge branch 'master-fetch-dev' into master-fetch 2023-02-17 18:15:50 +08:00
奔跑的面条
3790bc0207 Merge branch 'dev' into master-fetch-dev 2023-02-17 18:15:35 +08:00
奔跑的面条
b3bff2ee45 fix: 解决顶层无法写 await 的问题 2023-02-17 18:15:00 +08:00
奔跑的面条
8c4e3e8965 Merge branch 'master-fetch-dev' into master-fetch 2023-02-17 14:34:28 +08:00
奔跑的面条
b03107d8cb build: 升级带后端版本到2.1.7 2023-02-17 14:33:53 +08:00
奔跑的面条
e9a4ebe38f Merge branch 'master-fetch-dev' into master-fetch 2023-02-17 14:33:18 +08:00
奔跑的面条
a702decfd4 Merge branch 'dev' into master-fetch-dev 2023-02-15 14:26:56 +08:00
奔跑的面条
fc58df2148 feat: 新增 public 预览配置项preview 2023-02-15 14:24:56 +08:00
奔跑的面条
0eecc1e19d Merge branch 'dev' into master-fetch-dev 2023-02-15 09:45:37 +08:00
奔跑的面条
4f2609a121 perf: 优化内存泄漏问题 2023-02-15 09:20:48 +08:00
奔跑的面条
f21c9f1246 perf: 优化 iframe 组件默认宽度 2023-02-14 21:12:30 +08:00
奔跑的面条
182b2c508a Merge branch 'dev' into master-fetch-dev 2023-02-09 16:24:19 +08:00
奔跑的面条
d7aa41094b perf: 优化过滤器体验,提示错误内容 2023-02-09 11:29:23 +08:00
奔跑的面条
4ec1bbd912 fix: 解决预览序列化遗漏替换的位置 2023-02-08 16:38:38 +08:00
奔跑的面条
a7b98fe3d6 feat: 新增初始化函数,全局异步错误捕获功能 2023-02-02 20:54:02 +08:00
奔跑的面条
bc02950a6f !126 工作空间初始化,右侧页面配置内容被挤出
Merge pull request !126 from 且听风吟720/N/A
2023-02-02 09:45:29 +00:00
且听风吟720
4e5c921bf2 fix: 工作空间初始化,右侧页面配置内容被挤出
Signed-off-by: 且听风吟720 <shige720@qq.com>
2023-02-02 09:34:50 +00:00
奔跑的面条
14c5d935c4 !125 轮播列表配置界面增加轮播方式配置项
Merge pull request !125 from alucardpj/dev
2023-02-02 08:52:08 +00:00
pengjian
b73893a6af 轮播列表配置界面增加轮播方式配置项 2023-02-02 10:00:30 +08:00
60 changed files with 1179 additions and 148 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "go-view",
"version": "2.1.6",
"version": "2.1.8",
"engines": {
"node": ">=16.14 <18.0.0"
},

View File

@@ -6,6 +6,7 @@ import { CreateComponentType, ChartFrameEnum } from '@/packages/index.d'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { RequestDataTypeEnum } from '@/enums/httpEnum'
import { isPreview, newFunctionHandle, intervalUnitHandle } from '@/utils'
import { setOption } from '@/packages/public/chart'
// 获取类型
type ChartEditStoreType = typeof useChartEditStore
@@ -34,7 +35,7 @@ export const useChartDataFetch = (
const echartsUpdateHandle = (dataset: any) => {
if (chartFrame === ChartFrameEnum.ECHARTS) {
if (vChartRef.value) {
vChartRef.value.setOption({ dataset: dataset })
setOption(vChartRef.value, { dataset: dataset })
}
}
}

View File

@@ -3,7 +3,7 @@ import App from './App.vue'
import router, { setupRouter } from '@/router'
import i18n from '@/i18n/index'
import { setupStore } from '@/store'
import { setupNaive, setupDirectives, setupCustomComponents } from '@/plugins'
import { setupNaive, setupDirectives, setupCustomComponents, initFunction } from '@/plugins'
import { GoAppProvider } from '@/components/GoAppProvider/index'
import { setHtmlTheme } from '@/utils'
@@ -53,4 +53,7 @@ async function appInit() {
window['$vue'] = app
}
void appInit()
appInit().then(() => {
initFunction()
})

View File

@@ -122,23 +122,28 @@ const calcData = (data: any, type?: string) => {
// 数据解析
const calcCapsuleLengthAndLabelData = (dataset: any) => {
const { source } = dataset
if (!source.length) return
try {
const { source } = dataset
if (!source || !source.length) return
state.capsuleItemHeight = numberSizeHandle(state.mergedConfig.itemHeight)
const capsuleValue = source.map((item: DataProps) => item[state.mergedConfig.dataset.dimensions[1]])
state.capsuleItemHeight = numberSizeHandle(state.mergedConfig.itemHeight)
const capsuleValue = source.map((item: DataProps) => item[state.mergedConfig.dataset.dimensions[1]])
const maxValue = Math.max(...capsuleValue)
const maxValue = Math.max(...capsuleValue)
state.capsuleValue = capsuleValue
state.capsuleValue = capsuleValue
state.capsuleLength = capsuleValue.map((v: any) => (maxValue ? v / maxValue : 0))
state.capsuleLength = capsuleValue.map((v: any) => (maxValue ? v / maxValue : 0))
const oneFifth = maxValue / 5
const oneFifth = maxValue / 5
const labelData = Array.from(new Set(new Array(6).fill(0).map((v, i) => Math.ceil(i * oneFifth))))
const labelData = Array.from(new Set(new Array(6).fill(0).map((v, i) => Math.ceil(i * oneFifth))))
state.labelData = labelData
state.labelData = labelData
} catch (error) {
console.warn(error);
}
}
const numberSizeHandle = (val: string | number) => {

View File

@@ -1,7 +1,6 @@
import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
import { LineCommonConfig } from './index'
import { CreateComponentType } from '@/packages/index.d'
import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json'

View File

@@ -15,7 +15,7 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore
import { chartColorsSearch, defaultTheme } from '@/settings/chartThemes/index'
import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components'
import { useChartDataFetch } from '@/hooks'
import { isPreview } from '@/utils'
import { isPreview, colorGradientCustomMerge} from '@/utils'
const props = defineProps({
themeSetting: {
@@ -45,7 +45,9 @@ watch(
(newColor: keyof typeof chartColorsSearch) => {
try {
if (!isPreview()) {
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
const themeColor =
colorGradientCustomMerge(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo)[newColor] ||
colorGradientCustomMerge(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo)[defaultTheme]
props.chartConfig.option.series.forEach((value: any, index: number) => {
value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [
{

View File

@@ -14,7 +14,7 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore
import { chartColorsSearch, defaultTheme } from '@/settings/chartThemes/index'
import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components'
import { useChartDataFetch } from '@/hooks'
import { isPreview } from '@/utils'
import { isPreview, colorGradientCustomMerge} from '@/utils'
const props = defineProps({
themeSetting: {
@@ -44,7 +44,9 @@ watch(
(newColor: keyof typeof chartColorsSearch) => {
try {
if (!isPreview()) {
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
const themeColor =
colorGradientCustomMerge(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo)[newColor] ||
colorGradientCustomMerge(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo)[defaultTheme]
props.chartConfig.option.series.forEach((value: any, index: number) => {
value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [
{

View File

@@ -15,7 +15,7 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore
import { chartColorsSearch, defaultTheme } from '@/settings/chartThemes/index'
import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components'
import { useChartDataFetch } from '@/hooks'
import { isPreview } from '@/utils'
import { isPreview, colorGradientCustomMerge } from '@/utils'
const props = defineProps({
themeSetting: {
@@ -45,7 +45,9 @@ watch(
(newColor: keyof typeof chartColorsSearch) => {
try {
if (!isPreview()) {
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
const themeColor =
colorGradientCustomMerge(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo)[newColor] ||
colorGradientCustomMerge(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo)[defaultTheme]
props.chartConfig.option.series.forEach((value: any) => {
value.lineStyle.shadowColor = themeColor[2]
value.lineStyle.color.colorStops.forEach((v: { color: string }, i: number) => {

View File

@@ -11,7 +11,7 @@ import { use, registerMap } from 'echarts/core'
import { EffectScatterChart, MapChart } from 'echarts/charts'
import { CanvasRenderer } from 'echarts/renderers'
import { useChartDataFetch } from '@/hooks'
import { mergeTheme } from '@/packages/public/chart'
import { mergeTheme, setOption } from '@/packages/public/chart'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { isPreview } from '@/utils'
import mapJsonWithoutHainanIsLands from './mapWithoutHainanIsLands.json'
@@ -76,7 +76,7 @@ registerMapInitAsync()
// 手动触发渲染
const vEchartsSetOption = () => {
option.value = props.chartConfig.option
vChartRef.value?.setOption(props.chartConfig.option)
setOption(vChartRef.value, props.chartConfig.option)
}
// 更新数据处理

View File

@@ -10,7 +10,7 @@ import { use } from 'echarts/core'
import { CanvasRenderer } from 'echarts/renderers'
import { HeatmapChart } from 'echarts/charts'
import { includes } from './config'
import { mergeTheme } from '@/packages/public/chart'
import { mergeTheme, setOption } from '@/packages/public/chart'
import { useChartDataFetch } from '@/hooks'
import { CreateComponentType } from '@/packages/index.d'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
@@ -68,7 +68,7 @@ const dataSetHandle = (dataset: typeof dataJson) => {
props.chartConfig.option.series[0].data = seriesData
}
if (vChartRef.value && isPreview()) {
vChartRef.value.setOption(props.chartConfig.option)
setOption(vChartRef.value, props.chartConfig.option)
}
}

View File

@@ -10,7 +10,7 @@ import { use } from 'echarts/core'
import { CanvasRenderer } from 'echarts/renderers'
import { RadarChart } from 'echarts/charts'
import { includes } from './config'
import { mergeTheme } from '@/packages/public/chart'
import { mergeTheme, setOption } from '@/packages/public/chart'
import { useChartDataFetch } from '@/hooks'
import { CreateComponentType } from '@/packages/index.d'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
@@ -50,7 +50,7 @@ const dataSetHandle = (dataset: typeof dataJson) => {
props.chartConfig.option.radar.indicator = dataset.radarIndicator
}
if (vChartRef.value && isPreview()) {
vChartRef.value.setOption(props.chartConfig.option)
setOption(vChartRef.value, props.chartConfig.option)
}
}

View File

@@ -10,7 +10,7 @@ import { use } from 'echarts/core'
import { CanvasRenderer } from 'echarts/renderers'
import { TreemapChart } from 'echarts/charts'
import { includes } from './config'
import { mergeTheme } from '@/packages/public/chart'
import { mergeTheme, setOption } from '@/packages/public/chart'
import { useChartDataFetch } from '@/hooks'
import { CreateComponentType } from '@/packages/index.d'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
@@ -42,7 +42,7 @@ const option = computed(() => {
const dataSetHandle = (dataset: typeof dataJson) => {
if (dataset) {
props.chartConfig.option.series[0].data = dataset
vChartRef.value?.setOption(props.chartConfig.option)
setOption(vChartRef.value, props.chartConfig.option)
}
}

View File

@@ -10,7 +10,7 @@ import 'echarts-liquidfill/src/liquidFill.js'
import { CanvasRenderer } from 'echarts/renderers'
import { GridComponent } from 'echarts/components'
import config from './config'
import { isPreview, isString, isNumber } from '@/utils'
import { isPreview, isString, isNumber, colorGradientCustomMerge } from '@/utils'
import { chartColorsSearch, defaultTheme } from '@/settings/chartThemes/index'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { useChartDataFetch } from '@/hooks'
@@ -44,7 +44,9 @@ watch(
(newColor: keyof typeof chartColorsSearch) => {
try {
if (!isPreview()) {
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
const themeColor =
colorGradientCustomMerge(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo)[newColor] ||
colorGradientCustomMerge(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo)[defaultTheme]
// 背景颜色
props.chartConfig.option.series[0].backgroundStyle.color = themeColor[2]
// 水球颜色

View File

@@ -14,7 +14,7 @@ export const option = {
export default class Config extends PublicConfigClass implements CreateComponentType
{
public key = IframeConfig.key
public attr = { ...chartInitConfig, w: 800, h: 800, zIndex: -1 }
public attr = { ...chartInitConfig, w: 1200, h: 800, zIndex: -1 }
public chartConfig = cloneDeep(IframeConfig)
public option = cloneDeep(option)
}

View File

@@ -16,7 +16,7 @@ import 'echarts-wordcloud'
import { use } from 'echarts/core'
import { CanvasRenderer } from 'echarts/renderers'
import config, { includes } from './config'
import { mergeTheme } from '@/packages/public/chart'
import { mergeTheme, setOption } from '@/packages/public/chart'
import { useChartDataFetch } from '@/hooks'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { isPreview } from '@/utils'
@@ -49,7 +49,7 @@ const option = computed(() => {
const dataSetHandle = (dataset: typeof dataJson) => {
try {
dataset && (props.chartConfig.option.series[0].data = dataset)
vChartRef.value && isPreview() && vChartRef.value.setOption(props.chartConfig.option)
vChartRef.value && isPreview() && setOption(vChartRef.value, props.chartConfig.option)
} catch (error) {
console.log(error)
}

View File

@@ -15,7 +15,6 @@ export const FontWeightObject = {
}
export const option = {
dataset: '让数字化看得见',
fontSize: 32,
fontColor: '#ffffff',
@@ -39,4 +38,5 @@ export default class Config extends PublicConfigClass implements CreateComponent
public attr = { ...chartInitConfig, w: 500, h: 70, zIndex: -1 }
public chartConfig = cloneDeep(TextBarrageConfig)
public option = cloneDeep(option)
public preview = { overFlowHidden: true }
}

View File

@@ -40,6 +40,15 @@
<SettingItem name="列宽度">
<n-input v-model:value="columnWidth" :min="1" size="small" placeholder="列宽度(英文','分割)"></n-input>
</SettingItem>
<SettingItem name="轮播方式">
<n-select
v-model:value="optionData.carousel"
:options="[
{ label: '单条轮播', value: 'single' },
{ label: '整页轮播', value: 'page' },
]"
/>
</SettingItem>
</SettingItemBox>
<SettingItemBox name="样式">

View File

@@ -114,6 +114,10 @@ export interface PublicConfigType {
// 动画
animations: string[]
}
preview?: {
// 预览超出隐藏
overFlowHidden?: boolean
}
filter?: string
status: StatusType
events: {

View File

@@ -2,6 +2,7 @@ import merge from 'lodash/merge'
import pick from 'lodash/pick'
import { EchartsDataType } from '../index.d'
import { globalThemeJson } from '@/settings/chartThemes/index'
import type VChart from 'vue-echarts'
/**
* * 合并 color 和全局配置项
@@ -33,3 +34,15 @@ export const setData = (option: any, data: EchartsDataType) => {
option.dataset = data
return option
}
/**
* * 配置公共 setOption 方法
* @param instance
* @param data
*/
export const setOption = <T extends typeof VChart | undefined, D>(instance: T, data: D) => {
if (!instance) return
const option = instance.getOption()
option.dataset = null
instance.setOption(data)
}

View File

@@ -78,6 +78,10 @@ export class PublicConfigClass implements PublicConfigType {
// 动画
animations: []
}
// 预览
public preview = {
overFlowHidden: false
}
// 状态
public status = {
lock: false,

View File

@@ -1,4 +1,5 @@
import {
Add as AddIcon,
Close as CloseIcon,
Remove as RemoveIcon,
Resize as ResizeIcon,
@@ -52,6 +53,7 @@ import {
ColorWand as ColorWandIcon,
ArrowBack as ArrowBackIcon,
ArrowForward as ArrowForwardIcon,
ArrowDown as ArrowDownIcon,
Planet as PawIcon,
Search as SearchIcon,
Reload as ReloadIcon,
@@ -103,6 +105,8 @@ import {
} from '@vicons/carbon'
const ionicons5 = {
// 新增
AddIcon,
// 帮助(问号)
HelpOutlineIcon,
// 添加
@@ -208,6 +212,8 @@ const ionicons5 = {
ArrowBackIcon,
// 前进
ArrowForwardIcon,
// 向下
ArrowDownIcon,
// 狗爪
PawIcon,
// 搜索(放大镜)

View File

@@ -2,3 +2,4 @@ export { setupNaive } from '@/plugins/naive'
export { setupDirectives } from '@/plugins/directives'
export { setupCustomComponents } from '@/plugins/customComponents'
export { icon } from '@/plugins/icon'
export { initFunction } from '@/plugins/initFunction'

View File

@@ -0,0 +1,9 @@
/**
* * 页面初始化就执行的函数
*/
export const initFunction = async () => {
// 捕获全局错误
window.addEventListener("unhandledrejection", event => {
console.warn(`UNHANDLED PROMISE REJECTION: ${event.reason}`);
});
}

View File

@@ -57,6 +57,7 @@ import {
NProgress,
NDatePicker,
NGrid,
NGi,
NGridItem,
NList,
NListItem,
@@ -160,6 +161,7 @@ const naive = create({
NProgress,
NDatePicker,
NGrid,
NGi,
NGridItem,
NList,
NListItem,

View File

@@ -31,38 +31,20 @@ export const chartColors = {
// 默认主题
export const defaultTheme = 'dark'
// 主题色列表
export type ChartColorsNameType = keyof typeof chartColorsName
export const chartColorsName = {
dark: '明亮',
customed: '暗淡',
macarons: '马卡龙',
walden: '蓝绿',
purplePassion: '深紫',
vintage: '复古',
chalk: '粉青',
westeros: '灰粉',
wonderland: '青草',
essos: '橘红',
shine: '深色',
roma: '罗马红'
// 默认展示的选择器颜色列表
export const swatchesColors = ['#232324', '#2a2a2b', '#313132', '#373739', '#757575', '#e0e0e0', '#eeeeee', '#fafafa']
// 自定义颜色
export type CustomColorsType = {
id: string,
name: string,
color: string[]
}
// 主题色列表
export const chartColorsshow = {
dark: 'linear-gradient(to right, #4992ff 0%, #7cffb2 100%)',
customed: 'linear-gradient(to right, #5470c6 0%, #91cc75 100%)',
macarons: 'linear-gradient(to right, #2ec7c9 0%, #b6a2de 100%)',
walden: 'linear-gradient(to right, #3fb1e3 0%, #6be6c1 100%)',
purplePassion: 'linear-gradient(to right, #9b8bba 0%, #e098c7 100%)',
vintage: 'linear-gradient(to right, #d87c7c 0%, #919e8b 100%)',
chalk: 'linear-gradient(to right, #fc97af 0%, #87f7cf 100%)',
westeros: 'linear-gradient(to right, #516b91 0%, #edafda 100%)',
wonderland: 'linear-gradient(to right, #4ea397 0%, #22c3aa 100%)',
essos: 'linear-gradient(to right, #893448 0%, #d95850 100%)',
shine: 'linear-gradient(to right, #c12e34 0%, #0098d9 100%)',
roma: 'linear-gradient(to right, #e01f54 0%, #5e4ea5 100%)'
}
// 主题色列表, 自定义的颜色使用的是 UUID 作为标识,因为两者数据结构不一致
export type ChartColorsNameType = keyof typeof chartColors
// 渐变主题色列表主色1、主色2、阴影、渐变1、渐变2
export const chartColorsSearch = {
dark: ['#4992ff', '#7cffb2', 'rgba(68, 181, 226, 0.3)', 'rgba(73, 146, 255, 0.5)', 'rgba(124, 255, 178, 0.5)'],

View File

@@ -8,5 +8,6 @@
"#d4a4eb",
"#d2f5a6",
"#76f2f2"
]
],
"name": "粉青"
}

View File

@@ -9,5 +9,6 @@
"#fc8452",
"#9a60b4",
"#ea7ccc"
]
],
"name": "暗淡"
}

View File

@@ -9,5 +9,6 @@
"#ff8a45",
"#8d48e3",
"#dd79ff"
]
],
"name": "明亮"
}

View File

@@ -6,5 +6,6 @@
"#ffb248",
"#f2d643",
"#ebdba4"
]
],
"name": "橘红"
}

View File

@@ -20,5 +20,6 @@
"#7eb00a",
"#6f5553",
"#c14089"
]
],
"name": "马卡龙"
}

View File

@@ -6,5 +6,6 @@
"#71669e",
"#cc70af",
"#7cb4cc"
]
],
"name": "深紫"
}

View File

@@ -20,5 +20,6 @@
"#3cb371",
"#d5b158",
"#38b6b6"
]
],
"name": "罗马红"
}

View File

@@ -8,5 +8,6 @@
"#339ca8",
"#cda819",
"#32a487"
]
],
"name": "深色"
}

View File

@@ -10,5 +10,6 @@
"#cc7e63",
"#724e58",
"#4b565b"
]
],
"name": "复古"
}

View File

@@ -6,5 +6,6 @@
"#a0a7e6",
"#c4ebad",
"#96dee8"
]
],
"name": "蓝绿"
}

View File

@@ -6,5 +6,6 @@
"#93b7e3",
"#a5e7f0",
"#cbb0e3"
]
],
"name": "灰粉"
}

View File

@@ -6,5 +6,6 @@
"#d0648a",
"#f58db2",
"#f2b3c9"
]
],
"name": "青草"
}

View File

@@ -11,7 +11,7 @@ import {
RequestParamsObjType
} from '@/enums/httpEnum'
import { PreviewScaleEnum } from '@/enums/styleEnum'
import type { ChartColorsNameType, GlobalThemeJsonType } from '@/settings/chartThemes/index'
import type { ChartColorsNameType, CustomColorsType, GlobalThemeJsonType } from '@/settings/chartThemes/index'
// 项目数据枚举
export enum ProjectInfoEnum {
@@ -79,6 +79,7 @@ export enum EditCanvasConfigEnum {
WIDTH = 'width',
HEIGHT = 'height',
CHART_THEME_COLOR = 'chartThemeColor',
CHART_CUSTOM_THEME_COLOR_INFO = 'chartCustomThemeColorInfo',
CHART_THEME_SETTING = 'chartThemeSetting',
BACKGROUND = 'background',
BACKGROUND_IMAGE = 'backgroundImage',
@@ -121,9 +122,12 @@ export type EditCanvasConfigType = {
[EditCanvasConfigEnum.HEIGHT]: number
// 背景色
[EditCanvasConfigEnum.BACKGROUND]?: string
// 背景图片
[EditCanvasConfigEnum.BACKGROUND_IMAGE]?: string | null
// 图表主题颜色
[EditCanvasConfigEnum.CHART_THEME_COLOR]: ChartColorsNameType
// 自定义图表主题颜色
[EditCanvasConfigEnum.CHART_CUSTOM_THEME_COLOR_INFO]?: CustomColorsType[]
// 图表全局配置
[EditCanvasConfigEnum.CHART_THEME_SETTING]: GlobalThemeJsonType
// 图表主题颜色

View File

@@ -126,6 +126,8 @@ export const useChartEditStore = defineStore({
selectColor: true,
// chart 主题色
chartThemeColor: defaultTheme || 'dark',
// 自定义颜色列表
chartCustomThemeColorInfo: undefined,
// 全局配置
chartThemeSetting: globalThemeJson,
// 适配方式

View File

@@ -44,7 +44,7 @@ export const clearLocalStorage = (name: string) => {
*/
export const setSessionStorage = <T>(k: string, v: T) => {
try {
window.sessionStorage.setItem(k, JSON.stringify(v))
window.sessionStorage.setItem(k, JSONStringify(v))
} catch (error) {
return false
}

View File

@@ -2,6 +2,7 @@ import Color from 'color'
import { useDesignStore } from '@/store/modules/designStore/designStore'
import { PickCreateComponentType } from '@/packages/index.d'
import { EditCanvasConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
import { chartColors, chartColorsSearch, CustomColorsType } from '@/settings/chartThemes/index'
type AttrType = PickCreateComponentType<'attr'>
type StylesType = PickCreateComponentType<'styles'>
@@ -86,6 +87,21 @@ export function darken(color: string, concentration: number) {
return Color(color).darken(concentration).toString()
}
/**
* * hsl 转成16进制
* @param hsl
* @returns
*/
export function hslToHexa(hslString: string): string {
const color = Color(hslString)
return color.hexa()
}
export function hslToHex(hslString: string): string {
const color = Color(hslString)
return color.hex()
}
/**
* * 修改主题色
* @param themeName 主题名称
@@ -100,3 +116,48 @@ export const setHtmlTheme = (themeName?: string) => {
const designStore = useDesignStore()
e.setAttribute('data-theme', designStore.themeName)
}
/**
* * 合并基础颜色和自定义颜色
* @param chartDefaultColors
* @param customColor
* @returns
*/
export const colorCustomMerge = (customColor?: CustomColorsType[]) => {
type FormateCustomColorType = {
[T: string]: {
color: string[]
name: string
}
}
const formateCustomColor: FormateCustomColorType = {}
customColor?.forEach(item => {
formateCustomColor[item.id] = {
color: item.color,
name: item.name
}
})
return { ...formateCustomColor, ...chartColors }
}
/**
* * 合并基础渐变颜色和自定义渐变颜色
* @param customColor
*/
export const colorGradientCustomMerge = (customColor?: CustomColorsType[]) => {
type FormateGradientCustomColorType = {
[T: string]: string[]
}
const formateGradientCustomColor: FormateGradientCustomColorType = {}
customColor?.forEach(item => {
formateGradientCustomColor[item.id] = [
item.color[0],
item.color[1],
fade(item.color[0], 0.3),
fade(item.color[0], 0.5),
fade(item.color[1], 0.5)
]
})
return { ...formateGradientCustomColor, ...chartColorsSearch }
}

View File

@@ -1,7 +1,16 @@
<template>
<div class="go-chart-theme-color">
<n-card class="card-box" size="small" hoverable embedded @click="createColorHandle">
<n-text class="go-flex-items-center">
<span>自定义颜色</span>
<n-icon size="16">
<add-icon></add-icon>
</n-icon>
</n-text>
</n-card>
<n-card
v-for="(value, key) in chartColors"
v-for="(value, key) in comChartColors"
:key="key"
class="card-box"
:class="{ selected: key === selectName }"
@@ -11,41 +20,51 @@
@click="selectTheme(key)"
>
<div class="go-flex-items-center">
<n-text>{{ chartColorsName[key] }}</n-text>
<n-ellipsis style="text-align: left; width: 60px">{{ value.name }} </n-ellipsis>
<span
class="theme-color-item"
v-for="colorItem in fetchShowColors(value.color)"
:key="colorItem"
:style="{ backgroundColor: colorItem }"
></span>
></span>
</div>
<div
class="theme-bottom"
:style="{ backgroundImage: chartColorsshow[key] }"
></div>
<div class="theme-bottom" :style="{ backgroundImage: colorBackgroundImage(value) }"></div>
</n-card>
<!-- 自定义颜色 modal -->
<create-color v-model:modelShow="createColorModelShow"></create-color>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { ref, computed } from 'vue'
import cloneDeep from 'lodash/cloneDeep'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { EditCanvasConfigEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
import {
chartColors,
chartColorsName,
chartColorsshow,
ChartColorsNameType
} from '@/settings/chartThemes/index'
import { chartColors, ChartColorsNameType } from '@/settings/chartThemes/index'
import { useDesignStore } from '@/store/modules/designStore/designStore'
import cloneDeep from 'lodash/cloneDeep'
import { loadAsyncComponent, colorCustomMerge } from '@/utils'
import { icon } from '@/plugins'
const { SquareIcon } = icon.ionicons5
type FormateCustomColorType = {
[T: string]: {
color: string[]
name: string
}
}
const CreateColor = loadAsyncComponent(() => import('../CreateColor/index.vue'))
const { SquareIcon, AddIcon } = icon.ionicons5
const chartEditStore = useChartEditStore()
// 全局颜色
const designStore = useDesignStore()
const createColorModelShow = ref(false)
// 合并默认颜色和自定义颜色
const comChartColors = computed(() => {
return colorCustomMerge(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo)
})
// 颜色
const themeColor = computed(() => {
@@ -57,6 +76,16 @@ const selectName = computed(() => {
return chartEditStore.getEditCanvasConfig.chartThemeColor
})
// 创建颜色
const createColorHandle = () => {
createColorModelShow.value = true
}
// 底色
const colorBackgroundImage = (item: { color: string[] }) => {
return `linear-gradient(to right, ${item.color[0]} 0%, ${item.color[5]} 100%)`
}
// 获取用来展示的色号
const fetchShowColors = (colors: Array<string>) => {
return cloneDeep(colors).splice(0, 6)
@@ -69,36 +98,34 @@ const selectTheme = (theme: ChartColorsNameType) => {
</script>
<style lang="scss" scoped>
@include go(chart-theme-color) {
padding-top: 20px;
$radius: 10px;
$itemRadius: 6px;
@include go('chart-theme-color') {
.card-box {
cursor: pointer;
margin-top: 15px;
padding: 0;
@include fetch-bg-color('background-color4-shallow');
border-radius: 23px;
border-radius: $radius;
overflow: hidden;
@include deep() {
.n-card__content {
padding-top: 5px;
padding-bottom: 10px;
}
}
&.selected {
border: 1px solid v-bind('themeColor');
border: 2px solid v-bind('themeColor');
border-bottom: 1px solid rgba(0, 0, 0, 0);
}
&:first-child {
margin-top: 0;
margin-top: 5px;
}
.go-flex-items-center {
justify-content: space-between;
margin-top: -4px;
}
.theme-color-item {
display: inline-block;
width: 20px;
height: 20px;
border-radius: 50%;
border-radius: $itemRadius;
}
.theme-bottom {
position: absolute;
@@ -106,7 +133,6 @@ const selectTheme = (theme: ChartColorsNameType) => {
bottom: 0px;
width: 100%;
height: 3px;
background-image: linear-gradient(to right, #e0c3fc 0%, #8ec5fc 100%);
}
}
}

View File

@@ -0,0 +1,393 @@
<template>
<n-modal class="go-chart-create-color" v-model:show="modelShowRef" :mask-closable="false" :closeOnEsc="false">
<n-card :bordered="false" role="dialog" size="small" aria-modal="true" style="width: 900px; height: 720px">
<template #header></template>
<template #header-extra> </template>
<div class="create-content">
<div class="create-color-setting-box">
<create-color-render
v-if="selectColorId"
:selectColor="selectColor.selectInfo"
@updateColor="updateColorHandle"
></create-color-render>
<!-- 无数据 -->
<div v-else class="no-data go-flex-center">
<img :src="noData" alt="暂无数据" />
<n-text :depth="3">暂未选择自定义颜色</n-text>
</div>
</div>
<div class="color-list-box">
<n-timeline class="pond-item-timeline" style="width: 20px">
<n-timeline-item type="info"> </n-timeline-item>
<n-timeline-item type="success"></n-timeline-item>
</n-timeline>
<div class="color-list">
<n-space>
<!-- 新增 -->
<n-button
class="create-btn"
:class="{ 'is-full': !!!selectColorId }"
type="primary"
:ghost="!!!selectColorId"
:secondary="!!selectColorId"
@click="createColor"
>
<span> 创建 </span>
<template #icon>
<n-icon>
<duplicate-outline-icon></duplicate-outline-icon>
</n-icon>
</template>
</n-button>
<n-badge v-if="selectColorId" :show="updateColor !== undefined" dot>
<n-button class="create-btn" type="info" secondary @click="saveHandle">
<span> 应用数据 </span>
<template #icon>
<n-icon>
<arrow-down-icon></arrow-down-icon>
</n-icon>
</template>
</n-button>
</n-badge>
</n-space>
<n-divider style="margin: 10px 0"></n-divider>
<n-text v-if="!selectColorId" class="not-data-text" :depth="3">
暂无自定义颜色
<n-a @click="createColor">立即创建</n-a>
</n-text>
<!-- 列表 -->
<div class="color-card-box" v-for="(item, index) in colorList" :key="index">
<n-card
class="color-card"
:class="{ selected: item.id === selectColorId }"
size="small"
hoverable
embedded
@click="selectHandle(item)"
>
<div class="go-flex-items-center">
<n-ellipsis style="text-align: left; width: 70px">{{ item.name }} </n-ellipsis>
<span
class="theme-color-item"
v-for="(colorItem, index) in item.color"
:key="index"
:style="{ backgroundColor: colorItem }"
></span>
</div>
<div class="theme-bottom" :style="{ backgroundImage: colorBackgroundImage(item) }"></div>
</n-card>
<n-tooltip trigger="hover">
<template #trigger>
<n-button text :disabled="item.id === selectThemeColor" @click="deleteHandle(index)">
<n-icon class="go-ml-1 go-cursor-pointer" size="16" :depth="3">
<trash-icon></trash-icon>
</n-icon>
</n-button>
</template>
删除自定义颜色
</n-tooltip>
</div>
</div>
</div>
</div>
<!-- 底部 -->
<template #action>
<n-space justify="end">
<n-button @click="closeHandle">操作完成</n-button>
</n-space>
</template>
</n-card>
</n-modal>
</template>
<script setup lang="ts">
import { ref, watch, computed, reactive, nextTick, onMounted } from 'vue'
import cloneDeep from 'lodash/cloneDeep'
import noData from '@/assets/images/canvas/noData.png'
import { getUUID, goDialog } from '@/utils'
import { icon } from '@/plugins'
import { UvIndex } from '@vicons/carbon'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { EditCanvasConfigEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
import { CreateColorRender } from '../CreateColorRender/index'
const props = defineProps({
modelShow: Boolean
})
const emit = defineEmits(['update:modelShow', 'editSaveHandle'])
const { DuplicateOutlineIcon, TrashIcon, ArrowDownIcon } = icon.ionicons5
type ColorType = {
id: string
name: string
color: string[]
}
// 默认颜色组
const defaultColor: ColorType = {
id: getUUID(),
name: '未命名',
color: ['#6ae5bb', '#69e3de', '#5ac5ee', '#5ac4ee', '#4498ec', '#3c7ddf']
}
const chartEditStore = useChartEditStore()
const modelShowRef = ref(false)
// 颜色列表
let colorList = reactive<Array<ColorType>>(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo || [])
// 子组件更新过的数据
const updateColor = ref<ColorType | undefined>(undefined)
// 所选颜色
const selectColor = reactive<{
selectInfo: ColorType | undefined
}>({
selectInfo: colorList[0]
})
watch(
() => props.modelShow,
newValue => {
modelShowRef.value = newValue
if (newValue) {
// 默认选中
if (colorList.length) selectColor.selectInfo = colorList[0]
}
}
)
// 当前选中的 ID
const selectColorId = computed(() => selectColor?.selectInfo?.id)
// 全局选择的主题
const selectThemeColor = computed(() => chartEditStore.getEditCanvasConfig.chartThemeColor)
// 选择
const selectHandle = (item: ColorType) => {
if (item.id === selectColorId.value) return
if (updateColor.value !== undefined) {
goDialog({
message: '当前有变动未保存,是否直接放弃修改?',
onPositiveCallback: () => {
updateColor.value = undefined
selectColor.selectInfo = item
}
})
} else {
selectColor.selectInfo = item
}
}
// 创建
const createColor = () => {
const positiveHandle = () => {
const newData = { ...cloneDeep(defaultColor), id: getUUID() }
selectColor.selectInfo = newData
colorList.push(newData)
selectHandle(newData)
updateColor.value = newData
saveHandle(false)
}
if (updateColor.value !== undefined) {
goDialog({
message: '当前有变动未保存,是否直接放弃修改?',
onPositiveCallback: () => {
updateColor.value = undefined
positiveHandle()
}
})
} else {
positiveHandle()
}
}
// 删除
const deleteHandle = (index: number) => {
const positiveHandle = () => {
colorList.splice(index, 1)
chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.CHART_CUSTOM_THEME_COLOR_INFO, cloneDeep(colorList))
nextTick(() => {
if (colorList.length) {
selectHandle(colorList[index - 1 > -1 ? index - 1 : index])
} else {
// 已清空
selectColor.selectInfo = undefined
}
})
}
if (updateColor.value !== undefined) {
goDialog({
message: '当前有变动未保存,是否直接放弃修改?',
onPositiveCallback: () => {
updateColor.value = undefined
positiveHandle()
}
})
} else {
goDialog({
message: `是否删除此颜色?`,
onPositiveCallback: () => {
positiveHandle()
}
})
}
}
// 存储更新数据的值
const updateColorHandle = (newColor: ColorType) => {
updateColor.value = newColor
}
// 保存数据
const saveHandle = (onMessage = true) => {
if (!updateColor.value) return
const index = colorList.findIndex(item => item.id === updateColor.value?.id)
if (index !== -1) {
onMessage && window.$message.success('数据应用成功!')
const updateColorPrefix = cloneDeep({ ...updateColor.value, name: updateColor.value.name || '未定义' })
colorList.splice(index, 1, updateColorPrefix)
updateColor.value = undefined
const selectTheme = chartEditStore.getEditCanvasConfig.chartThemeColor
// 变换主题强制渐变色更新
chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.CHART_THEME_COLOR, 'dark')
// 存储到全局数据中
nextTick(() => {
chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.CHART_CUSTOM_THEME_COLOR_INFO, cloneDeep(colorList))
chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.CHART_THEME_COLOR, selectTheme)
})
} else {
window.$message.error('数据应用失败!')
}
}
// 关闭
const closeHandle = () => {
const positiveHandle = () => {
updateColor.value = undefined
selectColor.selectInfo = undefined
emit('update:modelShow', false)
}
if (updateColor.value !== undefined) {
goDialog({
message: '当前有变动未保存,是否直接放弃修改?',
onPositiveCallback: () => {
positiveHandle()
}
})
} else {
positiveHandle()
}
}
// 底色
const colorBackgroundImage = (item: ColorType) => {
return `linear-gradient(to right, ${item.color[0]} 0%, ${item.color[5]} 100%)`
}
</script>
<style scoped lang="scss">
$height: 600px;
$listWidth: 280px;
$color-radius: 8px;
$color-item-radius: 4px;
@include go('chart-create-color') {
.create-content {
display: flex;
/* 左侧 */
.create-color-setting-box {
flex: 1;
.no-data {
flex-direction: column;
width: 100%;
height: 100%;
img {
width: 200px;
}
}
}
/* 列表 */
.color-list-box {
display: flex;
padding-top: 10px;
margin-right: 5px;
.pond-item-timeline > .n-timeline-item {
&:first-child {
height: $height;
}
}
.color-list {
width: $listWidth;
position: relative;
padding-right: 8px;
.create-btn {
width: 133px;
&.is-full {
width: 280px;
}
}
.not-data-text {
display: block;
text-align: center;
}
.color-card-box {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 15px;
&:first-child {
margin-top: 0;
}
.color-card {
overflow: hidden;
cursor: pointer;
border-radius: $color-radius;
border: 2px solid rgba(0, 0, 0, 0);
border-bottom: 1px solid rgba(0, 0, 0, 0);
@include fetch-bg-color('background-color4-shallow');
@include deep() {
& > .n-card__content {
padding: 7px;
padding-top: 10px;
padding-bottom: 10px;
}
}
&.selected {
border: 2px solid var(--n-color-target);
border-bottom: 1px solid rgba(0, 0, 0, 0);
}
.go-flex-items-center {
justify-content: space-between;
margin-top: -4px;
}
.theme-color-item {
display: inline-block;
width: 16px;
height: 16px;
border-radius: $color-item-radius;
}
.theme-bottom {
position: absolute;
left: 0;
bottom: 0px;
width: 100%;
height: 3px;
}
}
}
}
}
}
&.n-card.n-modal,
.n-card {
@extend .go-background-filter;
}
.n-card-shallow {
background-color: rgba(0, 0, 0, 0) !important;
}
@include deep() {
& > .n-card__content {
padding-right: 0;
}
}
}
</style>

View File

@@ -0,0 +1,3 @@
import CreateColorRender from './index.vue'
export { CreateColorRender }

View File

@@ -0,0 +1,284 @@
<template>
<div class="create-color-setting" v-if="editColor">
<n-card :bordered="false" role="dialog" size="small" aria-modal="true">
<n-space justify="space-between">
<!-- 名称 -->
<n-input-group>
<n-input-group-label>名称:</n-input-group-label>
<n-input
class="create-color-name"
v-model:value.trim="editColor.name"
maxlength="8"
show-count
clearable
@change="titleChangeHandle"
/>
</n-input-group>
<n-tag type="warning">底部图表仅展示 7 条数据</n-tag>
</n-space>
<!-- 颜色 -->
<n-scrollbar style="max-height: 132px">
<div class="color-list-box go-mt-3" :x-gap="12" :y-gap="12" :cols="4">
<div class="color-list-item" v-for="(item, index) in editColor.color" :key="index">
<div class="go-flex-items-center" :class="{ select: index === targetColor.index }">
<n-color-picker
style="width: 95px"
v-model:value="editColor.color[index]"
:show-preview="true"
:modes="['hex']"
@complete="completeHandle($event, index)"
@update:show="selectHandle(item, index)"
/>
<div v-show="index > 5">
<n-tooltip trigger="hover">
<template #trigger>
<n-icon class="go-ml-1 go-cursor-pointer" size="16" :depth="3" @click="deleteColor(index)">
<trash-icon></trash-icon>
</n-icon>
</template>
删除颜色
</n-tooltip>
</div>
</div>
</div>
<div>
<n-button type="primary" secondary @click="addColor">
<div class="go-flex-items-center">
<span class="go-mr-4">添加</span>
<n-icon size="16">
<add-icon></add-icon>
</n-icon>
</div>
</n-button>
</div>
</div>
</n-scrollbar>
</n-card>
<!-- 扩展色 -->
<div class="expend-color-box">
<n-card class="go-mt-3 expend-color" :bordered="false" role="dialog" size="small" aria-modal="true">
<n-text>默认扩展色</n-text>
<n-divider style="margin: 10px 0"></n-divider>
<n-space :size="[4, 0]" justify="center">
<div
class="color-computed-item"
v-for="(item, index) in expandColorList.default"
:key="index"
@click="selectExpandColor(item, false)"
>
<div class="n-color-picker-checkboard"></div>
<div :style="getRenderBackgroundColor(item)"></div>
</div>
</n-space>
</n-card>
<n-card class="go-mt-3 expend-color" :bordered="false" role="dialog" size="small" aria-modal="true">
<n-text>透明扩展色</n-text>
<n-divider style="margin: 10px 0"></n-divider>
<n-space :size="[4, 0]" justify="center">
<div
class="color-computed-item"
v-for="(item, index) in expandColorList.fade"
:key="index"
@click="selectExpandColor(item, true)"
>
<div class="n-color-picker-checkboard"></div>
<div :style="getRenderBackgroundColor(item)"></div>
</div>
</n-space>
</n-card>
</div>
<!-- 展示图表 -->
<create-color-render-chart :color="cloneDeep(editColor.color).splice(0, 7)"></create-color-render-chart>
</div>
</template>
<script setup lang="ts">
import { PropType, ref, watch, computed, reactive, nextTick } from 'vue'
import cloneDeep from 'lodash/cloneDeep'
import { darken, lighten, fade, hslToHex, hslToHexa, loadAsyncComponent } from '@/utils'
import { icon } from '@/plugins'
type ColorType = {
id: string
name: string
color: string[]
}
const props = defineProps({
selectColor: Object as PropType<ColorType>
})
const emit = defineEmits(['updateColor'])
const { AddIcon, TrashIcon } = icon.ionicons5
const CreateColorRenderChart = loadAsyncComponent(() => import('../CreateColorRenderChart/index.vue'))
// 拷贝的一份数据
const editColor = ref<ColorType | undefined>()
// 目标颜色
const targetColor = reactive<{
index: number
color?: string
}>({
// -1 表示无选中元素
index: -1,
color: ''
})
// 监听值
watch(
() => props.selectColor?.id,
() => {
editColor.value = cloneDeep(props.selectColor)
targetColor.index = 0
targetColor.color = editColor.value?.color[0]
},
{
immediate: true,
deep: false
}
)
// 扩展色
const expandColorList = computed(() => {
return computedColorList(targetColor.color)
})
// 计算背景色
const computedColorList = (color?: string) => {
if (!color)
return {
default: [],
fade: []
}
const num: number = 36
const comDarkenArr: string[] = []
const comLightenArr: string[] = []
const comDarkenFadeArr: string[] = []
for (let i = 0; i < num; i++) {
comLightenArr.unshift(lighten(color, (1 / 100) * (i + 1)))
comDarkenArr.push(darken(color, (3.5 / 100) * (i + 1)))
}
// 透明
comDarkenArr.forEach((item, i) => {
comDarkenFadeArr.unshift(fade(item, (1 / 100) * (i + 1)))
})
return {
default: [
...comLightenArr.reverse().splice(0, parseInt(`${num / 2}`) - 9),
...comDarkenArr.splice(0, parseInt(`${num / 2}`))
],
fade: comDarkenFadeArr.reverse().splice(0, 27)
}
}
// 渲染背景色
const getRenderBackgroundColor = (color?: string) => {
return {
backgroundColor: color
}
}
// 点击颜色
const selectHandle = (color: string, index: number) => {
targetColor.color = color
targetColor.index = index
}
// 顶部改变颜色
const completeHandle = (color?: string, index?: number) => {
color && (targetColor.color = color)
index && (targetColor.index = index)
nextTick(() => {
emit('updateColor', editColor.value)
})
}
// 选择扩展色
const selectExpandColor = (color: string, isHexa: boolean) => {
const hexColor = isHexa ? hslToHexa(color) : hslToHex(color)
editColor.value && (editColor.value.color[targetColor.index] = hexColor)
nextTick(() => {
emit('updateColor', editColor.value)
})
}
// 新增颜色
const addColor = () => {
const lastData = editColor.value?.color[editColor.value?.color.length - 1] || '#2c2c31'
editColor.value?.color.push(lastData)
nextTick(() => {
emit('updateColor', editColor.value)
})
}
// 删除颜色
const deleteColor = (index: number) => {
editColor.value?.color.splice(index, 1)
if (index === targetColor.index) {
completeHandle(editColor.value?.color[index - 1], index - 1)
}
}
// 修改名称
const titleChangeHandle = () => {
nextTick(() => {
emit('updateColor', editColor.value)
})
}
</script>
<style scoped lang="scss">
.create-color-setting {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
padding-right: 10px;
.create-color-name {
width: 200px;
}
.color-list-box {
display: flex;
flex-wrap: wrap;
row-gap: 8px;
.color-list-item {
width: calc(100% / 4);
.select {
.n-color-picker {
border: 2px solid v-bind('targetColor.color');
border-radius: 5px;
}
}
}
}
.expend-color-box {
display: flex;
justify-content: space-between;
align-items: center;
.expend-color {
width: calc(50% - 5px);
.color-computed-item {
position: relative;
display: inline-block;
height: 22px;
width: 22px;
cursor: pointer;
overflow: hidden;
border-radius: 4px;
& div {
position: absolute;
display: inline-block;
height: 22px;
width: 22px;
}
}
}
}
}
</style>

View File

@@ -0,0 +1,47 @@
import { echartOptionProfixHandle } from '@/packages/public'
export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
const seriesHandle = (color: string[]) => {
const numHandle = (numsi: number, i: number) => parseInt(`${numsi * Math.random()}`, 10) * 2
const nums = [260, 251, 200, 334, 366, 256, 253]
return color.map((item, index) => ({
name: `data${index + 1}`,
type: 'bar',
data: nums.map((numsItem, numsi) => numHandle(numsItem, index))
}))
}
export const option = (color: string[]) => {
return echartOptionProfixHandle(
{
tooltip: {
trigger: 'axis',
showContent: false,
axisPointer: {
type: 'shadow'
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'category',
data: color.map((e, i) => `data${i + 1}`),
axisTick: {
alignWithLabel: true
}
},
yAxis: {
show: true,
type: 'value'
},
series: seriesHandle(color || [])
},
includes
)
}

View File

@@ -0,0 +1,3 @@
import CreateColorRenderChart from './index.vue'
export { CreateColorRenderChart }

View File

@@ -0,0 +1,67 @@
<template>
<n-space>
<n-card v-if="barOption" class="go-mt-3" :bordered="false" role="dialog" size="small" aria-modal="true">
<n-tabs type="segment" size="small" animated>
<n-tab-pane name="柱状图" tab="柱状图">
<v-chart
ref="vChartRefBar"
:theme="{ color }"
:option="barOption"
:manual-update="true"
autoresize
:style="chartStyle"
></v-chart>
</n-tab-pane>
<n-tab-pane name="折线图" tab="折线图">
<v-chart
ref="vChartRefLine"
:theme="{ color }"
:option="lineOption"
:manual-update="true"
autoresize
:style="chartStyle"
></v-chart>
</n-tab-pane>
</n-tabs>
</n-card>
</n-space>
</template>
<script setup lang="ts">
import { ref, watch, PropType } from 'vue'
import VChart from 'vue-echarts'
import { CanvasRenderer } from 'echarts/renderers'
import { BarChart, LineChart } from 'echarts/charts'
import { use } from 'echarts/core'
import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components'
import { option as barOptions } from './barOptions'
import { option as lineOptions } from './lineOptions'
const props = defineProps({
color: {
type: Array as PropType<string[]>,
required: true
}
})
use([DatasetComponent, CanvasRenderer, BarChart, LineChart, GridComponent, TooltipComponent, LegendComponent])
const barOption = ref()
const lineOption = ref()
const chartStyle = {
width: '528px',
height: '200px'
}
watch(
() => props.color,
(newData: string[]) => {
barOption.value = barOptions(newData)
lineOption.value = lineOptions(newData)
},
{
immediate: true,
deep: true
}
)
</script>

View File

@@ -0,0 +1,72 @@
import { echartOptionProfixHandle } from '@/packages/public'
import { graphic } from 'echarts/core'
import { fade, hslToHex } from '@/utils'
export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
const seriesHandle = (color: string[]) => {
const numHandle = (numsi: number, i: number) => parseInt(`${numsi * Math.random()}`, 10) * 2
const nums = [130, 251, 200, 334, 366, 456, 223]
return color.map((item, index) => ({
name: `data${index + 1}`,
type: 'line',
smooth: true,
lineStyle: {
width: 1,
type: 'solid'
},
emphasis: {
focus: 'series'
},
areaStyle: {
opacity: 0.8,
color: new graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 1,
color: item
},
{
offset: 0,
color: item
}
])
},
showSymbol: false,
data: nums.reverse().map((numsItem, numsi) => numHandle(numsItem, index))
}))
}
export const option = (color: string[]) => {
return echartOptionProfixHandle(
{
tooltip: {
trigger: 'axis',
showContent: false,
axisPointer: {
type: 'shadow'
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'category',
boundaryGap: false,
data: color.map((e, i) => `data${i + 1}`),
axisTick: {
alignWithLabel: true
}
},
yAxis: {
show: true,
type: 'value'
},
series: seriesHandle(color || [])
},
includes
)
}

View File

@@ -22,7 +22,7 @@
</n-form-item>
</n-form>
<n-card class="upload-box">
<div class="upload-box">
<n-upload
v-model:file-list="uploadFileListRef"
:show-file-list="false"
@@ -39,7 +39,7 @@
</div>
</n-upload-dragger>
</n-upload>
</n-card>
</div>
<n-space vertical :size="12">
<n-space>
<n-text>背景颜色</n-text>
@@ -128,6 +128,7 @@
<script setup lang="ts">
import { ref, nextTick, watch } from 'vue'
import { backgroundImageSize } from '@/settings/designSetting'
import { swatchesColors } from '@/settings/chartThemes/index'
import { FileTypeEnum } from '@/enums/fileTypeEnum'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { EditCanvasConfigEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
@@ -166,9 +167,6 @@ const selectColorOptions = [
}
]
// 默认展示颜色列表
const swatchesColors = ['#232324', '#2a2a2b', '#313132', '#373739', '#757575', '#e0e0e0', '#eeeeee', '#fafafa']
const globalTabList = [
{
key: 'ChartTheme',
@@ -317,13 +315,10 @@ $uploadHeight: 193px;
cursor: pointer;
margin-bottom: 20px;
@include deep() {
.n-card__content {
padding: 0;
overflow: hidden;
}
.n-upload-dragger {
padding: 5px;
width: $uploadWidth;
background-color: rgba(0, 0, 0, 0);
}
}
.upload-show {
@@ -354,8 +349,8 @@ $uploadHeight: 193px;
padding-right: 2.25em;
}
.select-preview-icon {
padding-right: .68em;
padding-left: .68em;
padding-right: 0.68em;
padding-left: 0.68em;
}
.tabs-box {
margin-top: 20px;

View File

@@ -150,7 +150,7 @@ const filterRes = computed(() => {
} catch (error) {
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
errorFlag.value = true
return '过滤函数错误'
return `过滤函数错误,日志:${error}`
}
})

View File

@@ -1,6 +1,6 @@
<template>
<div class="go-chart-data-pond-list">
<n-timeline style="width: 20px">
<n-timeline class="pond-item-timeline" style="width: 20px">
<n-timeline-item type="info"> </n-timeline-item>
<n-timeline-item type="success"></n-timeline-item>
</n-timeline>
@@ -115,11 +115,9 @@ $textSize: 10px;
padding-bottom: 5px;
margin-right: 5px;
display: flex;
@include deep() {
.n-timeline > .n-timeline-item {
&:first-child {
height: $height;
}
.pond-item-timeline > .n-timeline-item {
&:first-child {
height: $height;
}
}
.pond-item-box {

View File

@@ -56,7 +56,7 @@ import { MenuEnum } from '@/enums/editPageEnum'
import { chartColors } from '@/settings/chartThemes/index'
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
import { MenuOptionsItemType } from '@/views/chart/hooks/useContextMenu.hook.d'
import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle } from '@/utils'
import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle, colorCustomMerge } from '@/utils'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { useContextMenu, divider } from '@/views/chart/hooks/useContextMenu.hook'
import { useMouseHandle } from '../../hooks/useDrag.hook'
@@ -117,8 +117,8 @@ const optionsHandle = (
// 配置项
const themeColor = computed(() => {
const chartThemeColor = chartEditStore.getEditCanvasConfig.chartThemeColor
return chartColors[chartThemeColor]
const colorCustomMergeData = colorCustomMerge(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo)
return colorCustomMergeData[chartEditStore.getEditCanvasConfig.chartThemeColor]
})
// 主题色

View File

@@ -55,7 +55,7 @@ const rangeModelStyle = computed(() => {
position: relative;
transform-origin: left top;
background-size: cover;
border-radius: 20px;
border-radius: 10px;
overflow: hidden;
@include fetch-border-color('hover-border-color');
@include fetch-bg-color('background-color2');

View File

@@ -87,7 +87,7 @@ import { onMounted, computed } from 'vue'
import { chartColors } from '@/settings/chartThemes/index'
import { MenuEnum } from '@/enums/editPageEnum'
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle } from '@/utils'
import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle, colorCustomMerge } from '@/utils'
import { useContextMenu } from '@/views/chart/hooks/useContextMenu.hook'
import { MenuOptionsItemType } from '@/views/chart/hooks/useContextMenu.hook.d'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
@@ -148,8 +148,8 @@ const themeSetting = computed(() => {
// 配置项
const themeColor = computed(() => {
const chartThemeColor = chartEditStore.getEditCanvasConfig.chartThemeColor
return chartColors[chartThemeColor]
const colorCustomMergeData = colorCustomMerge(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo)
return colorCustomMergeData[chartEditStore.getEditCanvasConfig.chartThemeColor]
})
// 是否展示渲染

View File

@@ -5,8 +5,10 @@
</n-icon>
<n-text @click="handleFocus">
工作空间 -
<n-button v-show="!focus" secondary round size="tiny">
<span class="title">{{ comTitle }}</span>
<n-button v-show="!focus" secondary size="tiny">
<span class="title">
{{ comTitle }}
</span>
</n-button>
</n-text>
@@ -17,7 +19,6 @@
type="text"
maxlength="16"
show-count
round
placeholder="请输入项目名称"
v-model:value.trim="title"
@keyup.enter="handleBlur"
@@ -81,6 +82,8 @@ const handleBlur = async () => {
</script>
<style lang="scss" scoped>
.title {
padding-left: 5px;
padding-right: 5px;
font-size: 15px;
}
</style>

View File

@@ -14,8 +14,10 @@
</template>
</layout-header-pro>
<n-layout-content content-style="overflow:hidden; display: flex">
<content-charts></content-charts>
<content-layers></content-layers>
<div style="overflow:hidden; display: flex">
<content-charts></content-charts>
<content-layers></content-layers>
</div>
<content-configurations></content-configurations>
</n-layout-content>
</n-layout>

View File

@@ -9,6 +9,7 @@
...getFilterStyle(item.styles),
...getTransformStyle(item.styles),
...getStatusStyle(item.status),
...getPreviewConfigStyle(item.preview),
...getBlendModeStyle(item.styles) as any
}"
>
@@ -28,7 +29,7 @@
import { PropType } from 'vue'
import { CreateComponentGroupType } from '@/packages/index.d'
import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle } from '@/utils'
import { getSizeStyle, getComponentAttrStyle, getStatusStyle } from '../../utils'
import { getSizeStyle, getComponentAttrStyle, getStatusStyle, getPreviewConfigStyle } from '../../utils'
import { useLifeHandler } from '@/hooks'
const props = defineProps({
@@ -54,6 +55,5 @@ const props = defineProps({
<style lang="scss" scoped>
.chart-item {
position: absolute;
overflow: hidden;
}
</style>

View File

@@ -2,13 +2,14 @@
<div
class="chart-item"
v-for="(item, index) in localStorageInfo.componentList"
:class="[animationsClass(item.styles.animations), !item.isGroup && 'hidden']"
:class="animationsClass(item.styles.animations)"
:key="item.id"
:style="{
...getComponentAttrStyle(item.attr, index),
...getFilterStyle(item.styles),
...getTransformStyle(item.styles),
...getStatusStyle(item.status),
...getPreviewConfigStyle(item.preview),
...getBlendModeStyle(item.styles) as any
}"
>
@@ -42,12 +43,14 @@ import { ChartEditStorageType } from '../../index.d'
import { PreviewRenderGroup } from '../PreviewRenderGroup/index'
import { CreateComponentGroupType } from '@/packages/index.d'
import { chartColors } from '@/settings/chartThemes/index'
import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle } from '@/utils'
import { getSizeStyle, getComponentAttrStyle, getStatusStyle } from '../../utils'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle, colorCustomMerge } from '@/utils'
import { getSizeStyle, getComponentAttrStyle, getStatusStyle, getPreviewConfigStyle } from '../../utils'
import { useLifeHandler } from '@/hooks'
// 初始化数据池
const { initDataPond, clearMittDataPondMap } = useChartDataPondFetch()
const chartEditStore = useChartEditStore()
const props = defineProps({
localStorageInfo: {
@@ -62,10 +65,11 @@ const themeSetting = computed(() => {
return chartThemeSetting
})
// 配置项
const themeColor = computed(() => {
const chartThemeColor = props.localStorageInfo.editCanvasConfig.chartThemeColor
return chartColors[chartThemeColor]
const colorCustomMergeData = colorCustomMerge(props.localStorageInfo.editCanvasConfig.chartCustomThemeColorInfo)
return colorCustomMergeData[props.localStorageInfo.editCanvasConfig.chartThemeColor]
})
// 组件渲染结束初始化数据池
@@ -78,8 +82,5 @@ onMounted(() => {
<style lang="scss" scoped>
.chart-item {
position: absolute;
&.hidden {
overflow: hidden;
}
}
</style>

View File

@@ -3,6 +3,7 @@ import { EditCanvasConfigType } from '@/store/modules/chartEditStore/chartEditSt
type AttrType = PickCreateComponentType<'attr'>
type StatusType = PickCreateComponentType<'status'>
type PreviewConfig = PickCreateComponentType<'preview'>
// 设置位置
export const getComponentAttrStyle = (attr: AttrType, index: number) => {
@@ -29,6 +30,17 @@ export const getStatusStyle = (attr: StatusType) => {
}
}
// 设置预览配置样式
export const getPreviewConfigStyle = (previewConfig: PreviewConfig) => {
const previewStyle: Partial<CSSStyleDeclaration> = {}
if (previewConfig) {
if (previewConfig.overFlowHidden) {
previewStyle.overflow = 'hidden'
}
}
return previewStyle
}
// 全局样式
export const getEditCanvasConfigStyle = (canvas: EditCanvasConfigType) => {
// 背景