@vtx/cs-map-layer 1.0.10 → 1.0.12
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/lib/DeviceLayer/index.js +10 -8
- package/lib/_util/http.js +28 -22
- package/lib/_util/layerConfig.d.ts +1 -1
- package/lib/_util/layerConfig.js +5 -2
- package/package.json +12 -12
package/lib/DeviceLayer/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["code", "params", "showModal"];
|
|
2
|
+
var _excluded = ["code", "params", "showModal", "styleOption"];
|
|
3
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -10,31 +10,33 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
10
10
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
11
11
|
import { FeatureLayer } from '@vtx/cs-map';
|
|
12
12
|
import React from 'react';
|
|
13
|
+
import DeviceTemplate from "../_components/Template/DeviceTemplate";
|
|
13
14
|
import { DEVICE_CODE } from "../_util/interface";
|
|
14
15
|
import { deviceCodeMap, getDeviceStyle } from "../_util/layerConfig";
|
|
15
|
-
import DeviceTemplate from "../_components/Template/DeviceTemplate";
|
|
16
16
|
var DeviceLayer = function DeviceLayer(props) {
|
|
17
17
|
var _props$code = props.code,
|
|
18
18
|
code = _props$code === void 0 ? DEVICE_CODE.DEFAULT : _props$code,
|
|
19
19
|
_props$params = props.params,
|
|
20
20
|
params = _props$params === void 0 ? {} : _props$params,
|
|
21
21
|
showModal = props.showModal,
|
|
22
|
+
_props$styleOption = props.styleOption,
|
|
23
|
+
styleOption = _props$styleOption === void 0 ? {} : _props$styleOption,
|
|
22
24
|
otherProps = _objectWithoutProperties(props, _excluded);
|
|
23
|
-
var
|
|
24
|
-
name =
|
|
25
|
-
labelField =
|
|
26
|
-
icon =
|
|
25
|
+
var _ref = deviceCodeMap[code] || {},
|
|
26
|
+
name = _ref.name,
|
|
27
|
+
labelField = _ref.labelField,
|
|
28
|
+
icon = _ref.icon;
|
|
27
29
|
return /*#__PURE__*/React.createElement(FeatureLayer, _extends({
|
|
28
30
|
url: "/cloud/zhsw-jcyj/api/basicDevice/list",
|
|
29
31
|
params: _objectSpread({
|
|
30
32
|
deviceTypeId: code
|
|
31
33
|
}, params),
|
|
32
34
|
style: function style(f) {
|
|
33
|
-
return getDeviceStyle(f, icon || '');
|
|
35
|
+
return getDeviceStyle(f, icon || '', styleOption);
|
|
34
36
|
},
|
|
35
37
|
name: name,
|
|
36
38
|
labelField: labelField,
|
|
37
|
-
legend: icon,
|
|
39
|
+
legend: icon || (styleOption === null || styleOption === void 0 ? void 0 : styleOption.icon),
|
|
38
40
|
zIndex: 4,
|
|
39
41
|
id: code,
|
|
40
42
|
template: function template(feature) {
|
package/lib/_util/http.js
CHANGED
|
@@ -9,21 +9,20 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
9
9
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
10
|
import axios from 'axios';
|
|
11
11
|
// 安装axios的同时会同步安装qs包 https://www.npmjs.com/package/qs
|
|
12
|
-
import {
|
|
12
|
+
import { trim } from '@vtx/utils';
|
|
13
13
|
import { message } from 'antd';
|
|
14
14
|
import isObject from 'lodash/isObject';
|
|
15
15
|
import pickBy from 'lodash/pickBy';
|
|
16
16
|
import qs from 'qs';
|
|
17
|
+
import { getVtxToken } from "@vtx/utils";
|
|
17
18
|
|
|
18
19
|
// 默认30秒超时
|
|
19
20
|
var SECOND = 30;
|
|
20
21
|
var MILL_SECOND = 1000;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*
|
|
25
|
-
* axios文档 http://www.axios-js.com/zh-cn/docs/
|
|
26
|
-
* 支持 Get 和 Post 请求
|
|
22
|
+
/**
|
|
23
|
+
* 基于 axios 封装的请求封装
|
|
24
|
+
* axios文档 http://www.axios-js.com/zh-cn/docs/
|
|
25
|
+
* 支持 Get 和 Post 请求
|
|
27
26
|
*/
|
|
28
27
|
var Http = /*#__PURE__*/function () {
|
|
29
28
|
function Http(options) {
|
|
@@ -37,6 +36,11 @@ var Http = /*#__PURE__*/function () {
|
|
|
37
36
|
_createClass(Http, [{
|
|
38
37
|
key: "_createAxios",
|
|
39
38
|
value: function _createAxios(options) {
|
|
39
|
+
var _ref = getVtxToken() || {},
|
|
40
|
+
token = _ref.token,
|
|
41
|
+
tenantId = _ref.tenantId,
|
|
42
|
+
userId = _ref.userId;
|
|
43
|
+
|
|
40
44
|
// 创建实例
|
|
41
45
|
var instance = axios.create(_objectSpread({
|
|
42
46
|
// `timeout` 指定请求超时的毫秒数(0 表示无超时时间)
|
|
@@ -44,17 +48,19 @@ var Http = /*#__PURE__*/function () {
|
|
|
44
48
|
timeout: MILL_SECOND * SECOND,
|
|
45
49
|
headers: {
|
|
46
50
|
Authorization: token ? "Bearer ".concat(token) : '',
|
|
47
|
-
'Cache-Control': 'no-cache'
|
|
51
|
+
'Cache-Control': 'no-cache',
|
|
52
|
+
tenantId: tenantId,
|
|
53
|
+
userId: userId
|
|
48
54
|
}
|
|
49
55
|
}, options));
|
|
50
56
|
instance.interceptors.response.use(this._responseHandler, this._errorHandler);
|
|
51
57
|
return instance;
|
|
52
58
|
}
|
|
53
59
|
|
|
54
|
-
/**
|
|
55
|
-
* get 请求
|
|
56
|
-
* @param {*} url
|
|
57
|
-
* @param {*} options {body}
|
|
60
|
+
/**
|
|
61
|
+
* get 请求
|
|
62
|
+
* @param {*} url
|
|
63
|
+
* @param {*} options {body}
|
|
58
64
|
*/
|
|
59
65
|
}, {
|
|
60
66
|
key: "get",
|
|
@@ -72,10 +78,10 @@ var Http = /*#__PURE__*/function () {
|
|
|
72
78
|
});
|
|
73
79
|
}
|
|
74
80
|
|
|
75
|
-
/**
|
|
76
|
-
* post 请求
|
|
77
|
-
* @param {*} url
|
|
78
|
-
* @param {*} options
|
|
81
|
+
/**
|
|
82
|
+
* post 请求
|
|
83
|
+
* @param {*} url
|
|
84
|
+
* @param {*} options
|
|
79
85
|
*/
|
|
80
86
|
}, {
|
|
81
87
|
key: "post",
|
|
@@ -93,9 +99,9 @@ var Http = /*#__PURE__*/function () {
|
|
|
93
99
|
});
|
|
94
100
|
}
|
|
95
101
|
|
|
96
|
-
/**
|
|
97
|
-
* 响应数据的处理
|
|
98
|
-
* @param {*} response
|
|
102
|
+
/**
|
|
103
|
+
* 响应数据的处理
|
|
104
|
+
* @param {*} response
|
|
99
105
|
*/
|
|
100
106
|
}, {
|
|
101
107
|
key: "_responseHandler",
|
|
@@ -116,9 +122,9 @@ var Http = /*#__PURE__*/function () {
|
|
|
116
122
|
throw error;
|
|
117
123
|
}
|
|
118
124
|
|
|
119
|
-
/**
|
|
120
|
-
* 请求错误处理
|
|
121
|
-
* @param {*} error
|
|
125
|
+
/**
|
|
126
|
+
* 请求错误处理
|
|
127
|
+
* @param {*} error
|
|
122
128
|
*/
|
|
123
129
|
}, {
|
|
124
130
|
key: "_errorHandler",
|
|
@@ -15,7 +15,7 @@ type DeviceI = {
|
|
|
15
15
|
};
|
|
16
16
|
declare const facilityCodeMap: FacilityI;
|
|
17
17
|
declare const deviceCodeMap: DeviceI;
|
|
18
|
-
export declare const getDeviceStyle: (f: any, icon: string) => {
|
|
18
|
+
export declare const getDeviceStyle: (f: any, icon: string, styleOption?: {}) => {
|
|
19
19
|
type: string;
|
|
20
20
|
style: {
|
|
21
21
|
icon: string;
|
package/lib/_util/layerConfig.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
var _facilityCodeMap;
|
|
2
2
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
6
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
5
7
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
@@ -250,6 +252,7 @@ var deviceCodeMap = {
|
|
|
250
252
|
}
|
|
251
253
|
};
|
|
252
254
|
export var getDeviceStyle = function getDeviceStyle(f, icon) {
|
|
255
|
+
var styleOption = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
253
256
|
var value = f._properties.properties._value;
|
|
254
257
|
var statusMap = {
|
|
255
258
|
1: '',
|
|
@@ -262,11 +265,11 @@ export var getDeviceStyle = function getDeviceStyle(f, icon) {
|
|
|
262
265
|
};
|
|
263
266
|
return {
|
|
264
267
|
type: 'Marker',
|
|
265
|
-
style: {
|
|
268
|
+
style: _objectSpread({
|
|
266
269
|
icon: icon,
|
|
267
270
|
scale: 0.65,
|
|
268
271
|
status: statusMap[value.status]
|
|
269
|
-
}
|
|
272
|
+
}, styleOption)
|
|
270
273
|
};
|
|
271
274
|
};
|
|
272
275
|
export { deviceCodeMap, facilityCodeMap };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtx/cs-map-layer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "React components for Vortex",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "father build",
|
|
13
13
|
"build:watch": "father dev",
|
|
14
|
+
"cesium:fix": "node ./scripts/cesium-fix.js",
|
|
14
15
|
"dev": "npm run cesium:fix && dumi dev",
|
|
15
16
|
"docs:build": "npm run cesium:fix && dumi build",
|
|
16
17
|
"doctor": "father doctor",
|
|
17
|
-
"cesium:fix": "node ./scripts/cesium-fix.js",
|
|
18
18
|
"lint": "npm run lint:es && npm run lint:css",
|
|
19
19
|
"lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
|
|
20
20
|
"lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
|
|
@@ -57,14 +57,21 @@
|
|
|
57
57
|
"qs": "^6.0.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
+
"@ant-design/icons": "4.7.0",
|
|
60
61
|
"@babel/runtime": "^7.6.3",
|
|
61
62
|
"@commitlint/cli": "^17.1.2",
|
|
62
63
|
"@commitlint/config-conventional": "^17.1.0",
|
|
64
|
+
"@turf/turf": "^6.5.0",
|
|
63
65
|
"@types/lodash": "^4.14.202",
|
|
64
66
|
"@types/qs": "^6.9.11",
|
|
65
67
|
"@types/react": "^18.0.0",
|
|
66
68
|
"@types/react-dom": "^18.0.0",
|
|
67
69
|
"@umijs/lint": "^4.0.0",
|
|
70
|
+
"@vtx/cs-map": "latest",
|
|
71
|
+
"@vtx/map-icon": "^2.0.16",
|
|
72
|
+
"ahooks": "^3.1.5",
|
|
73
|
+
"antd": "4.20.5",
|
|
74
|
+
"axios": "^0.21.1",
|
|
68
75
|
"babel-plugin-import": "^1.13.8",
|
|
69
76
|
"dumi": "^2.2.13",
|
|
70
77
|
"eslint": "^8.23.0",
|
|
@@ -76,21 +83,14 @@
|
|
|
76
83
|
"prettier-plugin-packagejson": "^2.2.18",
|
|
77
84
|
"react": "^18.0.0",
|
|
78
85
|
"react-dom": "^18.0.0",
|
|
79
|
-
"@ant-design/icons": "4.7.0",
|
|
80
|
-
"@vtx/cs-map": "^1.0.53",
|
|
81
|
-
"@turf/turf": "^6.5.0",
|
|
82
|
-
"@vtx/map-icon": "^2.0.16",
|
|
83
|
-
"ahooks": "^3.1.5",
|
|
84
|
-
"axios": "^0.21.1",
|
|
85
|
-
"antd": "4.20.5",
|
|
86
86
|
"stylelint": "^14.9.1"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
|
-
"
|
|
90
|
-
"@vtx/map-icon": ">=2.0.0",
|
|
89
|
+
"@ant-design/icons": ">=4.0.0",
|
|
91
90
|
"@vtx/cs-map": ">=1.0.40",
|
|
91
|
+
"@vtx/map-icon": ">=2.0.0",
|
|
92
|
+
"antd": ">4.0.0",
|
|
92
93
|
"axios": ">=0.21.1",
|
|
93
|
-
"@ant-design/icons": ">=4.0.0",
|
|
94
94
|
"react": ">=16.9.0",
|
|
95
95
|
"react-dom": ">=16.9.0"
|
|
96
96
|
},
|