Compare commits
55 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5738f5cf4 | ||
|
|
dbd33cd676 | ||
|
|
032956e03b | ||
|
|
b94b44090b | ||
|
|
19a382afe5 | ||
|
|
02fe552d1b | ||
|
|
22924eb36f | ||
|
|
a626f64e57 | ||
|
|
00a4c752ed | ||
|
|
134b44944e | ||
|
|
1eb0485a86 | ||
|
|
35e5374628 | ||
|
|
432cceed2a | ||
|
|
5b828d4982 | ||
|
|
605fd14b3d | ||
|
|
1b2b319467 | ||
|
|
dc458ea88e | ||
|
|
6f4e967b49 | ||
|
|
97899f275a | ||
|
|
8b6c616a15 | ||
|
|
87386e69a3 | ||
|
|
196df94aee | ||
|
|
a407d118fa | ||
|
|
0fc7bde348 | ||
|
|
9a8899ae40 | ||
|
|
8cb711b892 | ||
|
|
49d8c35747 | ||
|
|
125856677a | ||
|
|
bcf0417624 | ||
|
|
4b81a09293 | ||
|
|
bcaffd1579 | ||
|
|
7309d603f5 | ||
|
|
ada4ce9885 | ||
|
|
7758fb30d0 | ||
|
|
6ddea30289 | ||
|
|
ac42782f12 | ||
|
|
4348688e34 | ||
|
|
d447c85830 | ||
|
|
0a3c1b3438 | ||
|
|
b3bff2ee45 | ||
|
|
d90e0953b9 | ||
|
|
ba04005b09 | ||
|
|
fc58df2148 | ||
|
|
4f2609a121 | ||
|
|
f21c9f1246 | ||
|
|
16d7ae8176 | ||
|
|
0e77b196b6 | ||
|
|
0ea81aeaee | ||
|
|
d7aa41094b | ||
|
|
4ec1bbd912 | ||
|
|
a7b98fe3d6 | ||
|
|
bc02950a6f | ||
|
|
4e5c921bf2 | ||
|
|
14c5d935c4 | ||
|
|
b73893a6af |
87
README.md
@@ -1,12 +1,40 @@
|
||||
## 总览
|
||||
|
||||
#### 总览
|
||||
<p align="center">
|
||||
<img src="readme/logo-t-y.png" alt="go-view" />
|
||||
</p>
|
||||
|
||||
<h4 align="center">开源、精美、便捷的「数据可视化」低代码开发平台</h4>
|
||||
|
||||
#### 😶 **纯前端** 分支: **`master`**
|
||||
#### 长期赞助商
|
||||
<div>
|
||||
<div align="center" style="column-gap: 20px;">
|
||||
<a
|
||||
href="http://www.ccflow.org/?from=goviewGitee"
|
||||
target="_blank"
|
||||
style="
|
||||
padding: 10px 20px;
|
||||
display: inline-block;
|
||||
border-radius: 10px;
|
||||
background: #f9f9f9;
|
||||
">
|
||||
<img src="readme/sponsors/ccflow-banner.png" alt="go-view" style="width: 250px;" width="250px" />
|
||||
</a>
|
||||
<span> </span>
|
||||
<a
|
||||
href="https://www.qeasy.cloud/"
|
||||
target="_blank"
|
||||
style="
|
||||
padding: 10px 20px;
|
||||
display: inline-block;
|
||||
border-radius: 10px;
|
||||
background: #f9f9f9;
|
||||
">
|
||||
<img src="readme/sponsors/qyy-banner.png" alt="go-view" style="width: 250px;" width="250px"/>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
#### 😶 **纯前端** 分支: **`master`**
|
||||
|
||||
#### 👻 携带 **后端** 请求分支: **`master-fetch`**
|
||||
|
||||
@@ -16,9 +44,8 @@
|
||||
|
||||
项目带后端-Demo 地址:[https://demo.mtruning.club/](https://demo.mtruning.club/)
|
||||
|
||||
文档-源码地址:[https://gitee.com/MTrun/go-view-doc](https://gitee.com/MTrun/go-view-doc)
|
||||
|
||||
Cloud IDE 代码在线预览地址:[https://idegitee.com/dromara/go-view](https://idegitee.com/dromara/go-view)
|
||||
|
||||
#### 🤯 后端项目看这里!
|
||||
|
||||
后端项目 gitee 地址:[https://gitee.com/MTrun/go-view-serve](https://gitee.com/MTrun/go-view-serve)
|
||||
@@ -58,6 +85,9 @@ Cloud IDE 代码在线预览地址:[https://idegitee.com/dromara/go-view](http
|
||||
高级事件编辑:
|
||||

|
||||
|
||||
自定义组件颜色:
|
||||

|
||||
|
||||
快捷主页:
|
||||

|
||||
|
||||
@@ -103,45 +133,7 @@ Cloud IDE 代码在线预览地址:[https://idegitee.com/dromara/go-view](http
|
||||
|
||||
## 安装
|
||||
|
||||
本项目采用` pnpm` 进行包管理
|
||||
|
||||
```shell
|
||||
#建议使用 nrm 切换到淘宝源 https://registry.npmmirror.com/
|
||||
#pnpm
|
||||
pnpm install
|
||||
|
||||
#yarn
|
||||
yarn install
|
||||
|
||||
# 千万不要使用 npm 会报错
|
||||
```
|
||||
|
||||
## 启动
|
||||
|
||||
```shell
|
||||
#pnpm
|
||||
pnpm dev
|
||||
|
||||
#yarn
|
||||
yarn dev
|
||||
|
||||
#Makefile
|
||||
make dev
|
||||
```
|
||||
|
||||
## 编译
|
||||
|
||||
```shell
|
||||
#pnpm
|
||||
pnpm run build
|
||||
|
||||
#yarn
|
||||
yarn run build
|
||||
|
||||
#Makefile
|
||||
make dist
|
||||
|
||||
```
|
||||
请查看文档:[https://www.mtruning.club/](https://www.mtruning.club/)
|
||||
|
||||
## 代码提交
|
||||
|
||||
@@ -157,10 +149,9 @@ make dist
|
||||
- style: 不影响程序逻辑的代码修改
|
||||
- chore: 不属于以上类型的其他类型(日常事务)
|
||||
|
||||
## 交流
|
||||
## 交流群
|
||||
|
||||
QQ 群:1030129384
|
||||
|
||||

|
||||
QQ 群:663629294
|
||||
<img width="260px" src="readme/go-view-qq.png" alt="QQ群" style="border-radius: 20px" />
|
||||
|
||||

|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "go-view",
|
||||
"version": "1.1.9",
|
||||
"version": "1.2.2",
|
||||
"engines": {
|
||||
"node": ">=16.14 <18.0.0"
|
||||
"node": ">=12.0"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vite --host",
|
||||
|
||||
BIN
readme/go-view-echarts-color.png
Normal file
|
After Width: | Height: | Size: 292 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 70 KiB |
BIN
readme/sponsors/ccflow-banner.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
readme/sponsors/qyy-banner.png
Normal file
|
After Width: | Height: | Size: 38 KiB |
@@ -172,7 +172,9 @@ export const customizeHttp = (targetParams: RequestConfigType, globalParams: Req
|
||||
|
||||
case RequestBodyEnum.JSON:
|
||||
headers['Content-Type'] = ContentTypeEnum.JSON
|
||||
data = translateStr(JSON.parse(targetRequestParams.Body['json']))
|
||||
//json对象也能使用'javasctipt:'来动态拼接参数
|
||||
data = translateStr(targetRequestParams.Body['json'])
|
||||
if(typeof data === 'string') data = JSON.parse(data)
|
||||
// json 赋值给 data
|
||||
break
|
||||
|
||||
|
||||
BIN
src/assets/images/chart/informations/photo_carousel.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
@@ -12,7 +12,8 @@ export enum DragKeyEnum {
|
||||
// 不同页面保存操作
|
||||
export enum SavePageEnum {
|
||||
CHART = 'SaveChart',
|
||||
JSON = 'SaveJSON'
|
||||
JSON = 'SaveJSON',
|
||||
CLOSE = 'close'
|
||||
}
|
||||
|
||||
// 操作枚举
|
||||
|
||||
@@ -7,15 +7,15 @@ export enum BaseEvent {
|
||||
// 移入
|
||||
ON_MOUSE_ENTER = 'mouseenter',
|
||||
// 移出
|
||||
ON_MOUSE_LEAVE = 'mouseleave',
|
||||
ON_MOUSE_LEAVE = 'mouseleave'
|
||||
}
|
||||
|
||||
// vue3 生命周期事件
|
||||
export enum EventLife {
|
||||
export enum EventLife {
|
||||
// 渲染之后
|
||||
VNODE_MOUNTED = 'vnodeMounted',
|
||||
// 渲染之前
|
||||
VNODE_BEFORE_MOUNT = 'vnodeBeforeMount',
|
||||
VNODE_BEFORE_MOUNT = 'vnodeBeforeMount'
|
||||
}
|
||||
|
||||
// 内置字符串函数对象列表
|
||||
@@ -28,4 +28,9 @@ export const excludeParseEventKeyList = [
|
||||
BaseEvent.ON_MOUSE_LEAVE,
|
||||
//过滤器
|
||||
'filter'
|
||||
]
|
||||
]
|
||||
// 内置字符串函数键值列表
|
||||
export const excludeParseEventValueList = [
|
||||
// 请求里的函数语句
|
||||
'javascript:'
|
||||
]
|
||||
|
||||
@@ -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 })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<n-layout-header bordered class="go-header">
|
||||
<header class="go-header-box">
|
||||
<header class="go-header-box" :class="{ 'is-project': isProject }">
|
||||
<div class="header-item left">
|
||||
<n-space>
|
||||
<slot name="left"></slot>
|
||||
@@ -23,17 +23,29 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { GoThemeSelect } from '@/components/GoThemeSelect'
|
||||
import { GoLangSelect } from '@/components/GoLangSelect'
|
||||
import { ThemeColorSelect } from '@/components/Pages/ThemeColorSelect'
|
||||
import { PageEnum } from '@/enums/pageEnum'
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const isProject = computed(() => {
|
||||
return route.fullPath === PageEnum.BASE_HOME_ITEMS
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$min-width: 400px;
|
||||
$min-width: 520px;
|
||||
@include go(header) {
|
||||
&-box {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 33.33%);
|
||||
grid-template-columns: repeat(3, 33%);
|
||||
&.is-project {
|
||||
grid-template-columns: none;
|
||||
}
|
||||
.header-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -49,7 +61,7 @@ $min-width: 400px;
|
||||
}
|
||||
}
|
||||
height: $--header-height;
|
||||
padding: 0 60px;
|
||||
padding: 0 20px 0 60px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -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, [
|
||||
{
|
||||
|
||||
@@ -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, [
|
||||
{
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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'
|
||||
@@ -59,13 +59,14 @@ const getGeojson = (regionId: string) => {
|
||||
}
|
||||
|
||||
//异步时先注册空的 保证初始化不报错
|
||||
registerMap(props.chartConfig.option.mapRegion.adcode, { geoJSON: {} as any, specialAreas: {} })
|
||||
registerMap(`${props.chartConfig.option.mapRegion.adcode}`, { geoJSON: {} as any, specialAreas: {} })
|
||||
|
||||
// 进行更换初始化地图 如果为china 单独处理
|
||||
const registerMapInitAsync = async () => {
|
||||
await nextTick()
|
||||
if (props.chartConfig.option.mapRegion.adcode != 'china') {
|
||||
await getGeojson(props.chartConfig.option.mapRegion.adcode)
|
||||
const adCode = `${props.chartConfig.option.mapRegion.adcode}`;
|
||||
if (adCode !== 'china') {
|
||||
await getGeojson(adCode)
|
||||
} else {
|
||||
await hainanLandsHandle(props.chartConfig.option.mapRegion.showHainanIsLands)
|
||||
}
|
||||
@@ -76,7 +77,7 @@ registerMapInitAsync()
|
||||
// 手动触发渲染
|
||||
const vEchartsSetOption = () => {
|
||||
option.value = props.chartConfig.option
|
||||
vChartRef.value?.setOption(props.chartConfig.option)
|
||||
setOption(vChartRef.value, props.chartConfig.option)
|
||||
}
|
||||
|
||||
// 更新数据处理
|
||||
@@ -127,7 +128,7 @@ watch(
|
||||
|
||||
//监听地图展示区域发生变化
|
||||
watch(
|
||||
() => props.chartConfig.option.mapRegion.adcode,
|
||||
() => `${props.chartConfig.option.mapRegion.adcode}`,
|
||||
async newData => {
|
||||
try {
|
||||
await getGeojson(newData)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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]
|
||||
// 水球颜色
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import { PublicConfigClass } from '@/packages/public'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { CarouselConfig } from './index'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import logo from '@/assets/logo.png'
|
||||
|
||||
// 示例图片资源
|
||||
const modules = import.meta.globEager("./images/*");
|
||||
const dataset = [logo]
|
||||
for (var item in modules) {
|
||||
dataset.push(modules[item].default)
|
||||
}
|
||||
|
||||
export const option = {
|
||||
// 图片资源列表
|
||||
dataset: dataset,
|
||||
// 自动播放
|
||||
autoplay: true,
|
||||
// 自动播放的间隔(ms)
|
||||
interval: 5000,
|
||||
// 每页显示的图片数量
|
||||
slidesPerview: 1,
|
||||
// 轮播方向
|
||||
direction: "horizontal",
|
||||
// 拖曳切换
|
||||
draggable: true,
|
||||
// 居中显示
|
||||
centeredSlides: false,
|
||||
// 过渡效果
|
||||
effect: "slide",
|
||||
// 是否显示指示点
|
||||
showDots: true,
|
||||
// 指示器样式
|
||||
dotType: "dot",
|
||||
// 指示器位置
|
||||
dotPlacement: "bottom",
|
||||
// 显示箭头
|
||||
showArrow: false,
|
||||
// 图片样式
|
||||
fit: "contain",
|
||||
}
|
||||
|
||||
export default class Config extends PublicConfigClass implements CreateComponentType {
|
||||
public key = CarouselConfig.key
|
||||
public chartConfig = cloneDeep(CarouselConfig)
|
||||
public option = cloneDeep(option)
|
||||
}
|
||||
176
src/packages/components/Informations/Mores/Carousel/config.vue
Normal file
@@ -0,0 +1,176 @@
|
||||
<template>
|
||||
<collapse-item name="属性" :expanded="true">
|
||||
<setting-item-box name="路径" :alone="true">
|
||||
<setting-item v-for="item, index in optionData.dataset" :key="index">
|
||||
<n-input-group>
|
||||
<n-input v-model:value="optionData.dataset[index]" size="small" placeholder="请输入图片地址"></n-input>
|
||||
<n-button ghost @click="optionData.dataset.splice(index, 1)">
|
||||
-
|
||||
</n-button>
|
||||
</n-input-group>
|
||||
</setting-item>
|
||||
<setting-item>
|
||||
<n-button size="small" @click="optionData.dataset.push('')">
|
||||
+
|
||||
</n-button>
|
||||
</setting-item>
|
||||
</setting-item-box>
|
||||
<setting-item-box name="播放器">
|
||||
<setting-item>
|
||||
<n-space>
|
||||
<n-switch v-model:value="optionData.autoplay" size="small" />
|
||||
<n-text>自动播放</n-text>
|
||||
</n-space>
|
||||
</setting-item>
|
||||
<!-- 开启自动播放时,设置间隔时间 -->
|
||||
<setting-item name="间隔时间">
|
||||
<n-input-number v-model:value="optionData.interval" size="small" placeholder=""></n-input-number>
|
||||
</setting-item>
|
||||
<setting-item name="轮播方向">
|
||||
<n-select v-model:value="optionData.direction" :options="directions" placeholder="选择方向" />
|
||||
</setting-item>
|
||||
<setting-item name="过渡效果">
|
||||
<n-select v-model:value="optionData.effect" :options="effects" placeholder="效果" />
|
||||
</setting-item>
|
||||
<setting-item name="每页数量">
|
||||
<n-input-number v-model:value="optionData.slidesPerview" size="small" placeholder=""></n-input-number>
|
||||
</setting-item>
|
||||
<setting-item>
|
||||
<n-space>
|
||||
<n-switch v-model:value="optionData.centeredSlides" size="small" />
|
||||
<n-text>居中显示</n-text>
|
||||
</n-space>
|
||||
</setting-item>
|
||||
<setting-item name="图片样式">
|
||||
<n-select v-model:value="optionData.fit" :options="fitList" placeholder="样式" />
|
||||
</setting-item>
|
||||
</setting-item-box>
|
||||
|
||||
<setting-item-box name="指示器">
|
||||
<setting-item name="样式">
|
||||
<n-select v-model:value="optionData.dotType" :options="dotTypes" placeholder="选择样式" />
|
||||
</setting-item>
|
||||
<setting-item name="位置">
|
||||
<n-select v-model:value="optionData.dotPlacement" :options="dotPlacements" placeholder="选择位置" />
|
||||
</setting-item>
|
||||
<setting-item>
|
||||
<n-space>
|
||||
<n-switch v-model:value="optionData.showDots" size="small" />
|
||||
<n-text>显示</n-text>
|
||||
</n-space>
|
||||
</setting-item>
|
||||
<setting-item>
|
||||
<n-space>
|
||||
<n-switch v-model:value="optionData.showArrow" size="small" />
|
||||
<n-text>箭头</n-text>
|
||||
</n-space>
|
||||
</setting-item>
|
||||
<setting-item>
|
||||
<n-space>
|
||||
<n-switch v-model:value="optionData.draggable" size="small" />
|
||||
<n-text>拖曳切换</n-text>
|
||||
</n-space>
|
||||
</setting-item>
|
||||
</setting-item-box>
|
||||
|
||||
</collapse-item>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { option } from './config'
|
||||
import {
|
||||
CollapseItem,
|
||||
SettingItemBox,
|
||||
SettingItem
|
||||
} from '@/components/Pages/ChartItemSetting'
|
||||
|
||||
const props = defineProps({
|
||||
optionData: {
|
||||
type: Object as PropType<typeof option>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
// 字典
|
||||
const dotTypes = [
|
||||
{
|
||||
label: "点",
|
||||
value: "dot"
|
||||
},
|
||||
{
|
||||
label: "线",
|
||||
value: "line"
|
||||
}
|
||||
]
|
||||
const directions = [
|
||||
{
|
||||
label: "水平方向",
|
||||
value: "horizontal"
|
||||
},
|
||||
{
|
||||
label: "垂直方向",
|
||||
value: "vertical"
|
||||
}
|
||||
]
|
||||
const effects = [
|
||||
{
|
||||
label: "slide",
|
||||
value: "slide"
|
||||
},
|
||||
{
|
||||
label: "fade",
|
||||
value: "fade"
|
||||
},
|
||||
{
|
||||
label: "card",
|
||||
value: "card"
|
||||
},
|
||||
{
|
||||
label: "custom",
|
||||
value: "custom"
|
||||
}
|
||||
]
|
||||
const dotPlacements = [
|
||||
{
|
||||
label: "上边",
|
||||
value: "top"
|
||||
},
|
||||
{
|
||||
label: "下边",
|
||||
value: "bottom"
|
||||
},
|
||||
{
|
||||
label: "左边",
|
||||
value: "left"
|
||||
},
|
||||
{
|
||||
label: "右边",
|
||||
value: "right"
|
||||
}
|
||||
]
|
||||
|
||||
// 适应类型
|
||||
const fitList = [
|
||||
{
|
||||
value: 'fill',
|
||||
label: 'fill'
|
||||
},
|
||||
{
|
||||
value: 'contain',
|
||||
label: 'contain'
|
||||
},
|
||||
{
|
||||
value: 'cover',
|
||||
label: 'cover'
|
||||
},
|
||||
{
|
||||
value: 'scale-down',
|
||||
label: 'scale-down'
|
||||
},
|
||||
{
|
||||
value: 'none',
|
||||
label: 'none'
|
||||
},
|
||||
]
|
||||
</script>
|
||||
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 12 KiB |
14
src/packages/components/Informations/Mores/Carousel/index.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
|
||||
import { ChatCategoryEnum,ChatCategoryEnumName } from '../../index.d'
|
||||
|
||||
export const CarouselConfig: ConfigType = {
|
||||
key: 'Carousel',
|
||||
chartKey: 'VCarousel',
|
||||
conKey: 'VCCarousel',
|
||||
title: '轮播图',
|
||||
category: ChatCategoryEnum.MORE,
|
||||
categoryName: ChatCategoryEnumName.MORE,
|
||||
package: PackagesCategoryEnum.INFORMATIONS,
|
||||
chartFrame: ChartFrameEnum.NAIVE_UI,
|
||||
image: 'photo.png'
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<template>
|
||||
<div>
|
||||
<n-carousel :autoplay="autoplay" :interval="interval" :centered-slides="centeredSlides" :direction="direction"
|
||||
:dot-placement="dotPlacement" :dot-type="dotType" :draggable="draggable" :effect="effect"
|
||||
:slides-per-view="slidesPerview" :show-arrow="showArrow" :show-dots="showDots">
|
||||
<n-image v-for="url in option.dataset" :object-fit="fit" preview-disabled :src="url"
|
||||
:fallback-src="requireErrorImg()" :width="w" :height="h"></n-image>
|
||||
</n-carousel>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { PropType, toRefs, shallowReactive, watch } from 'vue'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { requireErrorImg } from '@/utils'
|
||||
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 option = shallowReactive({
|
||||
dataset: configOption.dataset
|
||||
})
|
||||
|
||||
const { w, h } = toRefs(props.chartConfig.attr)
|
||||
const { autoplay, interval, slidesPerview, direction, draggable, centeredSlides, effect, dotType, dotPlacement, showArrow, showDots, fit } = toRefs(props.chartConfig.option)
|
||||
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
(newData: any) => {
|
||||
option.dataset = newData
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
deep: false
|
||||
}
|
||||
)
|
||||
|
||||
useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
|
||||
option.dataset = newData
|
||||
})
|
||||
</script>
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import { PublicConfigClass } from '@/packages/public'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { ImageCarouselConfig } from './index'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import logo from '@/assets/logo.png'
|
||||
|
||||
export const option = {
|
||||
// 图片资源列表
|
||||
dataset: [
|
||||
'https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel1.jpeg',
|
||||
'https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel2.jpeg',
|
||||
'https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel3.jpeg',
|
||||
],
|
||||
// 自动播放
|
||||
autoplay: true,
|
||||
// 自动播放的间隔(豪秒)
|
||||
interval: 5000,
|
||||
// 每页显示的图片数量
|
||||
slidesPerview: 1,
|
||||
// 轮播方向
|
||||
direction: "horizontal",
|
||||
// 拖曳切换
|
||||
draggable: true,
|
||||
// 居中显示
|
||||
centeredSlides: false,
|
||||
// 过渡效果
|
||||
effect: "slide",
|
||||
// 是否显示指示点
|
||||
showDots: true,
|
||||
// 指示器样式
|
||||
dotType: "dot",
|
||||
// 指示器位置
|
||||
dotPlacement: "bottom",
|
||||
// 显示箭头
|
||||
showArrow: false,
|
||||
// 图片样式
|
||||
fit: "contain",
|
||||
}
|
||||
|
||||
export default class Config extends PublicConfigClass implements CreateComponentType {
|
||||
public key = ImageCarouselConfig.key
|
||||
public chartConfig = cloneDeep(ImageCarouselConfig)
|
||||
public option = cloneDeep(option)
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
<template>
|
||||
<collapse-item name="路径" :expanded="true">
|
||||
<setting-item v-for="(item, index) in optionData.dataset" :key="index">
|
||||
<n-input-group>
|
||||
<n-input v-model:value="optionData.dataset[index]" size="small" placeholder="请输入图片地址"></n-input>
|
||||
<n-button ghost @click="optionData.dataset.splice(index, 1)"> - </n-button>
|
||||
</n-input-group>
|
||||
</setting-item>
|
||||
<setting-item>
|
||||
<n-button size="small" @click="optionData.dataset.push('')"> + 新增</n-button>
|
||||
</setting-item>
|
||||
</collapse-item>
|
||||
<collapse-item name="轮播属性" :expanded="true">
|
||||
<setting-item-box name="播放器">
|
||||
<setting-item>
|
||||
<n-space>
|
||||
<n-switch v-model:value="optionData.autoplay" size="small" />
|
||||
<n-text>自动播放</n-text>
|
||||
</n-space>
|
||||
</setting-item>
|
||||
<!-- 开启自动播放时,设置间隔时间 -->
|
||||
<setting-item name="间隔时间">
|
||||
<n-input-number v-model:value="optionData.interval" size="small" placeholder="">
|
||||
<template #suffix> 毫秒 </template>
|
||||
</n-input-number>
|
||||
</setting-item>
|
||||
<setting-item name="轮播方向">
|
||||
<n-select v-model:value="optionData.direction" :options="directions" placeholder="选择方向" />
|
||||
</setting-item>
|
||||
<setting-item name="过渡效果">
|
||||
<n-select v-model:value="optionData.effect" :options="effects" placeholder="效果" />
|
||||
</setting-item>
|
||||
<setting-item name="每页数量">
|
||||
<n-input-number v-model:value="optionData.slidesPerview" size="small" placeholder=""></n-input-number>
|
||||
</setting-item>
|
||||
<setting-item>
|
||||
<n-space>
|
||||
<n-switch v-model:value="optionData.centeredSlides" size="small" />
|
||||
<n-text>居中显示</n-text>
|
||||
</n-space>
|
||||
</setting-item>
|
||||
<setting-item name="图片样式">
|
||||
<n-select v-model:value="optionData.fit" :options="fitList" placeholder="样式" />
|
||||
</setting-item>
|
||||
</setting-item-box>
|
||||
<setting-item-box name="指示器">
|
||||
<setting-item name="样式">
|
||||
<n-select v-model:value="optionData.dotType" :options="dotTypes" placeholder="选择样式" />
|
||||
</setting-item>
|
||||
<setting-item name="位置">
|
||||
<n-select v-model:value="optionData.dotPlacement" :options="dotPlacements" placeholder="选择位置" />
|
||||
</setting-item>
|
||||
<setting-item>
|
||||
<n-space>
|
||||
<n-switch v-model:value="optionData.showDots" size="small" />
|
||||
<n-text>显示</n-text>
|
||||
</n-space>
|
||||
</setting-item>
|
||||
<setting-item>
|
||||
<n-space>
|
||||
<n-switch v-model:value="optionData.showArrow" size="small" />
|
||||
<n-text>箭头</n-text>
|
||||
</n-space>
|
||||
</setting-item>
|
||||
<setting-item>
|
||||
<n-space>
|
||||
<n-switch v-model:value="optionData.draggable" size="small" />
|
||||
<n-text>拖曳切换</n-text>
|
||||
</n-space>
|
||||
</setting-item>
|
||||
</setting-item-box>
|
||||
</collapse-item>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { option } from './config'
|
||||
import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
||||
|
||||
const props = defineProps({
|
||||
optionData: {
|
||||
type: Object as PropType<typeof option>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
// 字典
|
||||
const dotTypes = [
|
||||
{
|
||||
label: '点',
|
||||
value: 'dot'
|
||||
},
|
||||
{
|
||||
label: '线',
|
||||
value: 'line'
|
||||
}
|
||||
]
|
||||
const directions = [
|
||||
{
|
||||
label: '水平方向',
|
||||
value: 'horizontal'
|
||||
},
|
||||
{
|
||||
label: '垂直方向',
|
||||
value: 'vertical'
|
||||
}
|
||||
]
|
||||
const effects = [
|
||||
{
|
||||
label: 'slide',
|
||||
value: 'slide'
|
||||
},
|
||||
{
|
||||
label: 'fade',
|
||||
value: 'fade'
|
||||
},
|
||||
{
|
||||
label: 'card',
|
||||
value: 'card'
|
||||
},
|
||||
{
|
||||
label: 'custom',
|
||||
value: 'custom'
|
||||
}
|
||||
]
|
||||
const dotPlacements = [
|
||||
{
|
||||
label: '上边',
|
||||
value: 'top'
|
||||
},
|
||||
{
|
||||
label: '下边',
|
||||
value: 'bottom'
|
||||
},
|
||||
{
|
||||
label: '左边',
|
||||
value: 'left'
|
||||
},
|
||||
{
|
||||
label: '右边',
|
||||
value: 'right'
|
||||
}
|
||||
]
|
||||
|
||||
// 适应类型
|
||||
const fitList = [
|
||||
{
|
||||
value: 'fill',
|
||||
label: 'fill'
|
||||
},
|
||||
{
|
||||
value: 'contain',
|
||||
label: 'contain'
|
||||
},
|
||||
{
|
||||
value: 'cover',
|
||||
label: 'cover'
|
||||
},
|
||||
{
|
||||
value: 'scale-down',
|
||||
label: 'scale-down'
|
||||
},
|
||||
{
|
||||
value: 'none',
|
||||
label: 'none'
|
||||
}
|
||||
]
|
||||
</script>
|
||||
@@ -0,0 +1,14 @@
|
||||
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
|
||||
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
||||
|
||||
export const ImageCarouselConfig: ConfigType = {
|
||||
key: 'ImageCarousel',
|
||||
chartKey: 'VImageCarousel',
|
||||
conKey: 'VCImageCarousel',
|
||||
title: '轮播图',
|
||||
category: ChatCategoryEnum.MORE,
|
||||
categoryName: ChatCategoryEnumName.MORE,
|
||||
package: PackagesCategoryEnum.INFORMATIONS,
|
||||
chartFrame: ChartFrameEnum.NAIVE_UI,
|
||||
image: 'photo_carousel.png'
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<template>
|
||||
<div>
|
||||
<n-carousel
|
||||
:autoplay="autoplay"
|
||||
:interval="interval"
|
||||
:centered-slides="centeredSlides"
|
||||
:direction="direction"
|
||||
:dot-placement="dotPlacement"
|
||||
:dot-type="dotType"
|
||||
:draggable="draggable"
|
||||
:effect="effect"
|
||||
:slides-per-view="slidesPerview"
|
||||
:show-arrow="showArrow"
|
||||
:show-dots="showDots"
|
||||
>
|
||||
<n-image
|
||||
v-for="(url, index) in option.dataset"
|
||||
preview-disabled
|
||||
:key="index"
|
||||
:object-fit="fit"
|
||||
:src="url"
|
||||
:fallback-src="requireErrorImg()"
|
||||
:width="w"
|
||||
:height="h"
|
||||
></n-image>
|
||||
</n-carousel>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { PropType, toRefs, shallowReactive, watch } from 'vue'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { requireErrorImg } from '@/utils'
|
||||
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 option = shallowReactive({
|
||||
dataset: configOption.dataset
|
||||
})
|
||||
|
||||
const { w, h } = toRefs(props.chartConfig.attr)
|
||||
const {
|
||||
autoplay,
|
||||
interval,
|
||||
slidesPerview,
|
||||
direction,
|
||||
draggable,
|
||||
centeredSlides,
|
||||
effect,
|
||||
dotType,
|
||||
dotPlacement,
|
||||
showArrow,
|
||||
showDots,
|
||||
fit
|
||||
} = toRefs(props.chartConfig.option)
|
||||
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
(newData: any) => {
|
||||
option.dataset = newData
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
deep: false
|
||||
}
|
||||
)
|
||||
|
||||
useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
|
||||
option.dataset = newData
|
||||
})
|
||||
</script>
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { ImageConfig } from './Image/index'
|
||||
import { ImageCarouselConfig } from './ImageCarousel/index'
|
||||
import { IframeConfig } from './Iframe/index'
|
||||
import { VideoConfig } from './Video/index'
|
||||
import { WordCloudConfig } from './WordCloud/index'
|
||||
import { CarouselConfig } from './Carousel/index'
|
||||
|
||||
export default [WordCloudConfig, ImageConfig, VideoConfig, IframeConfig]
|
||||
export default [ImageConfig, ImageCarouselConfig, VideoConfig, IframeConfig, WordCloudConfig]
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
|
||||
@@ -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="样式">
|
||||
|
||||
4
src/packages/index.d.ts
vendored
@@ -114,6 +114,10 @@ export interface PublicConfigType {
|
||||
// 动画
|
||||
animations: string[]
|
||||
}
|
||||
preview?: {
|
||||
// 预览超出隐藏
|
||||
overFlowHidden?: boolean
|
||||
}
|
||||
filter?: string
|
||||
status: StatusType
|
||||
events: {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -78,6 +78,10 @@ export class PublicConfigClass implements PublicConfigType {
|
||||
// 动画
|
||||
animations: []
|
||||
}
|
||||
// 预览
|
||||
public preview = {
|
||||
overFlowHidden: false
|
||||
}
|
||||
// 状态
|
||||
public status = {
|
||||
lock: false,
|
||||
|
||||
@@ -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,
|
||||
ChevronUpOutline as ChevronUpOutlineIcon,
|
||||
@@ -64,7 +66,8 @@ import {
|
||||
List as ListIcon,
|
||||
EyeOutline as EyeOutlineIcon,
|
||||
EyeOffOutline as EyeOffOutlineIcon,
|
||||
Albums as AlbumsIcon
|
||||
Albums as AlbumsIcon,
|
||||
Analytics as AnalyticsIcon
|
||||
} from '@vicons/ionicons5'
|
||||
|
||||
import {
|
||||
@@ -101,6 +104,8 @@ import {
|
||||
} from '@vicons/carbon'
|
||||
|
||||
const ionicons5 = {
|
||||
// 新增
|
||||
AddIcon,
|
||||
// 帮助(问号)
|
||||
HelpOutlineIcon,
|
||||
// 添加
|
||||
@@ -206,6 +211,8 @@ const ionicons5 = {
|
||||
ArrowBackIcon,
|
||||
// 前进
|
||||
ArrowForwardIcon,
|
||||
// 向下
|
||||
ArrowDownIcon,
|
||||
// 狗爪
|
||||
PawIcon,
|
||||
// 搜索(放大镜)
|
||||
@@ -232,7 +239,9 @@ const ionicons5 = {
|
||||
EyeOutlineIcon,
|
||||
EyeOffOutlineIcon,
|
||||
// 图表列表
|
||||
AlbumsIcon
|
||||
AlbumsIcon,
|
||||
// 分析
|
||||
AnalyticsIcon
|
||||
}
|
||||
|
||||
const carbon = {
|
||||
|
||||
@@ -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'
|
||||
|
||||
9
src/plugins/initFunction.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* * 页面初始化就执行的函数
|
||||
*/
|
||||
export const initFunction = async () => {
|
||||
// 捕获全局错误
|
||||
window.addEventListener("unhandledrejection", event => {
|
||||
console.warn(`UNHANDLED PROMISE REJECTION: ${event.reason}`);
|
||||
});
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -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)'],
|
||||
|
||||
@@ -8,5 +8,6 @@
|
||||
"#d4a4eb",
|
||||
"#d2f5a6",
|
||||
"#76f2f2"
|
||||
]
|
||||
],
|
||||
"name": "粉青"
|
||||
}
|
||||
@@ -9,5 +9,6 @@
|
||||
"#fc8452",
|
||||
"#9a60b4",
|
||||
"#ea7ccc"
|
||||
]
|
||||
],
|
||||
"name": "暗淡"
|
||||
}
|
||||
@@ -9,5 +9,6 @@
|
||||
"#ff8a45",
|
||||
"#8d48e3",
|
||||
"#dd79ff"
|
||||
]
|
||||
],
|
||||
"name": "明亮"
|
||||
}
|
||||
@@ -6,5 +6,6 @@
|
||||
"#ffb248",
|
||||
"#f2d643",
|
||||
"#ebdba4"
|
||||
]
|
||||
],
|
||||
"name": "橘红"
|
||||
}
|
||||
@@ -20,5 +20,6 @@
|
||||
"#7eb00a",
|
||||
"#6f5553",
|
||||
"#c14089"
|
||||
]
|
||||
],
|
||||
"name": "马卡龙"
|
||||
}
|
||||
@@ -6,5 +6,6 @@
|
||||
"#71669e",
|
||||
"#cc70af",
|
||||
"#7cb4cc"
|
||||
]
|
||||
],
|
||||
"name": "深紫"
|
||||
}
|
||||
@@ -20,5 +20,6 @@
|
||||
"#3cb371",
|
||||
"#d5b158",
|
||||
"#38b6b6"
|
||||
]
|
||||
],
|
||||
"name": "罗马红"
|
||||
}
|
||||
@@ -8,5 +8,6 @@
|
||||
"#339ca8",
|
||||
"#cda819",
|
||||
"#32a487"
|
||||
]
|
||||
],
|
||||
"name": "深色"
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
"#cc7e63",
|
||||
"#724e58",
|
||||
"#4b565b"
|
||||
]
|
||||
],
|
||||
"name": "复古"
|
||||
}
|
||||
@@ -6,5 +6,6 @@
|
||||
"#a0a7e6",
|
||||
"#c4ebad",
|
||||
"#96dee8"
|
||||
]
|
||||
],
|
||||
"name": "蓝绿"
|
||||
}
|
||||
@@ -6,5 +6,6 @@
|
||||
"#93b7e3",
|
||||
"#a5e7f0",
|
||||
"#cbb0e3"
|
||||
]
|
||||
],
|
||||
"name": "灰粉"
|
||||
}
|
||||
@@ -6,5 +6,6 @@
|
||||
"#d0648a",
|
||||
"#f58db2",
|
||||
"#f2b3c9"
|
||||
]
|
||||
],
|
||||
"name": "青草"
|
||||
}
|
||||
@@ -10,7 +10,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 EditCanvasTypeEnum {
|
||||
@@ -22,7 +22,8 @@ export enum EditCanvasTypeEnum {
|
||||
LOCK_SCALE = 'lockScale',
|
||||
IS_CREATE = 'isCreate',
|
||||
IS_DRAG = 'isDrag',
|
||||
IS_SELECT = 'isSelect'
|
||||
IS_SELECT = 'isSelect',
|
||||
IS_CODE_EDIT="isCodeEdit"
|
||||
}
|
||||
|
||||
// 编辑区域
|
||||
@@ -44,6 +45,8 @@ export type EditCanvasType = {
|
||||
[EditCanvasTypeEnum.IS_DRAG]: boolean
|
||||
// 框选中
|
||||
[EditCanvasTypeEnum.IS_SELECT]: boolean
|
||||
// 代码编辑中
|
||||
[EditCanvasTypeEnum.IS_CODE_EDIT]: boolean
|
||||
}
|
||||
|
||||
// 滤镜/背景色/宽高主题等
|
||||
@@ -52,6 +55,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',
|
||||
@@ -87,9 +91,12 @@ export interface 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
|
||||
// 图表主题颜色
|
||||
|
||||
@@ -54,7 +54,9 @@ export const useChartEditStore = defineStore({
|
||||
// 拖拽中
|
||||
isDrag: false,
|
||||
// 框选中
|
||||
isSelect: false
|
||||
isSelect: false,
|
||||
// 代码编辑中
|
||||
isCodeEdit: false
|
||||
},
|
||||
// 右键菜单
|
||||
rightMenuShow: false,
|
||||
@@ -108,6 +110,8 @@ export const useChartEditStore = defineStore({
|
||||
selectColor: true,
|
||||
// chart 主题色
|
||||
chartThemeColor: defaultTheme || 'dark',
|
||||
// 自定义颜色列表
|
||||
chartCustomThemeColorInfo: undefined,
|
||||
// 全局配置
|
||||
chartThemeSetting: globalThemeJson,
|
||||
// 适配方式
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import cloneDeep from 'lodash/cloneDeep'
|
||||
import { WinKeyboard } from '@/enums/editPageEnum'
|
||||
import { RequestHttpIntervalEnum, RequestParamsObjType } from '@/enums/httpEnum'
|
||||
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
|
||||
import { excludeParseEventKeyList } from '@/enums/eventEnum'
|
||||
import { excludeParseEventKeyList, excludeParseEventValueList } from '@/enums/eventEnum'
|
||||
|
||||
/**
|
||||
* * 判断是否是开发环境
|
||||
@@ -320,10 +320,17 @@ export const JSONStringify = <T>(data: T) => {
|
||||
*/
|
||||
export const JSONParse = (data: string) => {
|
||||
return JSON.parse(data, (k, v) => {
|
||||
// 过滤函数字符串
|
||||
if (excludeParseEventKeyList.includes(k)) return v
|
||||
// 过滤函数值表达式
|
||||
if (typeof v === 'string') {
|
||||
const someValue = excludeParseEventValueList.some(excludeValue => v.indexOf(excludeValue) > -1)
|
||||
if (someValue) return v
|
||||
}
|
||||
// 还原函数值
|
||||
if (typeof v === 'string' && v.indexOf && (v.indexOf('function') > -1 || v.indexOf('=>') > -1)) {
|
||||
return eval(`(function(){return ${v}})()`)
|
||||
} else if (typeof v === 'string' && v.indexOf && (v.indexOf('return ') > -1)) {
|
||||
} else if (typeof v === 'string' && v.indexOf && v.indexOf('return ') > -1) {
|
||||
const baseLeftIndex = v.indexOf('(')
|
||||
if (baseLeftIndex > -1) {
|
||||
const newFn = `function ${v.substring(baseLeftIndex)}`
|
||||
@@ -340,4 +347,4 @@ export const JSONParse = (data: string) => {
|
||||
*/
|
||||
export const setTitle = (title?: string) => {
|
||||
title && (document.title = title)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -0,0 +1,3 @@
|
||||
import CreateColorRender from './index.vue'
|
||||
|
||||
export { CreateColorRender }
|
||||
@@ -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>
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import CreateColorRenderChart from './index.vue'
|
||||
|
||||
export { CreateColorRenderChart }
|
||||
@@ -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>
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
@@ -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'
|
||||
@@ -162,9 +163,6 @@ const selectColorOptions = [
|
||||
}
|
||||
]
|
||||
|
||||
// 默认展示颜色列表
|
||||
const swatchesColors = ['#232324', '#2a2a2b', '#313132', '#373739', '#757575', '#e0e0e0', '#eeeeee', '#fafafa']
|
||||
|
||||
const globalTabList = [
|
||||
{
|
||||
key: 'ChartTheme',
|
||||
@@ -294,13 +292,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 {
|
||||
@@ -331,8 +326,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;
|
||||
|
||||
@@ -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}`
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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]
|
||||
})
|
||||
|
||||
// 主题色
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -1,42 +1,68 @@
|
||||
import { watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import throttle from 'lodash/throttle'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||
import { useSync } from '@/views/chart/hooks/useSync.hook'
|
||||
import { ChartEnum } from '@/enums/pageEnum'
|
||||
import { SavePageEnum } from '@/enums/editPageEnum'
|
||||
import { editToJsonInterval } from '@/settings/designSetting'
|
||||
import { goDialog } from '@/utils'
|
||||
|
||||
const { updateComponent } = useSync()
|
||||
const chartEditStore = useChartEditStore()
|
||||
|
||||
export const syncData = () => {
|
||||
goDialog({
|
||||
message: '是否覆盖源视图内容,此操作不可撤回?',
|
||||
isMaskClosable: true,
|
||||
transformOrigin: 'center',
|
||||
onPositiveCallback: () => {
|
||||
window['$message'].success('正在同步编辑器...')
|
||||
dispatchEvent(new CustomEvent(SavePageEnum.CHART, { detail: chartEditStore.getStorageInfo }))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 侦听器更新
|
||||
const useSyncUpdateHandle = () => {
|
||||
// 定义侦听器变量
|
||||
let timer: any
|
||||
const updateFn = (e: any) => updateComponent(e!.detail, true, false)
|
||||
const syncData = async () => {
|
||||
dispatchEvent(new CustomEvent(SavePageEnum.CHART, { detail: chartEditStore.getStorageInfo }))
|
||||
|
||||
// 更新处理
|
||||
const updateFn = (e: any) => {
|
||||
window['$message'].success('正在进行更新...')
|
||||
updateComponent(e!.detail, true)
|
||||
}
|
||||
|
||||
// 页面关闭处理
|
||||
const closeFn = () => {
|
||||
chartEditStore.setEditCanvas(EditCanvasTypeEnum.IS_CODE_EDIT, false)
|
||||
}
|
||||
|
||||
// 开启侦听
|
||||
const use = () => {
|
||||
// // 1、定时同步数据
|
||||
// 定时同步数据(暂不开启)
|
||||
// timer = setInterval(() => {
|
||||
// // 窗口激活并且处于工作台
|
||||
// document.hasFocus() && syncData()
|
||||
// }, editToJsonInterval)
|
||||
// 2、失焦同步数据
|
||||
addEventListener('blur', syncData)
|
||||
|
||||
// 【监听JSON代码 刷新工作台图表】
|
||||
// 失焦同步数据(暂不开启)
|
||||
// addEventListener('blur', syncData)
|
||||
|
||||
// 监听编辑器保存事件 刷新工作台图表
|
||||
addEventListener(SavePageEnum.JSON, updateFn)
|
||||
|
||||
// 监听编辑页关闭
|
||||
addEventListener(SavePageEnum.CLOSE, throttle(closeFn, 1000))
|
||||
}
|
||||
|
||||
// 关闭侦听
|
||||
const unUse = () => {
|
||||
// clearInterval(timer)
|
||||
// removeEventListener('blur', syncData)
|
||||
removeEventListener(SavePageEnum.JSON, updateFn)
|
||||
removeEventListener('blur', syncData)
|
||||
}
|
||||
|
||||
// 路由变更时处理
|
||||
@@ -48,11 +74,11 @@ const useSyncUpdateHandle = () => {
|
||||
use()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return watchHandler
|
||||
}
|
||||
|
||||
export const useSyncUpdate = () => {
|
||||
const routerParamsInfo = useRoute()
|
||||
watch(() => routerParamsInfo.name, useSyncUpdateHandle(), { immediate: true })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,14 @@ import { ref, computed } from 'vue'
|
||||
import { useSettingStore } from '@/store/modules/settingStore/settingStore'
|
||||
import { ToolsStatusEnum } from '@/store/modules/settingStore/settingStore.d'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { fetchRouteParamsLocation, fetchPathByName, routerTurnByPath, setSessionStorage, getLocalStorage } from '@/utils'
|
||||
import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||
import {
|
||||
fetchRouteParamsLocation,
|
||||
fetchPathByName,
|
||||
routerTurnByPath,
|
||||
setSessionStorage,
|
||||
getLocalStorage
|
||||
} from '@/utils'
|
||||
import { EditEnum } from '@/enums/pageEnum'
|
||||
import { StorageEnum } from '@/enums/storageEnum'
|
||||
import { useRoute } from 'vue-router'
|
||||
@@ -137,8 +144,8 @@ const toolsMouseoutHandle = () => {
|
||||
|
||||
// 编辑处理
|
||||
const editHandle = () => {
|
||||
window['$message'].warning('将开启失焦更新!')
|
||||
// window['$message'].warning('将开启失焦更新与 5 秒同步更新!')
|
||||
window['$message'].warning('请通过顶部【同步内容】按钮同步最新数据!')
|
||||
chartEditStore.setEditCanvas(EditCanvasTypeEnum.IS_CODE_EDIT, true)
|
||||
setTimeout(() => {
|
||||
// 获取id路径
|
||||
const path = fetchPathByName(EditEnum.CHART_EDIT_NAME, 'href')
|
||||
@@ -146,7 +153,7 @@ const editHandle = () => {
|
||||
const id = fetchRouteParamsLocation()
|
||||
updateToSession(id)
|
||||
routerTurnByPath(path, [id], undefined, true)
|
||||
}, 1000)
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
// 把内存中的数据同步到SessionStorage 便于传递给新窗口初始化数据
|
||||
@@ -169,7 +176,6 @@ const updateToSession = (id: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 配置列表
|
||||
const btnList: BtnListType[] = [
|
||||
{
|
||||
|
||||
@@ -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'
|
||||
@@ -146,8 +146,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]
|
||||
})
|
||||
|
||||
// 是否展示渲染
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<n-space class="go-mt-0">
|
||||
<n-button v-for="item in btnList" :key="item.title" ghost @click="item.event">
|
||||
<n-button v-for="item in comBtnList" :key="item.title" :type="item.type" ghost @click="item.event">
|
||||
<template #icon>
|
||||
<component :is="item.icon"></component>
|
||||
</template>
|
||||
@@ -10,16 +10,17 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { shallowReactive } from 'vue'
|
||||
import { computed } from 'vue'
|
||||
import { renderIcon, goDialog, fetchPathByName, routerTurnByPath, setSessionStorage, getLocalStorage } from '@/utils'
|
||||
import { PreviewEnum } from '@/enums/pageEnum'
|
||||
import { StorageEnum } from '@/enums/storageEnum'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||
import { syncData } from '../../ContentEdit/components/EditTools/hooks/useSyncUpdate.hook'
|
||||
import { icon } from '@/plugins'
|
||||
import { cloneDeep } from 'lodash'
|
||||
|
||||
const { BrowsersOutlineIcon, SendIcon } = icon.ionicons5
|
||||
const { BrowsersOutlineIcon, SendIcon, AnalyticsIcon } = icon.ionicons5
|
||||
const chartEditStore = useChartEditStore()
|
||||
|
||||
const routerParamsInfo = useRoute()
|
||||
@@ -42,7 +43,8 @@ const previewHandle = () => {
|
||||
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, sessionStorageInfo)
|
||||
} else {
|
||||
sessionStorageInfo.push({
|
||||
id: previewId, ...storageInfo
|
||||
id: previewId,
|
||||
...storageInfo
|
||||
})
|
||||
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, sessionStorageInfo)
|
||||
}
|
||||
@@ -63,7 +65,14 @@ const sendHandle = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const btnList = shallowReactive([
|
||||
const btnList = [
|
||||
{
|
||||
select: true,
|
||||
title: '同步内容',
|
||||
type: 'primary',
|
||||
icon: renderIcon(AnalyticsIcon),
|
||||
event: syncData
|
||||
},
|
||||
{
|
||||
select: true,
|
||||
title: '预览',
|
||||
@@ -76,9 +85,18 @@ const btnList = shallowReactive([
|
||||
icon: renderIcon(SendIcon),
|
||||
event: sendHandle
|
||||
}
|
||||
])
|
||||
]
|
||||
|
||||
const comBtnList = computed(() => {
|
||||
if (chartEditStore.getEditCanvas.isCodeEdit) {
|
||||
return btnList
|
||||
}
|
||||
const cloneList = cloneDeep(btnList)
|
||||
cloneList.shift()
|
||||
return cloneList
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.align-center {
|
||||
margin-top: -4px;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
</n-icon>
|
||||
<n-text @click="handleFocus">
|
||||
工作空间 -
|
||||
<n-button v-show="!focus" secondary round size="tiny">
|
||||
<n-button v-show="!focus" secondary size="tiny">
|
||||
<span class="title">
|
||||
{{ comTitle }}
|
||||
</span>
|
||||
@@ -19,7 +19,6 @@
|
||||
type="text"
|
||||
maxlength="16"
|
||||
show-count
|
||||
round
|
||||
placeholder="请输入项目名称"
|
||||
v-model:value.trim="title"
|
||||
@keyup.enter="handleBlur"
|
||||
@@ -74,6 +73,8 @@ const handleBlur = () => {
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.title {
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
font-size: 15px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -14,8 +14,17 @@
|
||||
</n-button>
|
||||
</div>
|
||||
<n-space>
|
||||
<n-tag :bordered="false" type="warning"> 「页面失焦保存」 </n-tag>
|
||||
<n-tag :bordered="false" type="warning"> 「ctrl + s 保存」 </n-tag>
|
||||
<!-- 暂时关闭 -->
|
||||
<!-- <n-tag :bordered="false" type="warning"> 「页面失焦保存」 </n-tag> -->
|
||||
<n-tag :bordered="false" type="warning"> 「Ctrl + S 更新视图」 </n-tag>
|
||||
<n-button v-if="showOpenFilePicker" class="go-mr-3" size="medium" @click="updateSync">
|
||||
<template #icon>
|
||||
<n-icon>
|
||||
<analytics-icon></analytics-icon>
|
||||
</n-icon>
|
||||
</template>
|
||||
保存
|
||||
</n-button>
|
||||
</n-space>
|
||||
</n-layout-header>
|
||||
<n-layout-content>
|
||||
@@ -26,28 +35,31 @@
|
||||
lineNumbers: 'on',
|
||||
minimap: { enabled: true }
|
||||
}"
|
||||
/>
|
||||
/>
|
||||
</n-layout-content>
|
||||
</n-layout>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { ref } from 'vue'
|
||||
import { MonacoEditor } from '@/components/Pages/MonacoEditor'
|
||||
import { SavePageEnum } from '@/enums/editPageEnum'
|
||||
import { getSessionStorageInfo } from '../preview/utils'
|
||||
import type { ChartEditStorageType } from '../preview/index.d'
|
||||
import { setSessionStorage, JSONStringify, JSONParse, setTitle } from '@/utils'
|
||||
import { setSessionStorage, JSONStringify, JSONParse, setTitle, goDialog } from '@/utils'
|
||||
import { StorageEnum } from '@/enums/storageEnum'
|
||||
import { icon } from '@/plugins'
|
||||
import type { ChartEditStorageType } from '../preview/index.d'
|
||||
|
||||
const { ChevronBackOutlineIcon, DownloadIcon } = icon.ionicons5
|
||||
const { ChevronBackOutlineIcon, DownloadIcon, AnalyticsIcon } = icon.ionicons5
|
||||
const showOpenFilePicker: Function = (window as any).showOpenFilePicker
|
||||
const content = ref('')
|
||||
|
||||
window['$message'].warning('请不要刷新此窗口!')
|
||||
|
||||
// 从sessionStorage 获取数据
|
||||
async function getDataBySession() {
|
||||
const localStorageInfo: ChartEditStorageType = await getSessionStorageInfo() as unknown as ChartEditStorageType
|
||||
const localStorageInfo: ChartEditStorageType = (await getSessionStorageInfo()) as unknown as ChartEditStorageType
|
||||
setTitle(`编辑-${localStorageInfo.editCanvasConfig.projectName}`)
|
||||
content.value = JSONStringify(localStorageInfo)
|
||||
}
|
||||
@@ -60,44 +72,75 @@ function back() {
|
||||
}
|
||||
|
||||
// 导入json文本
|
||||
async function importJSON() {
|
||||
const files = await showOpenFilePicker()
|
||||
const file = await files[0].getFile()
|
||||
const fr = new FileReader()
|
||||
fr.readAsText(file)
|
||||
fr.onloadend = () => {
|
||||
content.value = (fr.result || '').toString()
|
||||
}
|
||||
function importJSON() {
|
||||
goDialog({
|
||||
message: '导入数据将覆盖内容,此操作不可撤回,是否继续?',
|
||||
isMaskClosable: true,
|
||||
transformOrigin: 'center',
|
||||
onPositiveCallback: async () => {
|
||||
try {
|
||||
const files = await showOpenFilePicker()
|
||||
const file = await files[0].getFile()
|
||||
const fr = new FileReader()
|
||||
fr.readAsText(file)
|
||||
fr.onloadend = () => {
|
||||
content.value = (fr.result || '').toString()
|
||||
}
|
||||
window['$message'].success('导入成功!')
|
||||
} catch (error) {
|
||||
window['$message'].error('导入失败,请检查文件是否损坏!')
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 同步 [画布页失去焦点时同步数据到JSON页,JSON页Ctrl+S 时同步数据到画布页]
|
||||
// 同步数据编辑页
|
||||
window.opener.addEventListener(SavePageEnum.CHART, (e: any) => {
|
||||
window['$message'].success('正在进行更新...')
|
||||
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, [e.detail])
|
||||
content.value = JSONStringify(e.detail)
|
||||
})
|
||||
|
||||
// 窗口失焦 + 保存 => 同步数据
|
||||
// 保存按钮同步数据
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (e.keyCode == 83 && (navigator.platform.match('Mac') ? e.metaKey : e.ctrlKey)) {
|
||||
e.preventDefault()
|
||||
updateSync()
|
||||
}
|
||||
})
|
||||
addEventListener('blur', updateSync)
|
||||
|
||||
// 失焦保存(暂时关闭)
|
||||
// addEventListener('blur', updateSync)
|
||||
|
||||
// 同步更新
|
||||
async function updateSync() {
|
||||
if (!window.opener) {
|
||||
return window['$message'].error('源窗口已关闭,视图同步失败')
|
||||
return window['$message'].error('源窗口已关闭,视图同步失败!')
|
||||
}
|
||||
try {
|
||||
const detail = JSONParse(content.value)
|
||||
delete detail.id
|
||||
// 保持id不变
|
||||
window.opener.dispatchEvent(new CustomEvent(SavePageEnum.JSON, { detail }))
|
||||
} catch (e) {
|
||||
window['$message'].error('内容格式有误')
|
||||
console.log(e)
|
||||
goDialog({
|
||||
message: '是否覆盖源视图内容? 此操作不可撤!',
|
||||
isMaskClosable: true,
|
||||
transformOrigin: 'center',
|
||||
onPositiveCallback: () => {
|
||||
try {
|
||||
const detail = JSONParse(content.value)
|
||||
delete detail.id
|
||||
// 保持id不变
|
||||
window.opener.dispatchEvent(new CustomEvent(SavePageEnum.JSON, { detail }))
|
||||
window['$message'].success('正在同步内容...')
|
||||
} catch (e) {
|
||||
window['$message'].error('内容格式有误')
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 关闭页面发送关闭事件
|
||||
window.onbeforeunload = () => {
|
||||
if (window.opener) {
|
||||
window.opener.dispatchEvent(new CustomEvent(SavePageEnum.CLOSE))
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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) => {
|
||||
// 背景
|
||||
|
||||