Compare commits
141 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
766a3a8ede | ||
|
|
f3ec85050e | ||
|
|
ba54d934a2 | ||
|
|
d6ecad6467 | ||
|
|
74cab1e9af | ||
|
|
a823851541 | ||
|
|
618d1d77cb | ||
|
|
17c48608ec | ||
|
|
6d5dfbced0 | ||
|
|
c773bd8010 | ||
|
|
5746da73dd | ||
|
|
60bbfd9c92 | ||
|
|
12d92f3aa4 | ||
|
|
2edb1caf18 | ||
|
|
75067221da | ||
|
|
3358e164a1 | ||
|
|
94cde3f517 | ||
|
|
a2c8827a35 | ||
|
|
172a3163aa | ||
|
|
4d189e954c | ||
|
|
8a1f3ac2ef | ||
|
|
68dbf3e9ef | ||
|
|
0aece46d91 | ||
|
|
094c7ed392 | ||
|
|
c48517a89b | ||
|
|
68c68e96b1 | ||
|
|
36b1f37f3f | ||
|
|
51e5c756a7 | ||
|
|
8df951992e | ||
|
|
1a00993ee8 | ||
|
|
cb7e887c36 | ||
|
|
255b14a597 | ||
|
|
3f462c1bee | ||
|
|
cacc99683d | ||
|
|
d3a9f7d60f | ||
|
|
8d4dd3160d | ||
|
|
6847f7d966 | ||
|
|
35204898fc | ||
|
|
7fe743d624 | ||
|
|
6a285f610c | ||
|
|
a4c0450f7a | ||
|
|
a81f016e3f | ||
|
|
ee5fed4cd0 | ||
|
|
3fb0fe43bb | ||
|
|
f1f5f9cca9 | ||
|
|
2ce17c3974 | ||
|
|
1d7e40950f | ||
|
|
91bda457e7 | ||
|
|
68aeea70cf | ||
|
|
7a19346700 | ||
|
|
8d2269df78 | ||
|
|
b133cbdfea | ||
|
|
f45d4ca5af | ||
|
|
d96e7f71d7 | ||
|
|
24fee76237 | ||
|
|
d59193bc33 | ||
|
|
6928a70d9f | ||
|
|
e0796280f5 | ||
|
|
5d803e3fa6 | ||
|
|
749c0a2f39 | ||
|
|
737504cef5 | ||
|
|
8115950893 | ||
|
|
f458a21a2f | ||
|
|
13a9675894 | ||
|
|
77b5a41af9 | ||
|
|
2bf895ad3d | ||
|
|
6a5abd6762 | ||
|
|
5cb458c45b | ||
|
|
f828c48ab6 | ||
|
|
2626bc794f | ||
|
|
734dd68607 | ||
|
|
19f53f705c | ||
|
|
b93caf1386 | ||
|
|
aa613e2805 | ||
|
|
616584fc19 | ||
|
|
a5e83bfe9f | ||
|
|
1252d266dd | ||
|
|
3c820d53a6 | ||
|
|
f0525c7522 | ||
|
|
600f1b2dd2 | ||
|
|
757b79514a | ||
|
|
cf8121eb00 | ||
|
|
faf2d44fbb | ||
|
|
88516d9491 | ||
|
|
88dbbe03ea | ||
|
|
ae1fd2e7cf | ||
|
|
d3931f47bc | ||
|
|
bf9bd59b63 | ||
|
|
fb0ff50837 | ||
|
|
93727a0ac7 | ||
|
|
2641e70c78 | ||
|
|
bc44584698 | ||
|
|
82394dd7a3 | ||
|
|
2e688ad686 | ||
|
|
9b998e0c6d | ||
|
|
1045588301 | ||
|
|
ba86399fd3 | ||
|
|
a89164f885 | ||
|
|
7f2344c82c | ||
|
|
3c8e430533 | ||
|
|
f7209fba53 | ||
|
|
9fae683d8b | ||
|
|
79a2b98a1a | ||
|
|
98b28a631a | ||
|
|
6fec64f515 | ||
|
|
01d5890b35 | ||
|
|
fea583eb5b | ||
|
|
bfe5039a1c | ||
|
|
7a57d944c8 | ||
|
|
ca27e87241 | ||
|
|
e674a1ece4 | ||
|
|
dfb63346d3 | ||
|
|
4d899d48dc | ||
|
|
fa3a3dfcb0 | ||
|
|
e36210aa27 | ||
|
|
20a599594c | ||
|
|
70f8dbae53 | ||
|
|
d8022b2682 | ||
|
|
0d7c5b8ace | ||
|
|
88c9850c44 | ||
|
|
f1ed62cdca | ||
|
|
bfac86d5dd | ||
|
|
341015c584 | ||
|
|
7c5a66978e | ||
|
|
b21fc3f5e7 | ||
|
|
0e52628842 | ||
|
|
f7922cafa5 | ||
|
|
8c5496829e | ||
|
|
8514f051a7 | ||
|
|
61feb29fe2 | ||
|
|
fa29881f04 | ||
|
|
46cb8e7d0b | ||
|
|
b6143bc75e | ||
|
|
92e1ec05d2 | ||
|
|
75f23bb1bf | ||
|
|
5f5731f813 | ||
|
|
55159be0dc | ||
|
|
0c4e1dc7ae | ||
|
|
b4abdeb246 | ||
|
|
7e61dda4aa | ||
|
|
283aafb27d |
12
.env
@@ -1,14 +1,8 @@
|
||||
# port
|
||||
VITE_DEV_PORT = '8001'
|
||||
VITE_DEV_PORT = '8080'
|
||||
|
||||
# development path
|
||||
VITE_DEV_PATH = '/'
|
||||
VITE_DEV_PATH = 'http://1.117.240.165:8080'
|
||||
|
||||
# production path
|
||||
VITE_PRO_PATH = '/'
|
||||
|
||||
# spa-title
|
||||
VITE_GLOB_APP_TITLE = GoView
|
||||
|
||||
# spa shortname
|
||||
VITE_GLOB_APP_SHORT_NAME = GoView
|
||||
VITE_PRO_PATH = 'http://1.117.240.165:8080'
|
||||
@@ -1,51 +0,0 @@
|
||||
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:
|
||||
- .*
|
||||
@@ -1,49 +0,0 @@
|
||||
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
|
||||
@@ -1,36 +0,0 @@
|
||||
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
|
||||
195
README.md
@@ -2,21 +2,17 @@
|
||||
|
||||

|
||||
|
||||
GoView 是一个高效的拖拽式低代码数据可视化开发平台,将图表或页面元素封装为基础组件,无需编写代码即可制作数据大屏,减少心智负担。
|
||||
**`master-fetch` 分支是带有后端接口请求的分支**
|
||||
|
||||
### 😶 纯 **前端** 分支: **`master`**
|
||||
**后端项目地址:[https://gitee.com/MTrun/go-view-serve](https://gitee.com/MTrun/go-view-serve)**
|
||||
|
||||
### 👻 携带 **后端** 请求分支: **`master-fetch`**
|
||||
**接口说明地址:[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)**
|
||||
|
||||
### 📚 GoView **文档** 地址:[http://www.mtruning.club:81/](http://www.mtruning.club:81/)
|
||||
## 使用
|
||||
|
||||
项目纯前端-Demo 地址:[https://www.mtruning.club](https://www.mtruning.club)
|
||||
所有的接口地址位置:`src\api\path\*`
|
||||
|
||||
项目带后端-Demo 地址:[后端 Demo 地址](http://1.117.240.165:8080/goview/#/login)
|
||||
|
||||
文档-在线地址:[http://www.mtruning.club:81/](http://www.mtruning.club:81/)
|
||||
|
||||
文档-源码地址:[https://gitee.com/MTrun/go-view-doc](https://gitee.com/MTrun/go-view-doc)
|
||||
接口地址修改:`.env`
|
||||
|
||||
### 🤯 后端项目
|
||||
|
||||
@@ -24,124 +20,103 @@ GoView 是一个高效的拖拽式低代码数据可视化开发平台,将图
|
||||
|
||||
接口说明地址:[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)
|
||||
|
||||
技术点:
|
||||
|
||||
- 框架:基于 `Vue3` 框架编写,使用 `hooks` 写法抽离部分逻辑,使代码结构更加清晰;
|
||||
|
||||
- 类型:使用 `TypeScript` 进行类型约束,减少未知错误发生概率,可以大胆修改逻辑内容;
|
||||
|
||||
- 性能:多处性能优化,使用页面懒加载、组件动态注册、数据滚动加载等方式,提升页面渲染速度;
|
||||
|
||||
- 存储:拥有本地记忆,部分配置项采用 `storage` 存储本地,提升使用体验;
|
||||
|
||||
- 封装:项目进行了详细的工具类封装如:路由、存储、加/解密、文件处理、主题、NaiveUI 全局方法、组件等
|
||||
|
||||
工作台:
|
||||

|
||||
|
||||
请求配置:
|
||||

|
||||
|
||||
数据过滤:
|
||||

|
||||
|
||||
主题色:
|
||||

|
||||
|
||||
主要技术栈为:
|
||||
|
||||
| 名称 | 版本 | 名称 | 版本 |
|
||||
| ------------------- | ----- | ----------- | ------ |
|
||||
| Vue | 3.2.x | TypeScript4 | 4.6.x |
|
||||
| Vite | 2.9.x | NaiveUI | 2.27.x |
|
||||
| ECharts | 5.3.x | Pinia | 2.0.x |
|
||||
| 详见 `package.json` | 😁 | 🥰 | 🤗 |
|
||||
|
||||
开发环境:
|
||||
|
||||
| 名称 | 版本 | 名称 | 版本 |
|
||||
| ---- | ------- | ------- | ----- |
|
||||
| node | 16.14.x | npm | 8.5.x |
|
||||
| pnpm | 7.1.x | windows | 11 |
|
||||
|
||||
已完成图表:
|
||||
|
||||
| 分类 | 名称 | 名称 | 名称 | 名称 |
|
||||
| ------ | ---------------- | ---------- | -------------- | ------------------------ |
|
||||
| 图表 | 柱状图 | 横向柱状图 | 折线图 | 单/多 折线面积图(渐变色) |
|
||||
| \* | 饼图 | 环形图 | 水球图 | 雷达图 |
|
||||
| \* | NaiveUI 多种进度 | 散点图 | 对数回归散点图 | 热力图 |
|
||||
| \* | 漏斗图 | 中国地图 | 🤪 | 🤖 |
|
||||
| 信息 | 文字 | 渐变文字 | 图片 | 😶 |
|
||||
| 列表 | 滚动排名列表 | 滚动表格 | 🤓 | 👻 |
|
||||
| 小组件 | 边框-01~13 | 装饰-01~05 | 数字翻牌 | 通用时间 |
|
||||
|
||||
## 浏览器支持
|
||||
|
||||
开发和测试平台均在 `Google` 和最新版 `EDGE` 上完成,暂未测试 `IE11` 等其它浏览器,如有需求请自行测试与兼容。
|
||||
|
||||
## 安装
|
||||
|
||||
本项目采用` pnpm` 进行包管理
|
||||
|
||||
```shell
|
||||
#建议使用 nrm 切换到淘宝源 https://registry.npmmirror.com/
|
||||
#pnpm
|
||||
pnpm install
|
||||
# port
|
||||
VITE_DEV_PORT = '8080'
|
||||
|
||||
#yarn
|
||||
yarn install
|
||||
# development path
|
||||
VITE_DEV_PATH = 'http://127.0.0.1:8080'
|
||||
|
||||
#npm
|
||||
npm install
|
||||
# production path
|
||||
VITE_PRO_PATH = 'http://127.0.0.1:8080'
|
||||
```
|
||||
|
||||
## 启动
|
||||
公共前缀修改:`src\settings\httpSetting.ts`
|
||||
|
||||
```shell
|
||||
#pnpm
|
||||
pnpm dev
|
||||
|
||||
# npm
|
||||
npm run dev
|
||||
|
||||
#yarn
|
||||
yarn dev
|
||||
|
||||
#Makefile
|
||||
make dev
|
||||
// 请求前缀
|
||||
export const axiosPre = '/api/goview'
|
||||
```
|
||||
|
||||
## 编译
|
||||
接口封装:`src\api\http.ts`
|
||||
|
||||
```shell
|
||||
#pnpm
|
||||
pnpm run build
|
||||
```ts
|
||||
import axiosInstance from './axios'
|
||||
import { RequestHttpEnum, ContentTypeEnum } from '@/enums/httpEnum'
|
||||
|
||||
# npm
|
||||
npm run build
|
||||
export const get = (url: string, params?: object) => {
|
||||
return axiosInstance({
|
||||
url: url,
|
||||
method: RequestHttpEnum.GET,
|
||||
params: params,
|
||||
})
|
||||
}
|
||||
|
||||
#yarn
|
||||
yarn run build
|
||||
export const post = (url: string, data?: object, headersType?: string) => {
|
||||
return axiosInstance({
|
||||
url: url,
|
||||
method: RequestHttpEnum.POST,
|
||||
data: data,
|
||||
headers: {
|
||||
'Content-Type': headersType || ContentTypeEnum.JSON
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#Makefile
|
||||
make dist
|
||||
export const put = (url: string, data?: object, headersType?: string) => {
|
||||
return axiosInstance({
|
||||
url: url,
|
||||
method: RequestHttpEnum.PUT,
|
||||
data: data,
|
||||
headers: {
|
||||
'Content-Type': headersType || ContentTypeEnum.JSON
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const del = (url: string, params?: object) => {
|
||||
return axiosInstance({
|
||||
url: url,
|
||||
method: RequestHttpEnum.DELETE,
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
// 获取请求函数,默认get
|
||||
export const http = (type?: RequestHttpEnum) => {
|
||||
switch (type) {
|
||||
case RequestHttpEnum.GET:
|
||||
return get
|
||||
|
||||
case RequestHttpEnum.POST:
|
||||
return post
|
||||
|
||||
case RequestHttpEnum.PUT:
|
||||
return put
|
||||
|
||||
case RequestHttpEnum.DELETE:
|
||||
return del
|
||||
|
||||
default:
|
||||
return get
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## 代码提交
|
||||
|
||||
- feat: 新功能
|
||||
- fix: 修复 Bug
|
||||
- docs: 文档修改
|
||||
- perf: 性能优化
|
||||
- revert: 版本回退
|
||||
- ci: CICD 集成相关
|
||||
- test: 添加测试代码
|
||||
- refactor: 代码重构
|
||||
- build: 影响项目构建或依赖修改
|
||||
- style: 不影响程序逻辑的代码修改
|
||||
- chore: 不属于以上类型的其他类型(日常事务)
|
||||
* feat: 新功能
|
||||
* fix: 修复 Bug
|
||||
* docs: 文档修改
|
||||
* perf: 性能优化
|
||||
* revert: 版本回退
|
||||
* ci: CICD集成相关
|
||||
* test: 添加测试代码
|
||||
* refactor: 代码重构
|
||||
* build: 影响项目构建或依赖修改
|
||||
* style: 不影响程序逻辑的代码修改
|
||||
* chore: 不属于以上类型的其他类型(日常事务)
|
||||
|
||||
## 交流
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
/**
|
||||
* Get the configuration file variable name
|
||||
* @param env
|
||||
*/
|
||||
export const getConfigFileName = (env: Record<string, any>) => {
|
||||
return `__PRODUCTION__${env.VITE_GLOB_APP_SHORT_NAME || '__APP'}__CONF__`
|
||||
.toUpperCase()
|
||||
.replace(/\s/g, '');
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "go-view",
|
||||
"version": "1.1.3",
|
||||
"version": "2.0.91",
|
||||
"scripts": {
|
||||
"dev": "vite --host",
|
||||
"build": "vue-tsc --noEmit && vite build",
|
||||
@@ -22,7 +22,6 @@
|
||||
"echarts-liquidfill": "^3.1.0",
|
||||
"echarts-stat": "^1.2.0",
|
||||
"echarts-wordcloud": "^2.0.0",
|
||||
"gsap": "^3.11.3",
|
||||
"highlight.js": "^11.5.0",
|
||||
"html2canvas": "^1.4.1",
|
||||
"keymaster": "^1.6.2",
|
||||
@@ -30,10 +29,9 @@
|
||||
"naive-ui": "2.33.4",
|
||||
"pinia": "^2.0.13",
|
||||
"screenfull": "^6.0.1",
|
||||
"three": "^0.145.0",
|
||||
"vue": "^3.2.31",
|
||||
"vue-demi": "^0.13.1",
|
||||
"vue-i18n": "9.1.9",
|
||||
"vue-i18n": "9.1.10",
|
||||
"vue-router": "4.0.12",
|
||||
"vue3-lazyload": "^0.2.5-beta",
|
||||
"vue3-sketch-ruler": "^1.3.3",
|
||||
@@ -43,7 +41,6 @@
|
||||
"@commitlint/cli": "^17.0.2",
|
||||
"@commitlint/config-conventional": "^17.0.2",
|
||||
"@types/node": "^16.11.26",
|
||||
"@types/three": "^0.144.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.18.0",
|
||||
"@typescript-eslint/parser": "^5.18.0",
|
||||
"@vicons/carbon": "^0.12.0",
|
||||
|
||||
102
pnpm-lock.yaml
generated
@@ -8,7 +8,6 @@ specifiers:
|
||||
'@types/keymaster': ^1.6.30
|
||||
'@types/lodash': ^4.14.184
|
||||
'@types/node': ^16.11.26
|
||||
'@types/three': ^0.144.0
|
||||
'@typescript-eslint/eslint-plugin': ^5.18.0
|
||||
'@typescript-eslint/parser': ^5.18.0
|
||||
'@vicons/carbon': ^0.12.0
|
||||
@@ -32,7 +31,6 @@ specifiers:
|
||||
eslint-plugin-import: ^2.26.0
|
||||
eslint-plugin-prettier: ^4.0.0
|
||||
eslint-plugin-vue: ^8.5.0
|
||||
gsap: ^3.11.3
|
||||
highlight.js: ^11.5.0
|
||||
html2canvas: ^1.4.1
|
||||
husky: ^8.0.1
|
||||
@@ -47,7 +45,6 @@ specifiers:
|
||||
sass: ^1.49.11
|
||||
sass-loader: ^12.6.0
|
||||
screenfull: ^6.0.1
|
||||
three: ^0.145.0
|
||||
typescript: 4.6.3
|
||||
vite: 2.9.9
|
||||
vite-plugin-compression: ^0.5.1
|
||||
@@ -57,7 +54,7 @@ specifiers:
|
||||
vue: ^3.2.31
|
||||
vue-demi: ^0.13.1
|
||||
vue-echarts: ^6.0.2
|
||||
vue-i18n: 9.1.9
|
||||
vue-i18n: 9.1.10
|
||||
vue-router: 4.0.12
|
||||
vue-tsc: ^0.28.10
|
||||
vue3-lazyload: ^0.2.5-beta
|
||||
@@ -76,7 +73,6 @@ dependencies:
|
||||
echarts-liquidfill: 3.1.0_echarts@5.3.3
|
||||
echarts-stat: 1.2.0
|
||||
echarts-wordcloud: 2.0.0_echarts@5.3.3
|
||||
gsap: 3.11.3
|
||||
highlight.js: 11.5.1
|
||||
html2canvas: 1.4.1
|
||||
keymaster: 1.6.2
|
||||
@@ -84,10 +80,9 @@ dependencies:
|
||||
naive-ui: 2.33.4_vue@3.2.37
|
||||
pinia: 2.0.14_ub5l46u3nefphax5x2tezui4oq
|
||||
screenfull: 6.0.1
|
||||
three: 0.145.0
|
||||
vue: 3.2.37
|
||||
vue-demi: 0.13.1_vue@3.2.37
|
||||
vue-i18n: 9.1.9_vue@3.2.37
|
||||
vue-i18n: 9.1.10_vue@3.2.37
|
||||
vue-router: 4.0.12_vue@3.2.37
|
||||
vue3-lazyload: 0.2.5-beta_2yymnzrok6eda47acnj2yjm3ae
|
||||
vue3-sketch-ruler: 1.3.4_vue@3.2.37
|
||||
@@ -97,7 +92,6 @@ devDependencies:
|
||||
'@commitlint/cli': 17.0.2
|
||||
'@commitlint/config-conventional': 17.0.2
|
||||
'@types/node': 16.11.40
|
||||
'@types/three': 0.144.0
|
||||
'@typescript-eslint/eslint-plugin': 5.28.0_evi7yu7wunhzwb24olrfvzynny
|
||||
'@typescript-eslint/parser': 5.28.0_sfmgizikprcxt7r54j7cnzjamu
|
||||
'@vicons/carbon': 0.12.0
|
||||
@@ -659,60 +653,60 @@ packages:
|
||||
resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==}
|
||||
dev: true
|
||||
|
||||
/@intlify/core-base/9.1.9:
|
||||
resolution: {integrity: sha512-x5T0p/Ja0S8hs5xs+ImKyYckVkL4CzcEXykVYYV6rcbXxJTe2o58IquSqX9bdncVKbRZP7GlBU1EcRaQEEJ+vw==}
|
||||
/@intlify/core-base/9.1.10:
|
||||
resolution: {integrity: sha512-So9CNUavB/IsZ+zBmk2Cv6McQp6vc2wbGi1S0XQmJ8Vz+UFcNn9MFXAe9gY67PreIHrbLsLxDD0cwo1qsxM1Nw==}
|
||||
engines: {node: '>= 10'}
|
||||
dependencies:
|
||||
'@intlify/devtools-if': 9.1.9
|
||||
'@intlify/message-compiler': 9.1.9
|
||||
'@intlify/message-resolver': 9.1.9
|
||||
'@intlify/runtime': 9.1.9
|
||||
'@intlify/shared': 9.1.9
|
||||
'@intlify/vue-devtools': 9.1.9
|
||||
'@intlify/devtools-if': 9.1.10
|
||||
'@intlify/message-compiler': 9.1.10
|
||||
'@intlify/message-resolver': 9.1.10
|
||||
'@intlify/runtime': 9.1.10
|
||||
'@intlify/shared': 9.1.10
|
||||
'@intlify/vue-devtools': 9.1.10
|
||||
dev: false
|
||||
|
||||
/@intlify/devtools-if/9.1.9:
|
||||
resolution: {integrity: sha512-oKSMKjttG3Ut/1UGEZjSdghuP3fwA15zpDPcjkf/1FjlOIm6uIBGMNS5jXzsZy593u+P/YcnrZD6cD3IVFz9vQ==}
|
||||
/@intlify/devtools-if/9.1.10:
|
||||
resolution: {integrity: sha512-SHaKoYu6sog3+Q8js1y3oXLywuogbH1sKuc7NSYkN3GElvXSBaMoCzW+we0ZSFqj/6c7vTNLg9nQ6rxhKqYwnQ==}
|
||||
engines: {node: '>= 10'}
|
||||
dependencies:
|
||||
'@intlify/shared': 9.1.9
|
||||
'@intlify/shared': 9.1.10
|
||||
dev: false
|
||||
|
||||
/@intlify/message-compiler/9.1.9:
|
||||
resolution: {integrity: sha512-6YgCMF46Xd0IH2hMRLCssZI3gFG4aywidoWQ3QP4RGYQXQYYfFC54DxhSgfIPpVoPLQ+4AD29eoYmhiHZ+qLFQ==}
|
||||
/@intlify/message-compiler/9.1.10:
|
||||
resolution: {integrity: sha512-+JiJpXff/XTb0EadYwdxOyRTB0hXNd4n1HaJ/a4yuV960uRmPXaklJsedW0LNdcptd/hYUZtCkI7Lc9J5C1gxg==}
|
||||
engines: {node: '>= 10'}
|
||||
dependencies:
|
||||
'@intlify/message-resolver': 9.1.9
|
||||
'@intlify/shared': 9.1.9
|
||||
'@intlify/message-resolver': 9.1.10
|
||||
'@intlify/shared': 9.1.10
|
||||
source-map: 0.6.1
|
||||
dev: false
|
||||
|
||||
/@intlify/message-resolver/9.1.9:
|
||||
resolution: {integrity: sha512-Lx/DBpigeK0sz2BBbzv5mu9/dAlt98HxwbG7xLawC3O2xMF9MNWU5FtOziwYG6TDIjNq0O/3ZbOJAxwITIWXEA==}
|
||||
/@intlify/message-resolver/9.1.10:
|
||||
resolution: {integrity: sha512-5YixMG/M05m0cn9+gOzd4EZQTFRUu8RGhzxJbR1DWN21x/Z3bJ8QpDYj6hC4FwBj5uKsRfKpJQ3Xqg98KWoA+w==}
|
||||
engines: {node: '>= 10'}
|
||||
dev: false
|
||||
|
||||
/@intlify/runtime/9.1.9:
|
||||
resolution: {integrity: sha512-XgPw8+UlHCiie3fI41HPVa/VDJb3/aSH7bLhY1hJvlvNV713PFtb4p4Jo+rlE0gAoMsMCGcsiT982fImolSltg==}
|
||||
/@intlify/runtime/9.1.10:
|
||||
resolution: {integrity: sha512-7QsuByNzpe3Gfmhwq6hzgXcMPpxz8Zxb/XFI6s9lQdPLPe5Lgw4U1ovRPZTOs6Y2hwitR3j/HD8BJNGWpJnOFA==}
|
||||
engines: {node: '>= 10'}
|
||||
dependencies:
|
||||
'@intlify/message-compiler': 9.1.9
|
||||
'@intlify/message-resolver': 9.1.9
|
||||
'@intlify/shared': 9.1.9
|
||||
'@intlify/message-compiler': 9.1.10
|
||||
'@intlify/message-resolver': 9.1.10
|
||||
'@intlify/shared': 9.1.10
|
||||
dev: false
|
||||
|
||||
/@intlify/shared/9.1.9:
|
||||
resolution: {integrity: sha512-xKGM1d0EAxdDFCWedcYXOm6V5Pfw/TMudd6/qCdEb4tv0hk9EKeg7lwQF1azE0dP2phvx0yXxrt7UQK+IZjNdw==}
|
||||
/@intlify/shared/9.1.10:
|
||||
resolution: {integrity: sha512-Om54xJeo1Vw+K1+wHYyXngE8cAbrxZHpWjYzMR9wCkqbhGtRV5VLhVc214Ze2YatPrWlS2WSMOWXR8JktX/IgA==}
|
||||
engines: {node: '>= 10'}
|
||||
dev: false
|
||||
|
||||
/@intlify/vue-devtools/9.1.9:
|
||||
resolution: {integrity: sha512-YPehH9uL4vZcGXky4Ev5qQIITnHKIvsD2GKGXgqf+05osMUI6WSEQHaN9USRa318Rs8RyyPCiDfmA0hRu3k7og==}
|
||||
/@intlify/vue-devtools/9.1.10:
|
||||
resolution: {integrity: sha512-5l3qYARVbkWAkagLu1XbDUWRJSL8br1Dj60wgMaKB0+HswVsrR6LloYZTg7ozyvM621V6+zsmwzbQxbVQyrytQ==}
|
||||
engines: {node: '>= 10'}
|
||||
dependencies:
|
||||
'@intlify/message-resolver': 9.1.9
|
||||
'@intlify/runtime': 9.1.9
|
||||
'@intlify/shared': 9.1.9
|
||||
'@intlify/message-resolver': 9.1.10
|
||||
'@intlify/runtime': 9.1.10
|
||||
'@intlify/shared': 9.1.10
|
||||
dev: false
|
||||
|
||||
/@jridgewell/gen-mapping/0.1.1:
|
||||
@@ -911,7 +905,7 @@ packages:
|
||||
dev: true
|
||||
|
||||
/@types/node/17.0.43:
|
||||
resolution: {integrity: sha512-jnUpgw8fL9kP2iszfIDyBQtw5Mf4/XSqy0Loc1J9pI14ejL83XcCEvSf50Gs/4ET0I9VCCDoOfufQysj0S66xA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npm.taobao.org/@types/node/-/node-17.0.43.tgz}
|
||||
resolution: {integrity: sha512-jnUpgw8fL9kP2iszfIDyBQtw5Mf4/XSqy0Loc1J9pI14ejL83XcCEvSf50Gs/4ET0I9VCCDoOfufQysj0S66xA==, registry: https://registry.npm.taobao.org/}
|
||||
|
||||
/@types/normalize-package-data/2.4.1:
|
||||
resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==}
|
||||
@@ -927,22 +921,12 @@ packages:
|
||||
'@types/node': 17.0.43
|
||||
dev: true
|
||||
|
||||
/@types/three/0.144.0:
|
||||
resolution: {integrity: sha512-psvEs6q5rLN50jUYZ3D4pZMfxTbdt3A243blt0my7/NcL6chaCZpHe2csbCtx0SOD9fI/XnF3wnVUAYZGqCSYg==}
|
||||
dependencies:
|
||||
'@types/webxr': 0.5.0
|
||||
dev: true
|
||||
|
||||
/@types/through/0.0.30:
|
||||
resolution: {integrity: sha512-FvnCJljyxhPM3gkRgWmxmDZyAQSiBQQWLI0A0VFL0K7W1oRUrPJSqNO0NvTnLkBcotdlp3lKvaT0JrnyRDkzOg==}
|
||||
dependencies:
|
||||
'@types/node': 17.0.43
|
||||
dev: true
|
||||
|
||||
/@types/webxr/0.5.0:
|
||||
resolution: {integrity: sha512-IUMDPSXnYIbEO2IereEFcgcqfDREOgmbGqtrMpVPpACTU6pltYLwHgVkrnYv0XhWEcjio9sYEfIEzgn3c7nDqA==}
|
||||
dev: true
|
||||
|
||||
/@typescript-eslint/eslint-plugin/5.28.0_evi7yu7wunhzwb24olrfvzynny:
|
||||
resolution: {integrity: sha512-DXVU6Cg29H2M6EybqSg2A+x8DgO9TCUBRp4QEXQHJceLS7ogVDP0g3Lkg/SZCqcvkAP/RruuQqK0gdlkgmhSUA==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
@@ -1900,7 +1884,7 @@ packages:
|
||||
dev: true
|
||||
|
||||
/csstype/2.6.20:
|
||||
resolution: {integrity: sha512-/WwNkdXfckNgw6S5R125rrW8ez139lBHWouiBvX8dfMFtcn6V81REDqnH7+CRpRipfYlyU1CmOnOxrmGcFOjeA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npm.taobao.org/csstype/-/csstype-2.6.20.tgz}
|
||||
resolution: {integrity: sha512-/WwNkdXfckNgw6S5R125rrW8ez139lBHWouiBvX8dfMFtcn6V81REDqnH7+CRpRipfYlyU1CmOnOxrmGcFOjeA==, registry: https://registry.npm.taobao.org/}
|
||||
dev: false
|
||||
|
||||
/csstype/3.0.11:
|
||||
@@ -2107,7 +2091,7 @@ packages:
|
||||
dev: false
|
||||
|
||||
/echarts-wordcloud/2.0.0_echarts@5.3.3:
|
||||
resolution: {integrity: sha512-K7l6pTklqdW7ZWzT/1CS0KhBSINr/cd7c5N1fVMzZMwLQHEwT7x+nivK7g5hkVh7WNcAv4Dn6/ZS5zMKRozC1g==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npm.taobao.org/echarts-wordcloud/-/echarts-wordcloud-2.0.0.tgz}
|
||||
resolution: {integrity: sha512-K7l6pTklqdW7ZWzT/1CS0KhBSINr/cd7c5N1fVMzZMwLQHEwT7x+nivK7g5hkVh7WNcAv4Dn6/ZS5zMKRozC1g==, registry: https://registry.npm.taobao.org/}
|
||||
peerDependencies:
|
||||
echarts: ^5.0.1
|
||||
dependencies:
|
||||
@@ -3048,10 +3032,6 @@ packages:
|
||||
resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==}
|
||||
dev: true
|
||||
|
||||
/gsap/3.11.3:
|
||||
resolution: {integrity: sha512-xc/iIJy+LWiMbRa4IdMtdnnKa/7PXEK6NNzV71gdOYUVeTZN7UWnLU0fB7Hi1iwiz4ZZoYkBZPPYGg+2+zzFHA==}
|
||||
dev: false
|
||||
|
||||
/handlebars/4.7.7:
|
||||
resolution: {integrity: sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==}
|
||||
engines: {node: '>=0.4.7'}
|
||||
@@ -4845,10 +4825,6 @@ packages:
|
||||
resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==}
|
||||
dev: true
|
||||
|
||||
/three/0.145.0:
|
||||
resolution: {integrity: sha512-EKoHQEtEJ4CB6b2BGMBgLZrfwLjXcSUfoI/MiIXUuRpeYsfK5aPWbYhdtIVWOH+x6X0TouldHKHBuc/LAiFzAw==}
|
||||
dev: false
|
||||
|
||||
/through/2.3.8:
|
||||
resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==}
|
||||
dev: true
|
||||
@@ -5373,15 +5349,15 @@ packages:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/vue-i18n/9.1.9_vue@3.2.37:
|
||||
resolution: {integrity: sha512-JeRdNVxS2OGp1E+pye5XB6+M6BBkHwAv9C80Q7+kzoMdUDGRna06tjC0vCB/jDX9aWrl5swxOMFcyAr7or8XTA==}
|
||||
/vue-i18n/9.1.10_vue@3.2.37:
|
||||
resolution: {integrity: sha512-jpr7gV5KPk4n+sSPdpZT8Qx3XzTcNDWffRlHV/cT2NUyEf+sEgTTmLvnBAibjOFJ0zsUyZlVTAWH5DDnYep+1g==}
|
||||
engines: {node: '>= 10'}
|
||||
peerDependencies:
|
||||
vue: ^3.0.0
|
||||
dependencies:
|
||||
'@intlify/core-base': 9.1.9
|
||||
'@intlify/shared': 9.1.9
|
||||
'@intlify/vue-devtools': 9.1.9
|
||||
'@intlify/core-base': 9.1.10
|
||||
'@intlify/shared': 9.1.10
|
||||
'@intlify/vue-devtools': 9.1.10
|
||||
'@vue/devtools-api': 6.1.4
|
||||
vue: 3.2.37
|
||||
dev: false
|
||||
|
||||
@@ -18,7 +18,7 @@ import { zhCN, dateZhCN, NConfigProvider } from 'naive-ui'
|
||||
import { GoAppProvider } from '@/components/GoAppProvider'
|
||||
import { I18n } from '@/components/I18n'
|
||||
|
||||
import { useDarkThemeHook, useThemeOverridesHook, useCode } from '@/hooks'
|
||||
import { useSystemInit, useDarkThemeHook, useThemeOverridesHook, useCode } from '@/hooks'
|
||||
|
||||
// 暗黑主题
|
||||
const darkTheme = useDarkThemeHook()
|
||||
@@ -28,4 +28,7 @@ const overridesTheme = useThemeOverridesHook()
|
||||
|
||||
// 代码主题
|
||||
const hljsTheme = useCode()
|
||||
|
||||
// 系统全局数据初始化
|
||||
useSystemInit()
|
||||
</script>
|
||||
|
||||
14
src/api/axios.config.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { ModuleTypeEnum } from '@/enums/httpEnum'
|
||||
|
||||
// 接口白名单(免登录)
|
||||
export const fetchAllowList = [
|
||||
// 登录
|
||||
`${ModuleTypeEnum.SYSTEM}/login`,
|
||||
// 获取 OSS 接口
|
||||
`${ModuleTypeEnum.SYSTEM}/getOssInfo`,
|
||||
// 预览获取数据
|
||||
`${ModuleTypeEnum.PROJECT}/getData`,
|
||||
]
|
||||
|
||||
// 接口黑名单
|
||||
export const fetchBlockList = []
|
||||
@@ -1,19 +1,38 @@
|
||||
import axios, { AxiosResponse, AxiosRequestConfig } from 'axios'
|
||||
import { ResultEnum } from "@/enums/httpEnum"
|
||||
import { ErrorPageNameMap } from "@/enums/pageEnum"
|
||||
import { redirectErrorPage } from '@/utils'
|
||||
import { PageEnum, ErrorPageNameMap } from "@/enums/pageEnum"
|
||||
import { StorageEnum } from '@/enums/storageEnum'
|
||||
import { axiosPre } from '@/settings/httpSetting'
|
||||
import { SystemStoreEnum, SystemStoreUserInfoEnum } from '@/store/modules/systemStore/systemStore.d'
|
||||
import { redirectErrorPage, getLocalStorage, routerTurnByName, httpErrorHandle } from '@/utils'
|
||||
import { fetchAllowList } from './axios.config'
|
||||
import includes from 'lodash/includes'
|
||||
|
||||
const axiosInstance = axios.create({
|
||||
baseURL: import.meta.env.DEV ? import.meta.env.VITE_DEV_PATH : import.meta.env.VITE_PRO_PATH,
|
||||
baseURL: `${import.meta.env.PROD ? import.meta.env.VITE_PRO_PATH : ''}${axiosPre}`,
|
||||
timeout: ResultEnum.TIMEOUT,
|
||||
})
|
||||
|
||||
axiosInstance.interceptors.request.use(
|
||||
(config: AxiosRequestConfig) => {
|
||||
// 白名单校验
|
||||
if (includes(fetchAllowList, config.url)) return config
|
||||
// 获取 token
|
||||
const info = getLocalStorage(StorageEnum.GO_SYSTEM_STORE)
|
||||
// 重新登录
|
||||
if (!info) {
|
||||
routerTurnByName(PageEnum.BASE_LOGIN_NAME)
|
||||
return config
|
||||
}
|
||||
const userInfo = info[SystemStoreEnum.USER_INFO]
|
||||
config.headers = {
|
||||
...config.headers,
|
||||
[userInfo[SystemStoreUserInfoEnum.TOKEN_NAME] || 'token']: userInfo[SystemStoreUserInfoEnum.USER_TOKEN] || ''
|
||||
}
|
||||
return config
|
||||
},
|
||||
(error: AxiosRequestConfig) => {
|
||||
Promise.reject(error)
|
||||
(err: AxiosRequestConfig) => {
|
||||
Promise.reject(err)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -21,9 +40,27 @@ axiosInstance.interceptors.request.use(
|
||||
axiosInstance.interceptors.response.use(
|
||||
(res: AxiosResponse) => {
|
||||
const { code } = res.data as { code: number }
|
||||
if (code === ResultEnum.DATA_SUCCESS) return Promise.resolve(res.data)
|
||||
// 重定向
|
||||
if (ErrorPageNameMap.get(code)) redirectErrorPage(code)
|
||||
|
||||
// 成功
|
||||
if (code === ResultEnum.SUCCESS) {
|
||||
return Promise.resolve(res.data)
|
||||
}
|
||||
|
||||
// 登录过期
|
||||
if (code === ResultEnum.TOKEN_OVERDUE) {
|
||||
window['$message'].error(window['$t']('http.token_overdue_message'))
|
||||
routerTurnByName(PageEnum.BASE_LOGIN_NAME)
|
||||
return Promise.resolve(res.data)
|
||||
}
|
||||
|
||||
// 固定错误码重定向
|
||||
if (ErrorPageNameMap.get(code)) {
|
||||
redirectErrorPage(code)
|
||||
return Promise.resolve(res.data)
|
||||
}
|
||||
|
||||
// 提示错误
|
||||
window['$message'].error(window['$t']((res.data as any).msg))
|
||||
return Promise.resolve(res.data)
|
||||
},
|
||||
(err: AxiosResponse) => {
|
||||
|
||||
@@ -13,7 +13,7 @@ export const get = (url: string, params?: object) => {
|
||||
return axiosInstance({
|
||||
url: url,
|
||||
method: RequestHttpEnum.GET,
|
||||
params: params
|
||||
params: params,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ export const scatterBasicUrl = '/mock/scatterBasic'
|
||||
export const mapUrl = '/mock/map'
|
||||
export const wordCloudUrl = '/mock/wordCloud'
|
||||
export const treemapUrl = '/mock/treemap'
|
||||
export const threeEarth01Url = '/mock/threeEarth01Data'
|
||||
|
||||
const mockObject: MockMethod[] = [
|
||||
{
|
||||
@@ -92,11 +91,6 @@ const mockObject: MockMethod[] = [
|
||||
method: RequestHttpEnum.GET,
|
||||
response: () => test.fetchTreemap
|
||||
},
|
||||
{
|
||||
url: threeEarth01Url,
|
||||
method: RequestHttpEnum.GET,
|
||||
response: () => test.threeEarth01Data
|
||||
},
|
||||
]
|
||||
|
||||
export default mockObject
|
||||
|
||||
@@ -254,21 +254,4 @@ export default {
|
||||
msg: '请求成功',
|
||||
data: tTreemapJson
|
||||
},
|
||||
// 三维地球
|
||||
threeEarth01Data: {
|
||||
code: 0,
|
||||
status: 200,
|
||||
msg: '请求成功',
|
||||
data: [
|
||||
{
|
||||
startArray: { name: '@name', N: '@integer(10, 100)', E: '@integer(10, 100)' },
|
||||
endArray: [
|
||||
{ name: '@name', N: '@integer(10, 100)', E: '@integer(10, 100)' },
|
||||
{ name: '@name', N: '@integer(10, 100)', E: '@integer(10, 100)' },
|
||||
{ name: '@name', N: '@integer(10, 100)', E: '@integer(10, 100)' },
|
||||
{ name: '@name', N: '@integer(10, 100)', E: '@integer(10, 100)' }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
2
src/api/path/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from '@/api/path/project.api'
|
||||
export * from '@/api/path/system.api'
|
||||
84
src/api/path/project.api.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
import { http } from '@/api/http'
|
||||
import { httpErrorHandle } from '@/utils'
|
||||
import { ContentTypeEnum, RequestHttpEnum, ModuleTypeEnum } from '@/enums/httpEnum'
|
||||
|
||||
// * 项目列表
|
||||
export const projectListApi = async (data: object) => {
|
||||
try {
|
||||
const res = await http(RequestHttpEnum.GET)(`${ModuleTypeEnum.PROJECT}/list`, data);
|
||||
return res;
|
||||
} catch {
|
||||
httpErrorHandle();
|
||||
}
|
||||
}
|
||||
|
||||
// * 新增项目
|
||||
export const createProjectApi = async (data: object) => {
|
||||
try {
|
||||
const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.PROJECT}/create`, data);
|
||||
return res;
|
||||
} catch {
|
||||
httpErrorHandle();
|
||||
}
|
||||
}
|
||||
|
||||
// * 获取项目
|
||||
export const fetchProjectApi = async (data: object) => {
|
||||
try {
|
||||
const res = await http(RequestHttpEnum.GET)(`${ModuleTypeEnum.PROJECT}/getData`, data);
|
||||
return res;
|
||||
} catch {
|
||||
httpErrorHandle();
|
||||
}
|
||||
}
|
||||
|
||||
// * 保存项目
|
||||
export const saveProjectApi = async (data: object) => {
|
||||
try {
|
||||
const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.PROJECT}/save/data`, data, ContentTypeEnum.FORM_URLENCODED);
|
||||
return res;
|
||||
} catch {
|
||||
httpErrorHandle();
|
||||
}
|
||||
}
|
||||
|
||||
// * 修改项目基础信息
|
||||
export const updateProjectApi = async (data: object) => {
|
||||
try {
|
||||
const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.PROJECT}/edit`, data);
|
||||
return res;
|
||||
} catch {
|
||||
httpErrorHandle();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * 删除项目
|
||||
export const deleteProjectApi = async (data: object) => {
|
||||
try {
|
||||
const res = await http(RequestHttpEnum.DELETE)(`${ModuleTypeEnum.PROJECT}/delete`, data);
|
||||
return res;
|
||||
} catch {
|
||||
httpErrorHandle();
|
||||
}
|
||||
}
|
||||
|
||||
// * 修改发布状态 [-1未发布,1发布]
|
||||
export const changeProjectReleaseApi = async (data: object) => {
|
||||
try {
|
||||
const res = await http(RequestHttpEnum.PUT)(`${ModuleTypeEnum.PROJECT}/publish`, data);
|
||||
return res;
|
||||
} catch {
|
||||
httpErrorHandle();
|
||||
}
|
||||
}
|
||||
|
||||
// * 上传文件
|
||||
export const uploadFile = async (url:string, data: object) => {
|
||||
try {
|
||||
const res = await http(RequestHttpEnum.POST)(url, data, ContentTypeEnum.FORM_DATA);
|
||||
return res;
|
||||
} catch {
|
||||
httpErrorHandle();
|
||||
}
|
||||
}
|
||||
33
src/api/path/system.api.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { http } from '@/api/http'
|
||||
import { httpErrorHandle } from '@/utils'
|
||||
import { RequestHttpEnum, ModuleTypeEnum } from '@/enums/httpEnum'
|
||||
|
||||
// * 登录
|
||||
export const loginApi = async (data: object) => {
|
||||
try {
|
||||
const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.SYSTEM}/login`, data);
|
||||
return res;
|
||||
} catch(err) {
|
||||
httpErrorHandle();
|
||||
}
|
||||
}
|
||||
|
||||
// * 登出
|
||||
export const logoutApi = async () => {
|
||||
try {
|
||||
const res = await http(RequestHttpEnum.GET)(`${ModuleTypeEnum.SYSTEM}/logout`);
|
||||
return res;
|
||||
} catch(err) {
|
||||
httpErrorHandle();
|
||||
}
|
||||
}
|
||||
|
||||
// * 获取 oss 上传接口
|
||||
export const ossUrlApi = async (data: object) => {
|
||||
try {
|
||||
const res = await http(RequestHttpEnum.GET)(`${ModuleTypeEnum.SYSTEM}/getOssInfo`, data);
|
||||
return res;
|
||||
} catch(err) {
|
||||
httpErrorHandle();
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 176 KiB |
@@ -21,23 +21,6 @@
|
||||
</setting-item-box>
|
||||
</collapse-item>
|
||||
|
||||
<collapse-item v-if="grid" name="容器">
|
||||
<setting-item-box name="距离">
|
||||
<setting-item name="左侧距离">
|
||||
<n-input v-model:value="grid.left" size="small"></n-input>
|
||||
</setting-item>
|
||||
<setting-item name="右侧距离">
|
||||
<n-input v-model:value="grid.right" size="small"></n-input>
|
||||
</setting-item>
|
||||
<setting-item name="上侧距离">
|
||||
<n-input v-model:value="grid.top" size="small"></n-input>
|
||||
</setting-item>
|
||||
<setting-item name="下侧距离">
|
||||
<n-input v-model:value="grid.bottom" size="small"></n-input>
|
||||
</setting-item>
|
||||
</setting-item-box>
|
||||
</collapse-item>
|
||||
|
||||
<collapse-item v-if="xAxis" name="X轴">
|
||||
<template #header>
|
||||
<n-switch v-model:value="xAxis.show" size="small"></n-switch>
|
||||
@@ -68,9 +51,6 @@
|
||||
<setting-item name="大小">
|
||||
<n-input-number v-model:value="xAxis.axisLabel.fontSize" :min="8" size="small"></n-input-number>
|
||||
</setting-item>
|
||||
<setting-item name="偏移量">
|
||||
<n-input-number v-model:value="xAxis.axisLabel.rotate" :min="-90" :max="90" size="small"></n-input-number>
|
||||
</setting-item>
|
||||
</setting-item-box>
|
||||
<setting-item-box name="轴线">
|
||||
<setting-item name="展示">
|
||||
@@ -160,9 +140,6 @@
|
||||
<setting-item name="大小">
|
||||
<n-input-number v-model:value="yAxis.axisLabel.fontSize" :min="8" size="small"></n-input-number>
|
||||
</setting-item>
|
||||
<setting-item name="偏移量">
|
||||
<n-input-number v-model:value="yAxis.axisLabel.rotate" :min="-90" :max="90" size="small"></n-input-number>
|
||||
</setting-item>
|
||||
</setting-item-box>
|
||||
<setting-item-box name="轴线">
|
||||
<setting-item name="展示">
|
||||
@@ -312,10 +289,6 @@ const legend = computed(() => {
|
||||
return props.optionData.legend
|
||||
})
|
||||
|
||||
const grid = computed(() => {
|
||||
return props.optionData.grid
|
||||
})
|
||||
|
||||
const visualMap = computed(() => {
|
||||
return props.optionData.visualMap
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<setting-item-box v-if="targetData" name="位置">
|
||||
<setting-item-box name="位置">
|
||||
<setting-item :name="`偏移 X:${targetData.left || 0}px`">
|
||||
<n-input-number v-model:value="targetData.left" size="small" step="10"></n-input-number>
|
||||
</setting-item>
|
||||
|
||||
@@ -40,8 +40,9 @@ export enum MenuEnum {
|
||||
UN_GROUP = 'unGroup',
|
||||
// 后退
|
||||
BACK = 'back',
|
||||
// 前进
|
||||
FORWORD = 'forward',
|
||||
// 保存
|
||||
SAVE = 'save',
|
||||
// 锁定
|
||||
LOCK = 'lock',
|
||||
// 解除锁定
|
||||
@@ -72,3 +73,15 @@ export enum MacKeyboard {
|
||||
SHIFT_SOURCE_KEY = '⇧',
|
||||
ALT_SOURCE_KEY = '⌥'
|
||||
}
|
||||
|
||||
// 同步状态枚举
|
||||
export enum SyncEnum {
|
||||
// 等待
|
||||
PENDING,
|
||||
// 开始
|
||||
START,
|
||||
// 成功
|
||||
SUCCESS,
|
||||
// 失败
|
||||
FAILURE
|
||||
}
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
/**
|
||||
* @description: 请求结果集
|
||||
*/
|
||||
// 模块 Path 前缀分类
|
||||
export enum ModuleTypeEnum {
|
||||
SYSTEM = 'sys',
|
||||
PROJECT = 'project',
|
||||
}
|
||||
|
||||
// 请求结果集
|
||||
export enum ResultEnum {
|
||||
DATA_SUCCESS = 0,
|
||||
SUCCESS = 200,
|
||||
SERVER_ERROR = 500,
|
||||
SERVER_FORBIDDEN = 403,
|
||||
NOT_FOUND = 404,
|
||||
TIMEOUT = 60000
|
||||
TOKEN_OVERDUE = 886,
|
||||
TIMEOUT = 60000,
|
||||
}
|
||||
|
||||
// 数据相关
|
||||
@@ -26,9 +31,13 @@ export enum RequestContentTypeEnum {
|
||||
SQL = 1
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 请求方法
|
||||
*/
|
||||
// 头部
|
||||
export enum RequestHttpHeaderEnum {
|
||||
TOKEN = 'Token',
|
||||
COOKIE = 'Cookie'
|
||||
}
|
||||
|
||||
// 请求方法
|
||||
export enum RequestHttpEnum {
|
||||
GET = 'get',
|
||||
POST = 'post',
|
||||
@@ -109,9 +118,7 @@ export type RequestParams = {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 常用的contentTyp类型
|
||||
*/
|
||||
// 常用的contentTyp类型
|
||||
export enum ContentTypeEnum {
|
||||
// json
|
||||
JSON = 'application/json;charset=UTF-8',
|
||||
|
||||
@@ -20,10 +20,15 @@ export enum PageEnum {
|
||||
//重定向
|
||||
REDIRECT = '/redirect',
|
||||
REDIRECT_NAME = 'Redirect',
|
||||
|
||||
// 未发布
|
||||
REDIRECT_UN_PUBLISH = '/redirect/unPublish',
|
||||
REDIRECT_UN_PUBLISH_NAME = 'redirect-un-publish',
|
||||
|
||||
// 重载
|
||||
RELOAD = '/reload',
|
||||
RELOAD_NAME = 'Reload',
|
||||
|
||||
|
||||
// 首页
|
||||
BASE_HOME = '/project',
|
||||
BASE_HOME_NAME = 'Project',
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
export enum StorageEnum {
|
||||
// 全局设置
|
||||
GO_SYSTEM_SETTING_STORE = 'GO_SYSTEM_SETTING',
|
||||
// token 等信息
|
||||
GO_ACCESS_TOKEN_STORE = 'GO_ACCESS_TOKEN',
|
||||
GO_SETTING_STORE = 'GO_SETTING',
|
||||
// 登录信息
|
||||
GO_LOGIN_INFO_STORE = 'GO_LOGIN_INFO',
|
||||
GO_SYSTEM_STORE = 'GO_SYSTEM',
|
||||
// 语言
|
||||
GO_LANG_STORE = 'GO_LANG',
|
||||
// 当前选择的主题
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from '@/hooks/useTheme.hook'
|
||||
export * from '@/hooks/usePreviewScale.hook'
|
||||
export * from '@/hooks/useCode.hook'
|
||||
export * from '@/hooks/useChartDataFetch.hook'
|
||||
export * from '@/hooks/useChartDataFetch.hook'
|
||||
export * from '@/hooks/useSystemInit.hook'
|
||||
@@ -59,18 +59,18 @@ export const useChartDataFetch = (
|
||||
|
||||
const fetchFn = async () => {
|
||||
const res = await customizeHttp(toRaw(targetComponent.request), toRaw(chartEditStore.requestGlobalConfig))
|
||||
if (res) {
|
||||
if (res && res.data) {
|
||||
try {
|
||||
const filter = targetComponent.filter
|
||||
// eCharts 组件配合 vChart 库更新方式
|
||||
if (chartFrame === ChartFrameEnum.ECHARTS) {
|
||||
if (vChartRef.value) {
|
||||
vChartRef.value.setOption({ dataset: newFunctionHandle(res?.data, res, filter) })
|
||||
vChartRef.value.setOption({ dataset: newFunctionHandle(res.data, filter) })
|
||||
}
|
||||
}
|
||||
// 更新回调函数
|
||||
if (updateCallback) {
|
||||
updateCallback(newFunctionHandle(res?.data, res, filter))
|
||||
updateCallback(newFunctionHandle(res.data, filter))
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
@@ -90,7 +90,7 @@ export const useChartDataFetch = (
|
||||
}
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
23
src/hooks/useSystemInit.hook.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { useSystemStore } from '@/store/modules/systemStore/systemStore'
|
||||
import { SystemStoreEnum } from '@/store/modules/systemStore/systemStore.d'
|
||||
import { ResultEnum } from '@/enums/httpEnum'
|
||||
import { ossUrlApi } from '@/api/path/'
|
||||
|
||||
|
||||
// * 初始化
|
||||
export const useSystemInit = async () => {
|
||||
const systemStore = useSystemStore()
|
||||
|
||||
// 获取 OSS 信息
|
||||
const getOssUrl = async () => {
|
||||
const res = await ossUrlApi({}) as unknown as MyResponseType
|
||||
if (res.code === ResultEnum.SUCCESS) {
|
||||
systemStore.setItem(SystemStoreEnum.FETCH_INFO, {
|
||||
OSSUrl: res.data?.bucketURL
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 执行
|
||||
getOssUrl()
|
||||
}
|
||||
@@ -11,6 +11,8 @@ const global = {
|
||||
help: 'Help',
|
||||
contact: 'About Software',
|
||||
logout: 'Logout',
|
||||
logout_success: 'Logout success!',
|
||||
logout_failure: 'Logout Failed!',
|
||||
// system setting
|
||||
sys_set: 'System Setting',
|
||||
lang_set: 'Language Setting',
|
||||
@@ -26,8 +28,14 @@ const global = {
|
||||
r_more: 'More',
|
||||
}
|
||||
|
||||
const http = {
|
||||
error_message: 'The interface is abnormal, please check the interface!',
|
||||
token_overdue_message: 'Login expired, please log in again!'
|
||||
}
|
||||
|
||||
export default {
|
||||
global,
|
||||
http,
|
||||
login,
|
||||
project
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ export default {
|
||||
desc: "Login",
|
||||
form_auto: "Sign in automatically",
|
||||
form_button: "Login",
|
||||
login_success: "Login success",
|
||||
login_message: "Please complete the letter",
|
||||
login_success: "Login success!",
|
||||
login_message: "Please complete the letter!",
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
export default {
|
||||
create_btn: 'Creat',
|
||||
create_tip: 'Please select a content for development',
|
||||
create_success: 'Creat Success!',
|
||||
create_failure: 'Failed to create, please try again later!',
|
||||
create_tip: 'Please select a content for development!',
|
||||
project: 'Project',
|
||||
my: 'My',
|
||||
new_project: 'New Project',
|
||||
|
||||
@@ -11,6 +11,8 @@ const global = {
|
||||
help: '帮助中心',
|
||||
contact: '关于软件',
|
||||
logout: '退出登录',
|
||||
logout_success: '退出成功!',
|
||||
logout_failure: '退出失败!',
|
||||
// 系统设置
|
||||
sys_set: '系统设置',
|
||||
lang_set: '语言设置',
|
||||
@@ -18,16 +20,27 @@ const global = {
|
||||
r_edit: '编辑',
|
||||
r_preview: '预览',
|
||||
r_copy: '克隆',
|
||||
r_copy_success: '克隆成功!',
|
||||
r_rename: '重命名',
|
||||
r_rename_success: '重命名成功!',
|
||||
r_publish: '发布',
|
||||
r_publish_success: '成功发布!',
|
||||
r_unpublish: '取消发布',
|
||||
r_unpublish_success: '取消成功!',
|
||||
r_download: '下载',
|
||||
r_delete: '删除',
|
||||
r_delete_success: '删除成功!',
|
||||
r_more: '更多',
|
||||
}
|
||||
|
||||
const http = {
|
||||
error_message: '获取数据失败,请稍后重试!',
|
||||
token_overdue_message: '登录过期,请重新登录!'
|
||||
}
|
||||
|
||||
export default {
|
||||
global,
|
||||
http,
|
||||
login,
|
||||
project
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ export default {
|
||||
desc: "登录",
|
||||
form_auto: "自动登录",
|
||||
form_button: "登录",
|
||||
login_success: "登录成功",
|
||||
login_message: "请填写完整信息",
|
||||
login_success: "登录成功!",
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
export default {
|
||||
// aside
|
||||
create_btn: '新建',
|
||||
create_success: '新建成功!',
|
||||
create_failure: '新建失败,请稍后重试!',
|
||||
create_tip: '从哪里出发好呢?',
|
||||
project: '项目',
|
||||
my: '我的',
|
||||
|
||||
@@ -4,21 +4,17 @@ import { CreateComponentType } from '@/packages/index.d'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import dataJson from './data.json'
|
||||
|
||||
export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
|
||||
export const includes = ['legend', 'xAxis', 'yAxis']
|
||||
|
||||
export const seriesItem = {
|
||||
type: 'bar',
|
||||
barWidth: 15,
|
||||
label: {
|
||||
show: true,
|
||||
position: 'top',
|
||||
color: '#fff',
|
||||
fontSize: 12
|
||||
},
|
||||
barWidth: null,
|
||||
itemStyle: {
|
||||
color: null,
|
||||
borderRadius: 2
|
||||
borderRadius: 0
|
||||
}
|
||||
}
|
||||
|
||||
export const option = {
|
||||
tooltip: {
|
||||
show: true,
|
||||
@@ -28,7 +24,10 @@ export const option = {
|
||||
type: 'shadow'
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
legend: {
|
||||
show: true
|
||||
},
|
||||
xAxis: {
|
||||
show: true,
|
||||
type: 'category'
|
||||
},
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
<template>
|
||||
<!-- Echarts 全局设置 -->
|
||||
<!-- Echarts 全局设置 -->
|
||||
<global-setting :optionData="optionData"></global-setting>
|
||||
<CollapseItem v-for="(item, index) in seriesList" :key="index" :name="`柱状图-${index + 1}`" :expanded="true">
|
||||
<CollapseItem
|
||||
v-for="(item, index) in seriesList"
|
||||
:key="index"
|
||||
:name="`柱状图-${index + 1}`"
|
||||
:expanded="true"
|
||||
>
|
||||
<SettingItemBox name="图形">
|
||||
<SettingItem name="颜色">
|
||||
<n-color-picker size="small" :modes="['hex']" v-model:value="item.itemStyle.color"></n-color-picker>
|
||||
<n-color-picker
|
||||
size="small"
|
||||
:modes="['hex']"
|
||||
v-model:value="item.itemStyle.color"
|
||||
></n-color-picker>
|
||||
</SettingItem>
|
||||
<SettingItem>
|
||||
<n-button size="small" @click="item.itemStyle.color = null"> 恢复默认 </n-button>
|
||||
<n-button size="small" @click="item.itemStyle.color = null">
|
||||
恢复默认
|
||||
</n-button>
|
||||
</SettingItem>
|
||||
<SettingItem name="宽度">
|
||||
<n-input-number
|
||||
@@ -19,40 +30,24 @@
|
||||
></n-input-number>
|
||||
</SettingItem>
|
||||
<SettingItem name="圆角">
|
||||
<n-input-number v-model:value="item.itemStyle.borderRadius" :min="0" size="small"></n-input-number>
|
||||
<n-input-number
|
||||
v-model:value="item.itemStyle.borderRadius"
|
||||
:min="0"
|
||||
size="small"
|
||||
></n-input-number>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
<setting-item-box name="标签">
|
||||
<setting-item>
|
||||
<n-space>
|
||||
<n-switch v-model:value="item.label.show" size="small" />
|
||||
<n-text>展示标签</n-text>
|
||||
</n-space>
|
||||
</setting-item>
|
||||
<setting-item name="大小">
|
||||
<n-input-number v-model:value="item.label.fontSize" size="small" :min="1"></n-input-number>
|
||||
</setting-item>
|
||||
<setting-item name="颜色">
|
||||
<n-color-picker size="small" :modes="['hex']" v-model:value="item.label.color"></n-color-picker>
|
||||
</setting-item>
|
||||
<setting-item name="位置">
|
||||
<n-select
|
||||
v-model:value="item.label.position"
|
||||
:options="[
|
||||
{ label: 'top', value: 'top' },
|
||||
{ label: 'left', value: 'left' },
|
||||
{ label: 'right', value: 'right' },
|
||||
{ label: 'bottom', value: 'bottom' }
|
||||
]"
|
||||
/>
|
||||
</setting-item>
|
||||
</setting-item-box>
|
||||
</CollapseItem>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType, computed } from 'vue'
|
||||
import { GlobalSetting, CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
||||
import {
|
||||
GlobalSetting,
|
||||
CollapseItem,
|
||||
SettingItemBox,
|
||||
SettingItem
|
||||
} from '@/components/Pages/ChartItemSetting'
|
||||
import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
|
||||
|
||||
const props = defineProps({
|
||||
|
||||
@@ -53,21 +53,17 @@ const option = computed(() => {
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
(newData: { dimensions: any }, oldData) => {
|
||||
try {
|
||||
if (!isObject(newData) || !('dimensions' in newData)) return
|
||||
if (Array.isArray(newData?.dimensions)) {
|
||||
const seriesArr = []
|
||||
for (let i = 0; i < newData.dimensions.length - 1; i++) {
|
||||
seriesArr.push(seriesItem)
|
||||
}
|
||||
replaceMergeArr.value = ['series']
|
||||
props.chartConfig.option.series = seriesArr
|
||||
nextTick(() => {
|
||||
replaceMergeArr.value = []
|
||||
})
|
||||
if (!isObject(newData) || !('dimensions' in newData)) return
|
||||
if (newData?.dimensions.length !== oldData?.dimensions.length) {
|
||||
const seriesArr = []
|
||||
for (let i = 0; i < newData.dimensions.length - 1; i++) {
|
||||
seriesArr.push(seriesItem)
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
replaceMergeArr.value = ['series']
|
||||
props.chartConfig.option.series = seriesArr
|
||||
nextTick(() => {
|
||||
replaceMergeArr.value = []
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -4,21 +4,17 @@ import { CreateComponentType } from '@/packages/index.d'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import dataJson from './data.json'
|
||||
|
||||
export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
|
||||
export const includes = ['legend', 'xAxis', 'yAxis']
|
||||
|
||||
export const seriesItem = {
|
||||
type: 'bar',
|
||||
barWidth: null,
|
||||
label: {
|
||||
show: true,
|
||||
position: 'right',
|
||||
color: '#fff',
|
||||
fontSize: 12
|
||||
},
|
||||
itemStyle: {
|
||||
color: null,
|
||||
borderRadius: 0
|
||||
}
|
||||
}
|
||||
|
||||
export const option = {
|
||||
tooltip: {
|
||||
show: true,
|
||||
@@ -28,9 +24,12 @@ export const option = {
|
||||
type: 'shadow'
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
show: true
|
||||
},
|
||||
xAxis: {
|
||||
show: true,
|
||||
type: 'value'
|
||||
type: 'value',
|
||||
},
|
||||
yAxis: {
|
||||
show: true,
|
||||
|
||||
@@ -26,39 +26,6 @@
|
||||
></n-input-number>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
<setting-item-box name="标签">
|
||||
<setting-item>
|
||||
<n-space>
|
||||
<n-switch v-model:value="item.label.show" size="small" />
|
||||
<n-text>展示标签</n-text>
|
||||
</n-space>
|
||||
</setting-item>
|
||||
<setting-item name="大小">
|
||||
<n-input-number
|
||||
v-model:value="item.label.fontSize"
|
||||
size="small"
|
||||
:min="1"
|
||||
></n-input-number>
|
||||
</setting-item>
|
||||
<setting-item name="颜色">
|
||||
<n-color-picker
|
||||
size="small"
|
||||
:modes="['hex']"
|
||||
v-model:value="item.label.color"
|
||||
></n-color-picker>
|
||||
</setting-item>
|
||||
<setting-item name="位置">
|
||||
<n-select
|
||||
v-model:value="item.label.position"
|
||||
:options="[
|
||||
{ label: 'top', value: 'top' },
|
||||
{ label: 'left', value: 'left' },
|
||||
{ label: 'right', value: 'right' },
|
||||
{ label: 'bottom', value: 'bottom' },
|
||||
]"
|
||||
/>
|
||||
</setting-item>
|
||||
</setting-item-box>
|
||||
</CollapseItem>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -52,21 +52,17 @@ const option = computed(() => {
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
(newData: { dimensions: any }, oldData) => {
|
||||
try {
|
||||
if (!isObject(newData) || !('dimensions' in newData)) return
|
||||
if (Array.isArray(newData?.dimensions)) {
|
||||
const seriesArr = []
|
||||
for (let i = 0; i < newData.dimensions.length - 1; i++) {
|
||||
seriesArr.push(seriesItem)
|
||||
}
|
||||
replaceMergeArr.value = ['series']
|
||||
props.chartConfig.option.series = seriesArr
|
||||
nextTick(() => {
|
||||
replaceMergeArr.value = []
|
||||
})
|
||||
if (!isObject(newData) || !('dimensions' in newData)) return
|
||||
if (newData?.dimensions.length !== oldData?.dimensions.length) {
|
||||
const seriesArr = []
|
||||
for (let i = 0; i < newData.dimensions.length - 1; i++) {
|
||||
seriesArr.push(seriesItem)
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
replaceMergeArr.value = ['series']
|
||||
props.chartConfig.option.series = seriesArr
|
||||
nextTick(() => {
|
||||
replaceMergeArr.value = []
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -4,24 +4,17 @@ import { CreateComponentType } from '@/packages/index.d'
|
||||
import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
|
||||
import dataJson from './data.json'
|
||||
|
||||
export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
|
||||
export const includes = ['legend', 'xAxis', 'yAxis']
|
||||
|
||||
export const seriesItem = {
|
||||
type: 'line',
|
||||
label: {
|
||||
show: true,
|
||||
position: 'top',
|
||||
color: '#fff',
|
||||
fontSize: 12
|
||||
},
|
||||
symbolSize: 5, //设定实心点的大小
|
||||
itemStyle: {
|
||||
color: null,
|
||||
borderRadius: 0
|
||||
},
|
||||
lineStyle: {
|
||||
type: 'solid',
|
||||
width: 3,
|
||||
color: null
|
||||
itemStyle: {
|
||||
color: null,
|
||||
borderRadius: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +26,9 @@ export const option = {
|
||||
type: 'line'
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
show: true
|
||||
},
|
||||
xAxis: {
|
||||
show: true,
|
||||
type: 'category'
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<template>
|
||||
<!-- Echarts 全局设置 -->
|
||||
<global-setting :optionData="optionData"></global-setting>
|
||||
<CollapseItem v-for="(item, index) in seriesList" :key="index" :name="`折线图-${index + 1}`" :expanded="true">
|
||||
<CollapseItem
|
||||
v-for="(item, index) in seriesList"
|
||||
:key="index"
|
||||
:name="`折线图-${index + 1}`"
|
||||
:expanded="true"
|
||||
>
|
||||
<SettingItemBox name="线条">
|
||||
<setting-item name="颜色">
|
||||
<n-color-picker size="small" :modes="['hex']" v-model:value="item.lineStyle.color"></n-color-picker>
|
||||
</setting-item>
|
||||
<SettingItem name="宽度">
|
||||
<n-input-number
|
||||
v-model:value="item.lineStyle.width"
|
||||
@@ -13,48 +15,16 @@
|
||||
:max="100"
|
||||
size="small"
|
||||
placeholder="自动计算"
|
||||
></n-input-number>
|
||||
></n-input-number>
|
||||
</SettingItem>
|
||||
<SettingItem name="类型">
|
||||
<n-select v-model:value="item.lineStyle.type" size="small" :options="lineConf.lineStyle.type"></n-select>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
<SettingItemBox name="实心点">
|
||||
<SettingItem name="大小">
|
||||
<n-input-number
|
||||
v-model:value="item.symbolSize"
|
||||
:min="1"
|
||||
:max="100"
|
||||
size="small"
|
||||
placeholder="自动计算"
|
||||
></n-input-number>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
<setting-item-box name="标签">
|
||||
<setting-item>
|
||||
<n-space>
|
||||
<n-switch v-model:value="item.label.show" size="small" />
|
||||
<n-text>展示标签</n-text>
|
||||
</n-space>
|
||||
</setting-item>
|
||||
<setting-item name="大小">
|
||||
<n-input-number v-model:value="item.label.fontSize" size="small" :min="1"></n-input-number>
|
||||
</setting-item>
|
||||
<setting-item name="颜色">
|
||||
<n-color-picker size="small" :modes="['hex']" v-model:value="item.label.color"></n-color-picker>
|
||||
</setting-item>
|
||||
<setting-item name="位置">
|
||||
<n-select
|
||||
v-model:value="item.label.position"
|
||||
:options="[
|
||||
{ label: 'top', value: 'top' },
|
||||
{ label: 'left', value: 'left' },
|
||||
{ label: 'right', value: 'right' },
|
||||
{ label: 'bottom', value: 'bottom' }
|
||||
]"
|
||||
/>
|
||||
</setting-item>
|
||||
</setting-item-box>
|
||||
v-model:value="item.lineStyle.type"
|
||||
size="small"
|
||||
:options="lineConf.lineStyle.type"
|
||||
></n-select>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
</CollapseItem>
|
||||
</template>
|
||||
|
||||
@@ -62,7 +32,12 @@
|
||||
import { PropType, computed } from 'vue'
|
||||
import { lineConf } from '@/packages/chartConfiguration/echarts/index'
|
||||
import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
|
||||
import { GlobalSetting, CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
||||
import {
|
||||
GlobalSetting,
|
||||
CollapseItem,
|
||||
SettingItemBox,
|
||||
SettingItem
|
||||
} from '@/components/Pages/ChartItemSetting'
|
||||
|
||||
const props = defineProps({
|
||||
optionData: {
|
||||
|
||||
@@ -53,21 +53,17 @@ const option = computed(() => {
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
(newData: { dimensions: any }, oldData) => {
|
||||
try {
|
||||
if (!isObject(newData) || !('dimensions' in newData)) return
|
||||
if (Array.isArray(newData?.dimensions)) {
|
||||
const seriesArr = []
|
||||
for (let i = 0; i < newData.dimensions.length - 1; i++) {
|
||||
seriesArr.push(seriesItem)
|
||||
}
|
||||
replaceMergeArr.value = ['series']
|
||||
props.chartConfig.option.series = seriesArr
|
||||
nextTick(() => {
|
||||
replaceMergeArr.value = []
|
||||
})
|
||||
if (!isObject(newData) || !('dimensions' in newData)) return
|
||||
if (newData?.dimensions.length !== oldData?.dimensions.length) {
|
||||
const seriesArr = []
|
||||
for (let i = 0; i < newData.dimensions.length - 1; i++) {
|
||||
seriesArr.push(seriesItem)
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
replaceMergeArr.value = ['series']
|
||||
props.chartConfig.option.series = seriesArr
|
||||
nextTick(() => {
|
||||
replaceMergeArr.value = []
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ import { graphic } from 'echarts/core'
|
||||
import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
|
||||
import dataJson from './data.json'
|
||||
|
||||
export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
|
||||
export const includes = ['legend', 'xAxis', 'yAxis']
|
||||
|
||||
const options = {
|
||||
tooltip: {
|
||||
@@ -15,6 +15,9 @@ const options = {
|
||||
type: 'line'
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
show: true
|
||||
},
|
||||
xAxis: {
|
||||
show: true,
|
||||
type: 'category'
|
||||
@@ -28,13 +31,6 @@ const options = {
|
||||
{
|
||||
type: 'line',
|
||||
smooth: false,
|
||||
symbolSize: 5, //设定实心点的大小
|
||||
label: {
|
||||
show: true,
|
||||
position: 'top',
|
||||
color: '#fff',
|
||||
fontSize: 12
|
||||
},
|
||||
lineStyle: {
|
||||
type: 'solid',
|
||||
width: 3
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
<template>
|
||||
<!-- Echarts 全局设置 -->
|
||||
<global-setting :optionData="optionData"></global-setting>
|
||||
<CollapseItem v-for="(item, index) in seriesList" :key="index" name="单折线面积图" :expanded="true">
|
||||
<CollapseItem
|
||||
v-for="(item, index) in seriesList"
|
||||
:key="index"
|
||||
name="单折线面积图"
|
||||
:expanded="true"
|
||||
>
|
||||
<SettingItemBox name="线条">
|
||||
<SettingItem name="宽度">
|
||||
<n-input-number
|
||||
@@ -13,45 +18,13 @@
|
||||
></n-input-number>
|
||||
</SettingItem>
|
||||
<SettingItem name="类型">
|
||||
<n-select v-model:value="item.lineStyle.type" size="small" :options="lineConf.lineStyle.type"></n-select>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
<SettingItemBox name="实心点">
|
||||
<SettingItem name="大小">
|
||||
<n-input-number
|
||||
v-model:value="item.symbolSize"
|
||||
:min="1"
|
||||
:max="100"
|
||||
size="small"
|
||||
placeholder="自动计算"
|
||||
></n-input-number>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
<setting-item-box name="标签">
|
||||
<setting-item>
|
||||
<n-space>
|
||||
<n-switch v-model:value="item.label.show" size="small" />
|
||||
<n-text>展示标签</n-text>
|
||||
</n-space>
|
||||
</setting-item>
|
||||
<setting-item name="大小">
|
||||
<n-input-number v-model:value="item.label.fontSize" size="small" :min="1"></n-input-number>
|
||||
</setting-item>
|
||||
<setting-item name="颜色">
|
||||
<n-color-picker size="small" :modes="['hex']" v-model:value="item.label.color"></n-color-picker>
|
||||
</setting-item>
|
||||
<setting-item name="位置">
|
||||
<n-select
|
||||
v-model:value="item.label.position"
|
||||
:options="[
|
||||
{ label: 'top', value: 'top' },
|
||||
{ label: 'left', value: 'left' },
|
||||
{ label: 'right', value: 'right' },
|
||||
{ label: 'bottom', value: 'bottom' }
|
||||
]"
|
||||
/>
|
||||
</setting-item>
|
||||
</setting-item-box>
|
||||
v-model:value="item.lineStyle.type"
|
||||
size="small"
|
||||
:options="lineConf.lineStyle.type"
|
||||
></n-select>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
</CollapseItem>
|
||||
</template>
|
||||
|
||||
@@ -59,13 +32,18 @@
|
||||
import { PropType, computed } from 'vue'
|
||||
import { lineConf } from '@/packages/chartConfiguration/echarts/index'
|
||||
import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
|
||||
import { GlobalSetting, CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
||||
import {
|
||||
GlobalSetting,
|
||||
CollapseItem,
|
||||
SettingItemBox,
|
||||
SettingItem
|
||||
} from '@/components/Pages/ChartItemSetting'
|
||||
|
||||
const props = defineProps({
|
||||
optionData: {
|
||||
type: Object as PropType<GlobalThemeJsonType>,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
const seriesList = computed(() => {
|
||||
|
||||
@@ -43,27 +43,23 @@ const option = reactive({
|
||||
watch(
|
||||
() => chartEditStore.getEditCanvasConfig.chartThemeColor,
|
||||
(newColor: keyof typeof chartColorsSearch) => {
|
||||
try {
|
||||
if (!isPreview()) {
|
||||
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
||||
props.chartConfig.option.series.forEach((value: any, index: number) => {
|
||||
value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [
|
||||
{
|
||||
offset: 0,
|
||||
color: themeColor[3]
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: 'rgba(0,0,0, 0)'
|
||||
}
|
||||
])
|
||||
})
|
||||
}
|
||||
option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
||||
props.chartConfig.option = option.value
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
if (!isPreview()) {
|
||||
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
||||
props.chartConfig.option.series.forEach((value: any, index: number) => {
|
||||
value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [
|
||||
{
|
||||
offset: 0,
|
||||
color: themeColor[3]
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: 'rgba(0,0,0, 0)'
|
||||
}
|
||||
])
|
||||
})
|
||||
}
|
||||
option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
||||
props.chartConfig.option = option.value
|
||||
},
|
||||
{
|
||||
immediate: true
|
||||
@@ -74,6 +70,9 @@ watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
() => {
|
||||
option.value = props.chartConfig.option
|
||||
},
|
||||
{
|
||||
deep: false
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -5,9 +5,12 @@ import { graphic } from 'echarts/core'
|
||||
import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
|
||||
import dataJson from './data.json'
|
||||
|
||||
export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
|
||||
export const includes = ['legend', 'xAxis', 'yAxis']
|
||||
|
||||
const option = {
|
||||
legend: {
|
||||
show: true
|
||||
},
|
||||
tooltip: {
|
||||
show: true,
|
||||
trigger: 'axis',
|
||||
@@ -28,13 +31,6 @@ const option = {
|
||||
{
|
||||
type: 'line',
|
||||
smooth: false,
|
||||
symbolSize: 5, //设定实心点的大小
|
||||
label: {
|
||||
show: true,
|
||||
position: 'top',
|
||||
color: '#fff',
|
||||
fontSize: 12
|
||||
},
|
||||
lineStyle: {
|
||||
width: 3,
|
||||
type: 'solid'
|
||||
@@ -56,12 +52,6 @@ const option = {
|
||||
{
|
||||
type: 'line',
|
||||
smooth: false,
|
||||
label: {
|
||||
show: true,
|
||||
position: 'top',
|
||||
color: '#fff',
|
||||
fontSize: 12
|
||||
},
|
||||
lineStyle: {
|
||||
width: 3,
|
||||
type: 'solid'
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<n-input-number
|
||||
v-model:value="item.lineStyle.width"
|
||||
:min="1"
|
||||
:max="100"
|
||||
size="small"
|
||||
placeholder="自动计算"
|
||||
></n-input-number>
|
||||
@@ -24,50 +25,6 @@
|
||||
></n-select>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
<SettingItemBox name="实心点">
|
||||
<SettingItem name="大小">
|
||||
<n-input-number
|
||||
v-model:value="item.symbolSize"
|
||||
:min="1"
|
||||
:max="100"
|
||||
size="small"
|
||||
placeholder="自动计算"
|
||||
></n-input-number>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
<setting-item-box name="标签">
|
||||
<setting-item>
|
||||
<n-space>
|
||||
<n-switch v-model:value="item.label.show" size="small" />
|
||||
<n-text>展示标签</n-text>
|
||||
</n-space>
|
||||
</setting-item>
|
||||
<setting-item name="大小">
|
||||
<n-input-number
|
||||
v-model:value="item.label.fontSize"
|
||||
size="small"
|
||||
:min="1"
|
||||
></n-input-number>
|
||||
</setting-item>
|
||||
<setting-item name="颜色">
|
||||
<n-color-picker
|
||||
size="small"
|
||||
:modes="['hex']"
|
||||
v-model:value="item.label.color"
|
||||
></n-color-picker>
|
||||
</setting-item>
|
||||
<setting-item name="位置">
|
||||
<n-select
|
||||
v-model:value="item.label.position"
|
||||
:options="[
|
||||
{ label: 'top', value: 'top' },
|
||||
{ label: 'left', value: 'left' },
|
||||
{ label: 'right', value: 'right' },
|
||||
{ label: 'bottom', value: 'bottom' },
|
||||
]"
|
||||
/>
|
||||
</setting-item>
|
||||
</setting-item-box>
|
||||
</CollapseItem>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -42,27 +42,23 @@ const option = reactive({
|
||||
watch(
|
||||
() => chartEditStore.getEditCanvasConfig.chartThemeColor,
|
||||
(newColor: keyof typeof chartColorsSearch) => {
|
||||
try {
|
||||
if (!isPreview()) {
|
||||
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
||||
props.chartConfig.option.series.forEach((value: any, index: number) => {
|
||||
value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [
|
||||
{
|
||||
offset: 0,
|
||||
color: themeColor[3 + index]
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: 'rgba(0,0,0, 0)'
|
||||
}
|
||||
])
|
||||
})
|
||||
}
|
||||
option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
||||
props.chartConfig.option = option.value
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
if (!isPreview()) {
|
||||
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
||||
props.chartConfig.option.series.forEach((value: any, index: number) => {
|
||||
value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [
|
||||
{
|
||||
offset: 0,
|
||||
color: themeColor[3 + index]
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: 'rgba(0,0,0, 0)'
|
||||
}
|
||||
])
|
||||
})
|
||||
}
|
||||
option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
||||
props.chartConfig.option = option.value
|
||||
},
|
||||
{
|
||||
immediate: true
|
||||
@@ -75,5 +71,6 @@ watch(
|
||||
option.value = props.chartConfig.option
|
||||
}
|
||||
)
|
||||
|
||||
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore)
|
||||
</script>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { CreateComponentType } from '@/packages/index.d'
|
||||
import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
|
||||
import dataJson from './data.json'
|
||||
|
||||
export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
|
||||
export const includes = ['legend', 'xAxis', 'yAxis']
|
||||
|
||||
export const option = {
|
||||
tooltip: {
|
||||
@@ -14,6 +14,9 @@ export const option = {
|
||||
type: 'line'
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
show: true
|
||||
},
|
||||
xAxis: {
|
||||
show: true,
|
||||
type: 'category'
|
||||
@@ -26,7 +29,6 @@ export const option = {
|
||||
series: [
|
||||
{
|
||||
type: 'line',
|
||||
symbolSize: 5, //设定实心点的大小
|
||||
lineStyle: {
|
||||
type: 'solid',
|
||||
width: 3,
|
||||
|
||||
@@ -39,17 +39,6 @@
|
||||
></n-select>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
<SettingItemBox name="实心点">
|
||||
<SettingItem name="大小">
|
||||
<n-input-number
|
||||
v-model:value="item.symbolSize"
|
||||
:min="1"
|
||||
:max="100"
|
||||
size="small"
|
||||
placeholder="自动计算"
|
||||
></n-input-number>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
<SettingItemBox name="阴影" :alone="true">
|
||||
<SettingItem name="颜色">
|
||||
<n-color-picker
|
||||
|
||||
@@ -43,21 +43,17 @@ const option = reactive({
|
||||
watch(
|
||||
() => chartEditStore.getEditCanvasConfig.chartThemeColor,
|
||||
(newColor: keyof typeof chartColorsSearch) => {
|
||||
try {
|
||||
if (!isPreview()) {
|
||||
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
||||
props.chartConfig.option.series.forEach((value: any) => {
|
||||
value.lineStyle.shadowColor = themeColor[2]
|
||||
value.lineStyle.color.colorStops.forEach((v: { color: string }, i: number) => {
|
||||
v.color = themeColor[i]
|
||||
})
|
||||
if (!isPreview()) {
|
||||
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
||||
props.chartConfig.option.series.forEach((value: any) => {
|
||||
value.lineStyle.shadowColor = themeColor[2]
|
||||
value.lineStyle.color.colorStops.forEach((v: { color: string }, i: number) => {
|
||||
v.color = themeColor[i]
|
||||
})
|
||||
}
|
||||
option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
||||
props.chartConfig.option = option.value
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
})
|
||||
}
|
||||
option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
||||
props.chartConfig.option = option.value
|
||||
},
|
||||
{
|
||||
immediate: true
|
||||
|
||||
@@ -64,9 +64,9 @@ registerMap(props.chartConfig.option.mapRegion.adcode, { geoJSON: {} as any, spe
|
||||
// 进行更换初始化地图 如果为china 单独处理
|
||||
const registerMapInitAsync = async () => {
|
||||
await nextTick()
|
||||
if (props.chartConfig.option.mapRegion.adcode != 'china') {
|
||||
if (props.chartConfig.option.mapRegion.adcode!="china") {
|
||||
await getGeojson(props.chartConfig.option.mapRegion.adcode)
|
||||
} else {
|
||||
}else{
|
||||
await hainanLandsHandle(props.chartConfig.option.mapRegion.showHainanIsLands)
|
||||
}
|
||||
vEchartsSetOption()
|
||||
@@ -90,12 +90,12 @@ const dataSetHandle = async (dataset: any) => {
|
||||
isPreview() && vEchartsSetOption()
|
||||
}
|
||||
// 处理海南群岛
|
||||
const hainanLandsHandle = async (newData: boolean) => {
|
||||
const hainanLandsHandle=async(newData:boolean)=>{
|
||||
if (newData) {
|
||||
await getGeojson('china')
|
||||
} else {
|
||||
registerMap('china', { geoJSON: mapJsonWithoutHainanIsLands as any, specialAreas: {} })
|
||||
}
|
||||
await getGeojson('china')
|
||||
} else {
|
||||
registerMap('china', { geoJSON: mapJsonWithoutHainanIsLands as any, specialAreas: {} })
|
||||
}
|
||||
}
|
||||
//监听 dataset 数据发生变化
|
||||
watch(
|
||||
@@ -113,12 +113,8 @@ watch(
|
||||
watch(
|
||||
() => props.chartConfig.option.mapRegion.showHainanIsLands,
|
||||
async newData => {
|
||||
try {
|
||||
await hainanLandsHandle(newData)
|
||||
vEchartsSetOption()
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
await hainanLandsHandle(newData)
|
||||
vEchartsSetOption()
|
||||
},
|
||||
{
|
||||
deep: false
|
||||
@@ -129,16 +125,12 @@ watch(
|
||||
watch(
|
||||
() => props.chartConfig.option.mapRegion.adcode,
|
||||
async newData => {
|
||||
try {
|
||||
await getGeojson(newData)
|
||||
props.chartConfig.option.geo.map = newData
|
||||
props.chartConfig.option.series.forEach((item: any) => {
|
||||
if (item.type === 'map') item.map = newData
|
||||
})
|
||||
vEchartsSetOption()
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
await getGeojson(newData)
|
||||
props.chartConfig.option.geo.map = newData
|
||||
props.chartConfig.option.series.forEach((item: any) => {
|
||||
if (item.type === 'map') item.map = newData
|
||||
})
|
||||
vEchartsSetOption()
|
||||
},
|
||||
{
|
||||
deep: false
|
||||
|
||||
@@ -4,7 +4,7 @@ import { CreateComponentType } from '@/packages/index.d'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import dataJson from './data.json'
|
||||
|
||||
export const includes = ['xAxis', 'yAxis', 'grid']
|
||||
export const includes = ['xAxis', 'yAxis']
|
||||
|
||||
export const option = {
|
||||
dataset: { ...dataJson },
|
||||
|
||||
@@ -75,11 +75,7 @@ const dataSetHandle = (dataset: typeof dataJson) => {
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
newData => {
|
||||
try {
|
||||
dataSetHandle(newData)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
dataSetHandle(newData)
|
||||
},
|
||||
{
|
||||
deep: false
|
||||
|
||||
@@ -57,11 +57,7 @@ const option = shallowReactive({
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
(newData: any) => {
|
||||
try {
|
||||
option.dataset = toNumber(newData, 2)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
option.dataset = toNumber(newData, 2)
|
||||
},
|
||||
{
|
||||
deep: false
|
||||
|
||||
@@ -57,11 +57,7 @@ const dataSetHandle = (dataset: typeof dataJson) => {
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
newData => {
|
||||
try {
|
||||
dataSetHandle(newData)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
dataSetHandle(newData)
|
||||
},
|
||||
{
|
||||
deep: false
|
||||
|
||||
@@ -49,12 +49,8 @@ const dataSetHandle = (dataset: typeof dataJson) => {
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
newData => {
|
||||
try {
|
||||
if (!isArray(newData)) return
|
||||
dataSetHandle(newData)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
if(!isArray(newData)) return
|
||||
dataSetHandle(newData)
|
||||
},
|
||||
{
|
||||
deep: false
|
||||
|
||||
@@ -42,27 +42,23 @@ const option = reactive({
|
||||
watch(
|
||||
() => chartEditStore.getEditCanvasConfig.chartThemeColor,
|
||||
(newColor: keyof typeof chartColorsSearch) => {
|
||||
try {
|
||||
if (!isPreview()) {
|
||||
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
||||
// 背景颜色
|
||||
props.chartConfig.option.series[0].backgroundStyle.color = themeColor[2]
|
||||
// 水球颜色
|
||||
props.chartConfig.option.series[0].color[0].colorStops = [
|
||||
{
|
||||
offset: 0,
|
||||
color: themeColor[0]
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: themeColor[1]
|
||||
}
|
||||
]
|
||||
}
|
||||
option.value = props.chartConfig.option
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
if (!isPreview()) {
|
||||
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
||||
// 背景颜色
|
||||
props.chartConfig.option.series[0].backgroundStyle.color = themeColor[2]
|
||||
// 水球颜色
|
||||
props.chartConfig.option.series[0].color[0].colorStops = [
|
||||
{
|
||||
offset: 0,
|
||||
color: themeColor[0]
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: themeColor[1]
|
||||
}
|
||||
]
|
||||
}
|
||||
option.value = props.chartConfig.option
|
||||
},
|
||||
{
|
||||
immediate: true
|
||||
@@ -79,7 +75,7 @@ const dataHandle = (newData: number | string) => {
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
newData => {
|
||||
if (!isString(newData) && !isNumber(newData)) return
|
||||
if(!isString(newData) && !isNumber(newData)) return
|
||||
props.chartConfig.option.series[0].data = [dataHandle(newData)]
|
||||
option.value = props.chartConfig.option
|
||||
},
|
||||
|
||||
@@ -48,13 +48,7 @@ const dataHandle = (newData: any) => {
|
||||
// 配置时
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
newData => {
|
||||
try {
|
||||
dataHandle(newData)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
},
|
||||
newData => dataHandle(newData),
|
||||
{
|
||||
immediate: true,
|
||||
deep: false
|
||||
|
||||
@@ -39,19 +39,15 @@ const option = computed(() => {
|
||||
watch(
|
||||
() => props.chartConfig.option.type,
|
||||
newData => {
|
||||
try {
|
||||
if (newData === 'nomal') {
|
||||
props.chartConfig.option.series[0].radius = '70%'
|
||||
props.chartConfig.option.series[0].roseType = false
|
||||
} else if (newData === 'ring') {
|
||||
props.chartConfig.option.series[0].radius = ['40%', '65%']
|
||||
props.chartConfig.option.series[0].roseType = false
|
||||
} else {
|
||||
props.chartConfig.option.series[0].radius = '70%'
|
||||
props.chartConfig.option.series[0].roseType = true
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
if (newData === 'nomal') {
|
||||
props.chartConfig.option.series[0].radius = '70%'
|
||||
props.chartConfig.option.series[0].roseType = false
|
||||
} else if (newData === 'ring') {
|
||||
props.chartConfig.option.series[0].radius = ['40%', '65%']
|
||||
props.chartConfig.option.series[0].roseType = false
|
||||
} else {
|
||||
props.chartConfig.option.series[0].radius = '70%'
|
||||
props.chartConfig.option.series[0].roseType = true
|
||||
}
|
||||
},
|
||||
{ deep: false, immediate: true }
|
||||
|
||||
@@ -4,7 +4,7 @@ import { CreateComponentType } from '@/packages/index.d'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import dataJson from './data.json'
|
||||
|
||||
export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
|
||||
export const includes = ['legend', 'xAxis', 'yAxis']
|
||||
|
||||
export const seriesItem = {
|
||||
type: 'scatter',
|
||||
|
||||
@@ -69,21 +69,17 @@ const option = computed(() => {
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
(newData, oldData) => {
|
||||
try {
|
||||
if (!isArray(newData)) return
|
||||
if (Array.isArray(newData)) {
|
||||
replaceMergeArr.value = ['series']
|
||||
// eslint-disable-next-line vue/no-mutating-props
|
||||
props.chartConfig.option.series = newData.map((item: { dimensions: any[] }, index: number) => ({
|
||||
...seriesItem,
|
||||
datasetIndex: index
|
||||
}))
|
||||
nextTick(() => {
|
||||
replaceMergeArr.value = []
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
if (!isArray(newData)) return
|
||||
if (newData?.length !== oldData?.length) {
|
||||
replaceMergeArr.value = ['series']
|
||||
// eslint-disable-next-line vue/no-mutating-props
|
||||
props.chartConfig.option.series = newData.map((item: { dimensions: any[] }, index: number) => ({
|
||||
...seriesItem,
|
||||
datasetIndex: index
|
||||
}))
|
||||
nextTick(() => {
|
||||
replaceMergeArr.value = []
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ import { CreateComponentType } from '@/packages/index.d'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import dataJson from './data.json'
|
||||
|
||||
export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
|
||||
export const includes = ['legend', 'xAxis', 'yAxis']
|
||||
|
||||
export const option = {
|
||||
dataset: dataJson,
|
||||
|
||||
@@ -133,14 +133,10 @@ const renderCountdown: CountdownProps['render'] = ({ hours, minutes, seconds })
|
||||
}
|
||||
|
||||
const updateTotalDuration = () => {
|
||||
try {
|
||||
countdownActive.value = false
|
||||
totalDuration.value = useEndDate.value ? endDate.value - new Date().getTime() : dataset.value * 1000
|
||||
countdownRef.value?.reset && countdownRef.value?.reset()
|
||||
countdownActive.value = true
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
countdownActive.value = false
|
||||
totalDuration.value = useEndDate.value ? endDate.value - new Date().getTime() : dataset.value * 1000
|
||||
countdownRef.value?.reset && countdownRef.value?.reset()
|
||||
countdownActive.value = true
|
||||
}
|
||||
|
||||
watch(
|
||||
|
||||
@@ -60,11 +60,7 @@ const updateDatasetHandler = (newVal: string | number) => {
|
||||
watch(
|
||||
() => props.chartConfig.option,
|
||||
newVal => {
|
||||
try {
|
||||
updateDatasetHandler((newVal as OptionType).dataset)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
updateDatasetHandler((newVal as OptionType).dataset)
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
|
||||
@@ -11,23 +11,23 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType, toRefs, ref, reactive, watch, onMounted, onUnmounted } from 'vue'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { useChartDataFetch } from '@/hooks'
|
||||
import { PropType, toRefs, ref, reactive, watch, onMounted, onUnmounted } from "vue";
|
||||
import { CreateComponentType } from "@/packages/index.d";
|
||||
import { useChartEditStore } from "@/store/modules/chartEditStore/chartEditStore";
|
||||
import { useChartDataFetch } from "@/hooks";
|
||||
|
||||
const props = defineProps({
|
||||
chartConfig: {
|
||||
type: Object as PropType<CreateComponentType>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
let yearMonthDay = ref('2021-2-3')
|
||||
let nowData = ref('08:00:00')
|
||||
let newData = ref('2021-2-3 08:00:00')
|
||||
let boxShadow = ref('none')
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
let yearMonthDay = ref("2021-2-3");
|
||||
let nowData = ref("08:00:00");
|
||||
let newData = ref("2021-2-3 08:00:00");
|
||||
let boxShadow = ref("none");
|
||||
|
||||
const { w, h } = toRefs(props.chartConfig.attr)
|
||||
const { w, h } = toRefs(props.chartConfig.attr);
|
||||
|
||||
let {
|
||||
timeColor,
|
||||
@@ -39,55 +39,54 @@ let {
|
||||
hShadow,
|
||||
vShadow,
|
||||
blurShadow,
|
||||
colorShadow
|
||||
} = toRefs(props.chartConfig.option)
|
||||
colorShadow,
|
||||
} = toRefs(props.chartConfig.option);
|
||||
|
||||
watch(
|
||||
props.chartConfig.option,
|
||||
() => {
|
||||
try {
|
||||
if (props.chartConfig.option.showShadow) {
|
||||
boxShadow.value = `${props.chartConfig.option.hShadow}px ${props.chartConfig.option.vShadow}px ${props.chartConfig.option.blurShadow}px ${props.chartConfig.option.colorShadow}`
|
||||
} else {
|
||||
boxShadow.value = 'none'
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
if (props.chartConfig.option.showShadow) {
|
||||
boxShadow.value = `${props.chartConfig.option.hShadow}px ${props.chartConfig.option.vShadow}px ${props.chartConfig.option.blurShadow}px ${props.chartConfig.option.colorShadow}`;
|
||||
} else {
|
||||
boxShadow.value = "none";
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: true
|
||||
immediate: true,
|
||||
}
|
||||
)
|
||||
);
|
||||
onMounted(() => {
|
||||
const timer = setInterval(() => {
|
||||
var datetime = new Date()
|
||||
var year = datetime.getFullYear()
|
||||
var month = datetime.getMonth() + 1 < 10 ? '0' + (datetime.getMonth() + 1) : datetime.getMonth() + 1
|
||||
var date = datetime.getDate() < 10 ? '0' + datetime.getDate() : datetime.getDate()
|
||||
var hh = datetime.getHours() // 时
|
||||
var mm = datetime.getMinutes() // 分
|
||||
var ss = datetime.getSeconds() // 分
|
||||
let time = ''
|
||||
if (hh < 10) time += '0'
|
||||
time += hh + ':'
|
||||
if (mm < 10) time += '0'
|
||||
time += mm + ':'
|
||||
if (ss < 10) time += '0'
|
||||
time += ss
|
||||
yearMonthDay.value = `${year}-${month}-${date}`
|
||||
nowData.value = time
|
||||
newData.value = yearMonthDay.value + ' ' + nowData.value
|
||||
}, 500)
|
||||
})
|
||||
var datetime = new Date();
|
||||
var year = datetime.getFullYear();
|
||||
var month =
|
||||
datetime.getMonth() + 1 < 10
|
||||
? "0" + (datetime.getMonth() + 1)
|
||||
: datetime.getMonth() + 1;
|
||||
var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
|
||||
var hh = datetime.getHours(); // 时
|
||||
var mm = datetime.getMinutes(); // 分
|
||||
var ss = datetime.getSeconds(); // 分
|
||||
let time = "";
|
||||
if (hh < 10) time += "0";
|
||||
time += hh + ":";
|
||||
if (mm < 10) time += "0";
|
||||
time += mm + ":";
|
||||
if (ss < 10) time += "0";
|
||||
time += ss;
|
||||
yearMonthDay.value = `${year}-${month}-${date}`;
|
||||
nowData.value = time;
|
||||
newData.value = yearMonthDay.value + " " + nowData.value;
|
||||
}, 500);
|
||||
});
|
||||
onUnmounted(() => {
|
||||
clearInterval()
|
||||
})
|
||||
useChartDataFetch(props.chartConfig, useChartEditStore)
|
||||
clearInterval();
|
||||
});
|
||||
useChartDataFetch(props.chartConfig, useChartEditStore);
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@include go('decorates-number') {
|
||||
@include go("decorates-number") {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,236 +0,0 @@
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-nocheck
|
||||
import {
|
||||
ArcCurve,
|
||||
BufferAttribute,
|
||||
BufferGeometry,
|
||||
Color,
|
||||
Line,
|
||||
LineBasicMaterial,
|
||||
Points,
|
||||
PointsMaterial,
|
||||
Quaternion,
|
||||
Vector3
|
||||
} from 'three'
|
||||
import { lon2xyz } from './common'
|
||||
|
||||
/*
|
||||
* 绘制一条圆弧飞线
|
||||
* 5个参数含义:( 飞线圆弧轨迹半径, 开始角度, 结束角度)
|
||||
*/
|
||||
function createFlyLine(radius, startAngle, endAngle, color) {
|
||||
const geometry = new BufferGeometry() //声明一个几何体对象BufferGeometry
|
||||
// ArcCurve创建圆弧曲线
|
||||
const arc = new ArcCurve(0, 0, radius, startAngle, endAngle, false)
|
||||
//getSpacedPoints是基类Curve的方法,返回一个vector2对象作为元素组成的数组
|
||||
const pointsArr = arc.getSpacedPoints(100) //分段数80,返回81个顶点
|
||||
geometry.setFromPoints(pointsArr) // setFromPoints方法从pointsArr中提取数据改变几何体的顶点属性vertices
|
||||
// 每个顶点对应一个百分比数据attributes.percent 用于控制点的渲染大小
|
||||
const percentArr = [] //attributes.percent的数据
|
||||
for (let i = 0; i < pointsArr.length; i++) {
|
||||
percentArr.push(i / pointsArr.length)
|
||||
}
|
||||
const percentAttribue = new BufferAttribute(new Float32Array(percentArr), 1)
|
||||
// 通过顶点数据percent点模型从大到小变化,产生小蝌蚪形状飞线
|
||||
geometry.attributes.percent = percentAttribue
|
||||
// 批量计算所有顶点颜色数据
|
||||
const colorArr = []
|
||||
for (let i = 0; i < pointsArr.length; i++) {
|
||||
const color1 = new Color(0xec8f43) //轨迹线颜色 青色
|
||||
const color2 = new Color(0xf3ae76) //黄色
|
||||
const color = color1.lerp(color2, i / pointsArr.length)
|
||||
colorArr.push(color.r, color.g, color.b)
|
||||
}
|
||||
// 设置几何体顶点颜色数据
|
||||
geometry.attributes.color = new BufferAttribute(new Float32Array(colorArr), 3)
|
||||
const size = 1.3
|
||||
// 点模型渲染几何体每个顶点
|
||||
const material = new PointsMaterial({
|
||||
size, //点大小
|
||||
// vertexColors: VertexColors, //使用顶点颜色渲染
|
||||
transparent: true,
|
||||
depthWrite: false
|
||||
})
|
||||
// 修改点材质的着色器源码(注意:不同版本细节可能会稍微会有区别,不过整体思路是一样的)
|
||||
material.onBeforeCompile = function (shader) {
|
||||
// 顶点着色器中声明一个attribute变量:百分比
|
||||
shader.vertexShader = shader.vertexShader.replace(
|
||||
'void main() {',
|
||||
[
|
||||
'attribute float percent;', //顶点大小百分比变量,控制点渲染大小
|
||||
'void main() {'
|
||||
].join('\n') // .join()把数组元素合成字符串
|
||||
)
|
||||
// 调整点渲染大小计算方式
|
||||
shader.vertexShader = shader.vertexShader.replace(
|
||||
'gl_PointSize = size;',
|
||||
['gl_PointSize = percent * size;'].join('\n') // .join()把数组元素合成字符串
|
||||
)
|
||||
}
|
||||
const FlyLine = new Points(geometry, material)
|
||||
material.color = new Color(color)
|
||||
FlyLine.name = '飞行线'
|
||||
|
||||
return FlyLine
|
||||
}
|
||||
|
||||
/**输入地球上任意两点的经纬度坐标,通过函数flyArc可以绘制一个飞线圆弧轨迹
|
||||
* lon1,lat1:轨迹线起点经纬度坐标
|
||||
* lon2,lat2:轨迹线结束点经纬度坐标
|
||||
*/
|
||||
function flyArc(radius, lon1, lat1, lon2, lat2, options) {
|
||||
const sphereCoord1 = lon2xyz(radius, lon1, lat1) //经纬度坐标转球面坐标
|
||||
// startSphereCoord:轨迹线起点球面坐标
|
||||
const startSphereCoord = new Vector3(sphereCoord1.x, sphereCoord1.y, sphereCoord1.z)
|
||||
const sphereCoord2 = lon2xyz(radius, lon2, lat2)
|
||||
// startSphereCoord:轨迹线结束点球面坐标
|
||||
const endSphereCoord = new Vector3(sphereCoord2.x, sphereCoord2.y, sphereCoord2.z)
|
||||
|
||||
//计算绘制圆弧需要的关于y轴对称的起点、结束点和旋转四元数
|
||||
const startEndQua = _3Dto2D(startSphereCoord, endSphereCoord)
|
||||
// 调用arcXOY函数绘制一条圆弧飞线轨迹
|
||||
const arcline = arcXOY(radius, startEndQua.startPoint, startEndQua.endPoint, options)
|
||||
arcline.quaternion.multiply(startEndQua.quaternion)
|
||||
return arcline
|
||||
}
|
||||
/*
|
||||
* 把3D球面上任意的两个飞线起点和结束点绕球心旋转到到XOY平面上,
|
||||
* 同时保持关于y轴对称,借助旋转得到的新起点和新结束点绘制
|
||||
* 一个圆弧,最后把绘制的圆弧反向旋转到原来的起点和结束点即可
|
||||
*/
|
||||
function _3Dto2D(startSphere, endSphere) {
|
||||
/*计算第一次旋转的四元数:表示从一个平面如何旋转到另一个平面*/
|
||||
const origin = new Vector3(0, 0, 0) //球心坐标
|
||||
const startDir = startSphere.clone().sub(origin) //飞线起点与球心构成方向向量
|
||||
const endDir = endSphere.clone().sub(origin) //飞线结束点与球心构成方向向量
|
||||
// dir1和dir2构成一个三角形,.cross()叉乘计算该三角形法线normal
|
||||
const normal = startDir.clone().cross(endDir).normalize()
|
||||
const xoyNormal = new Vector3(0, 0, 1) //XOY平面的法线
|
||||
//.setFromUnitVectors()计算从normal向量旋转达到xoyNormal向量所需要的四元数
|
||||
// quaternion表示把球面飞线旋转到XOY平面上需要的四元数
|
||||
const quaternion3D_XOY = new Quaternion().setFromUnitVectors(normal, xoyNormal)
|
||||
/*第一次旋转:飞线起点、结束点从3D空间第一次旋转到XOY平面*/
|
||||
const startSphereXOY = startSphere.clone().applyQuaternion(quaternion3D_XOY)
|
||||
const endSphereXOY = endSphere.clone().applyQuaternion(quaternion3D_XOY)
|
||||
|
||||
/*计算第二次旋转的四元数*/
|
||||
// middleV3:startSphereXOY和endSphereXOY的中点
|
||||
const middleV3 = startSphereXOY.clone().add(endSphereXOY).multiplyScalar(0.5)
|
||||
const midDir = middleV3.clone().sub(origin).normalize() // 旋转前向量midDir,中点middleV3和球心构成的方向向量
|
||||
const yDir = new Vector3(0, 1, 0) // 旋转后向量yDir,即y轴
|
||||
// .setFromUnitVectors()计算从midDir向量旋转达到yDir向量所需要的四元数
|
||||
// quaternion2表示让第一次旋转到XOY平面的起点和结束点关于y轴对称需要的四元数
|
||||
const quaternionXOY_Y = new Quaternion().setFromUnitVectors(midDir, yDir)
|
||||
|
||||
/*第二次旋转:使旋转到XOY平面的点再次旋转,实现关于Y轴对称*/
|
||||
const startSpherXOY_Y = startSphereXOY.clone().applyQuaternion(quaternionXOY_Y)
|
||||
const endSphereXOY_Y = endSphereXOY.clone().applyQuaternion(quaternionXOY_Y)
|
||||
|
||||
/**一个四元数表示一个旋转过程
|
||||
*.invert()方法表示四元数的逆,简单说就是把旋转过程倒过来
|
||||
* 两次旋转的四元数执行.invert()求逆,然后执行.multiply()相乘
|
||||
*新版本.invert()对应旧版本.invert()
|
||||
*/
|
||||
const quaternionInverse = quaternion3D_XOY.clone().invert().multiply(quaternionXOY_Y.clone().invert())
|
||||
return {
|
||||
// 返回两次旋转四元数的逆四元数
|
||||
quaternion: quaternionInverse,
|
||||
// 范围两次旋转后在XOY平面上关于y轴对称的圆弧起点和结束点坐标
|
||||
startPoint: startSpherXOY_Y,
|
||||
endPoint: endSphereXOY_Y
|
||||
}
|
||||
}
|
||||
/**通过函数arcXOY()可以在XOY平面上绘制一个关于y轴对称的圆弧曲线
|
||||
* startPoint, endPoint:表示圆弧曲线的起点和结束点坐标值,起点和结束点关于y轴对称
|
||||
* 同时在圆弧轨迹的基础上绘制一段飞线*/
|
||||
function arcXOY(radius, startPoint, endPoint, options) {
|
||||
// 计算两点的中点
|
||||
const middleV3 = new Vector3().addVectors(startPoint, endPoint).multiplyScalar(0.5)
|
||||
// 弦垂线的方向dir(弦的中点和圆心构成的向量)
|
||||
const dir = middleV3.clone().normalize()
|
||||
// 计算球面飞线的起点、结束点和球心构成夹角的弧度值
|
||||
const earthRadianAngle = radianAOB(startPoint, endPoint, new Vector3(0, 0, 0))
|
||||
/*设置飞线轨迹圆弧的中间点坐标
|
||||
弧度值 * radius * 0.2:表示飞线轨迹圆弧顶部距离地球球面的距离
|
||||
起点、结束点相聚越远,构成的弧线顶部距离球面越高*/
|
||||
const arcTopCoord = dir.multiplyScalar(radius + earthRadianAngle * radius * 0.2) // 黄色飞行线的高度
|
||||
//求三个点的外接圆圆心(飞线圆弧轨迹的圆心坐标)
|
||||
const flyArcCenter = threePointCenter(startPoint, endPoint, arcTopCoord)
|
||||
// 飞线圆弧轨迹半径flyArcR
|
||||
const flyArcR = Math.abs(flyArcCenter.y - arcTopCoord.y)
|
||||
/*坐标原点和飞线起点构成直线和y轴负半轴夹角弧度值
|
||||
参数分别是:飞线圆弧起点、y轴负半轴上一点、飞线圆弧圆心*/
|
||||
const flyRadianAngle = radianAOB(startPoint, new Vector3(0, -1, 0), flyArcCenter)
|
||||
const startAngle = -Math.PI / 2 + flyRadianAngle //飞线圆弧开始角度
|
||||
const endAngle = Math.PI - startAngle //飞线圆弧结束角度
|
||||
// 调用圆弧线模型的绘制函数
|
||||
const arcline = circleLine(flyArcCenter.x, flyArcCenter.y, flyArcR, startAngle, endAngle, options.color)
|
||||
// const arcline = new Group();// 不绘制轨迹线,使用 Group替换circleLine()即可
|
||||
arcline.center = flyArcCenter //飞线圆弧自定一个属性表示飞线圆弧的圆心
|
||||
arcline.topCoord = arcTopCoord //飞线圆弧自定一个属性表示飞线圆弧中间也就是顶部坐标
|
||||
|
||||
// const flyAngle = Math.PI/ 10; //飞线圆弧固定弧度
|
||||
const flyAngle = (endAngle - startAngle) / 7 //飞线圆弧的弧度和轨迹线弧度相关
|
||||
// 绘制一段飞线,圆心做坐标原点
|
||||
const flyLine = createFlyLine(flyArcR, startAngle, startAngle + flyAngle, options.flyLineColor)
|
||||
flyLine.position.y = flyArcCenter.y //平移飞线圆弧和飞线轨迹圆弧重合
|
||||
//飞线段flyLine作为飞线轨迹arcLine子对象,继承飞线轨迹平移旋转等变换
|
||||
arcline.add(flyLine)
|
||||
//飞线段运动范围startAngle~flyEndAngle
|
||||
flyLine.flyEndAngle = endAngle - startAngle - flyAngle
|
||||
flyLine.startAngle = startAngle
|
||||
// arcline.flyEndAngle:飞线段当前角度位置,这里设置了一个随机值用于演示
|
||||
flyLine.AngleZ = arcline.flyEndAngle * Math.random()
|
||||
// flyLine.rotation.z = arcline.AngleZ;
|
||||
// arcline.flyLine指向飞线段,便于设置动画是访问飞线段
|
||||
arcline.userData['flyLine'] = flyLine
|
||||
|
||||
return arcline
|
||||
}
|
||||
/*计算球面上两点和球心构成夹角的弧度值
|
||||
参数point1, point2:表示地球球面上两点坐标Vector3
|
||||
计算A、B两点和顶点O构成的AOB夹角弧度值*/
|
||||
function radianAOB(A, B, O) {
|
||||
// dir1、dir2:球面上两个点和球心构成的方向向量
|
||||
const dir1 = A.clone().sub(O).normalize()
|
||||
const dir2 = B.clone().sub(O).normalize()
|
||||
//点乘.dot()计算夹角余弦值
|
||||
const cosAngle = dir1.clone().dot(dir2)
|
||||
const radianAngle = Math.acos(cosAngle) //余弦值转夹角弧度值,通过余弦值可以计算夹角范围是0~180度
|
||||
return radianAngle
|
||||
}
|
||||
/*绘制一条圆弧曲线模型Line
|
||||
5个参数含义:(圆心横坐标, 圆心纵坐标, 飞线圆弧轨迹半径, 开始角度, 结束角度)*/
|
||||
function circleLine(x, y, r, startAngle, endAngle, color) {
|
||||
const geometry = new BufferGeometry() //声明一个几何体对象Geometry
|
||||
// ArcCurve创建圆弧曲线
|
||||
const arc = new ArcCurve(x, y, r, startAngle, endAngle, false)
|
||||
//getSpacedPoints是基类Curve的方法,返回一个vector2对象作为元素组成的数组
|
||||
const points = arc.getSpacedPoints(80) //分段数50,返回51个顶点
|
||||
geometry.setFromPoints(points) // setFromPoints方法从points中提取数据改变几何体的顶点属性vertices
|
||||
const material = new LineBasicMaterial({
|
||||
color: color || 0xd18547
|
||||
}) //线条材质
|
||||
const line = new Line(geometry, material) //线条模型对象
|
||||
return line
|
||||
}
|
||||
//求三个点的外接圆圆心,p1, p2, p3表示三个点的坐标Vector3。
|
||||
function threePointCenter(p1, p2, p3) {
|
||||
const L1 = p1.lengthSq() //p1到坐标原点距离的平方
|
||||
const L2 = p2.lengthSq()
|
||||
const L3 = p3.lengthSq()
|
||||
const x1 = p1.x,
|
||||
y1 = p1.y,
|
||||
x2 = p2.x,
|
||||
y2 = p2.y,
|
||||
x3 = p3.x,
|
||||
y3 = p3.y
|
||||
const S = x1 * y2 + x2 * y3 + x3 * y1 - x1 * y3 - x2 * y1 - x3 * y2
|
||||
const x = (L2 * y3 + L1 * y2 + L3 * y1 - L2 * y1 - L3 * y2 - L1 * y3) / S / 2
|
||||
const y = (L3 * x2 + L2 * x1 + L1 * x3 - L1 * x2 - L2 * x3 - L3 * x1) / S / 2
|
||||
// 三点外接圆圆心坐标
|
||||
const center = new Vector3(x, y, 0)
|
||||
return center
|
||||
}
|
||||
|
||||
export { arcXOY, flyArc }
|
||||
@@ -1,137 +0,0 @@
|
||||
import {
|
||||
CatmullRomCurve3,
|
||||
DoubleSide,
|
||||
Group,
|
||||
Mesh,
|
||||
MeshBasicMaterial,
|
||||
PlaneGeometry,
|
||||
Texture,
|
||||
TubeGeometry,
|
||||
Vector3
|
||||
} from 'three'
|
||||
import { punctuation } from '../world/Earth'
|
||||
|
||||
/**
|
||||
* 经纬度坐标转球面坐标
|
||||
* @param {地球半径} R
|
||||
* @param {经度(角度值)} longitude
|
||||
* @param {维度(角度值)} latitude
|
||||
*/
|
||||
export const lon2xyz = (R: number, longitude: number, latitude: number): Vector3 => {
|
||||
let lon = (longitude * Math.PI) / 180 // 转弧度值
|
||||
const lat = (latitude * Math.PI) / 180 // 转弧度值
|
||||
lon = -lon // js坐标系z坐标轴对应经度-90度,而不是90度
|
||||
|
||||
// 经纬度坐标转球面坐标计算公式
|
||||
const x = R * Math.cos(lat) * Math.cos(lon)
|
||||
const y = R * Math.sin(lat)
|
||||
const z = R * Math.cos(lat) * Math.sin(lon)
|
||||
// 返回球面坐标
|
||||
return new Vector3(x, y, z)
|
||||
}
|
||||
|
||||
// 创建波动光圈
|
||||
export const createWaveMesh = (options: { radius: number; lon: number; lat: number; textures: any }) => {
|
||||
const geometry = new PlaneGeometry(1, 1) //默认在XOY平面上
|
||||
const texture = options.textures.aperture
|
||||
|
||||
const material = new MeshBasicMaterial({
|
||||
color: 0xe99f68,
|
||||
map: texture,
|
||||
transparent: true, //使用背景透明的png贴图,注意开启透明计算
|
||||
opacity: 1.0,
|
||||
depthWrite: false //禁止写入深度缓冲区数据
|
||||
})
|
||||
const mesh = new Mesh(geometry, material)
|
||||
// 经纬度转球面坐标
|
||||
const coord = lon2xyz(options.radius * 1.001, options.lon, options.lat)
|
||||
const size = options.radius * 0.12 //矩形平面Mesh的尺寸
|
||||
mesh.scale.set(size, size, size) //设置mesh大小
|
||||
mesh.userData['size'] = size //自顶一个属性,表示mesh静态大小
|
||||
mesh.userData['scale'] = Math.random() * 1.0 //自定义属性._s表示mesh在原始大小基础上放大倍数 光圈在原来mesh.size基础上1~2倍之间变化
|
||||
mesh.position.set(coord.x, coord.y, coord.z)
|
||||
const coordVec3 = new Vector3(coord.x, coord.y, coord.z).normalize()
|
||||
const meshNormal = new Vector3(0, 0, 1)
|
||||
mesh.quaternion.setFromUnitVectors(meshNormal, coordVec3)
|
||||
return mesh
|
||||
}
|
||||
|
||||
// 创建柱状
|
||||
export const createLightPillar = (options: {
|
||||
radius: number
|
||||
lon: number
|
||||
lat: number
|
||||
index: number
|
||||
textures: Record<string, Texture>
|
||||
punctuation: punctuation
|
||||
}) => {
|
||||
const height = options.radius * 0.3
|
||||
const geometry = new PlaneGeometry(options.radius * 0.05, height)
|
||||
geometry.rotateX(Math.PI / 2)
|
||||
geometry.translate(0, 0, height / 2)
|
||||
const material = new MeshBasicMaterial({
|
||||
map: options.textures.light_column,
|
||||
color: options.index == 0 ? options.punctuation.lightColumn.startColor : options.punctuation.lightColumn.endColor,
|
||||
transparent: true,
|
||||
side: DoubleSide,
|
||||
depthWrite: false //是否对深度缓冲区有任何的影响
|
||||
})
|
||||
const mesh = new Mesh(geometry, material)
|
||||
const group = new Group()
|
||||
// 两个光柱交叉叠加
|
||||
group.add(mesh, mesh.clone().rotateZ(Math.PI / 2)) //几何体绕x轴旋转了,所以mesh旋转轴变为z
|
||||
// 经纬度转球面坐标
|
||||
const SphereCoord = lon2xyz(options.radius, options.lon, options.lat) //SphereCoord球面坐标
|
||||
group.position.set(SphereCoord.x, SphereCoord.y, SphereCoord.z) //设置mesh位置
|
||||
const coordVec3 = new Vector3(SphereCoord.x, SphereCoord.y, SphereCoord.z).normalize()
|
||||
const meshNormal = new Vector3(0, 0, 1)
|
||||
group.quaternion.setFromUnitVectors(meshNormal, coordVec3)
|
||||
return group
|
||||
}
|
||||
|
||||
// 光柱底座矩形平面
|
||||
export const createPointMesh = (options: { radius: number; lon: number; lat: number; material: MeshBasicMaterial }) => {
|
||||
const geometry = new PlaneGeometry(1, 1) //默认在XOY平面上
|
||||
const mesh = new Mesh(geometry, options.material)
|
||||
// 经纬度转球面坐标
|
||||
const coord = lon2xyz(options.radius * 1.001, options.lon, options.lat)
|
||||
const size = options.radius * 0.05 // 矩形平面Mesh的尺寸
|
||||
mesh.scale.set(size, size, size) // 设置mesh大小
|
||||
|
||||
// 设置mesh位置
|
||||
mesh.position.set(coord.x, coord.y, coord.z)
|
||||
const coordVec3 = new Vector3(coord.x, coord.y, coord.z).normalize()
|
||||
const meshNormal = new Vector3(0, 0, 1)
|
||||
mesh.quaternion.setFromUnitVectors(meshNormal, coordVec3)
|
||||
return mesh
|
||||
}
|
||||
|
||||
// 获取点
|
||||
export const getCirclePoints = (option: any) => {
|
||||
const list = []
|
||||
for (let j = 0; j < 2 * Math.PI - 0.1; j += (2 * Math.PI) / (option.number || 100)) {
|
||||
list.push([
|
||||
parseFloat((Math.cos(j) * (option.radius || 10)).toFixed(2)),
|
||||
0,
|
||||
parseFloat((Math.sin(j) * (option.radius || 10)).toFixed(2))
|
||||
])
|
||||
}
|
||||
if (option.closed) list.push(list[0])
|
||||
return list
|
||||
}
|
||||
|
||||
// 创建线
|
||||
|
||||
/**
|
||||
* 创建动态的线
|
||||
*/
|
||||
export const createAnimateLine = (option: any) => {
|
||||
// 由多个点数组构成的曲线 通常用于道路
|
||||
const l: Array<any> = []
|
||||
option.pointList.forEach((e: Array<any>) => l.push(new Vector3(e[0], e[1], e[2])))
|
||||
const curve = new CatmullRomCurve3(l) // 曲线路径
|
||||
|
||||
// 管道体
|
||||
const tubeGeometry = new TubeGeometry(curve, option.number || 50, option.radius || 1, option.radialSegments)
|
||||
return new Mesh(tubeGeometry, option.material)
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
export interface IEvents {
|
||||
resize: () => void
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
export interface IWord {
|
||||
dom: HTMLElement
|
||||
data: any
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
uniform vec3 glowColor;
|
||||
uniform float bias;
|
||||
uniform float power;
|
||||
uniform float time;
|
||||
varying vec3 vp;
|
||||
varying vec3 vNormal;
|
||||
varying vec3 vPositionNormal;
|
||||
uniform float scale;
|
||||
// 获取纹理
|
||||
uniform sampler2D map;
|
||||
// 纹理坐标
|
||||
varying vec2 vUv;
|
||||
|
||||
void main(void){
|
||||
float a = pow( bias + scale * abs(dot(vNormal, vPositionNormal)), power );
|
||||
if(vp.y > time && vp.y < time + 20.0) {
|
||||
float t = smoothstep(0.0, 0.8, (1.0 - abs(0.5 - (vp.y - time) / 20.0)) / 3.0 );
|
||||
gl_FragColor = mix(gl_FragColor, vec4(glowColor, 1.0), t * t );
|
||||
}
|
||||
gl_FragColor = mix(gl_FragColor, vec4( glowColor, 1.0 ), a);
|
||||
float b = 0.8;
|
||||
gl_FragColor = gl_FragColor + texture2D( map, vUv );
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
|
||||
varying vec2 vUv;
|
||||
varying vec3 vNormal;
|
||||
varying vec3 vp;
|
||||
varying vec3 vPositionNormal;
|
||||
void main(void){
|
||||
vUv = uv;
|
||||
vNormal = normalize( normalMatrix * normal ); // 转换到视图空间
|
||||
vp = position;
|
||||
vPositionNormal = normalize(( modelViewMatrix * vec4(position, 1.0) ).xyz);
|
||||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/**
|
||||
* 资源文件
|
||||
* 把模型和图片分开进行加载
|
||||
*/
|
||||
|
||||
interface ITextures {
|
||||
name: string
|
||||
url: string
|
||||
}
|
||||
|
||||
export interface IResources {
|
||||
textures?: ITextures[]
|
||||
}
|
||||
|
||||
const fileSuffix = ['earth', 'gradient', 'redCircle', 'label', 'aperture', 'glow', 'light_column', 'aircraft']
|
||||
const textures: ITextures[] = []
|
||||
|
||||
const modules = import.meta.globEager("../../images/earth/*");
|
||||
|
||||
for(let item in modules) {
|
||||
const n = item.split('/').pop()
|
||||
if(n) {
|
||||
textures.push({
|
||||
name: n.split('.')[0],
|
||||
url: modules[item].default
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const resources: IResources = {
|
||||
textures
|
||||
}
|
||||
|
||||
export { resources }
|
||||
@@ -1,62 +0,0 @@
|
||||
/**
|
||||
* 创建 threejs 四大天王
|
||||
* 场景、相机、渲染器、控制器
|
||||
*/
|
||||
|
||||
import * as THREE from 'three'
|
||||
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
|
||||
|
||||
export class Basic {
|
||||
public scene!: THREE.Scene
|
||||
public camera!: THREE.PerspectiveCamera
|
||||
public renderer!: THREE.WebGLRenderer
|
||||
public controls!: OrbitControls
|
||||
public dom: HTMLElement
|
||||
|
||||
constructor(dom: HTMLElement) {
|
||||
this.dom = dom
|
||||
this.initScenes()
|
||||
this.setControls()
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化场景
|
||||
*/
|
||||
initScenes() {
|
||||
this.scene = new THREE.Scene()
|
||||
|
||||
this.camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 100000)
|
||||
this.camera.position.set(0, 30, -250)
|
||||
|
||||
this.renderer = new THREE.WebGLRenderer({
|
||||
// canvas: this.dom,
|
||||
alpha: true, // 透明
|
||||
antialias: true // 抗锯齿
|
||||
})
|
||||
this.renderer.setPixelRatio(window.devicePixelRatio) // 设置屏幕像素比
|
||||
this.renderer.setSize(window.innerWidth, window.innerHeight) // 设置渲染器宽高
|
||||
this.dom.appendChild(this.renderer.domElement) // 添加到dom中
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置控制器
|
||||
*/
|
||||
setControls() {
|
||||
// 鼠标控制 相机,渲染dom
|
||||
this.controls = new OrbitControls(this.camera, this.renderer.domElement)
|
||||
|
||||
this.controls.autoRotateSpeed = 3
|
||||
// 使动画循环使用时阻尼或自转 意思是否有惯性
|
||||
this.controls.enableDamping = true
|
||||
// 动态阻尼系数 就是鼠标拖拽旋转灵敏度
|
||||
this.controls.dampingFactor = 0.05
|
||||
// 是否可以缩放
|
||||
this.controls.enableZoom = true
|
||||
// 设置相机距离原点的最远距离
|
||||
this.controls.minDistance = 100
|
||||
// 设置相机距离原点的最远距离
|
||||
this.controls.maxDistance = 300
|
||||
// 是否开启右键拖拽
|
||||
this.controls.enablePan = false
|
||||
}
|
||||
}
|
||||
@@ -1,496 +0,0 @@
|
||||
import {
|
||||
BufferAttribute,
|
||||
BufferGeometry,
|
||||
Color,
|
||||
DoubleSide,
|
||||
Group,
|
||||
Material,
|
||||
Mesh,
|
||||
MeshBasicMaterial,
|
||||
NormalBlending,
|
||||
Object3D,
|
||||
Points,
|
||||
PointsMaterial,
|
||||
ShaderMaterial,
|
||||
SphereGeometry,
|
||||
Sprite,
|
||||
SpriteMaterial,
|
||||
Texture,
|
||||
TextureLoader,
|
||||
Vector3
|
||||
} from 'three'
|
||||
|
||||
import {
|
||||
createAnimateLine,
|
||||
createLightPillar,
|
||||
createPointMesh,
|
||||
createWaveMesh,
|
||||
getCirclePoints,
|
||||
lon2xyz
|
||||
} from '../Utils/common'
|
||||
import gsap from 'gsap'
|
||||
import { flyArc } from '../Utils/arc'
|
||||
import earthVertex from '../shaders/earth/vertex.vs?raw'
|
||||
import earthFragment from '../shaders/earth/fragment.fs?raw'
|
||||
|
||||
export type punctuation = {
|
||||
circleColor: number
|
||||
lightColumn: {
|
||||
startColor: number // 起点颜色
|
||||
endColor: number // 终点颜色
|
||||
}
|
||||
}
|
||||
|
||||
type options = {
|
||||
data: {
|
||||
startArray: {
|
||||
name: string
|
||||
E: number // 经度
|
||||
N: number // 维度
|
||||
}
|
||||
endArray: {
|
||||
name: string
|
||||
E: number // 经度
|
||||
N: number // 维度
|
||||
}[]
|
||||
}[]
|
||||
dom: HTMLElement
|
||||
textures: Record<string, Texture> // 贴图
|
||||
earth: {
|
||||
radius: number // 地球半径
|
||||
rotateSpeed: number // 地球旋转速度
|
||||
isRotation: boolean // 地球组是否自转
|
||||
}
|
||||
satellite: {
|
||||
show: boolean // 是否显示卫星
|
||||
rotateSpeed: number // 旋转速度
|
||||
size: number // 卫星大小
|
||||
number: number // 一个圆环几个球
|
||||
}
|
||||
punctuation: punctuation
|
||||
flyLine: {
|
||||
color: number // 飞线的颜色
|
||||
speed: number // 飞机拖尾线速度
|
||||
flyLineColor: number // 飞行线的颜色
|
||||
}
|
||||
}
|
||||
type uniforms = {
|
||||
glowColor: { value: Color }
|
||||
scale: { type: string; value: number }
|
||||
bias: { type: string; value: number }
|
||||
power: { type: string; value: number }
|
||||
time: { type: string; value: any }
|
||||
isHover: { value: boolean }
|
||||
map: { value?: Texture }
|
||||
}
|
||||
|
||||
export default class earth {
|
||||
public group: Group
|
||||
public earthGroup: Group
|
||||
|
||||
public around!: BufferGeometry
|
||||
public aroundPoints!: Points<BufferGeometry, PointsMaterial>
|
||||
|
||||
public options: options
|
||||
public uniforms: uniforms
|
||||
public timeValue: number
|
||||
|
||||
public earth!: Mesh<SphereGeometry, ShaderMaterial>
|
||||
public punctuationMaterial!: MeshBasicMaterial
|
||||
public markupPoint: Group
|
||||
public waveMeshArr: Object3D[]
|
||||
|
||||
public circleLineList: any[]
|
||||
public circleList: any[]
|
||||
public x: number
|
||||
public n: number
|
||||
public isRotation: boolean
|
||||
public flyLineArcGroup!: Group
|
||||
|
||||
constructor(options: options) {
|
||||
this.options = options
|
||||
|
||||
this.group = new Group()
|
||||
this.group.name = 'group'
|
||||
this.group.scale.set(0, 0, 0)
|
||||
this.earthGroup = new Group()
|
||||
this.group.add(this.earthGroup)
|
||||
this.earthGroup.name = 'EarthGroup'
|
||||
|
||||
// 标注点效果
|
||||
this.markupPoint = new Group()
|
||||
this.markupPoint.name = 'markupPoint'
|
||||
this.waveMeshArr = []
|
||||
|
||||
// 卫星和标签
|
||||
this.circleLineList = []
|
||||
this.circleList = []
|
||||
this.x = 0
|
||||
this.n = 0
|
||||
|
||||
// 地球自转
|
||||
this.isRotation = this.options.earth.isRotation
|
||||
|
||||
// 扫光动画 shader
|
||||
this.timeValue = 200
|
||||
|
||||
this.uniforms = {
|
||||
glowColor: {
|
||||
value: new Color(0x0cd1eb)
|
||||
},
|
||||
scale: {
|
||||
type: 'f',
|
||||
value: -1.0
|
||||
},
|
||||
bias: {
|
||||
type: 'f',
|
||||
value: 1.0
|
||||
},
|
||||
power: {
|
||||
type: 'f',
|
||||
value: 3.3
|
||||
},
|
||||
time: {
|
||||
type: 'f',
|
||||
value: this.timeValue
|
||||
},
|
||||
isHover: {
|
||||
value: false
|
||||
},
|
||||
map: {
|
||||
value: undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async init(): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
const init = async () => {
|
||||
this.createEarth() // 创建地球
|
||||
this.createEarthGlow() // 创建地球辉光
|
||||
this.createEarthAperture() // 创建地球的大气层
|
||||
await this.createMarkupPoint() // 创建柱状点位
|
||||
this.createAnimateCircle() // 创建环绕卫星
|
||||
this.createFlyLine() // 创建飞线
|
||||
this.show()
|
||||
resolve()
|
||||
}
|
||||
init()
|
||||
})
|
||||
}
|
||||
|
||||
createEarth() {
|
||||
const earth_geometry = new SphereGeometry(this.options.earth.radius, 50, 50)
|
||||
const earth_border = new SphereGeometry(this.options.earth.radius + 10, 60, 60)
|
||||
|
||||
const pointMaterial = new PointsMaterial({
|
||||
color: 0x81ffff, //设置颜色,默认 0xFFFFFF
|
||||
transparent: true,
|
||||
sizeAttenuation: true,
|
||||
opacity: 0.1,
|
||||
vertexColors: false, //定义材料是否使用顶点颜色,默认false ---如果该选项设置为true,则color属性失效
|
||||
size: 0.2 //定义粒子的大小。默认为1.0
|
||||
})
|
||||
const points = new Points(earth_border, pointMaterial) //将模型添加到场景
|
||||
|
||||
this.earthGroup.add(points)
|
||||
|
||||
this.uniforms.map.value = this.options.textures.earth
|
||||
|
||||
const earth_material = new ShaderMaterial({
|
||||
// wireframe:true, // 显示模型线条
|
||||
uniforms: this.uniforms as any,
|
||||
vertexShader: earthVertex,
|
||||
fragmentShader: earthFragment
|
||||
})
|
||||
|
||||
earth_material.needsUpdate = true
|
||||
this.earth = new Mesh(earth_geometry, earth_material)
|
||||
this.earth.name = 'earth'
|
||||
this.earthGroup.add(this.earth)
|
||||
}
|
||||
|
||||
createEarthGlow() {
|
||||
const R = this.options.earth.radius //地球半径
|
||||
|
||||
// TextureLoader创建一个纹理加载器对象,可以加载图片作为纹理贴图
|
||||
const texture = this.options.textures.glow // 加载纹理贴图
|
||||
|
||||
// 创建精灵材质对象SpriteMaterial
|
||||
const spriteMaterial = new SpriteMaterial({
|
||||
map: texture, // 设置精灵纹理贴图
|
||||
color: 0x4390d1,
|
||||
transparent: true, //开启透明
|
||||
opacity: 0.7, // 可以通过透明度整体调节光圈
|
||||
depthWrite: false //禁止写入深度缓冲区数据
|
||||
})
|
||||
|
||||
// 创建表示地球光圈的精灵模型
|
||||
const sprite = new Sprite(spriteMaterial)
|
||||
sprite.scale.set(R * 3.0, R * 3.0, 1) //适当缩放精灵
|
||||
this.earthGroup.add(sprite)
|
||||
}
|
||||
|
||||
createEarthAperture() {
|
||||
const vertexShader = [
|
||||
'varying vec3 vVertexWorldPosition;',
|
||||
'varying vec3 vVertexNormal;',
|
||||
'varying vec4 vFragColor;',
|
||||
'void main(){',
|
||||
' vVertexNormal = normalize(normalMatrix * normal);', //将法线转换到视图坐标系中
|
||||
' vVertexWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;', //将顶点转换到世界坐标系中
|
||||
' // set gl_Position',
|
||||
' gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);',
|
||||
'}'
|
||||
].join('\n')
|
||||
|
||||
//大气层效果
|
||||
const AeroSphere = {
|
||||
uniforms: {
|
||||
coeficient: {
|
||||
type: 'f',
|
||||
value: 1.0
|
||||
},
|
||||
power: {
|
||||
type: 'f',
|
||||
value: 3
|
||||
},
|
||||
glowColor: {
|
||||
type: 'c',
|
||||
value: new Color(0x4390d1)
|
||||
}
|
||||
},
|
||||
vertexShader: vertexShader,
|
||||
fragmentShader: [
|
||||
'uniform vec3 glowColor;',
|
||||
'uniform float coeficient;',
|
||||
'uniform float power;',
|
||||
|
||||
'varying vec3 vVertexNormal;',
|
||||
'varying vec3 vVertexWorldPosition;',
|
||||
|
||||
'varying vec4 vFragColor;',
|
||||
|
||||
'void main(){',
|
||||
' vec3 worldCameraToVertex = vVertexWorldPosition - cameraPosition;', //世界坐标系中从相机位置到顶点位置的距离
|
||||
' vec3 viewCameraToVertex = (viewMatrix * vec4(worldCameraToVertex, 0.0)).xyz;', //视图坐标系中从相机位置到顶点位置的距离
|
||||
' viewCameraToVertex= normalize(viewCameraToVertex);', //规一化
|
||||
' float intensity = pow(coeficient + dot(vVertexNormal, viewCameraToVertex), power);',
|
||||
' gl_FragColor = vec4(glowColor, intensity);',
|
||||
'}'
|
||||
].join('\n')
|
||||
}
|
||||
//球体 辉光 大气层
|
||||
const material1 = new ShaderMaterial({
|
||||
uniforms: AeroSphere.uniforms,
|
||||
vertexShader: AeroSphere.vertexShader,
|
||||
fragmentShader: AeroSphere.fragmentShader,
|
||||
blending: NormalBlending,
|
||||
transparent: true,
|
||||
depthWrite: false
|
||||
})
|
||||
const sphere = new SphereGeometry(this.options.earth.radius + 0, 50, 50)
|
||||
const mesh = new Mesh(sphere, material1)
|
||||
this.earthGroup.add(mesh)
|
||||
}
|
||||
|
||||
async createMarkupPoint() {
|
||||
await Promise.all(
|
||||
this.options.data.map(async item => {
|
||||
const radius = this.options.earth.radius
|
||||
const lon = item.startArray.E //经度
|
||||
const lat = item.startArray.N //纬度
|
||||
|
||||
this.punctuationMaterial = new MeshBasicMaterial({
|
||||
color: this.options.punctuation.circleColor,
|
||||
map: this.options.textures.label,
|
||||
transparent: true, //使用背景透明的png贴图,注意开启透明计算
|
||||
depthWrite: false //禁止写入深度缓冲区数据
|
||||
})
|
||||
|
||||
const mesh = createPointMesh({ radius, lon, lat, material: this.punctuationMaterial }) //光柱底座矩形平面
|
||||
this.markupPoint.add(mesh)
|
||||
const LightPillar = createLightPillar({
|
||||
radius: this.options.earth.radius,
|
||||
lon,
|
||||
lat,
|
||||
index: 0,
|
||||
textures: this.options.textures,
|
||||
punctuation: this.options.punctuation
|
||||
}) //光柱
|
||||
this.markupPoint.add(LightPillar)
|
||||
const WaveMesh = createWaveMesh({ radius, lon, lat, textures: this.options.textures }) //波动光圈
|
||||
this.markupPoint.add(WaveMesh)
|
||||
this.waveMeshArr.push(WaveMesh)
|
||||
|
||||
await Promise.all(
|
||||
item.endArray.map(obj => {
|
||||
const lon = obj.E //经度
|
||||
const lat = obj.N //纬度
|
||||
const mesh = createPointMesh({ radius, lon, lat, material: this.punctuationMaterial }) //光柱底座矩形平面
|
||||
this.markupPoint.add(mesh)
|
||||
const LightPillar = createLightPillar({
|
||||
radius: this.options.earth.radius,
|
||||
lon,
|
||||
lat,
|
||||
index: 1,
|
||||
textures: this.options.textures,
|
||||
punctuation: this.options.punctuation
|
||||
}) //光柱
|
||||
this.markupPoint.add(LightPillar)
|
||||
const WaveMesh = createWaveMesh({ radius, lon, lat, textures: this.options.textures }) //波动光圈
|
||||
this.markupPoint.add(WaveMesh)
|
||||
this.waveMeshArr.push(WaveMesh)
|
||||
})
|
||||
)
|
||||
this.earthGroup.add(this.markupPoint)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
createAnimateCircle() {
|
||||
// 创建 圆环 点
|
||||
const list = getCirclePoints({
|
||||
radius: this.options.earth.radius + 15,
|
||||
number: 150, //切割数
|
||||
closed: true // 闭合
|
||||
})
|
||||
const mat = new MeshBasicMaterial({
|
||||
color: '#0c3172',
|
||||
transparent: true,
|
||||
opacity: 0.4,
|
||||
side: DoubleSide
|
||||
})
|
||||
const line = createAnimateLine({
|
||||
pointList: list,
|
||||
material: mat,
|
||||
number: 100,
|
||||
radius: 0.1
|
||||
})
|
||||
this.earthGroup.add(line)
|
||||
|
||||
// 在clone两条线出来
|
||||
const l2 = line.clone()
|
||||
l2.scale.set(1.2, 1.2, 1.2)
|
||||
l2.rotateZ(Math.PI / 6)
|
||||
this.earthGroup.add(l2)
|
||||
|
||||
const l3 = line.clone()
|
||||
l3.scale.set(0.8, 0.8, 0.8)
|
||||
l3.rotateZ(-Math.PI / 6)
|
||||
this.earthGroup.add(l3)
|
||||
|
||||
/**
|
||||
* 旋转的球
|
||||
*/
|
||||
const ball = new Mesh(
|
||||
new SphereGeometry(this.options.satellite.size, 32, 32),
|
||||
new MeshBasicMaterial({
|
||||
color: '#e0b187' // 745F4D
|
||||
})
|
||||
)
|
||||
|
||||
const ball2 = new Mesh(
|
||||
new SphereGeometry(this.options.satellite.size, 32, 32),
|
||||
new MeshBasicMaterial({
|
||||
color: '#628fbb' // 324A62
|
||||
})
|
||||
)
|
||||
|
||||
const ball3 = new Mesh(
|
||||
new SphereGeometry(this.options.satellite.size, 32, 32),
|
||||
new MeshBasicMaterial({
|
||||
color: '#806bdf' //6D5AC4
|
||||
})
|
||||
)
|
||||
|
||||
this.circleLineList.push(line, l2, l3)
|
||||
ball.name = ball2.name = ball3.name = '卫星'
|
||||
|
||||
for (let i = 0; i < this.options.satellite.number; i++) {
|
||||
const ball01 = ball.clone()
|
||||
// 一根线上总共有几个球,根据数量平均分布一下
|
||||
const num = Math.floor(list.length / this.options.satellite.number)
|
||||
ball01.position.set(list[num * (i + 1)][0] * 1, list[num * (i + 1)][1] * 1, list[num * (i + 1)][2] * 1)
|
||||
line.add(ball01)
|
||||
|
||||
const ball02 = ball2.clone()
|
||||
const num02 = Math.floor(list.length / this.options.satellite.number)
|
||||
ball02.position.set(list[num02 * (i + 1)][0] * 1, list[num02 * (i + 1)][1] * 1, list[num02 * (i + 1)][2] * 1)
|
||||
l2.add(ball02)
|
||||
|
||||
const ball03 = ball2.clone()
|
||||
const num03 = Math.floor(list.length / this.options.satellite.number)
|
||||
ball03.position.set(list[num03 * (i + 1)][0] * 1, list[num03 * (i + 1)][1] * 1, list[num03 * (i + 1)][2] * 1)
|
||||
l3.add(ball03)
|
||||
}
|
||||
}
|
||||
|
||||
createFlyLine() {
|
||||
this.flyLineArcGroup = new Group()
|
||||
this.flyLineArcGroup.userData['flyLineArray'] = []
|
||||
this.earthGroup.add(this.flyLineArcGroup)
|
||||
this.options.data.forEach(cities => {
|
||||
cities.endArray.forEach(item => {
|
||||
// 调用函数flyArc绘制球面上任意两点之间飞线圆弧轨迹
|
||||
const arcline = flyArc(
|
||||
this.options.earth.radius,
|
||||
cities.startArray.E,
|
||||
cities.startArray.N,
|
||||
item.E,
|
||||
item.N,
|
||||
this.options.flyLine
|
||||
)
|
||||
|
||||
this.flyLineArcGroup.add(arcline) // 飞线插入flyArcGroup中
|
||||
this.flyLineArcGroup.userData['flyLineArray'].push(arcline.userData['flyLine'])
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
show() {
|
||||
gsap.to(this.group.scale, {
|
||||
x: 1,
|
||||
y: 1,
|
||||
z: 1,
|
||||
duration: 2,
|
||||
ease: 'Quadratic'
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
this.flyLineArcGroup?.userData['flyLineArray']?.forEach((fly: any) => {
|
||||
fly.rotation.z += this.options.flyLine.speed // 调节飞线速度
|
||||
if (fly.rotation.z >= fly.flyEndAngle) fly.rotation.z = 0
|
||||
})
|
||||
|
||||
if (this.isRotation) {
|
||||
this.earthGroup.rotation.y += this.options.earth.rotateSpeed
|
||||
}
|
||||
|
||||
this.circleLineList.forEach(e => {
|
||||
e.rotateY(this.options.satellite.rotateSpeed)
|
||||
})
|
||||
|
||||
this.uniforms.time.value =
|
||||
this.uniforms.time.value < -this.timeValue ? this.timeValue : this.uniforms.time.value - 1
|
||||
|
||||
if (this.waveMeshArr.length) {
|
||||
this.waveMeshArr.forEach((mesh: any) => {
|
||||
mesh.userData['scale'] += 0.007
|
||||
mesh.scale.set(
|
||||
mesh.userData['size'] * mesh.userData['scale'],
|
||||
mesh.userData['size'] * mesh.userData['scale'],
|
||||
mesh.userData['size'] * mesh.userData['scale']
|
||||
)
|
||||
if (mesh.userData['scale'] <= 1.5) {
|
||||
(mesh.material as Material).opacity = (mesh.userData['scale'] - 1) * 2 //2等于1/(1.5-1.0),保证透明度在0~1之间变化
|
||||
} else if (mesh.userData['scale'] > 1.5 && mesh.userData['scale'] <= 2) {
|
||||
(mesh.material as Material).opacity = 1 - (mesh.userData['scale'] - 1.5) * 2 //2等于1/(2.0-1.5) mesh缩放2倍对应0 缩放1.5被对应1
|
||||
} else {
|
||||
mesh.userData['scale'] = 1
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/**
|
||||
* 资源管理和加载
|
||||
*/
|
||||
import { LoadingManager, Texture, TextureLoader } from 'three'
|
||||
import { loadingStart, loadingFinish, loadingError } from '@/utils'
|
||||
import { resources } from './Assets'
|
||||
export class Resources {
|
||||
private manager!: LoadingManager
|
||||
private callback: () => void
|
||||
private textureLoader!: InstanceType<typeof TextureLoader>
|
||||
public textures: Record<string, Texture>
|
||||
constructor(callback: () => void) {
|
||||
this.callback = callback // 资源加载完成的回调
|
||||
this.textures = {} // 贴图对象
|
||||
this.setLoadingManager()
|
||||
this.loadResources()
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理加载状态
|
||||
*/
|
||||
private setLoadingManager() {
|
||||
this.manager = new LoadingManager()
|
||||
// 开始加载
|
||||
this.manager.onStart = () => {
|
||||
loadingStart()
|
||||
}
|
||||
// 加载完成
|
||||
this.manager.onLoad = () => {
|
||||
this.callback()
|
||||
}
|
||||
// 正在进行中
|
||||
this.manager.onProgress = url => {
|
||||
loadingFinish()
|
||||
}
|
||||
|
||||
this.manager.onError = url => {
|
||||
loadingError()
|
||||
window['$message'].error('数据加载失败,请刷新重试!')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载资源
|
||||
*/
|
||||
private loadResources(): void {
|
||||
this.textureLoader = new TextureLoader(this.manager)
|
||||
resources.textures?.forEach(item => {
|
||||
this.textureLoader.load(item.url, t => {
|
||||
this.textures[item.name] = t
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
import { MeshBasicMaterial, PerspectiveCamera, Scene, ShaderMaterial, WebGLRenderer } from 'three'
|
||||
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
|
||||
// interfaces
|
||||
import { IWord } from '../interfaces/IWord'
|
||||
import { Basic } from './Basic'
|
||||
import { Resources } from './Resources'
|
||||
// earth
|
||||
import Earth from './Earth'
|
||||
|
||||
export default class World {
|
||||
public basic: Basic
|
||||
public scene: Scene
|
||||
public camera: PerspectiveCamera
|
||||
public renderer: WebGLRenderer
|
||||
public controls: OrbitControls
|
||||
public material!: ShaderMaterial | MeshBasicMaterial
|
||||
public resources: Resources
|
||||
public option: IWord
|
||||
public earth!: Earth
|
||||
|
||||
constructor(option: IWord) {
|
||||
/**
|
||||
* 加载资源
|
||||
*/
|
||||
this.option = option
|
||||
this.basic = new Basic(option.dom)
|
||||
this.scene = this.basic.scene
|
||||
this.renderer = this.basic.renderer
|
||||
this.controls = this.basic.controls
|
||||
this.camera = this.basic.camera
|
||||
this.updateSize()
|
||||
this.resources = new Resources(async () => {
|
||||
await this.createEarth()
|
||||
// 开始渲染
|
||||
this.render()
|
||||
})
|
||||
}
|
||||
|
||||
async createEarth(data?: any) {
|
||||
// 资源加载完成,开始制作地球,注释在new Earth()类型里面
|
||||
this.earth = new Earth({
|
||||
data: data || this.option.data,
|
||||
dom: this.option.dom,
|
||||
textures: this.resources.textures,
|
||||
earth: {
|
||||
radius: 50,
|
||||
rotateSpeed: 0.002,
|
||||
isRotation: true
|
||||
},
|
||||
satellite: {
|
||||
show: true,
|
||||
rotateSpeed: -0.01,
|
||||
size: 1,
|
||||
number: 2
|
||||
},
|
||||
punctuation: {
|
||||
circleColor: 0x3892ff,
|
||||
lightColumn: {
|
||||
startColor: 0xe4007f, // 起点颜色
|
||||
endColor: 0xffffff // 终点颜色
|
||||
}
|
||||
},
|
||||
flyLine: {
|
||||
color: 0xf3ae76, // 飞线的颜色
|
||||
flyLineColor: 0xff7714, // 飞行线的颜色
|
||||
speed: 0.004 // 拖尾飞线的速度
|
||||
}
|
||||
})
|
||||
|
||||
this.scene.add(this.earth.group)
|
||||
await this.earth.init()
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染函数
|
||||
*/
|
||||
public render() {
|
||||
requestAnimationFrame(this.render.bind(this))
|
||||
this.renderer.render(this.scene, this.camera)
|
||||
this.controls && this.controls.update()
|
||||
this.earth && this.earth.render()
|
||||
}
|
||||
|
||||
// 更新
|
||||
public updateSize(width?: number, height?: number) {
|
||||
let w = width || this.option.width
|
||||
let h = height || this.option.height
|
||||
// 取小值
|
||||
if (w < h) h = w
|
||||
else w = h
|
||||
|
||||
this.renderer.setSize(w, h)
|
||||
this.camera.aspect = w / h
|
||||
this.camera.updateProjectionMatrix()
|
||||
}
|
||||
|
||||
// 数据更新重新渲染
|
||||
public updateData(data?: any) {
|
||||
if (!this.earth.group) return
|
||||
// 先删除旧的
|
||||
this.scene.remove(this.earth.group)
|
||||
// 递归遍历组对象group释放所有后代网格模型绑定几何体占用内存
|
||||
this.earth.group.traverse((obj: any) => {
|
||||
if (obj.type === 'Mesh') {
|
||||
obj.geometry.dispose()
|
||||
obj.material.dispose()
|
||||
}
|
||||
})
|
||||
// 重新创建
|
||||
this.createEarth(data)
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { PublicConfigClass } from '@/packages/public'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { chartInitConfig } from '@/settings/designSetting'
|
||||
import { ThreeEarth01Config } from './index'
|
||||
import dataJson from './data.json'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
|
||||
export const option = {
|
||||
dataset: dataJson
|
||||
}
|
||||
|
||||
export default class Config extends PublicConfigClass implements CreateComponentType {
|
||||
public key = ThreeEarth01Config.key
|
||||
public attr = { ...chartInitConfig, w: 800, h: 800, zIndex: -1 }
|
||||
public chartConfig = cloneDeep(ThreeEarth01Config)
|
||||
public option = cloneDeep(option)
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<template></template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
||||
import { option } from './config'
|
||||
|
||||
const props = defineProps({
|
||||
optionData: {
|
||||
type: Object as PropType<typeof option>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -1,84 +0,0 @@
|
||||
[
|
||||
{
|
||||
"startArray": {
|
||||
"name": "杭州",
|
||||
"N": 30.246026,
|
||||
"E": 120.210792
|
||||
},
|
||||
"endArray": [
|
||||
{
|
||||
"name": "曼谷",
|
||||
"N": 22,
|
||||
"E": 100.49074172973633
|
||||
},
|
||||
{
|
||||
"name": "澳大利亚",
|
||||
"N": -23.68477416688374,
|
||||
"E": 133.857421875
|
||||
},
|
||||
|
||||
{
|
||||
"name": "新疆维吾尔自治区",
|
||||
"N": 41.748,
|
||||
"E": 84.9023
|
||||
},
|
||||
|
||||
{
|
||||
"name": "德黑兰",
|
||||
"N": 35,
|
||||
"E": 51
|
||||
},
|
||||
{
|
||||
"name": "德黑兰",
|
||||
"N": 35,
|
||||
"E": 51
|
||||
},
|
||||
{
|
||||
"name": "美国",
|
||||
"N": 34.125447565116126,
|
||||
"E": 241.7431640625
|
||||
},
|
||||
{
|
||||
"name": "英国",
|
||||
"N": 51.508742458803326,
|
||||
"E": 359.82421875
|
||||
},
|
||||
{
|
||||
"name": "巴西",
|
||||
"N": -9.96885060854611,
|
||||
"E": 668.1445312499999
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"startArray": {
|
||||
"name": "北京",
|
||||
"N": 39.89491,
|
||||
"E": 116.322056
|
||||
},
|
||||
"endArray": [
|
||||
{
|
||||
"name": "西藏",
|
||||
"N": 29.660361,
|
||||
"E": 91.132212
|
||||
},
|
||||
{
|
||||
"name": "广西",
|
||||
"N": 22.830824,
|
||||
"E": 108.30616
|
||||
},
|
||||
|
||||
{
|
||||
"name": "江西",
|
||||
"N": 28.676493,
|
||||
"E": 115.892151
|
||||
},
|
||||
|
||||
{
|
||||
"name": "贵阳",
|
||||
"N": 26.647661,
|
||||
"E": 106.630153
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
Before Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 566 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 504 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 42 KiB |
@@ -1,15 +0,0 @@
|
||||
import image from '@/assets/images/chart/decorates/threeEarth01.png'
|
||||
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
|
||||
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
||||
|
||||
export const ThreeEarth01Config: ConfigType = {
|
||||
key: 'ThreeEarth01',
|
||||
chartKey: 'VThreeEarth01',
|
||||
conKey: 'VCThreeEarth01',
|
||||
title: '三维地球',
|
||||
category: ChatCategoryEnum.THREE,
|
||||
categoryName: ChatCategoryEnumName.THREE,
|
||||
package: PackagesCategoryEnum.DECORATES,
|
||||
chartFrame: ChartFrameEnum.STATIC,
|
||||
image
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
<template>
|
||||
<div ref="chartRef"></div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, PropType, ref, toRefs, watch } from 'vue'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { useChartDataFetch } from '@/hooks'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { option } from './config'
|
||||
import World from './code/world/Word'
|
||||
import throttle from 'lodash/throttle'
|
||||
|
||||
const props = defineProps({
|
||||
chartConfig: {
|
||||
type: Object as PropType<CreateComponentType & typeof option>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const chartEditStore = useChartEditStore()
|
||||
|
||||
const chartRef = ref<HTMLElement>()
|
||||
const { w, h } = toRefs(props.chartConfig.attr)
|
||||
let threeClassInstance: World
|
||||
|
||||
// 初始化
|
||||
const init = () => {
|
||||
const dom: HTMLElement | undefined = chartRef.value
|
||||
if (dom) {
|
||||
threeClassInstance = new World({
|
||||
dom: dom,
|
||||
data: props.chartConfig.option.dataset,
|
||||
width: w.value,
|
||||
height: h.value
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const updateData = (data: any) => {
|
||||
try {
|
||||
threeClassInstance.updateData(data)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
// 改变大小
|
||||
watch(
|
||||
() => [w.value, h.value],
|
||||
throttle(([newWidth], [newHeight]) => {
|
||||
threeClassInstance.updateSize(newWidth, newHeight)
|
||||
}, 100)
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
(newData: any) => {
|
||||
updateData(newData)
|
||||
},
|
||||
{
|
||||
deep: false
|
||||
}
|
||||
)
|
||||
|
||||
// DOM 渲染之后进行初始化
|
||||
onMounted(() => {
|
||||
try {
|
||||
if (navigator.userAgent.indexOf('Chrome') < -1 || navigator.userAgent.indexOf('Edg') > -1) {
|
||||
window['$message'].error('此组件仅在【谷歌】浏览器上能正常展示!')
|
||||
chartEditStore.removeComponentList(undefined, false)
|
||||
return
|
||||
}
|
||||
init()
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
})
|
||||
|
||||
useChartDataFetch(props.chartConfig, useChartEditStore, updateData)
|
||||
</script>
|
||||
@@ -1,3 +0,0 @@
|
||||
import { ThreeEarth01Config } from './ThreeEarth01/index'
|
||||
|
||||
export default [ThreeEarth01Config]
|
||||
2
src/packages/components/Decorates/index.d.ts
vendored
@@ -1,13 +1,11 @@
|
||||
export enum ChatCategoryEnum {
|
||||
BORDER = 'Borders',
|
||||
DECORATE = 'Decorates',
|
||||
THREE = 'Three',
|
||||
MORE = 'Mores'
|
||||
}
|
||||
|
||||
export enum ChatCategoryEnumName {
|
||||
BORDER = '边框',
|
||||
DECORATE = '装饰',
|
||||
THREE = '三维',
|
||||
MORE = '更多'
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import Borders from './Borders'
|
||||
import Decorates from './Decorates'
|
||||
import Three from './Three'
|
||||
import Mores from './Mores'
|
||||
|
||||
export const DecorateList = [...Borders, ...Decorates, ...Three, ...Mores]
|
||||
export const DecorateList = [...Borders, ...Decorates, ...Mores]
|
||||
|
||||
@@ -47,12 +47,9 @@ 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)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
dataset && (props.chartConfig.option.series[0].data = dataset)
|
||||
|
||||
vChartRef.value && isPreview() && vChartRef.value.setOption(props.chartConfig.option)
|
||||
}
|
||||
|
||||
// dataset 无法变更条数的补丁
|
||||
|
||||
@@ -10,12 +10,19 @@
|
||||
<div class="rank" :style="`color: ${color};font-size: ${indexFontSize}px`">No.{{ item.ranking }}</div>
|
||||
<div class="info-name" :style="`font-size: ${leftFontSize}px`" v-html="item.name" />
|
||||
<div class="ranking-value" :style="`color: ${textColor};font-size: ${rightFontSize}px`">
|
||||
{{ status.mergedConfig.valueFormatter ? status.mergedConfig.valueFormatter(item) : item.value }}
|
||||
{{
|
||||
status.mergedConfig.valueFormatter
|
||||
? status.mergedConfig.valueFormatter(item)
|
||||
: item.value
|
||||
}}
|
||||
{{ unit }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="ranking-column" :style="`border-color: ${borderColor}`">
|
||||
<div class="inside-column" :style="`width: ${item.percent}%;background-color: ${color}`">
|
||||
<div
|
||||
class="inside-column"
|
||||
:style="`width: ${item.percent}%;background-color: ${color}`"
|
||||
>
|
||||
<div class="shine" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -32,8 +39,8 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore
|
||||
const props = defineProps({
|
||||
chartConfig: {
|
||||
type: Object as PropType<CreateComponentType>,
|
||||
required: true
|
||||
}
|
||||
required: true,
|
||||
},
|
||||
})
|
||||
const { w, h } = toRefs(props.chartConfig.attr)
|
||||
const { rowNum, unit, color, textColor, borderColor, indexFontSize, leftFontSize, rightFontSize } = toRefs(
|
||||
@@ -43,15 +50,13 @@ const { rowNum, unit, color, textColor, borderColor, indexFontSize, leftFontSize
|
||||
const status = reactive({
|
||||
mergedConfig: props.chartConfig.option,
|
||||
rowsData: [],
|
||||
rows: [
|
||||
{
|
||||
scroll: 0,
|
||||
ranking: 1,
|
||||
name: '',
|
||||
value: '',
|
||||
percent: 0
|
||||
}
|
||||
],
|
||||
rows: [{
|
||||
scroll: 0,
|
||||
ranking: 1,
|
||||
name: '',
|
||||
value: '',
|
||||
percent: 0
|
||||
}],
|
||||
heights: [0],
|
||||
animationIndex: 0,
|
||||
animationHandler: 0,
|
||||
@@ -76,16 +81,16 @@ const calcRowsData = () => {
|
||||
// abs of max
|
||||
const maxAbs = Math.abs(max)
|
||||
const total = max + minAbs
|
||||
dataset = dataset.map((row: any, i: number) => ({
|
||||
dataset = dataset.map((row: any, i:number) => ({
|
||||
...row,
|
||||
ranking: i + 1,
|
||||
percent: ((row.value + minAbs) / total) * 100
|
||||
percent: ((row.value + minAbs) / total) * 100,
|
||||
}))
|
||||
const rowLength = dataset.length
|
||||
if (rowLength > rowNum && rowLength < 2 * rowNum) {
|
||||
dataset = [...dataset, ...dataset]
|
||||
}
|
||||
dataset = dataset.map((d: any, i: number) => ({ ...d, scroll: i }))
|
||||
dataset = dataset.map((d:any, i:number) => ({ ...d, scroll: i }))
|
||||
status.rowsData = dataset
|
||||
status.rows = dataset
|
||||
}
|
||||
@@ -129,15 +134,11 @@ const stopAnimation = () => {
|
||||
}
|
||||
|
||||
const onRestart = async () => {
|
||||
try {
|
||||
if (!status.mergedConfig) return
|
||||
stopAnimation()
|
||||
calcRowsData()
|
||||
calcHeights(true)
|
||||
animation(true)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
if (!status.mergedConfig) return
|
||||
stopAnimation()
|
||||
calcRowsData()
|
||||
calcHeights(true)
|
||||
animation(true)
|
||||
}
|
||||
|
||||
onRestart()
|
||||
|
||||
@@ -1,47 +1,24 @@
|
||||
<template>
|
||||
<div class="dv-scroll-board">
|
||||
<div
|
||||
class="header"
|
||||
v-if="status.header.length && status.mergedConfig"
|
||||
:style="`background-color: ${status.mergedConfig.headerBGC};`"
|
||||
>
|
||||
<div
|
||||
class="header-item"
|
||||
v-for="(headerItem, i) in status.header"
|
||||
:key="`${headerItem}${i}`"
|
||||
:style="`
|
||||
<div class="header" v-if="status.header.length && status.mergedConfig"
|
||||
:style="`background-color: ${status.mergedConfig.headerBGC};`">
|
||||
<div class="header-item" v-for="(headerItem, i) in status.header" :key="`${headerItem}${i}`" :style="`
|
||||
height: ${status.mergedConfig.headerHeight}px;
|
||||
line-height: ${status.mergedConfig.headerHeight}px;
|
||||
width: ${status.widths[i]}px;
|
||||
`"
|
||||
:align="status.aligns[i]"
|
||||
v-html="headerItem"
|
||||
/>
|
||||
`" :align="status.aligns[i]" v-html="headerItem" />
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="status.mergedConfig"
|
||||
class="rows"
|
||||
:style="`height: ${h - (status.header.length ? status.mergedConfig.headerHeight : 0)}px;`"
|
||||
>
|
||||
<div
|
||||
class="row-item"
|
||||
v-for="(row, ri) in status.rows"
|
||||
:key="`${row.toString()}${row.scroll}`"
|
||||
:style="`
|
||||
<div v-if="status.mergedConfig" class="rows"
|
||||
:style="`height: ${h - (status.header.length ? status.mergedConfig.headerHeight : 0)}px;`">
|
||||
<div class="row-item" v-for="(row, ri) in status.rows" :key="`${row.toString()}${row.scroll}`" :style="`
|
||||
height: ${status.heights[ri]}px;
|
||||
line-height: ${status.heights[ri]}px;
|
||||
background-color: ${status.mergedConfig[row.rowIndex % 2 === 0 ? 'evenRowBGC' : 'oddRowBGC']};
|
||||
`"
|
||||
>
|
||||
<div
|
||||
class="ceil"
|
||||
v-for="(ceil, ci) in row.ceils"
|
||||
:key="`${ceil}${ri}${ci}`"
|
||||
:style="`width: ${status.widths[ci]}px;`"
|
||||
:align="status.aligns[ci]"
|
||||
v-html="ceil"
|
||||
/>
|
||||
`">
|
||||
<div class="ceil" v-for="(ceil, ci) in row.ceils" :key="`${ceil}${ri}${ci}`"
|
||||
:style="`width: ${status.widths[ci]}px;`" :align="status.aligns[ci]" v-html="ceil" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -58,8 +35,8 @@ import cloneDeep from 'lodash/cloneDeep'
|
||||
const props = defineProps({
|
||||
chartConfig: {
|
||||
type: Object as PropType<CreateComponentType>,
|
||||
required: true
|
||||
}
|
||||
required: true,
|
||||
},
|
||||
})
|
||||
|
||||
// 这里能拿到图表宽高等
|
||||
@@ -161,13 +138,11 @@ const status = reactive({
|
||||
mergedConfig: props.chartConfig.option,
|
||||
header: [],
|
||||
rowsData: [],
|
||||
rows: [
|
||||
{
|
||||
ceils: [],
|
||||
rowIndex: 0,
|
||||
scroll: 0
|
||||
}
|
||||
],
|
||||
rows: [{
|
||||
ceils: [],
|
||||
rowIndex: 0,
|
||||
scroll: 0
|
||||
}],
|
||||
widths: [],
|
||||
heights: [0],
|
||||
avgHeight: 0,
|
||||
@@ -188,7 +163,7 @@ const calcData = () => {
|
||||
animation(true)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
onMounted(()=> {
|
||||
calcData()
|
||||
})
|
||||
|
||||
@@ -210,21 +185,19 @@ const calcHeaderData = () => {
|
||||
const calcRowsData = () => {
|
||||
let { dataset, index, headerBGC, rowNum } = status.mergedConfig
|
||||
if (index) {
|
||||
dataset = dataset.map((row: any, i: number) => {
|
||||
dataset = dataset.map((row:any, i:number) => {
|
||||
row = [...row]
|
||||
const indexTag = `<span class="index" style="background-color: ${headerBGC};border-radius: 3px;padding: 0px 3px;">${
|
||||
i + 1
|
||||
}</span>`
|
||||
const indexTag = `<span class="index" style="background-color: ${headerBGC};border-radius: 3px;padding: 0px 3px;">${i + 1}</span>`
|
||||
row.unshift(indexTag)
|
||||
return row
|
||||
})
|
||||
}
|
||||
dataset = dataset.map((ceils: any, i: number) => ({ ceils, rowIndex: i }))
|
||||
dataset = dataset.map((ceils:any, i:number) => ({ ceils, rowIndex: i }))
|
||||
const rowLength = dataset.length
|
||||
if (rowLength > rowNum && rowLength < 2 * rowNum) {
|
||||
dataset = [...dataset, ...dataset]
|
||||
}
|
||||
dataset = dataset.map((d: any, i: number) => ({ ...d, scroll: i }))
|
||||
dataset = dataset.map((d:any, i:number) => ({ ...d, scroll: i }))
|
||||
|
||||
status.rowsData = dataset
|
||||
status.rows = dataset
|
||||
@@ -233,7 +206,7 @@ const calcRowsData = () => {
|
||||
const calcWidths = () => {
|
||||
const { mergedConfig, rowsData } = status
|
||||
const { columnWidth, header } = mergedConfig
|
||||
const usedWidth = columnWidth.reduce((all: any, ws: number) => all + ws, 0)
|
||||
const usedWidth = columnWidth.reduce((all:any, ws:number) => all + ws, 0)
|
||||
let columnNum = 0
|
||||
if (rowsData[0]) {
|
||||
columnNum = (rowsData[0] as any).ceils.length
|
||||
@@ -281,7 +254,7 @@ const animation = async (start = false) => {
|
||||
const rowLength = rowsData.length
|
||||
if (rowNum >= rowLength) return
|
||||
if (start) {
|
||||
await new Promise(resolve => setTimeout(resolve, waitTime * 1000))
|
||||
await new Promise(resolve => setTimeout(resolve, waitTime*1000))
|
||||
if (updater !== status.updater) return
|
||||
}
|
||||
const animationNum = carousel === 'single' ? 1 : rowNum
|
||||
@@ -296,7 +269,7 @@ const animation = async (start = false) => {
|
||||
const back = animationIndex - rowLength
|
||||
if (back >= 0) animationIndex = back
|
||||
status.animationIndex = animationIndex
|
||||
status.animationHandler = setTimeout(animation, waitTime * 1000 - 300) as any
|
||||
status.animationHandler = setTimeout(animation, waitTime*1000 - 300) as any
|
||||
}
|
||||
|
||||
const stopAnimation = () => {
|
||||
@@ -306,13 +279,9 @@ const stopAnimation = () => {
|
||||
}
|
||||
|
||||
const onRestart = async () => {
|
||||
try {
|
||||
if (!status.mergedConfig) return
|
||||
stopAnimation()
|
||||
calcData()
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
if (!status.mergedConfig) return
|
||||
stopAnimation()
|
||||
calcData()
|
||||
}
|
||||
|
||||
watch(
|
||||
@@ -335,7 +304,7 @@ watch(
|
||||
() => {
|
||||
onRestart()
|
||||
},
|
||||
{ deep: true }
|
||||
{deep:true}
|
||||
)
|
||||
|
||||
// 数据更新 (默认更新 dataset,若更新之后有其它操作,可添加回调函数)
|
||||
@@ -347,6 +316,7 @@ useChartDataFetch(props.chartConfig, useChartEditStore, (resData: any[]) => {
|
||||
onUnmounted(() => {
|
||||
stopAnimation()
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
1
src/packages/index.d.ts
vendored
@@ -115,6 +115,7 @@ export interface PublicConfigType {
|
||||
}
|
||||
filter?: string
|
||||
status: StatusType
|
||||
setPosition: Function
|
||||
}
|
||||
|
||||
export interface CreateComponentType extends PublicConfigType, requestConfig {
|
||||
|
||||
@@ -81,6 +81,12 @@ export class PublicConfigClass implements PublicConfigType {
|
||||
public request = cloneDeep(requestConfig)
|
||||
// 数据过滤
|
||||
public filter = undefined
|
||||
|
||||
// 设置坐标
|
||||
public setPosition(x: number, y: number): void {
|
||||
this.attr.x = x
|
||||
this.attr.y = y
|
||||
}
|
||||
}
|
||||
|
||||
// 多选成组类
|
||||
|
||||
@@ -8,7 +8,10 @@ import { SketchRule } from 'vue3-sketch-ruler'
|
||||
* @param app
|
||||
*/
|
||||
export function setupCustomComponents(app: App) {
|
||||
// 骨架屏
|
||||
app.component('GoSkeleton', GoSkeleton)
|
||||
// 加载
|
||||
app.component('GoLoading', GoLoading)
|
||||
// 标尺
|
||||
app.component('SketchRule', SketchRule)
|
||||
}
|
||||
|
||||