Compare commits

...

60 Commits

Author SHA1 Message Date
奔跑的面条
3ac9ffc73c Merge branch 'dev' 2022-11-22 12:44:51 +08:00
奔跑的面条
5ea963fb93 fix: 处理旧数据基础事件报错的问题 2022-11-22 12:42:23 +08:00
奔跑的面条
c420ae467f Merge branch 'dev' 2022-11-21 10:49:25 +08:00
奔跑的面条
be014225c1 fix: 去除页面错误静态数据 2022-11-21 10:49:04 +08:00
奔跑的面条
8334fe5bcc build: 升级版本到 1.1.5 2022-11-19 21:04:53 +08:00
奔跑的面条
f99edce6f4 Merge branch 'dev' 2022-11-19 21:04:32 +08:00
奔跑的面条
936d78975e fix: 解决点击图表分列没反应的bug 2022-11-19 20:37:06 +08:00
奔跑的面条
a25f9bc5a1 !100 胶囊柱图问题 ,滚动排名列表问题
Merge pull request !100 from daidai/dev
2022-11-19 06:03:47 +00:00
刘嘉威
5454f19f3d fix: 滚动排名列表问题当数据量小于等于列表数时,第一条数据会直接不显示 2022-11-18 11:25:41 +08:00
刘嘉威
b95cf946a8 perf: 胶囊图增加cloneDeep防止多个互相影响 2022-11-18 10:16:41 +08:00
刘嘉威
1b9a3f6f5b fix: 胶囊柱图source数量变化页面展示效果数量不变问题 2022-11-18 09:23:37 +08:00
奔跑的面条
d91cd00310 fix: 补充误删的代码 2022-11-17 22:35:49 +08:00
奔跑的面条
e4f821f46d perf: 去除多余代码,优化全局配置页面 2022-11-17 21:39:51 +08:00
奔跑的面条
ed5a452e2f perf: 优化配置页面结构 2022-11-17 00:41:11 +08:00
奔跑的面条
907a0afb77 chore: 优化地址输入框的长度 2022-11-17 00:18:39 +08:00
奔跑的面条
b32c718780 style: 新增注释 2022-11-16 22:55:03 +08:00
潘潘
adbdad1e88 perf: 注释定时同步 2022-11-15 21:42:22 +08:00
潘潘
f8229a0518 perf: 编辑JSON优化 2022-11-15 21:42:09 +08:00
奔跑的面条
48f00e44f6 feat: 新增数据池 hook 2022-11-15 21:25:35 +08:00
奔跑的面条
8c089b800a perf: 修改列表的样式wenti 2022-11-13 21:38:46 +08:00
奔跑的面条
44199fa4c4 feat: 新增图表展示模式切换 2022-11-13 21:28:38 +08:00
奔跑的面条
5e20689356 feat: 新增基础事件功能 2022-11-13 02:36:04 +08:00
奔跑的面条
9a9b752a96 feat: 新增基础事件 2022-11-12 23:03:13 +08:00
奔跑的面条
1ddf056ca6 fix: 修改事件类型错误 2022-11-12 22:03:51 +08:00
奔跑的面条
572ab73c92 perf: 优化事件代码结构 2022-11-12 21:49:04 +08:00
奔跑的面条
afc8f907ce perf: 优化修改json的代码 2022-11-12 17:20:11 +08:00
奔跑的面条
f6bad1513b perf: 优化获取id 的旧代码 2022-11-12 16:16:03 +08:00
奔跑的面条
fce514c490 chore: 转移master-fetch分支获取id函数到dev分支 2022-11-12 16:10:14 +08:00
奔跑的面条
30a9deaee7 fix: 解决部分组件的配置缺失深拷贝的问题 2022-11-12 15:37:41 +08:00
奔跑的面条
f47acca703 update README.md.
Signed-off-by: 奔跑的面条 <1262327911@qq.com>
2022-11-10 10:13:19 +00:00
奔跑的面条
73a6c6b920 update README.md.
Signed-off-by: 奔跑的面条 <1262327911@qq.com>
2022-11-10 10:10:58 +00:00
奔跑的面条
672f7a0a7c Merge branch 'dev' of https://gitee.com/MTrun/go-view 2022-11-05 21:46:26 +08:00
奔跑的面条
de78fb2149 docs: 新增文档截图 2022-11-05 18:19:33 +08:00
奔跑的面条
4a59e69bbe docs: 修改首页地址 2022-11-02 19:46:19 +08:00
奔跑的面条
a442e13a7b feat: 升级版本到1.1.4 2022-11-02 19:05:16 +08:00
奔跑的面条
4d093a4a80 Merge branch 'dev' of https://gitee.com/MTrun/go-view 2022-11-02 19:02:38 +08:00
奔跑的面条
7e59d8d36c docs: 修改链接地址 2022-11-02 09:57:28 +08:00
奔跑的面条
8241077495 update README.md.
Signed-off-by: 奔跑的面条 <1262327911@qq.com>
2022-10-29 12:09:36 +00:00
奔跑的面条
82b29a2f8b docs: 优化说明文档 2022-10-29 19:57:02 +08:00
奔跑的面条
b789d80f98 fix: 修改主页说明 2022-10-29 19:51:33 +08:00
奔跑的面条
a8c80e2366 docs: 修改主页说明 2022-10-29 19:50:30 +08:00
奔跑的面条
bdbdd37789 build: 升级版本到1.1.3 2022-10-15 17:17:34 +08:00
奔跑的面条
c8fb5b9152 Merge branch 'dev' of https://gitee.com/MTrun/go-view 2022-10-15 17:12:13 +08:00
奔跑的面条
aef155e039 fix: 修复组件导入数据错乱的问题 2022-10-09 16:37:30 +08:00
奔跑的面条
443573455b Merge branch 'dev' of https://gitee.com/MTrun/go-view 2022-10-09 09:28:38 +08:00
奔跑的面条
d811ab7dfa build: 撤回错误版本号 2022-10-08 21:12:58 +08:00
奔跑的面条
5f79ab6e6d build: 升级版本到1.1.2 2022-10-08 21:12:27 +08:00
奔跑的面条
502edbca5d Merge branch 'dev' of https://gitee.com/MTrun/go-view 2022-10-08 21:05:48 +08:00
奔跑的面条
1a04267cb7 build: 升级版本到1.1.1 2022-10-08 20:59:55 +08:00
奔跑的面条
9c2c1bdfa1 Merge branch 'dev' of https://gitee.com/MTrun/go-view 2022-10-08 20:59:25 +08:00
奔跑的面条
72e93f3768 Merge branch 'dev' of https://gitee.com/MTrun/go-view 2022-09-27 20:16:07 +08:00
奔跑的面条
e6f2066d42 Merge branch 'dev' of https://gitee.com/MTrun/go-view 2022-09-22 14:15:00 +08:00
奔跑的面条
2812c39524 Merge branch 'dev' of https://gitee.com/MTrun/go-view 2022-09-21 19:54:29 +08:00
奔跑的面条
491485856e Merge branch 'dev' of https://gitee.com/MTrun/go-view 2022-09-19 20:46:37 +08:00
奔跑的面条
abde7e176d Merge branch 'dev' of https://gitee.com/MTrun/go-view 2022-09-19 20:13:50 +08:00
奔跑的面条
bab8faadee add default pipeline template yaml 2022-09-19 11:58:32 +00:00
奔跑的面条
427d72fb8b Merge branch 'dev' of https://gitee.com/MTrun/go-view 2022-09-18 16:48:28 +08:00
奔跑的面条
dc5b20a329 build: 升级版本到1.1.0 2022-09-18 16:33:26 +08:00
奔跑的面条
4cb934eef3 Merge branch 'dev' of https://gitee.com/MTrun/go-view 2022-09-18 16:32:34 +08:00
奔跑的面条
35e8cea0b5 docs: 更新已完成图表说明 2022-09-17 23:00:51 +08:00
54 changed files with 1163 additions and 359 deletions

View File

@@ -0,0 +1,51 @@
version: '1.0'
name: branch-pipeline
displayName: BranchPipeline
stages:
- stage:
name: compile
displayName: 编译
steps:
- step: build@nodejs
name: build_nodejs
displayName: Nodejs 构建
# 支持8.16.2、10.17.0、12.16.1、14.16.0、15.12.0五个版本
nodeVersion: 14.16.0
# 构建命令:安装依赖 -> 清除上次打包产物残留 -> 执行构建 【请根据项目实际产出进行填写】
commands:
- npm install && rm -rf ./dist && npm run build
# 非必填字段开启后表示将构建产物暂存但不会上传到制品库中7天后自动清除
artifacts:
# 构建产物名字作为产物的唯一标识可向下传递支持自定义默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址
- name: BUILD_ARTIFACT
# 构建产物获取路径,是指代码编译完毕之后构建物的所在路径
path:
- ./dist
- step: publish@general_artifacts
name: publish_general_artifacts
displayName: 上传制品
# 上游构建任务定义的产物名默认BUILD_ARTIFACT
dependArtifact: BUILD_ARTIFACT
# 上传到制品库时的制品命名默认output
artifactName: output
dependsOn: build_nodejs
- stage:
name: release
displayName: 发布
steps:
- step: publish@release_artifacts
name: publish_release_artifacts
displayName: '发布'
# 上游上传制品任务的产出
dependArtifact: output
# 发布制品版本号
version: '1.0.0.0'
# 是否开启版本号自增,默认开启
autoIncrement: true
triggers:
push:
branches:
exclude:
- master
include:
- .*

View File

@@ -0,0 +1,49 @@
version: '1.0'
name: master-pipeline
displayName: MasterPipeline
stages:
- stage:
name: compile
displayName: 编译
steps:
- step: build@nodejs
name: build_nodejs
displayName: Nodejs 构建
# 支持8.16.2、10.17.0、12.16.1、14.16.0、15.12.0五个版本
nodeVersion: 14.16.0
# 构建命令:安装依赖 -> 清除上次打包产物残留 -> 执行构建 【请根据项目实际产出进行填写】
commands:
- npm install && rm -rf ./dist && npm run build
# 非必填字段开启后表示将构建产物暂存但不会上传到制品库中7天后自动清除
artifacts:
# 构建产物名字作为产物的唯一标识可向下传递支持自定义默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址
- name: BUILD_ARTIFACT
# 构建产物获取路径,是指代码编译完毕之后构建物的所在路径
path:
- ./dist
- step: publish@general_artifacts
name: publish_general_artifacts
displayName: 上传制品
# 上游构建任务定义的产物名默认BUILD_ARTIFACT
dependArtifact: BUILD_ARTIFACT
# 上传到制品库时的制品命名默认output
artifactName: output
dependsOn: build_nodejs
- stage:
name: release
displayName: 发布
steps:
- step: publish@release_artifacts
name: publish_release_artifacts
displayName: '发布'
# 上游上传制品任务的产出
dependArtifact: output
# 发布制品版本号
version: '1.0.0.0'
# 是否开启版本号自增,默认开启
autoIncrement: true
triggers:
push:
branches:
include:
- master

36
.workflow/pr-pipeline.yml Normal file
View File

@@ -0,0 +1,36 @@
version: '1.0'
name: pr-pipeline
displayName: PRPipeline
stages:
- stage:
name: compile
displayName: 编译
steps:
- step: build@nodejs
name: build_nodejs
displayName: Nodejs 构建
# 支持8.16.2、10.17.0、12.16.1、14.16.0、15.12.0五个版本
nodeVersion: 14.16.0
# 构建命令:安装依赖 -> 清除上次打包产物残留 -> 执行构建 【请根据项目实际产出进行填写】
commands:
- npm install && rm -rf ./dist && npm run build
# 非必填字段开启后表示将构建产物暂存但不会上传到制品库中7天后自动清除
artifacts:
# 构建产物名字作为产物的唯一标识可向下传递支持自定义默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址
- name: BUILD_ARTIFACT
# 构建产物获取路径,是指代码编译完毕之后构建物的所在路径
path:
- ./dist
- step: publish@general_artifacts
name: publish_general_artifacts
displayName: 上传制品
# 上游构建任务定义的产物名默认BUILD_ARTIFACT
dependArtifact: BUILD_ARTIFACT
# 上传到制品库时的制品命名默认output
artifactName: output
dependsOn: build_nodejs
triggers:
pr:
branches:
include:
- master

View File

@@ -1,30 +1,34 @@
## 总览
![logo](readme/logo-t-y.png)
<p align="center">
<img src="readme/logo-t-y.png" alt="go-view" />
</p>
GoView 是一个高效的拖拽式低代码数据可视化开发平台,将图表或页面元素封装为基础组件,无需编写代码即可制作数据大屏,减少心智负担。
<h4 align="center">开源、精美、便捷的「数据可视化」低代码开发平台</h4>
### 😶 **前端** 分支: **`master`**
#### 😶 **前端** 分支: **`master`**
### 👻 携带 **后端** 请求分支: **`master-fetch`**
#### 👻 携带 **后端** 请求分支: **`master-fetch`**
### 📚 GoView **文档** 地址:[http://www.mtruning.club:81/](http://www.mtruning.club:81/)
#### 📚 GoView **文档** 地址:[https://www.mtruning.club/](https://www.mtruning.club/)
项目纯前端-Demo 地址:[https://www.mtruning.club](https://www.mtruning.club)
项目纯前端-Demo 地址:[https://vue.mtruning.club/](https://vue.mtruning.club/)
项目带后端-Demo 地址:[后端 Demo 地址](http://1.117.240.165:8080/goview/#/login)
文档-在线地址:[http://www.mtruning.club:81/](http://www.mtruning.club:81/)
项目带后端-Demo 地址:[https://demo.mtruning.club/](https://demo.mtruning.club/)
文档-源码地址:[https://gitee.com/MTrun/go-view-doc](https://gitee.com/MTrun/go-view-doc)
### 🤯 后端项目
#### 🤯 后端项目看这里!
后端项目gitee地址[https://gitee.com/MTrun/go-view-serve](https://gitee.com/MTrun/go-view-serve)
后端项目 gitee 地址:[https://gitee.com/MTrun/go-view-serve](https://gitee.com/MTrun/go-view-serve)
接口说明地址:[https://docs.apipost.cn/preview/5aa85d10a59d66ce/ddb813732007ad2b?target_id=84dbc5b0-158f-4bcb-8f74-793ac604ada3#3e053622-1e76-43f9-a039-756aee822dbb](https://docs.apipost.cn/preview/5aa85d10a59d66ce/ddb813732007ad2b?target_id=84dbc5b0-158f-4bcb-8f74-793ac604ada3#3e053622-1e76-43f9-a039-756aee822dbb)
技术点
其它后端方案地址
- 【.NET】[https://gitee.com/sun_xiang_yu/go-view-dotnet](https://gitee.com/sun_xiang_yu/go-view-dotnet)
#### 整体介绍
- 框架:基于 `Vue3` 框架编写,使用 `hooks` 写法抽离部分逻辑,使代码结构更加清晰;
@@ -36,17 +40,29 @@ GoView 是一个高效的拖拽式低代码数据可视化开发平台,将图
- 封装:项目进行了详细的工具类封装如:路由、存储、加/解密、文件处理、主题、NaiveUI 全局方法、组件等
说明文档:
![说明文档](readme/go-view-doc.png)
工作台:
![项目截图](readme/go-view-canvas.png)
![工作台](readme/go-view-canvas.png)
请求配置:
![项目截图](readme/go-view-fetch.png)
![请求配置](readme/go-view-fetch.png)
数据过滤:
![项目截图](readme/go-view-filter.png)
![数据过滤](readme/go-view-filter.png)
高级事件编辑:
![高级事件编辑](readme/go-view-event.png)
快捷主页:
![快捷主页](readme/go-view-indexpage.png)
主题色:
![项目截图](readme/go-view-color.png)
![主题色](readme/go-view-color.png)
亮白主题:
![亮白主题](readme/go-view-theme.png)
主要技术栈为:
@@ -66,14 +82,17 @@ GoView 是一个高效的拖拽式低代码数据可视化开发平台,将图
已完成图表:
| 分类 | 名称 | 名称 | 名称 |
| ------ | ---------------- | ---------------- | -------- |
| 图表 | 柱状图 | 横向柱状图 | 折线图 |
| \* | 单/多 折线面积图 | 饼图 | 水球图 |
| \* | 环形图 | NaiveUI 多种进度 | 🤠 |
| 信息 | 文字 | 图 | 😶 |
| 列表 | 滚动排名列表 | 滚动表格 | 🤓 |
| 小组件 | 边框-01~13 | 装饰-01~05 | 数字翻牌 |
| 分类 | 名称 | 名称 | 名称 | 名称 |
| ------ | ---------------- | ---------- | -------------- | ------------------------ |
| 图表 | 柱状图 | 横向柱状图 | 折线图 | 单/多 折线面积图(渐变色) |
| \* | 饼图 | 环形图 | 水球图 | 雷达图 |
| \* | NaiveUI 多种进度 | 散点图 | 对数回归散点图 | 热力图 |
| \* | 漏斗图 | 中国地图 | 高德地 | 🦊 |
| 信息 | 文字 | 渐变文字 | 词云 | 嵌套网页 |
| \* | 图片 | 视频 | 😺 | 🐯 |
| 列表 | 滚动排名列表 | 滚动表格 | 🐮 | 🐐 |
| 小组件 | 边框-01~13 | 装饰-01~05 | 数字翻牌 | 通用时间 |
| \* | 数字计数 | 倒计时 | 时钟 | 🦁 |
## 浏览器支持

View File

@@ -1,6 +1,6 @@
{
"name": "go-view",
"version": "1.1.11",
"version": "1.1.5",
"scripts": {
"dev": "vite --host",
"build": "vue-tsc --noEmit && vite build",

BIN
readme/go-view-doc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

BIN
readme/go-view-theme.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 KiB

View File

@@ -2,5 +2,6 @@ export * from '@/hooks/useTheme.hook'
export * from '@/hooks/usePreviewScale.hook'
export * from '@/hooks/useCode.hook'
export * from '@/hooks/useChartDataFetch.hook'
export * from '@/hooks/useChartDataPondFetch.hook'
export * from '@/hooks/useLifeHandler.hook'
export * from '@/hooks/useLang.hook'

View File

@@ -1,6 +1,7 @@
import { ref, toRefs, toRaw } from 'vue'
import type VChart from 'vue-echarts'
import { customizeHttp } from '@/api/http'
import { useChartDataPondFetch } from '@/hooks/'
import { CreateComponentType, ChartFrameEnum } from '@/packages/index.d'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { RequestDataTypeEnum } from '@/enums/httpEnum'
@@ -23,6 +24,22 @@ export const useChartDataFetch = (
const vChartRef = ref<typeof VChart | null>(null)
let fetchInterval: any = 0
// 数据池
const { addGlobalDataInterface } = useChartDataPondFetch()
const { requestDataPondId } = toRefs(targetComponent.request)
// 组件类型
const { chartFrame } = targetComponent.chartConfig
// eCharts 组件配合 vChart 库更新方式
const echartsUpdateHandle = (dataset: any) => {
if (chartFrame === ChartFrameEnum.ECHARTS) {
if (vChartRef.value) {
vChartRef.value.setOption({ dataset: dataset })
}
}
}
const requestIntervalFn = () => {
const chartEditStore = useChartEditStore()
@@ -41,9 +58,6 @@ export const useChartDataFetch = (
requestInterval: targetInterval
} = toRefs(targetComponent.request)
// 组件类型
const { chartFrame } = targetComponent.chartConfig
// 非请求类型
if (requestDataType.value !== RequestDataTypeEnum.AJAX) return
@@ -58,16 +72,11 @@ export const useChartDataFetch = (
clearInterval(fetchInterval)
const fetchFn = async () => {
const res = await customizeHttp(toRaw(targetComponent.request), toRaw(chartEditStore.requestGlobalConfig))
const res = await customizeHttp(toRaw(targetComponent.request), toRaw(chartEditStore.getRequestGlobalConfig))
if (res) {
try {
const filter = targetComponent.filter
// eCharts 组件配合 vChart 库更新方式
if (chartFrame === ChartFrameEnum.ECHARTS) {
if (vChartRef.value) {
vChartRef.value.setOption({ dataset: newFunctionHandle(res?.data, res, filter) })
}
}
echartsUpdateHandle(newFunctionHandle(res?.data, res, filter))
// 更新回调函数
if (updateCallback) {
updateCallback(newFunctionHandle(res?.data, res, filter))
@@ -94,6 +103,11 @@ export const useChartDataFetch = (
}
}
isPreview() && requestIntervalFn()
if (isPreview()) {
// 判断是否有数据池对应 id
requestDataPondId
? addGlobalDataInterface(targetComponent, useChartEditStore, updateCallback || echartsUpdateHandle)
: requestIntervalFn()
}
return { vChartRef }
}

View File

@@ -0,0 +1,93 @@
import { toRaw } from 'vue'
import { customizeHttp } from '@/api/http'
import { CreateComponentType } from '@/packages/index.d'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { RequestGlobalConfigType, RequestDataPondItemType } from '@/store/modules/chartEditStore/chartEditStore.d'
import { newFunctionHandle } from '@/utils'
// 获取类型
type ChartEditStoreType = typeof useChartEditStore
// 数据池存储的数据类型
type DataPondMapType = {
updateCallback: (...args: any) => any
filter?: string | undefined
}
// 数据池 Map 中请求对应 callback
const mittDataPondMap = new Map<string, DataPondMapType[]>()
// 创建单个数据项轮询接口
const newPondItemInterval = (
requestGlobalConfig: RequestGlobalConfigType,
requestDataPondItem: RequestDataPondItemType,
dataPondMapItem?: DataPondMapType[]
) => {
if (!dataPondMapItem) return
// 请求
const fetchFn = async () => {
try {
const res = await customizeHttp(toRaw(requestDataPondItem.dataPondRequestConfig), toRaw(requestGlobalConfig))
if (res) {
try {
// 遍历更新回调函数
dataPondMapItem.forEach(item => {
item.updateCallback(newFunctionHandle(res?.data, res, item.filter))
})
} catch (error) {
console.error(error)
return error
}
}
} catch (error) {
return error
}
}
// 立即调用
fetchFn()
}
/**
* 数据池接口处理
*/
export const useChartDataPondFetch = () => {
// 新增全局接口
const addGlobalDataInterface = (
targetComponent: CreateComponentType,
useChartEditStore: ChartEditStoreType,
updateCallback: (...args: any) => any
) => {
const chartEditStore = useChartEditStore()
const { requestDataPond } = chartEditStore.getRequestGlobalConfig
// 组件对应的数据池 Id
const requestDataPondId = '111' || (targetComponent.request.requestDataPondId as string)
// 新增数据项
const mittPondIdArr = mittDataPondMap.get(requestDataPondId) || []
mittPondIdArr.push({
updateCallback: updateCallback,
filter: targetComponent.filter
})
mittDataPondMap.set(requestDataPondId, mittPondIdArr)
}
// 初始化数据池
const initDataPond = (requestGlobalConfig: RequestGlobalConfigType) => {
const { requestDataPond } = requestGlobalConfig
// 根据 mapId 查找对应的数据池配置
for (let pondKey of mittDataPondMap.keys()) {
const requestDataPondItem = requestDataPond.find(item => item.dataPondId === pondKey)
if (requestDataPondItem) {
newPondItemInterval(requestGlobalConfig, requestDataPondItem, mittDataPondMap.get(pondKey))
}
}
}
return {
addGlobalDataInterface,
initDataPond
}
}

View File

@@ -1,4 +1,4 @@
import { CreateComponentType, EventLife } from '@/packages/index.d'
import { CreateComponentType, CreateComponentGroupType, EventLife, BaseEvent } from '@/packages/index.d'
import * as echarts from 'echarts'
// 所有图表组件集合对象
@@ -7,26 +7,57 @@ const components: { [K in string]?: any } = {}
// 项目提供的npm 包变量
export const npmPkgs = { echarts }
export const useLifeHandler = (chartConfig: CreateComponentType) => {
const events = chartConfig.events || {}
// 组件事件处理 hook
export const useLifeHandler = (chartConfig: CreateComponentType | CreateComponentGroupType) => {
if (!chartConfig.events) return {}
// 处理基础事件
const baseEvent: { [key: string]: any } = {}
for (const key in chartConfig.events.baseEvent) {
const fnStr: string | undefined = (chartConfig.events.baseEvent as any)[key]
// 动态绑定基础事件
if (fnStr) {
baseEvent[key] = generateBaseFunc(fnStr)
}
}
// 生成生命周期事件
const events = chartConfig.events.advancedEvents || {}
const lifeEvents = {
[EventLife.BEFORE_MOUNT](e: any) {
[EventLife.VNODE_BEFORE_MOUNT](e: any) {
// 存储组件
components[chartConfig.id] = e.component
const fnStr = (events[EventLife.BEFORE_MOUNT] || '').trim()
const fnStr = (events[EventLife.VNODE_BEFORE_MOUNT] || '').trim()
generateFunc(fnStr, e)
},
[EventLife.MOUNTED](e: any) {
const fnStr = (events[EventLife.MOUNTED] || '').trim()
[EventLife.VNODE_MOUNTED](e: any) {
const fnStr = (events[EventLife.VNODE_MOUNTED] || '').trim()
generateFunc(fnStr, e)
}
}
return lifeEvents
return { ...baseEvent, ...lifeEvents }
}
/**
*
* 生成基础函数
* @param fnStr 用户方法体代码
* @param event 鼠标事件
*/
export function generateBaseFunc(fnStr: string) {
try {
return new Function(`
return (
async function(mouseEvent){
${fnStr}
}
)`)()
} catch (error) {
console.error(error)
}
}
/**
* 生成高级函数
* @param fnStr 用户方法体代码
* @param e 执行生命周期的动态组件实例
*/

View File

@@ -2,7 +2,7 @@
<div
v-if="state.mergedConfig"
class="go-dv-capsule-chart"
:style="{
:style="{
fontSize: numberSizeHandle(state.mergedConfig.valueFontSize),
paddingLeft: numberSizeHandle(state.mergedConfig.paddingLeft),
paddingRight: numberSizeHandle(state.mergedConfig.paddingRight)
@@ -53,11 +53,10 @@
<script setup lang="ts">
import { onMounted, watch, reactive, PropType } from 'vue'
import merge from 'lodash/merge'
import cloneDeep from 'lodash/cloneDeep'
import { useChartDataFetch } from '@/hooks'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import config, { option } from './config'
import cloneDeep from 'lodash/cloneDeep'
type DataProps = {
name: string | number
@@ -114,12 +113,11 @@ watch(
const calcData = (data: any) => {
mergeConfig(props.chartConfig.option)
calcCapsuleLengthAndLabelData()
}
const mergeConfig = (data: any) => {
state.mergedConfig = merge(cloneDeep(state.defaultConfig), data || {})
state.mergedConfig = cloneDeep(data || {})
}
// 数据解析

View File

@@ -2,6 +2,7 @@ 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'
export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
@@ -47,7 +48,7 @@ export const option = {
export default class Config extends PublicConfigClass implements CreateComponentType {
public key: string = LineCommonConfig.key
public chartConfig = LineCommonConfig
public chartConfig = cloneDeep(LineCommonConfig)
// 图表配置项
public option = echartOptionProfixHandle(option, includes)
}

View File

@@ -3,6 +3,7 @@ import { LineGradientSingleConfig } from './index'
import { CreateComponentType } from '@/packages/index.d'
import { graphic } from 'echarts/core'
import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json'
export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
@@ -58,7 +59,7 @@ const options = {
export default class Config extends PublicConfigClass implements CreateComponentType {
public key: string = LineGradientSingleConfig.key
public chartConfig = LineGradientSingleConfig
public chartConfig = cloneDeep(LineGradientSingleConfig)
// 图表配置项
public option = echartOptionProfixHandle(options, includes)
}

View File

@@ -3,6 +3,7 @@ import { LineGradientsConfig } from './index'
import { CreateComponentType } from '@/packages/index.d'
import { graphic } from 'echarts/core'
import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json'
export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
@@ -85,7 +86,7 @@ const option = {
export default class Config extends PublicConfigClass implements CreateComponentType {
public key: string = LineGradientsConfig.key
public chartConfig = LineGradientsConfig
public chartConfig = cloneDeep(LineGradientsConfig)
// 图表配置项
public option = echartOptionProfixHandle(option, includes)
}

View File

@@ -2,6 +2,7 @@ import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
import { LineLinearSingleConfig } 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'
export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
@@ -54,7 +55,7 @@ export const option = {
export default class Config extends PublicConfigClass implements CreateComponentType {
public key: string = LineLinearSingleConfig.key
public chartConfig = LineLinearSingleConfig
public chartConfig = cloneDeep(LineLinearSingleConfig)
// 图表配置项
public option = echartOptionProfixHandle(option, includes)
}

View File

@@ -2,6 +2,7 @@ import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
import { MapBaseConfig } from './index'
import { chartInitConfig } from '@/settings/designSetting'
import { CreateComponentType } from '@/packages/index.d'
import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json'
export const includes = []
@@ -151,6 +152,6 @@ export const MapDefaultConfig = { ...option }
export default class Config extends PublicConfigClass implements CreateComponentType {
public key: string = MapBaseConfig.key
public attr = { ...chartInitConfig, w: 750, h: 800, zIndex: -1 }
public chartConfig = MapBaseConfig
public chartConfig = cloneDeep(MapBaseConfig)
public option = echartOptionProfixHandle(option, includes)
}

View File

@@ -1,6 +1,7 @@
import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
import { PieCircleConfig } from './index'
import { CreateComponentType } from '@/packages/index.d'
import cloneDeep from 'lodash/cloneDeep'
export const includes = []
@@ -57,7 +58,7 @@ const option = {
export default class Config extends PublicConfigClass implements CreateComponentType {
public key: string = PieCircleConfig.key
public chartConfig = PieCircleConfig
public chartConfig = cloneDeep(PieCircleConfig)
// 图表配置项
public option = echartOptionProfixHandle(option, includes)

View File

@@ -1,6 +1,7 @@
import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
import { PieCommonConfig } from './index'
import { CreateComponentType } from '@/packages/index.d'
import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json'
export const includes = ['legend']
@@ -61,7 +62,7 @@ const option = {
export default class Config extends PublicConfigClass implements CreateComponentType {
public key: string = PieCommonConfig.key
public chartConfig = PieCommonConfig
public chartConfig = cloneDeep(PieCommonConfig)
// 图表配置项
public option = echartOptionProfixHandle(option, includes)

View File

@@ -62,7 +62,7 @@ const status = reactive({
const calcRowsData = () => {
let { dataset, rowNum, sort } = status.mergedConfig
// @ts-ignore
sort && dataset.sort(({ value: a }, { value: b }) => {
sort &&dataset.sort(({ value: a }, { value: b } ) => {
if (a > b) return -1
if (a < b) return 1
if (a === b) return 0
@@ -94,6 +94,7 @@ const calcHeights = (onresize = false) => {
const { rowNum, dataset } = status.mergedConfig
const avgHeight = h.value / rowNum
status.avgHeight = avgHeight
if (!onresize) status.heights = new Array(dataset.length).fill(avgHeight)
}
@@ -131,12 +132,17 @@ const stopAnimation = () => {
const onRestart = async () => {
try {
if (!status.mergedConfig) return
let { dataset, rowNum, sort } = status.mergedConfig
stopAnimation()
calcRowsData()
calcHeights(true)
animation(true)
let flag = true
if (dataset.length <= rowNum) {
flag=false
}
calcHeights(flag)
animation(flag)
} catch (error) {
console.log(error)
console.error(error)
}
}

View File

@@ -90,12 +90,24 @@ export const BlendModeEnumList = [
{ label: '亮度', value: 'luminosity' }
]
// 基础事件类型(vue不加 on)
export enum BaseEvent {
// 点击
ON_CLICK = 'click',
// 双击
ON_DBL_CLICK = 'dblclick',
// 移入
ON_MOUSE_ENTER = 'mouseenter',
// 移出
ON_MOUSE_LEAVE = 'mouseleave',
}
// vue3 生命周期事件
export enum EventLife {
export enum EventLife {
// 渲染之后
MOUNTED = 'vnodeMounted',
VNODE_MOUNTED = 'vnodeMounted',
// 渲染之前
BEFORE_MOUNT = 'vnodeBeforeMount',
VNODE_BEFORE_MOUNT = 'vnodeBeforeMount',
}
// 组件实例类
@@ -123,8 +135,13 @@ export interface PublicConfigType {
}
filter?: string
status: StatusType
events?: {
[K in EventLife]?: string
events: {
baseEvent: {
[K in BaseEvent]?: string
},
advancedEvents: {
[K in EventLife]?: string
}
}
}

View File

@@ -1,5 +1,4 @@
import { getUUID } from '@/utils'
import { ChartFrameEnum, PublicConfigType, CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
import { RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
import { groupTitle } from '@/settings/designSetting'
import {
@@ -9,6 +8,14 @@ import {
RequestContentTypeEnum,
RequestBodyEnum
} from '@/enums/httpEnum'
import {
BaseEvent,
EventLife,
ChartFrameEnum,
PublicConfigType,
CreateComponentType,
CreateComponentGroupType
} from '@/packages/index.d'
import { chartInitConfig } from '@/settings/designSetting'
import cloneDeep from 'lodash/cloneDeep'
@@ -82,7 +89,18 @@ export class PublicConfigClass implements PublicConfigType {
// 数据过滤
public filter = undefined
// 事件
public events = undefined
public events = {
baseEvent: {
[BaseEvent.ON_CLICK]: undefined,
[BaseEvent.ON_DBL_CLICK]: undefined,
[BaseEvent.ON_MOUSE_ENTER]: undefined,
[BaseEvent.ON_MOUSE_LEAVE]: undefined
},
advancedEvents: {
[EventLife.VNODE_MOUNTED]: undefined,
[EventLife.VNODE_BEFORE_MOUNT]: undefined
}
}
}
// 多选成组类

View File

@@ -63,7 +63,8 @@ import {
Images as ImagesIcon,
List as ListIcon,
EyeOutline as EyeOutlineIcon,
EyeOffOutline as EyeOffOutlineIcon
EyeOffOutline as EyeOffOutlineIcon,
Albums as AlbumsIcon
} from '@vicons/ionicons5'
import {
@@ -95,7 +96,8 @@ import {
Carbon3DCursor as Carbon3DCursorIcon,
Carbon3DSoftware as Carbon3DSoftwareIcon,
Filter as FilterIcon,
FilterEdit as FilterEditIcon
FilterEdit as FilterEditIcon,
Laptop as LaptopIcon
} from '@vicons/carbon'
const ionicons5 = {
@@ -228,7 +230,9 @@ const ionicons5 = {
ListIcon,
// 眼睛
EyeOutlineIcon,
EyeOffOutlineIcon
EyeOffOutlineIcon,
// 图表列表
AlbumsIcon
}
const carbon = {
@@ -279,7 +283,9 @@ const carbon = {
Carbon3DSoftwareIcon,
// 过滤器
FilterIcon,
FilterEditIcon
FilterEditIcon,
// 图层
LaptopIcon
}
// https://www.xicons.org/#/ 还有很多

View File

@@ -150,16 +150,27 @@ type RequestPublicConfigType = {
requestParams: RequestParams
}
// 数据池项类型
export type RequestDataPondItemType = {
dataPondId: string,
dataPondName: string,
dataPondRequestConfig: RequestConfigType
}
// 全局的图表请求配置
export interface RequestGlobalConfigType extends RequestPublicConfigType {
// 组件定制轮询时间
requestInterval: number
// 请求源地址
requestOriginUrl?: string
// 公共数据池
requestDataPond: RequestDataPondItemType[]
}
// 单个图表请求配置
export interface RequestConfigType extends RequestPublicConfigType {
// 所选全局数据池的对应 id
requestDataPondId?: string
// 组件定制轮询时间
requestInterval?: number
// 获取数据的方式

View File

@@ -108,11 +108,12 @@ export const useChartEditStore = defineStore({
chartThemeColor: defaultTheme || 'dark',
// 全局配置
chartThemeSetting: globalThemeJson,
// 预览方式
// 适配方式
previewScaleType: previewScaleType
},
// 数据请求处理(需存储给后端)
requestGlobalConfig: {
requestDataPond: [],
requestOriginUrl: '',
requestInterval: requestInterval,
requestIntervalUnit: requestIntervalUnit,

View File

@@ -1,3 +1,8 @@
export enum ChartModeEnum {
SINGLE= 'single',
DOUBLE = 'double'
}
export enum LayerModeEnum {
THUMBNAIL = 'thumbnail',
TEXT = 'text'
@@ -7,6 +12,7 @@ export enum ChartLayoutStoreEnum {
LAYERS = 'layers',
CHARTS = 'charts',
DETAILS = 'details',
Chart_TYPE = 'chartType',
LAYER_TYPE = 'layerType'
}
@@ -17,6 +23,8 @@ export interface ChartLayoutType {
[ChartLayoutStoreEnum.CHARTS]: boolean
// 详情设置
[ChartLayoutStoreEnum.DETAILS]: boolean
// 组件展示方式
[ChartLayoutStoreEnum.Chart_TYPE]: ChartModeEnum
// 层级展示方式
[ChartLayoutStoreEnum.LAYER_TYPE]: LayerModeEnum
}

View File

@@ -1,5 +1,5 @@
import { defineStore } from 'pinia'
import { ChartLayoutType, LayerModeEnum } from './chartLayoutStore.d'
import { ChartLayoutType, LayerModeEnum, ChartModeEnum } from './chartLayoutStore.d'
import { setLocalStorage, getLocalStorage } from '@/utils'
import { StorageEnum } from '@/enums/storageEnum'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
@@ -8,22 +8,25 @@ const chartEditStore = useChartEditStore()
const { GO_CHART_LAYOUT_STORE } = StorageEnum
const storageChartLayout: ChartLayoutType = getLocalStorage(GO_CHART_LAYOUT_STORE)
const storageChartLayout: Partial<ChartLayoutType> = getLocalStorage(GO_CHART_LAYOUT_STORE)
// 编辑区域布局和静态设置
export const useChartLayoutStore = defineStore({
id: 'useChartLayoutStore',
state: (): ChartLayoutType =>
storageChartLayout || {
// 图层控制
layers: true,
// 图表组件
charts: true,
// 详情设置收缩为true
details: false,
// 图层类型(默认图片)
layerType: LayerModeEnum.THUMBNAIL
},
state: (): ChartLayoutType => ({
// 图层控制
layers: true,
// 图表组件
charts: true,
// 详情设置收缩为true
details: false,
// 组件列表展示类型(默认单列)
chartType: ChartModeEnum.SINGLE,
// 图层类型(默认图片)
layerType: LayerModeEnum.THUMBNAIL,
// 防止值不存在
...storageChartLayout
}),
getters: {
getLayers(): boolean {
return this.layers
@@ -34,6 +37,9 @@ export const useChartLayoutStore = defineStore({
getDetails(): boolean {
return this.details
},
getChartType(): ChartModeEnum {
return this.chartType
},
getLayerType(): LayerModeEnum {
return this.layerType
}
@@ -41,8 +47,8 @@ export const useChartLayoutStore = defineStore({
actions: {
setItem<T extends keyof ChartLayoutType, K extends ChartLayoutType[T]>(key: T, value: K): void {
this.$patch(state => {
state[key]= value
});
state[key] = value
})
setLocalStorage(GO_CHART_LAYOUT_STORE, this.$state)
// 重新计算拖拽区域缩放比例
setTimeout(() => {

View File

@@ -153,6 +153,19 @@ export const fetchRouteParams = () => {
}
}
/**
* * 通过硬解析获取当前路由下的参数
* @returns object
*/
export const fetchRouteParamsLocation = () => {
try {
return document.location.hash.split('/').pop() || ''
} catch (error) {
window['$message'].warning('查询路由信息失败,请联系管理员!')
return ''
}
}
/**
* * 回到主页面
* @param confirm

View File

@@ -1,5 +1,5 @@
<template>
<div class="go-content-charts-item-box">
<div class="go-content-charts-item-box" :class="{ double: chartMode === ChartModeEnum.DOUBLE }">
<!-- 每一项组件的渲染 -->
<div
class="item-box"
@@ -11,21 +11,30 @@
@dblclick="dblclickHandle(item)"
>
<div class="list-header">
<mac-os-control-btn :mini="true" :disabled="true"></mac-os-control-btn>
<n-text class="list-header-text" depth="3">{{ item.title }}</n-text>
<mac-os-control-btn class="list-header-control-btn" :mini="true" :disabled="true"></mac-os-control-btn>
<n-text class="list-header-text" depth="3">
<n-ellipsis>{{ item.title }}</n-ellipsis>
</n-text>
</div>
<div class="list-center go-flex-center">
<img class="list-img" v-lazy="item.image" alt="图表图片" />
</div>
<div class="list-bottom">
<n-text class="list-bottom-text" depth="3">
<n-ellipsis style="max-width: 90%">{{ item.title }}</n-ellipsis>
</n-text>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { PropType } from 'vue'
import { PropType, ref, Ref, computed } from 'vue'
import { MacOsControlBtn } from '@/components/Tips/MacOsControlBtn/index'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
import { ChartModeEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
import { componentInstall, loadingStart, loadingFinish, loadingError } from '@/utils'
import { DragKeyEnum } from '@/enums/editPageEnum'
import { createComponent } from '@/packages'
@@ -41,6 +50,13 @@ defineProps({
}
})
const chartLayoutStore = useChartLayoutStore()
// 组件展示状态
const chartMode: Ref<ChartModeEnum> = computed(() => {
return chartLayoutStore.getChartType
})
// 拖拽处理
const dragStartHandle = (e: DragEvent, item: ConfigType) => {
// 动态注册图表组件
@@ -80,13 +96,19 @@ const dblclickHandle = async (item: ConfigType) => {
<style lang="scss" scoped>
/* 列表项宽度 */
$itemWidth: 86%;
$itemWidth: 100%;
$halfItemWidth: 46%;
/* 内容高度 */
$centerHeight: 100px;
$halfCenterHeight: 50px;
@include go('content-charts-item-box') {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 9px;
padding: 10px;
.item-box {
margin: 0 7%;
margin-bottom: 15px;
margin: 0;
width: $itemWidth;
overflow: hidden;
border-radius: 6px;
@@ -122,6 +144,39 @@ $centerHeight: 100px;
@extend .go-transition;
}
}
.list-bottom {
display: none;
.list-bottom-text {
font-size: 12px;
padding-left: 5px;
}
}
}
/* 缩小展示 */
&.double {
.list-header {
padding: 2px 5px;
.list-header-text {
display: none;
}
.list-header-control-btn {
transform: scale(0.7);
}
}
.item-box {
width: $halfItemWidth;
}
.list-center {
height: $halfCenterHeight;
padding-bottom: 0px;
.list-img {
height: $halfCenterHeight;
width: auto;
}
}
.list-bottom {
display: block;
}
}
}
</style>

View File

@@ -123,7 +123,6 @@ $menuWidth: 65px;
display: flex;
flex-direction: column;
align-items: center;
padding: 10px 0;
}
@include deep() {
.n-menu-item {

View File

@@ -1,82 +1,104 @@
<template>
<div class="go-chart-search">
<n-popover
class="chart-search-popover"
:show-arrow="false"
:show="showPopover"
:to="false"
trigger="hover"
placement="bottom-start"
>
<template #trigger>
<n-input-group>
<n-input
v-model:value.trim="search"
size="small"
:loading="loading"
placeholder="请输入组件名称"
@update:value="searchHandle"
>
<template #suffix>
<n-icon v-show="!loading" :component="SearchIcon" />
</template>
</n-input>
</n-input-group>
</template>
<div class="go-chart-search-box">
<div class="chart-search go-transition" :class="{ 'chart-search-focus': isFocus }">
<n-popover
class="chart-search-popover"
:show-arrow="false"
:show="showPopover"
:to="false"
trigger="hover"
placement="bottom-start"
>
<template #trigger>
<n-input-group>
<n-input
size="small"
placeholder="搜索组件"
v-model:value.trim="search"
:loading="loading"
@focus="focusHandle(true)"
@blur="focusHandle(false)"
@update:value="searchHandle"
>
<template #suffix>
<n-icon v-show="!loading" :component="SearchIcon" />
</template>
</n-input>
</n-input-group>
</template>
<div class="search-list-box">
<n-scrollbar style="max-height: 500px">
<n-empty
v-show="!searchRes.length"
size="small"
description="没有找到组件~"
></n-empty>
<div
class="list-item go-flex-items-center go-ellipsis-1"
v-for="item in searchRes"
:key="item.key"
:title="item.title"
@click="selectChartHandle(item)"
>
<img class="list-item-img" v-lazy="item.image" alt="展示图" />
<n-text class="list-item-fs" depth="2">{{ item.title }}</n-text>
</div>
</n-scrollbar>
<div class="popover-modal"></div>
</div>
</n-popover>
<div class="search-list-box">
<n-scrollbar style="max-height: 500px">
<n-empty v-show="!searchRes.length" size="small" description="没有找到组件~"></n-empty>
<div
class="list-item go-flex-items-center go-ellipsis-1"
v-for="item in searchRes"
:key="item.key"
:title="item.title"
@click="selectChartHandle(item)"
>
<img class="list-item-img" v-lazy="item.image" alt="展示图" />
<n-text class="list-item-fs" depth="2">{{ item.title }}</n-text>
</div>
</n-scrollbar>
<div class="popover-modal"></div>
</div>
</n-popover>
</div>
<n-button-group class="btn-group go-transition" :class="{ 'btn-group-focus': isFocus }" style="display: flex">
<n-button
ghost
size="small"
:key="index"
:type="chartMode === item.value ? 'primary' : 'tertiary'"
v-for="(item, index) in chartModeList"
@click="changeChartModeType(item.value)"
>
<n-tooltip :show-arrow="false" trigger="hover">
<template #trigger>
<n-icon size="14" :component="item.icon" />
</template>
{{ item.label }}
</n-tooltip>
</n-button>
</n-button-group>
</div>
</template>
<script setup lang="ts">
import { ref, onUnmounted } from 'vue'
import { icon } from '@/plugins'
import { createComponent } from '@/packages'
import { ConfigType, CreateComponentType } from '@/packages/index.d'
import { themeColor, MenuOptionsType } from '../../hooks/useAside.hook'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { ConfigType, CreateComponentType } from '@/packages/index.d'
import { createComponent } from '@/packages'
import { ChartModeEnum, ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
import { isString, addEventListener, removeEventListener } from '@/utils'
import { fetchConfigComponent, fetchChartComponent } from '@/packages/index'
import {
componentInstall,
loadingStart,
loadingFinish,
loadingError,
} from '@/utils'
import { componentInstall, loadingStart, loadingFinish, loadingError } from '@/utils'
const props = defineProps({
menuOptions: {
type: Array,
default: () => [],
},
default: () => []
}
})
const { SearchIcon } = icon.ionicons5
const chartEditStore = useChartEditStore()
const chartLayoutStore = useChartLayoutStore()
const { SearchIcon, AlbumsIcon, GridIcon } = icon.ionicons5
const isFocus = ref<boolean>(false)
const showPopover = ref<boolean>(false)
const loading = ref<boolean | undefined>(undefined)
const search = ref<string | null>(null)
const searchRes = ref<ConfigType[]>([])
const chartMode = ref<ChartModeEnum>(chartLayoutStore.getChartType)
const chartModeList = [
{ label: '单列', icon: AlbumsIcon, value: ChartModeEnum.SINGLE },
{ label: '双列', icon: GridIcon, value: ChartModeEnum.DOUBLE }
]
// 组件数组提取
const listFormatHandle = (options: any[]) => {
@@ -106,9 +128,7 @@ const searchHandle = (key: string | null) => {
}
loading.value = true
showPopover.value = true
searchRes.value = List.filter(
(e: ConfigType) => !key || e.title.toLowerCase().includes(key.toLowerCase())
)
searchRes.value = List.filter((e: ConfigType) => !key || e.title.toLowerCase().includes(key.toLowerCase()))
setTimeout(() => {
loading.value = undefined
}, 500)
@@ -145,6 +165,17 @@ const selectChartHandle = async (item: ConfigType) => {
}
}
// 聚焦设置
const focusHandle = (value: boolean) => {
isFocus.value = value
}
// 修改图表展示方式
const changeChartModeType = (value: ChartModeEnum) => {
chartMode.value = value
chartLayoutStore.setItem(ChartLayoutStoreEnum.Chart_TYPE, value)
}
addEventListener(document, 'click', (e: Event) => {
listenerCloseHandle(e)
})
@@ -155,54 +186,78 @@ onUnmounted(() => {
</script>
<style lang="scss" scoped>
$width: 178px;
@include go('chart-search') {
width: $width;
margin-right: -12px;
.chart-search-popover {
.search-list-box {
width: calc(#{$width} - 30px);
.list-item {
z-index: 2;
position: relative;
cursor: pointer;
padding: 2px;
padding-left: 6px;
margin-bottom: 5px;
&-fs {
font-size: 12px;
}
&-img {
height: 28px;
margin-right: 5px;
border-radius: 5px;
}
&:hover {
&::before {
content: '';
position: absolute;
width: 3px;
height: 100%;
left: 0;
top: 0;
border-radius: 2px;
background-color: v-bind('themeColor');
$width: 98px;
$searchWidth: 176px;
@include go('chart-search-box') {
display: flex;
.chart-search {
width: $width;
margin-right: 10px;
&.chart-search-focus {
width: $searchWidth;
&.chart-search {
margin-right: 0;
}
}
@include deep() {
.chart-search-popover {
padding-left: 5px;
padding-right: 8px;
}
}
.chart-search-popover {
.search-list-box {
width: 163px;
.list-item {
z-index: 2;
position: relative;
cursor: pointer;
padding: 2px;
padding-left: 6px;
margin-bottom: 5px;
&-fs {
font-size: 12px;
}
&::after {
z-index: -1;
content: '';
position: absolute;
width: 100%;
height: 100%;
opacity: 0.1;
left: 0;
top: 0;
&-img {
height: 28px;
margin-right: 5px;
border-radius: 5px;
background-color: v-bind('themeColor');
}
&:hover {
&::before {
content: '';
position: absolute;
width: 3px;
height: 100%;
left: 0;
top: 0;
border-radius: 2px;
background-color: v-bind('themeColor');
}
&::after {
z-index: -1;
content: '';
position: absolute;
width: 100%;
height: 100%;
opacity: 0.1;
left: 0;
top: 0;
border-radius: 5px;
background-color: v-bind('themeColor');
}
}
}
}
}
}
.btn-group {
width: 68px;
overflow: hidden;
&.btn-group-focus {
width: 0px;
}
}
}
</style>
</style>

View File

@@ -75,7 +75,7 @@
</n-button>
</n-space>
<n-space>
<n-text>预览方式</n-text>
<n-text>适配方式</n-text>
<n-button-group>
<n-button
v-for="item in previewTypeList"
@@ -279,7 +279,7 @@ const customRequest = (options: UploadCustomRequestOptions) => {
})
}
// 选择预览方式
// 选择适配方式
const selectPreviewType = (key: PreviewScaleEnum) => {
chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.PREVIEW_SCALE_TYPE, key)
}

View File

@@ -125,7 +125,7 @@ const sendHandle = async () => {
if (!targetData.value?.request) return
loading.value = true
try {
const res = await customizeHttp(toRaw(targetData.value.request), toRaw(chartEditStore.requestGlobalConfig))
const res = await customizeHttp(toRaw(targetData.value.request), toRaw(chartEditStore.getRequestGlobalConfig))
loading.value = false
if (res) {
if(!res?.data && !targetData.value.filter) window['$message'].warning('您的数据不符合默认格式,请配置过滤器!')

View File

@@ -102,12 +102,11 @@
<script lang="ts" setup>
import { ref, computed, watch, toRefs, toRaw } from 'vue'
import { MonacoEditor } from '@/components/Pages/MonacoEditor'
import { useTargetData } from '../../../hooks/useTargetData.hook'
import { RequestHttpEnum, RequestDataTypeEnum, ResultEnum } from '@/enums/httpEnum'
import { MonacoEditor } from '@/components/Pages/MonacoEditor'
import { icon } from '@/plugins'
import { goDialog, toString } from '@/utils'
import { http, customizeHttp } from '@/api/http'
import { customizeHttp } from '@/api/http'
import cloneDeep from 'lodash/cloneDeep'
const { DocumentTextIcon } = icon.ionicons5
@@ -128,7 +127,7 @@ const sourceData = ref<any>('')
// 动态获取数据
const fetchTargetData = async () => {
try {
const res = await customizeHttp(toRaw(targetData.value.request), toRaw(chartEditStore.requestGlobalConfig))
const res = await customizeHttp(toRaw(targetData.value.request), toRaw(chartEditStore.getRequestGlobalConfig))
if (res) {
sourceData.value = res
return

View File

@@ -3,8 +3,9 @@
<n-divider class="go-my-3" title-placement="left"></n-divider>
<setting-item-box
:itemRightStyle="{
gridTemplateColumns: '5fr 2fr 1fr'
gridTemplateColumns: '6fr 2fr'
}"
style="padding-right: 25px;"
>
<template #name>
地址
@@ -134,7 +135,7 @@ const apiList = [
},
{
value: `【三维地球】${threeEarth01Url}`
},
}
]
</script>

View File

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

View File

@@ -10,13 +10,17 @@
编辑
</n-button>
</template>
<n-card>
<n-card class="collapse-show-box">
<!-- 函数体 -->
<div v-for="eventName in EventLife" :key="eventName">
<p>
<span class="func-annotate">// {{ EventLifeName[eventName] }}</span>
<br />
<span class="func-keyword">async {{ eventName }}</span> (e, components, echarts, node_modules) {
</p>
<p class="go-ml-4"><n-code :code="(targetData.events || {})[eventName]" language="typescript"></n-code></p>
<p class="go-ml-4">
<n-code :code="(targetData.events.advancedEvents || {})[eventName] || ''" language="typescript"></n-code>
</p>
<p>}<span>,</span></p>
</div>
</n-card>
@@ -30,13 +34,15 @@
<n-text>高级事件编辑器配合源码使用</n-text>
</n-space>
</template>
<template #header-extra> </template>
<n-layout has-sider sider-placement="right">
<n-layout style="height: 580px; padding-right: 20px">
<n-tabs v-model:value="editTab" type="card" tab-style="min-width: 100px;">
<!-- 提示 -->
<template #suffix>
<n-text class="tab-tip" type="warning">tips: {{ EventLifeTip[editTab] }}</n-text>
<n-text class="tab-tip" type="warning">提示: {{ EventLifeTip[editTab] }}</n-text>
</template>
<n-tab-pane
v-for="(eventName, index) in EventLife"
@@ -50,7 +56,7 @@
<span class="func-keyNameWord">{{ eventName }}(e, components, echarts, node_modules)&nbsp;&nbsp;{</span>
</p>
<!-- 编辑主体 -->
<monaco-editor v-model:modelValue="events[eventName]" height="480px" language="javascript" />
<monaco-editor v-model:modelValue="advancedEvents[eventName]" height="480px" language="javascript" />
<!-- 函数结束 -->
<p class="go-pl-3 func-keyNameWord">}</p>
</n-tab-pane>
@@ -136,7 +142,7 @@
<template #icon>
<n-icon :component="DocumentTextIcon" />
</template>
提示
说明
</n-tag>
<n-text class="go-ml-2" depth="2">通过提供的参数可为图表增加定制化的tooltip交互事件等等</n-text>
</div>
@@ -158,29 +164,27 @@ import { useTargetData } from '../../../hooks/useTargetData.hook'
import { templateList } from './importTemplate'
import { npmPkgs } from '@/hooks'
import { icon } from '@/plugins'
import { goDialog, toString } from '@/utils'
import { CreateComponentType, EventLife } from '@/packages/index.d'
import { Script } from 'vm'
const { targetData, chartEditStore } = useTargetData()
const { DocumentTextIcon, ChevronDownIcon, PencilIcon } = icon.ionicons5
const EventLifeName = {
[EventLife.BEFORE_MOUNT]: '渲染之前',
[EventLife.MOUNTED]: '渲染之后'
[EventLife.VNODE_BEFORE_MOUNT]: '渲染之前',
[EventLife.VNODE_MOUNTED]: '渲染之后'
}
const EventLifeTip = {
[EventLife.BEFORE_MOUNT]: '此时组件 DOM 还未存在',
[EventLife.MOUNTED]: '此时组件 DOM 已经存在'
[EventLife.VNODE_BEFORE_MOUNT]: '此时组件 DOM 还未存在',
[EventLife.VNODE_MOUNTED]: '此时组件 DOM 已经存在'
}
//
const showModal = ref(false)
//
const editTab = ref(EventLife.MOUNTED)
const editTab = ref(EventLife.VNODE_MOUNTED)
// events
let events = ref({ ...targetData.value.events })
let advancedEvents = ref({ ...targetData.value.events.advancedEvents })
//
const errorFlag = ref(false)
@@ -190,7 +194,7 @@ const validEvents = () => {
let message = ''
let name = ''
errorFlag.value = Object.entries(events.value).every(([eventName, str]) => {
errorFlag.value = Object.entries(advancedEvents.value).every(([eventName, str]) => {
try {
// await
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor
@@ -221,11 +225,14 @@ const saveEvents = () => {
window['$message'].error('事件函数错误,无法进行保存')
return
}
if (Object.values(events.value).join('').trim() === '') {
if (Object.values(advancedEvents.value).join('').trim() === '') {
//
targetData.value.events = undefined
targetData.value.events.advancedEvents = {
vnodeBeforeMount: undefined,
vnodeMounted: undefined
}
} else {
targetData.value.events = { ...events.value }
targetData.value.events.advancedEvents = { ...advancedEvents.value }
}
closeEvents()
}
@@ -234,52 +241,12 @@ watch(
() => showModal.value,
(newData: boolean) => {
if (newData) {
events.value = { ...targetData.value.events }
advancedEvents.value = { ...targetData.value.events.advancedEvents }
}
}
)
</script>
<style lang="scss" scoped>
/* 外层也要使用 */
.func-keyword {
color: #b478cf;
}
@include go('chart-data-monaco-editor') {
.func-keyNameWord {
color: #70c0e8;
}
.tab-tip {
font-size: 12px;
}
&.n-card.n-modal,
.n-card {
@extend .go-background-filter;
}
}
@include deep() {
.n-layout,
.n-layout-sider {
background-color: transparent;
}
.go-editor-area {
max-height: 530px;
}
.checkbox--hidden:checked {
& + label {
.n-icon {
transition: all 0.3s;
transform: rotate(180deg);
}
}
& ~ .go-editor-area {
display: none;
}
}
//
.n-code > pre {
white-space: break-spaces;
}
}
@import '../index.scss';
</style>

View File

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

View File

@@ -0,0 +1,215 @@
<template>
<n-collapse-item title="基础事件配置" name="1">
<template #header-extra>
<n-button type="primary" tertiary size="small" @click.stop="showModal = true">
<template #icon>
<n-icon>
<pencil-icon />
</n-icon>
</template>
编辑
</n-button>
</template>
<n-card class="collapse-show-box">
<!-- 函数体 -->
<div v-for="eventName in BaseEvent" :key="eventName">
<p>
<span class="func-annotate">// {{ EventTypeName[eventName] }}</span>
<br />
<span class="func-keyword">async {{ eventName }}</span> (mouseEvent) {
</p>
<p class="go-ml-4">
<n-code :code="(targetData.events.baseEvent || {})[eventName] || ''" language="typescript"></n-code>
</p>
<p>}<span>,</span></p>
</div>
</n-card>
</n-collapse-item>
<!-- 弹窗 -->
<n-modal class="go-chart-data-monaco-editor" v-model:show="showModal" :mask-closable="false">
<n-card :bordered="false" role="dialog" size="small" aria-modal="true" style="width: 1200px; height: 700px">
<template #header>
<n-space>
<n-text>基础事件编辑器</n-text>
</n-space>
</template>
<template #header-extra> </template>
<n-layout has-sider sider-placement="right">
<n-layout style="height: 580px; padding-right: 20px">
<n-tabs v-model:value="editTab" type="card" tab-style="min-width: 100px;">
<!-- 提示 -->
<template #suffix>
<n-text class="tab-tip" type="warning">提示: ECharts 组件会拦截鼠标事件</n-text>
</template>
<n-tab-pane
v-for="(eventName, index) in BaseEvent"
:key="index"
:tab="`${EventTypeName[eventName]}-${eventName}`"
:name="eventName"
>
<!-- 函数名称 -->
<p class="go-pl-3">
<span class="func-keyword">async function &nbsp;&nbsp;</span>
<span class="func-keyNameWord">{{ eventName }}(mouseEvent)&nbsp;&nbsp;{</span>
</p>
<!-- 编辑主体 -->
<monaco-editor v-model:modelValue="baseEvent[eventName]" height="480px" language="javascript" />
<!-- 函数结束 -->
<p class="go-pl-3 func-keyNameWord">}</p>
</n-tab-pane>
</n-tabs>
</n-layout>
<n-layout-sider
:collapsed-width="14"
:width="340"
show-trigger="bar"
collapse-mode="transform"
content-style="padding: 12px 12px 0px 12px;margin-left: 3px;"
>
<n-tabs default-value="1" justify-content="space-evenly" type="segment">
<!-- 验证结果 -->
<n-tab-pane tab="验证结果" name="1" size="small">
<n-scrollbar trigger="none" style="max-height: 505px">
<n-collapse class="go-px-3" arrow-placement="right" :default-expanded-names="[1, 2, 3]">
<template v-for="error in [validEvents()]" :key="error">
<n-collapse-item title="错误函数" :name="1">
<n-text depth="3">{{ error.errorFn || '暂无' }}</n-text>
</n-collapse-item>
<n-collapse-item title="错误信息" :name="2">
<n-text depth="3">{{ error.name || '暂无' }}</n-text>
</n-collapse-item>
<n-collapse-item title="堆栈信息" :name="3">
<n-text depth="3">{{ error.message || '暂无' }}</n-text>
</n-collapse-item>
</template>
</n-collapse>
</n-scrollbar>
</n-tab-pane>
<!-- 辅助说明 -->
<n-tab-pane tab="变量说明" name="2">
<n-scrollbar trigger="none" style="max-height: 505px">
<n-collapse class="go-px-3" arrow-placement="right" :default-expanded-names="[1, 2]">
<n-collapse-item title="mouseEvent" :name="1">
<n-text depth="3">鼠标事件对象</n-text>
</n-collapse-item>
</n-collapse>
</n-scrollbar>
</n-tab-pane>
</n-tabs>
</n-layout-sider>
</n-layout>
<template #action>
<n-space justify="space-between">
<div class="go-flex-items-center">
<n-tag :bordered="false" type="primary">
<template #icon>
<n-icon :component="DocumentTextIcon" />
</template>
说明
</n-tag>
<n-text class="go-ml-2" depth="2">编写方式同正常 JavaScript 写法</n-text>
</div>
<n-space>
<n-button size="medium" @click="closeEvents">取消</n-button>
<n-button size="medium" type="primary" @click="saveEvents">保存</n-button>
</n-space>
</n-space>
</template>
</n-card>
</n-modal>
</template>
<script setup lang="ts">
import { ref, computed, watch, toRefs, toRaw } from 'vue'
import { MonacoEditor } from '@/components/Pages/MonacoEditor'
import { useTargetData } from '../../../hooks/useTargetData.hook'
import { CreateComponentType, BaseEvent } from '@/packages/index.d'
import { icon } from '@/plugins'
const { targetData, chartEditStore } = useTargetData()
const { DocumentTextIcon, ChevronDownIcon, PencilIcon } = icon.ionicons5
const EventTypeName = {
[BaseEvent.ON_CLICK]: '单击',
[BaseEvent.ON_DBL_CLICK]: '双击',
[BaseEvent.ON_MOUSE_ENTER]: '鼠标进入',
[BaseEvent.ON_MOUSE_LEAVE]: '鼠标移出'
}
// 受控弹窗
const showModal = ref(false)
// 编辑区域控制
const editTab = ref(BaseEvent.ON_CLICK)
// events 函数模板
let baseEvent = ref({ ...targetData.value.events.baseEvent })
// 事件错误标识
const errorFlag = ref(false)
// 验证语法
const validEvents = () => {
let errorFn = ''
let message = ''
let name = ''
errorFlag.value = Object.entries(baseEvent.value).every(([eventName, str]) => {
try {
// 支持await验证语法
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor
new AsyncFunction(str)
return true
} catch (error: any) {
message = error.message
name = error.name
errorFn = eventName
return false
}
})
return {
errorFn,
message,
name
}
}
// 关闭事件
const closeEvents = () => {
showModal.value = false
}
// 新增事件
const saveEvents = () => {
if (validEvents().errorFn) {
window['$message'].error('事件函数错误,无法进行保存')
return
}
if (Object.values(baseEvent.value).join('').trim() === '') {
// 清空事件
targetData.value.events.baseEvent = {
[BaseEvent.ON_CLICK]: undefined,
[BaseEvent.ON_DBL_CLICK]: undefined,
[BaseEvent.ON_MOUSE_ENTER]: undefined,
[BaseEvent.ON_MOUSE_LEAVE]: undefined
}
} else {
targetData.value.events.baseEvent = { ...baseEvent.value }
}
closeEvents()
}
watch(
() => showModal.value,
(newData: boolean) => {
if (newData) {
baseEvent.value = { ...targetData.value.events.baseEvent }
}
}
)
</script>
<style lang="scss" scoped>
@import '../index.scss';
</style>

View File

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

View File

@@ -0,0 +1,51 @@
/* 外层也要使用 */
.func-keyword {
color: #b478cf;
}
.func-annotate {
color: #70c0e8;
}
@include go('chart-data-monaco-editor') {
.func-keyNameWord {
color: #70c0e8;
}
.tab-tip {
font-size: 12px;
}
&.n-card.n-modal,
.n-card {
@extend .go-background-filter;
}
}
@include deep() {
.n-layout,
.n-layout-sider {
background-color: transparent;
}
.collapse-show-box {
.n-card__content {
padding-left: 20px;
padding-right: 10px;
}
}
.go-editor-area {
max-height: 530px;
}
.checkbox--hidden:checked {
& + label {
.n-icon {
transition: all 0.3s;
transform: rotate(180deg);
}
}
& ~ .go-editor-area {
display: none;
}
}
// 优化代码换行
.n-code > pre {
white-space: break-spaces;
}
}

View File

@@ -5,20 +5,15 @@
组件 id
<n-text>{{ targetData.id }}</n-text>
</n-text>
<n-collapse-item title="基础事件配置" name="1">
<div class="go-event">
<n-text depth="3">单击双击移入移出在开发中即将上线</n-text>
<br/>
<n-text depth="3">备注高级事件模块可自行实现上述功能</n-text>
</div>
</n-collapse-item>
<chart-event-monaco-editor></chart-event-monaco-editor>
<chart-event-base-handle></chart-event-base-handle>
<chart-event-advanced-handle></chart-event-advanced-handle>
</n-collapse>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { ChartEventMonacoEditor } from './components/ChartEventMonacoEditor'
import { ChartEventAdvancedHandle } from './components/ChartEventAdvancedHandle'
import { ChartEventBaseHandle } from './components/ChartEventBaseHandle'
import { useTargetData } from '../hooks/useTargetData.hook'
const { targetData } = useTargetData()

View File

@@ -38,6 +38,7 @@ export const useFile = () => {
await updateComponent(fileData, false, true)
window['$message'].success('导入成功!')
} catch (error) {
console.log(error)
window['$message'].error('组件导入失败,请检查文件完整性!')
}
},
@@ -48,6 +49,7 @@ export const useFile = () => {
await updateComponent(fileData, true, true)
window['$message'].success('导入成功!')
} catch (error) {
console.log(error)
window['$message'].error('组件导入失败,请检查文件完整性!')
}
}

View File

@@ -0,0 +1,58 @@
import { watch } from 'vue'
import { useRoute } from 'vue-router'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { useSync } from '@/views/chart/hooks/useSync.hook'
import { ChartEnum } from '@/enums/pageEnum'
import { SavePageEnum } from '@/enums/editPageEnum'
import { editToJsonInterval } from '@/settings/designSetting'
const { updateComponent } = useSync()
const chartEditStore = useChartEditStore()
// 侦听器更新
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 use = () => {
// // 1、定时同步数据
// timer = setInterval(() => {
// // 窗口激活并且处于工作台
// document.hasFocus() && syncData()
// }, editToJsonInterval)
// 2、失焦同步数据
addEventListener('blur', syncData)
// 【监听JSON代码 刷新工作台图表】
addEventListener(SavePageEnum.JSON, updateFn)
}
// 关闭侦听
const unUse = () => {
// clearInterval(timer)
removeEventListener(SavePageEnum.JSON, updateFn)
removeEventListener('blur', syncData)
}
// 路由变更时处理
const watchHandler = (toName: any, fromName: any) => {
if (fromName == ChartEnum.CHART_HOME_NAME) {
unUse()
}
if (toName == ChartEnum.CHART_HOME_NAME) {
use()
}
}
return watchHandler
}
export const useSyncUpdate = () => {
const routerParamsInfo = useRoute()
watch(() => routerParamsInfo.name, useSyncUpdateHandle(), { immediate: true })
}

View File

@@ -62,20 +62,18 @@
</template>
<script setup lang="ts">
import { ref, computed, h, watch } from 'vue'
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 { fetchPathByName, routerTurnByPath, setSessionStorage, getLocalStorage } from '@/utils'
import { editToJsonInterval } from '@/settings/designSetting'
import { EditEnum, ChartEnum } from '@/enums/pageEnum'
import { fetchRouteParamsLocation, fetchPathByName, routerTurnByPath, setSessionStorage, getLocalStorage } from '@/utils'
import { EditEnum } from '@/enums/pageEnum'
import { StorageEnum } from '@/enums/storageEnum'
import { useRoute } from 'vue-router'
import { useSync } from '@/views/chart/hooks/useSync.hook'
import { SavePageEnum } from '@/enums/editPageEnum'
import { GoSystemSet } from '@/components/GoSystemSet/index'
import { exportHandle } from './utils'
import { useFile } from './hooks/useFile.hooks'
import { useSyncUpdate } from './hooks/useSyncUpdate.hook'
import { BtnListType, TypeEnum } from './index.d'
import { icon } from '@/plugins'
@@ -83,7 +81,8 @@ const { DownloadIcon, ShareIcon, PawIcon, SettingsSharpIcon, CreateIcon } = icon
const settingStore = useSettingStore()
const chartEditStore = useChartEditStore()
const routerParamsInfo = useRoute()
const { updateComponent } = useSync()
// 初始化编辑 JSON 模块
useSyncUpdate()
// 鼠标悬停定时器
let mouseTime: any = null
@@ -138,13 +137,13 @@ const toolsMouseoutHandle = () => {
// 编辑处理
const editHandle = () => {
window['$message'].warning('将开启失焦更新与 5 秒同步更新')
window['$message'].warning('将开启失焦更新!')
// window['$message'].warning('将开启失焦更新与 5 秒同步更新!')
setTimeout(() => {
// 获取id路径
const path = fetchPathByName(EditEnum.CHART_EDIT_NAME, 'href')
if (!path) return
let { id } = routerParamsInfo.params as any
id = typeof id === 'string' ? id : id[0]
const id = fetchRouteParamsLocation()
updateToSession(id)
routerTurnByPath(path, [id], undefined, true)
}, 1000)
@@ -170,51 +169,6 @@ const updateToSession = (id: string) => {
}
}
// 侦听器更新
const useSyncUpdate = () => {
// 定义侦听器变量
let timer: any
const updateFn = (e: any) => updateComponent(e!.detail, true, false)
const syncData = () => {
if (routerParamsInfo.name == ChartEnum.CHART_HOME_NAME) {
dispatchEvent(new CustomEvent(SavePageEnum.CHART, { detail: chartEditStore.getStorageInfo }))
}
}
// 开启侦听
const use = () => {
// 1、定时同步数据
timer = setInterval(() => {
// 窗口激活并且处于工作台
document.hasFocus() && syncData()
}, editToJsonInterval)
// 2、失焦同步数据
addEventListener('blur', syncData)
// 【监听JSON代码 刷新工作台图表】
addEventListener(SavePageEnum.JSON, updateFn)
}
// 关闭侦听
const unUse = () => {
clearInterval(timer)
removeEventListener(SavePageEnum.JSON, updateFn)
removeEventListener('blur', syncData)
}
// 路由变更时处理
const watchHandler = (toName: any, fromName: any) => {
if (fromName == ChartEnum.CHART_HOME_NAME) {
unUse()
}
if (toName == ChartEnum.CHART_HOME_NAME) {
use()
}
}
return watchHandler
}
watch(() => routerParamsInfo.name, useSyncUpdate(), { immediate: true })
// 配置列表
const btnList: BtnListType[] = [
@@ -234,7 +188,7 @@ const btnList: BtnListType[] = [
{
key: 'edit',
type: TypeEnum.BUTTON,
name: '编辑JSON',
name: '编辑',
icon: CreateIcon,
handle: editHandle
},

View File

@@ -30,7 +30,7 @@
<script setup lang="ts">
import { ref, nextTick, computed } from 'vue'
import { fetchRouteParams } from '@/utils'
import { fetchRouteParamsLocation } from '@/utils'
import { icon } from '@/plugins'
const { FishIcon } = icon.ionicons5
@@ -39,9 +39,7 @@ const inputInstRef = ref(null)
// 根据路由 id 参数获取项目信息
const fetchProhectInfoById = () => {
const routeParamsRes = fetchRouteParams()
if (!routeParamsRes) return
const { id } = routeParamsRes
const id = fetchRouteParamsLocation()
if (id.length) {
return id[0]
}

View File

@@ -81,12 +81,13 @@ import { LayersGroupListItem } from './components/LayersGroupListItem/index'
import { icon } from '@/plugins'
const { LayersIcon, GridIcon, ListIcon } = icon.ionicons5
const { LaptopIcon } = icon.carbon
const chartLayoutStore = useChartLayoutStore()
const chartEditStore = useChartEditStore()
const { handleContextMenu, onClickOutSide } = useContextMenu()
const layerModeList = [
{ label: '缩略图', icon: GridIcon, value: LayerModeEnum.THUMBNAIL },
{ label: '缩略图', icon: LaptopIcon, value: LayerModeEnum.THUMBNAIL },
{ label: '文本列表', icon: ListIcon, value: LayerModeEnum.TEXT }
]

View File

@@ -3,28 +3,79 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore
import { ChartEditStoreEnum, ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d'
import { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHistoryStore'
import { fetchChartComponent, fetchConfigComponent, createComponent } from '@/packages/index'
import { CreateComponentType, CreateComponentGroupType, ConfigType } from '@/packages/index.d'
import { BaseEvent, EventLife, CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
import { PublicGroupConfigClass } from '@/packages/public/publicConfig'
import merge from 'lodash/merge'
/**
* 合并处理
* @param object 模板数据
* * 画布-版本升级对旧数据无法兼容的补丁
* @param object
*/
const canvasVersionUpdatePolyfill = (object: any) => {
return object
}
/**
* * 组件-版本升级对旧数据无法兼容的补丁
* @param newObject
* @param sources
*/
const componentVersionUpdatePolyfill = (newObject: any, sources: any) => {
try {
// 判断是否是组件
if (sources.id) {
// 处理事件补丁
const hasVnodeBeforeMount = 'vnodeBeforeMount' in sources.events
const hasVnodeMounted = 'vnodeMounted' in sources.events
if (hasVnodeBeforeMount) {
newObject.events.advancedEvents.vnodeBeforeMount = sources?.events.vnodeBeforeMount
}
if (hasVnodeMounted) {
newObject.events.advancedEvents.vnodeMounted = sources?.events.vnodeMounted
}
if (hasVnodeBeforeMount || hasVnodeMounted) {
sources.events = {
baseEvent: {
[BaseEvent.ON_CLICK]: undefined,
[BaseEvent.ON_DBL_CLICK]: undefined,
[BaseEvent.ON_MOUSE_ENTER]: undefined,
[BaseEvent.ON_MOUSE_LEAVE]: undefined
},
advancedEvents: {
[EventLife.VNODE_MOUNTED]: undefined,
[EventLife.VNODE_BEFORE_MOUNT]: undefined
}
}
}
return newObject
}
} catch (error) {
return newObject
}
}
/**
* * 合并处理
* @param newObject 新的模板数据
* @param sources 新拿到的数据
* @returns object
*/
const componentMerge = (object: any, sources: any, notComponent = false) => {
const componentMerge = (newObject: any, sources: any, notComponent = false) => {
// 处理组件补丁
componentVersionUpdatePolyfill(newObject, sources)
// 非组件不处理
if (notComponent) return merge(object, sources)
// 组件排除 options
if (notComponent) return merge(newObject, sources)
// 组件排除 newObject
const option = sources.option
if (!option) return merge(object, sources)
if (!option) return merge(newObject, sources)
// 为 undefined 的 sources 来源对象属性将被跳过详见 https://www.lodashjs.com/docs/lodash.merge
sources.option = undefined
if (option) {
return {
...merge(object, sources),
...merge(newObject, sources),
option: option
}
}
@@ -49,6 +100,9 @@ export const useSync = () => {
chartHistoryStore.clearBackStack()
chartHistoryStore.clearForwardStack()
}
// 画布补丁处理
projectData.editCanvasConfig = canvasVersionUpdatePolyfill(projectData.editCanvasConfig)
// 列表组件注册
projectData.componentList.forEach(async (e: CreateComponentType | CreateComponentGroupType) => {
const intComponent = (target: CreateComponentType) => {
@@ -119,7 +173,7 @@ export const useSync = () => {
// 分组插入到列表
chartEditStore.addComponentList(groupClass, false, true)
} else {
await create(comItem as CreateComponentType)
await create(comItem as CreateComponentType)
}
}
} else {

View File

@@ -44,14 +44,13 @@ import { icon } from '@/plugins'
const { ChevronBackOutlineIcon, DownloadIcon } = icon.ionicons5
const showOpenFilePicker: Function = (window as any).showOpenFilePicker
let content = ref('')
const content = ref('')
// 从sessionStorage 获取数据
function getDataBySession() {
const localStorageInfo: ChartEditStorageType = getSessionStorageInfo() as ChartEditStorageType
async function getDataBySession() {
const localStorageInfo: ChartEditStorageType = await getSessionStorageInfo() as unknown as ChartEditStorageType
content.value = JSON.stringify(localStorageInfo, undefined, 2)
}
getDataBySession()
setTimeout(getDataBySession)
// 返回父窗口
function back() {
@@ -86,7 +85,7 @@ document.addEventListener('keydown', function (e) {
addEventListener('blur', updateSync)
// 同步更新
function updateSync() {
async function updateSync() {
if (!window.opener) {
return window['$message'].error('源窗口已关闭,视图同步失败')
}

View File

@@ -14,6 +14,7 @@
>
<component
:is="item.chartConfig.chartKey"
:id="item.id"
:chartConfig="item"
:themeSetting="themeSetting"
:themeColor="themeColor"
@@ -29,6 +30,7 @@ import { CreateComponentGroupType } from '@/packages/index.d'
import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle } from '@/utils'
import { getSizeStyle, getComponentAttrStyle, getStatusStyle } from '../../utils'
import { useLifeHandler } from '@/hooks'
const props = defineProps({
groupData: {
type: Object as PropType<CreateComponentGroupType>,

View File

@@ -10,7 +10,7 @@
...getTransformStyle(item.styles),
...getStatusStyle(item.status),
...getBlendModeStyle(item.styles) as any
} as any"
}"
>
<!-- 分组 -->
<preview-render-group
@@ -25,6 +25,7 @@
<component
v-else
:is="item.chartConfig.chartKey"
:id="item.id"
:chartConfig="item"
:themeSetting="themeSetting"
:themeColor="themeColor"
@@ -35,7 +36,8 @@
</template>
<script setup lang="ts">
import { PropType, computed } from 'vue'
import { PropType, computed, onMounted } from 'vue'
import { useChartDataPondFetch } from '@/hooks'
import { ChartEditStorageType } from '../../index.d'
import { PreviewRenderGroup } from '../PreviewRenderGroup/index'
import { CreateComponentGroupType } from '@/packages/index.d'
@@ -43,6 +45,10 @@ import { chartColors } from '@/settings/chartThemes/index'
import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle } from '@/utils'
import { getSizeStyle, getComponentAttrStyle, getStatusStyle } from '../../utils'
import { useLifeHandler } from '@/hooks'
// 初始化数据池
const { initDataPond } = useChartDataPondFetch()
const props = defineProps({
localStorageInfo: {
type: Object as PropType<ChartEditStorageType>,
@@ -61,6 +67,11 @@ const themeColor = computed(() => {
const chartThemeColor = props.localStorageInfo.editCanvasConfig.chartThemeColor
return chartColors[chartThemeColor]
})
// 组件渲染结束初始化数据池
onMounted(() => {
initDataPond(props.localStorageInfo.requestGlobalConfig)
})
</script>
<style lang="scss" scoped>

View File

@@ -12,12 +12,12 @@ import { ref } from 'vue'
import Preview from './index.vue'
let key = ref(Date.now())
let localStorageInfo: ChartEditStorageType = getSessionStorageInfo() as ChartEditStorageType
// 数据变更 -> 同步sessionStorage -> reload页面 重新执行Mounted
// 数据变更 -> 组件销毁重建
;[SavePageEnum.JSON, SavePageEnum.CHART].forEach((saveEvent: string) => {
if (!window.opener) return
window.opener.addEventListener(saveEvent, (e: any) => {
window.opener.addEventListener(saveEvent, async (e: any) => {
const localStorageInfo: ChartEditStorageType = await getSessionStorageInfo() as unknown as ChartEditStorageType
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, [{ ...e.detail, id: localStorageInfo.id }])
key.value = Date.now()
})