runbir-tools 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,217 +1,218 @@
1
- # Vue 3 + TypeScript + Vite 项目
2
-
3
- 这是一个基于现代前端技术栈的项目,使用以下技术构建:
4
-
5
- ## 技术栈
6
-
7
- - ⚡️ [Vite](https://vitejs.dev/) - 下一代前端工具链
8
- - 🖖 [Vue 3](https://vuejs.org/) - 渐进式 JavaScript 框架
9
- - 🦾 [TypeScript](https://www.typescriptlang.org/) - 类型安全的 JavaScript 超集
10
- - 📦 [PNPM](https://pnpm.io/) - 快速、节省磁盘空间的包管理器
11
- - 💅 [Sass](https://sass-lang.com/) - 专业级的 CSS 扩展语言
12
- - 📅 [Day.js](https://day.js.org/) - 轻量级日期处理库
13
- - 📊 [Vue-ECharts](https://github.com/ecomfe/vue-echarts) - ECharts 图表组件
14
- - 🎨 [Element Plus](https://element-plus.org/) - Vue 3 组件库
15
- - � [ESLint](https://eslint.org/) - 可插拔的 JavaScript 代码检查工具
16
- - 🐶 [Husky](https://typicode.github.io/husky/) - Git 钩子工具
17
- - 🚫 [lint-staged](https://github.com/okonet/lint-staged) - 对暂存的 Git 文件运行 linter
18
-
19
- ## 项目结构
20
-
21
- ```bash
22
- ├── .husky/ # Git钩子配置
23
- │ ├── pre-commit # 提交前执行的脚本
24
- │ └── commit-msg # commit信息校验
25
- ├── .vscode/ # VSCode配置
26
- │ ├── settings.json # 编辑器设置
27
- │ └── extensions.json # 推荐插件
28
- ├── public/ # 静态资源目录
29
- │ └── vue.svg # 网站图标
30
- ├── src/ # 源代码目录
31
- │ ├── assets/ # 静态资源
32
- │ │ ├── fonts/ # 字体文件
33
- │ │ ├── images/ # 图片资源
34
- │ │ └── styles/ # 样式文件
35
- │ │ ├── _mixins.scss # SCSS混入
36
- │ │ └── _variables.scss # SCSS变量
37
- │ ├── components/ # 公共组件
38
- │ ├── composables/ # 组合式函数
39
- │ ├── router/ # 路由配置
40
- │ │ └── index.ts # 路由入口
41
- │ ├── services/ # API服务
42
- │ │ └── api-client.ts # 请求封装
43
- │ ├── stores/ # 状态管理
44
- │ │ ├── index.ts # Store入口
45
- │ │ └── modules/ # Store模块
46
- │ ├── types/ # 类型定义
47
- │ ├── utils/ # 工具函数
48
- │ ├── view/ # 页面组件
49
- │ ├── App.vue # 根组件
50
- │ ├── main.ts # 应用入口
51
- │ ├── style.css # 全局样式
52
- │ └── vite-env.d.ts # 环境变量类型
53
- ├── .env # 基础环境变量
54
- ├── .env.development # 开发环境变量
55
- ├── .env.production # 生产环境变量
56
- ├── .gitignore # Git忽略规则
57
- ├── .prettierrc.cjs # Prettier配置
58
- ├── auto-imports.d.ts # 自动导入声明
59
- ├── components.d.ts # 组件类型声明
60
- ├── eslint.config.js # ESLint配置
61
- ├── index.html # HTML入口
62
- ├── package.json # 项目配置
63
- ├── pnpm-lock.yaml # 依赖锁文件
64
- ├── README.md # 项目说明
65
- ├── tsconfig.app.json # 应用TS配置
66
- ├── tsconfig.json # 基础TS配置
67
- ├── tsconfig.node.json # Node环境TS配置
68
- └── vite.config.ts # Vite配置
69
1
 
2
+ # 软博工具包
3
+ 这是一个基于vue3开发的工具包,目前包依赖ol和@turf/turf。
4
+ #### 安装包
70
5
  ```
71
-
72
- ## 快速开始
73
-
74
- ### 安装依赖
75
-
76
- ```bash
77
- pnpm install
6
+ npm install runbir-tools
78
7
  ```
79
-
80
- ### 开发模式
81
-
82
- ```bash
83
- pnpm dev
8
+ ## 基于ol的快速开发组件
9
+ 主要是基于vue3,对ol的基本功能做双向绑定,以及提供气象相关的一些工具。
10
+ ### 快速开始
11
+ 基于天地图,创建简单的GIS。
12
+ ```typescript
13
+ <script setup>
14
+ import { VueOl } from "runbir-tools";
15
+ import { ref } from "vue";
16
+ const options = ref({
17
+   view: {
18
+     center: [113.41, 23.32],
19
+     zoom: 7,
20
+     projection: "EPSG:4326",
21
+   },
22
+   layers: [
23
+     {
24
+       id: "vec",
25
+       type: "xyz",
26
+       source: {
27
+         url: "https://t{0-7}.tianditu.gov.cn/vec_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=c&FORMAT=tiles&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}&tk=48fb1019fa26991b5831d6a97db2fc16",
28
+         projection: "EPSG:4326",
29
+       },
30
+     },
31
+     {
32
+       id: "cva",
33
+       type: "xyz",
34
+       source: {
35
+         url: "https://t{0-7}.tianditu.gov.cn/cva_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&STYLE=default&TILEMATRIXSET=c&FORMAT=tiles&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}&tk=48fb1019fa26991b5831d6a97db2fc16",
36
+         projection: "EPSG:4326",
37
+       },
38
+     },
39
+   ],
40
+ });
41
+ </script>
42
+ <template>
43
+   <div class="demo"><vue-ol :options="options"></vue-ol></div>
44
+ </template>
45
+ <style>
46
+ .demo {
47
+   width: 100%;
48
+   height: 100%;
49
+ }
50
+ </style>
84
51
  ```
85
-
86
- ### 生产构建
87
-
88
- ```bash
89
- pnpm build
52
+ ### options配置
53
+ #### 1. options.value.view 视图配置
54
+ 视图的options同[ol/view](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html)一致,由于基于vue做了双向绑定,故直接更改属性值即可刷新,免去ol原来的繁琐重渲染操作。
55
+ 例如,更改视图中心点
90
56
  ```
91
-
92
- ### 预览生产构建
93
-
94
- ```bash
95
- pnpm preview
57
+ options.value.view.center = [newlng,newlat]
96
58
  ```
97
59
 
98
- ### 代码检查
99
-
100
- ```bash
101
- pnpm lint
60
+ #### 2. options.value.layers 图层配置
61
+ 图层配置目前仅支持以下图层
62
+ ##### 2.1 xyz配置
63
+ xyz的options同[ol/layer/Tile](https://openlayers.org/en/latest/apidoc/module-ol_layer_Tile-TileLayer.html)和[ol/source/xyz](https://openlayers.org/en/latest/apidoc/module-ol_source_XYZ-XYZ.html)一致,必须配置type:"xyz"以及id(自定义命名),id是图层的唯一标记,示例如下:
64
+ ```typescript
65
+ <script setup>
66
+ import { VueOl } from "runbir-tools";
67
+ import { ref } from "vue";
68
+ const options = ref({
69
+   view: {.....},
70
+   layers: [
71
+     {
72
+       id: "radar",
73
+       type: "xyz",
74
+       source: {
75
+         url: "https://xxxx/data/radar_cut/20250703093600/{z}/{x}/{y}.png",
76
+         projection: "EPSG:4326",
77
+       },
78
+     },
79
+   ],
80
+ });
81
+ </script>
102
82
  ```
103
-
104
- ### 格式化代码
105
-
106
- ```bash
107
- pnpm format
83
+ 更改图层配置项值,同样能够直接渲染到地图
108
84
  ```
109
-
110
- ### 初始化 Git 钩子
111
-
112
- ```bash
113
- pnpm prepare
85
+     const radar = options.value.layers.find((l: any) => l.id === 'radar')
86
+ radar.source.url = "新的url"
114
87
  ```
115
-
116
- ### 运行测试(开发模式)
117
-
118
- ```bash
119
- pnpm test
120
- ```
121
-
122
- ### 运行测试(CI 模式)
123
-
124
- ```bash
125
- pnpm test:run
88
+ 删除图片则直接在layers删除即可
126
89
  ```
127
-
128
- ### 生成覆盖率报告
129
-
130
- ```bash
131
- pnpm coverage
90
+ const index = options.value.layers.findIndex((l: any) => l.id === 'radar')
91
+ options.value.layers.splice(index, 1)
132
92
  ```
133
-
134
- ## 主要依赖说明
135
-
136
- ### Element Plus 使用
137
-
138
- 项目已集成 Element Plus 组件库,自动按需导入配置已完成。使用方式:
139
-
93
+ ##### 2.2 imageStatic 静态图片配置
94
+ imageStatic的options同[ol/layer/image](https://openlayers.org/en/latest/apidoc/module-ol_layer_Image-ImageLayer.html)和
95
+ [ol/source/ImageStatic](https://openlayers.org/en/latest/apidoc/module-ol_source_ImageStatic-Static.html)一致,必须配置type:"imageStatic"以及id(自定义命名),id是图层的唯一标记,示例如下:
140
96
  ```typescript
141
- // 在组件中直接使用
142
- <el-button type="primary">按钮</el-button>
143
- ```
144
-
145
- ### Vue-ECharts 使用
146
-
147
- 项目已集成 Vue-ECharts 图表库,采用全局按需注册的方式,使用方式:
148
-
149
- ```typescript
150
- // 在main.ts 中注册
151
- import { BarChart, LineChart, PieChart } from 'echarts/charts'
152
-
153
- use([
154
- CanvasRenderer,
155
- BarChart,
156
- LineChart,
157
- PieChart,
158
- GridComponent,
159
- TooltipComponent,
160
- LegendComponent,
161
- TitleComponent,
162
- ])
97
+ <script setup>
98
+ import { VueOl } from "runbir-tools";
99
+ import { ref } from "vue";
100
+ const options = ref({
101
+   view: {.....},
102
+   layers: [
103
+       {
104
+         id: 'satellite',
105
+         type: 'imageStatic',
106
+         opacity: 0.2,
107
+         source: {
108
+           imageExtent: [54.3, -5, 159.6, 66],
109
+           url: 'https://xxxx/data/cloud/3D/20250704/FY2G_2025_07_04_02_01_M_PJ1_3D.GIF',
110
+         },
111
+       },
112
+   ],
113
+ });
114
+ </script>
163
115
  ```
164
-
116
+ 更新和删除同上
117
+ ##### 2.3 point 散点配置
118
+ point的options同[ol/layer/Vector](https://openlayers.org/en/latest/apidoc/module-ol_layer_Vector-VectorLayer.html)和
119
+ [ol/source/Vector](https://openlayers.org/en/latest/apidoc/module-ol_source_Vector-VectorSource.html)一致(仅支持ol/geom/Point,style样式除了ol内置style,还额外提供一个小组件风向杆),必须配置type:"point以及id(自定义命名),id是图层的唯一标记;示例如下:
165
120
  ```typescript
166
- // 在组件中使用
167
- <template>
168
- <v-chart class="chart" :option="option" />
169
- </template>
170
-
171
121
  <script setup>
172
- import type { EChartsOption } from 'echarts'
173
-
174
- const options = ref<EChartsOption>({
175
- // 配置项
176
- })
122
+ import { VueOl } from "runbir-tools";
123
+ import { ref } from "vue";
124
+ const options = ref({
125
+   view: {.....},
126
+   layers: [
127
+       {
128
+         id: 'point',
129
+         type: 'point',
130
+         data: [
131
+           {
132
+             lng: 113.5,
133
+             lat: 23.5,
134
+             style: {
135
+               image: {
136
+                 type: 'circle',
137
+                 radius: 10,
138
+                 fill: { color: 'blue' },
139
+                 stroke: { color: 'white', width: 2 },
140
+               },
141
+             },
142
+           },
143
+           { lng: 113.6, lat: 23.6, value: 22 },
144
+           {
145
+             lng: 113.4,
146
+             lat: 23.6,
147
+             winds: 14,
148
+             windd: 342,
149
+             style: { image: { type: 'windBarb' } },
150
+           },
151
+           {
152
+             lng: 113.5,
153
+             lat: 25.5,
154
+             text: '22mm',
155
+             style: { text: { font: '14px sans-serif' } },
156
+           },
157
+         ],
158
+       },
159
+   ],
160
+ });
177
161
  </script>
178
162
  ```
179
-
180
- ### Day.js 使用
181
-
182
- 项目已集成 Day.js 日期处理库,推荐使用方式:
183
-
163
+ 更新删除同上
164
+ ##### 2.3 typhoon 台风配置
165
+ 台风配置必须配置type:"typhoon以及id(自定义命名),id是图层的唯一标记,data数据格式只可以参考以下链接;示例如下:
184
166
  ```typescript
185
- import dayjs from 'dayjs'
186
-
187
- // 格式化日期
188
- const formattedDate = dayjs().format('YYYY-MM-DD HH:mm:ss')
167
+     const typhoon = {
168
+ "tsId": "764",
169
+ "tscName": "罗莎",
170
+ "tseName": "krosa",
171
+ "intlId": "2509",
172
+ "intId": "",
173
+ "landOn": "",
174
+ "origin": "",
175
+ "meanings": "",
176
+ "remark": "",
177
+ "crtTime": "2025-08-03 15:54:22.0"
178
+ }
179
+     const typhoonPath = (await getTyphoonPath('https://www.gzqxfw.com.cn/data/typhoon/2025/764.json')) as any
180
+     const data: any = { baseInfo: typhoon }
181
+     data.mainPath = 'BABJ' // 如果配置这项,则为单个台风单条路径(多用于面向公众系统);如果没有配置,则是单个台风多条路径(多用于内部系统)
182
+     typhoonPath.BABJ.color = '#ff0000'
183
+     typhoonPath.BCGZ.color = '#ff00ff'
184
+     typhoonPath.PGTW.color = '#91f4f5'
185
+     typhoonPath.RJTD.color = '#6eba39'
186
+     typhoonPath.VHHH.color = '#e39538'
187
+     data.data = typhoonPath
188
+     const ty = { id: 'typhoon', type: 'typhoon', data }
189
+     options.value.layers.push(ty)
189
190
  ```
191
+ 台风不提供更新、修改路径的功能(业务上很少有这种操作);删除同上
192
+ #### 3. options.value.event 事件配置
193
+ 关于ol的事件,建议使用以下配置;由于包内部也应用了事件监听,为了节约系统开支,使用以下配置统一调度
194
+ ```typescript
195
+ const options = ref<any>({
196
+     view: {....... },
197
+     layers: [.....],
198
+     event: {
199
+       register: ['singleclick'],
200
+       callback: (event: any) => {
201
+         console.log(event)
202
+       },
203
+     },
204
+   })
205
+ ```
206
+ #### 4. 以上功能不满足的情况下,可以获取地图对象,进行自定义操作
190
207
 
191
- ## Git 提交规范
192
-
193
- 项目使用 [Conventional Commits](https://www.conventionalcommits.org/) 规范,提交前会自动运行 lint-staged 进行检查。
194
-
195
- ## 编辑器配置
196
-
197
- 推荐使用 [VSCode](https://code.visualstudio.com/) 并安装以下插件:
198
-
199
- - [Vue - Official](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) - Vue 3 官方支持
200
- - [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) - 代码检查
201
- - [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) - 代码格式化
202
- - [Stylelint](https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint) - CSS/SCSS 检查
203
- - [Element Plus Snippets](https://marketplace.visualstudio.com/items?itemName=ElementPlus.element-plus-snippets) - Element Plus 代码片段
204
-
205
- ## 代码规范
206
-
207
- - 组件使用 `PascalCase` 命名
208
- - 组合式函数使用 `camelCase` 命名并以 `use` 开头
209
- - 类型定义使用 `PascalCase` 命名并以 `Type` 结尾
210
- - 接口定义使用 `PascalCase` 命名并以 `Interface` 结尾
211
- - 枚举使用 `PascalCase` 命名
212
- - Element Plus 组件保持原标签名 (如 `<el-button>`)
213
- - ECharts 相关变量以 `chart` 为前缀
214
-
215
- ## 浏览器支持
216
-
217
- 项目默认支持现代浏览器,如需兼容旧版浏览器,请自行配置 `@vitejs/plugin-legacy`。
208
+ 目前该组件只封装了一些常见的功能,在功能不满足使用的情况下,请获取地图对象,用原生ol编写代码;获取地图对象方法如下:
209
+ ```typescript
210
+ <script setup lang="ts">
211
+   const getMapObject = (map: any) => {
212
+     console.log(map)
213
+   }
214
+ </script>
215
+ <template>
216
+  <vue-ol :options="mapOptions" @ol-map="getMapObject" />
217
+ </template>
218
+ ```
@@ -1,4 +1,4 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".map[data-v-f90a5acf]{width:100%;height:100%}@keyframes rotate-f90a5acf{0%{transform:rotate(0)}to{transform:rotate(360deg)}}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".map[data-v-0a4735ce]{width:100%;height:100%}@keyframes rotate-0a4735ce{0%{transform:rotate(0)}to{transform:rotate(360deg)}}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
2
  var ze = Object.defineProperty;
3
3
  var Ve = (s, e, t) => e in s ? ze(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
4
4
  var se = (s, e, t) => Ve(s, typeof e != "symbol" ? e + "" : e, t);
@@ -24528,7 +24528,7 @@ const _hoisted_1 = {
24528
24528
  props.options.event && props.options.event.register.forEach((e) => {
24529
24529
  s.add(e);
24530
24530
  }), s.add("pointermove"), map.on([...s], (e) => {
24531
- switch (props.options.event.register.includes(e.type) && props.options.event.callback(e), e.type) {
24531
+ switch (props.options.event && props.options.event.register.includes(e.type) && props.options.event.callback(e), e.type) {
24532
24532
  case "pointermove":
24533
24533
  handlePointermove(e);
24534
24534
  break;
@@ -24618,7 +24618,7 @@ const _hoisted_1 = {
24618
24618
  for (const [i, n] of e)
24619
24619
  t[i] = n;
24620
24620
  return t;
24621
- }, VueOl = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f90a5acf"]]), plugin = {
24621
+ }, VueOl = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-0a4735ce"]]), plugin = {
24622
24622
  install(s) {
24623
24623
  s.component("VueOl", VueOl);
24624
24624
  }