@zgfe/business-lib 1.1.34-alpha.2 → 1.1.34-alpha.21
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/es/addToPanel/index.js +7 -1
- package/es/addToScene/index.js +1 -1
- package/es/assets/colorIcon/demo.css +539 -0
- package/es/assets/colorIcon/demo_index.html +741 -0
- package/es/assets/colorIcon/iconfont.css +112 -0
- package/es/assets/colorIcon/iconfont.js +43 -0
- package/es/assets/colorIcon/iconfont.json +177 -0
- package/es/assets/colorIcon/iconfont.svg +67 -0
- package/es/assets/colorIcon/iconfont.ttf +0 -0
- package/es/assets/colorIcon/iconfont.woff +0 -0
- package/es/assets/colorIcon/iconfont.woff2 +0 -0
- package/es/assets/iconfont/demo_index.html +95 -3
- package/es/assets/iconfont/iconfont.css +19 -3
- package/es/assets/iconfont/iconfont.js +1 -1
- package/es/assets/iconfont/iconfont.json +28 -0
- package/es/assets/iconfont/iconfont.ttf +0 -0
- package/es/assets/iconfont/iconfont.woff +0 -0
- package/es/assets/iconfont/iconfont.woff2 +0 -0
- package/es/assets/theme.js +1 -2
- package/es/attrConditions/components/stringList.js +0 -1
- package/es/attrConditions/components/valuesList.js +1 -0
- package/es/attrConditions/demo/group.js +3 -2
- package/es/attrConditions/demo/index.js +1 -11
- package/es/attrConditions/index.d.ts +3 -1
- package/es/attrConditions/index.js +24 -19
- package/es/attrConditions/types.d.ts +1 -1
- package/es/attributeSelector/index.js +10 -8
- package/es/attributeSelector/types.d.ts +4 -0
- package/es/attributeSelector/util.js +5 -1
- package/es/chart/util/formatOption.js +1 -1
- package/es/colorIcon/demo/index.d.ts +3 -0
- package/es/colorIcon/demo/index.js +10 -0
- package/es/colorIcon/index.d.ts +9 -0
- package/es/colorIcon/index.js +19 -0
- package/es/constants/apis.d.ts +6 -0
- package/es/constants/apis.js +7 -1
- package/es/constants/common.d.ts +11 -0
- package/es/constants/common.js +35 -0
- package/es/context/index.d.ts +4 -1
- package/es/cycleTime/month.js +17 -15
- package/es/datePicker/index.d.ts +1 -1
- package/es/datePicker/index.js +1 -1
- package/es/datePicker/styles/index.less +1 -1
- package/es/demoWrapper/content.d.ts +2 -1
- package/es/demoWrapper/content.js +25 -12
- package/es/demoWrapper/demo/index.js +5 -3
- package/es/demoWrapper/head.d.ts +3 -1
- package/es/demoWrapper/head.js +17 -5
- package/es/demoWrapper/index.js +18 -10
- package/es/dialog/index.js +1 -1
- package/es/eventSelector/demo/index.js +1 -0
- package/es/eventSelector/index.js +15 -10
- package/es/eventSelector/listPanel.js +33 -7
- package/es/eventSelector/types.d.ts +2 -0
- package/es/index.d.ts +3 -1
- package/es/index.js +3 -1
- package/es/select/handle.js +6 -2
- package/es/select/index.js +13 -11
- package/es/socket/demo/demo.d.ts +2 -0
- package/es/socket/demo/demo.js +145 -0
- package/es/socket/demo/index.less +27 -0
- package/es/socket/index.d.ts +33 -0
- package/es/socket/index.js +304 -0
- package/es/socket/types.d.ts +38 -0
- package/es/socket/types.js +28 -0
- package/es/targetConditionGroup/components/targetDimension.js +29 -27
- package/es/targetConditionGroup/data/operates.js +0 -3
- package/es/targetConditionGroup/demo/index.js +2 -1
- package/es/targetConditionGroup/index.js +65 -34
- package/es/targetConditionGroup/types.d.ts +1 -0
- package/es/targetSelector/index.js +9 -7
- package/es/userCondition/conditionTypeList.js +11 -8
- package/es/userCondition/conditions/business/operatorCondition.d.ts +11 -0
- package/es/userCondition/conditions/business/operatorCondition.js +181 -0
- package/es/userCondition/conditions/business/paramsCondition.d.ts +9 -0
- package/es/userCondition/conditions/business/paramsCondition.js +79 -0
- package/es/userCondition/conditions/businessCondition.d.ts +2 -8
- package/es/userCondition/conditions/businessCondition.js +37 -203
- package/es/userCondition/conditions/cdpCondition.js +1 -1
- package/es/userCondition/conditions/dataAttribute.js +78 -274
- package/es/userCondition/conditions/eventCondition.js +7 -4
- package/es/userCondition/conditions/order/runPeriodCondition.d.ts +11 -0
- package/es/userCondition/conditions/order/runPeriodCondition.js +142 -0
- package/es/userCondition/conditions/order/runTimesCondition.d.ts +11 -0
- package/es/userCondition/conditions/order/runTimesCondition.js +112 -0
- package/es/userCondition/conditions/textDesc.d.ts +1 -1
- package/es/userCondition/conditions/textDesc.js +160 -2
- package/es/userCondition/conditions/timeDimension.d.ts +1 -0
- package/es/userCondition/conditions/timeDimension.js +26 -76
- package/es/userCondition/demo/business.d.ts +3 -0
- package/es/userCondition/demo/business.js +71 -0
- package/es/userCondition/index.js +14 -2
- package/es/userCondition/orConditions.js +9 -4
- package/es/userCondition/types.d.ts +42 -8
- package/es/userCondition/types.js +8 -1
- package/es/userCondition/util.d.ts +1 -1
- package/es/userCondition/util.js +7 -4
- package/es/userTagsSelector/index.js +5 -3
- package/es/utils/ajax.js +0 -1
- package/package.json +60 -60
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
13
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
|
+
import { notification } from 'antd';
|
|
17
|
+
import _ from 'lodash';
|
|
18
|
+
import request from 'umi-request';
|
|
19
|
+
import Apis from '../constants/apis';
|
|
20
|
+
import SocketClientTypes from './types';
|
|
21
|
+
var SocketClient = /*#__PURE__*/function () {
|
|
22
|
+
function SocketClient(url, appkey, params) {
|
|
23
|
+
_classCallCheck(this, SocketClient);
|
|
24
|
+
this.client = void 0;
|
|
25
|
+
this.url = void 0;
|
|
26
|
+
this.params = void 0;
|
|
27
|
+
this.listeners = {};
|
|
28
|
+
this.catch = [];
|
|
29
|
+
this.showLog = false;
|
|
30
|
+
this.pingTimer = void 0;
|
|
31
|
+
this.appkey = void 0;
|
|
32
|
+
this.token = void 0;
|
|
33
|
+
this.appkey = appkey;
|
|
34
|
+
this.url = url;
|
|
35
|
+
this.params = params;
|
|
36
|
+
this.open();
|
|
37
|
+
}
|
|
38
|
+
_createClass(SocketClient, [{
|
|
39
|
+
key: "emit",
|
|
40
|
+
value: function emit(event, payload) {
|
|
41
|
+
var _this$client, _this$client2;
|
|
42
|
+
this.log('info', 'emit message', [event, payload]);
|
|
43
|
+
if (!this.client) {
|
|
44
|
+
this.log('info', '缓存消息', [event, payload]);
|
|
45
|
+
this.catch.push([event, payload]);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
switch ((_this$client = this.client) === null || _this$client === void 0 ? void 0 : _this$client.readyState) {
|
|
49
|
+
case WebSocket.CLOSED:
|
|
50
|
+
notification.warn({
|
|
51
|
+
message: '连接已关闭'
|
|
52
|
+
});
|
|
53
|
+
break;
|
|
54
|
+
case WebSocket.CLOSING:
|
|
55
|
+
notification.warn({
|
|
56
|
+
message: '正在关闭连接'
|
|
57
|
+
});
|
|
58
|
+
break;
|
|
59
|
+
case WebSocket.CONNECTING:
|
|
60
|
+
notification.warn({
|
|
61
|
+
message: '连接中'
|
|
62
|
+
});
|
|
63
|
+
this.log('info', '缓存消息', [event, payload]);
|
|
64
|
+
this.catch.push([event, payload]);
|
|
65
|
+
break;
|
|
66
|
+
case WebSocket.OPEN:
|
|
67
|
+
(_this$client2 = this.client) === null || _this$client2 === void 0 ? void 0 : _this$client2.send(JSON.stringify({
|
|
68
|
+
type: SocketClientTypes.RequestType.normal,
|
|
69
|
+
data: {
|
|
70
|
+
event: event,
|
|
71
|
+
payload: payload
|
|
72
|
+
}
|
|
73
|
+
}));
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
key: "on",
|
|
79
|
+
value: function on(type, handle) {
|
|
80
|
+
if (!this.listeners[type]) {
|
|
81
|
+
this.listeners[type] = [];
|
|
82
|
+
}
|
|
83
|
+
this.listeners[type].push(handle);
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
key: "onConnected",
|
|
87
|
+
value: function onConnected(handle) {
|
|
88
|
+
this.on(SocketClientTypes.EventType.connected, handle);
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "onDisconnected",
|
|
92
|
+
value: function onDisconnected(handle) {
|
|
93
|
+
this.on(SocketClientTypes.EventType.disconnected, handle);
|
|
94
|
+
}
|
|
95
|
+
}, {
|
|
96
|
+
key: "onError",
|
|
97
|
+
value: function onError(handle) {
|
|
98
|
+
this.on(SocketClientTypes.EventType.error, handle);
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
key: "_onError",
|
|
102
|
+
value: function _onError(error) {
|
|
103
|
+
var _this$listeners$error;
|
|
104
|
+
this.log('error', 'socket连接异常', error);
|
|
105
|
+
(_this$listeners$error = this.listeners['error']) === null || _this$listeners$error === void 0 ? void 0 : _this$listeners$error.forEach(function (handle) {
|
|
106
|
+
handle.call(undefined, error);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "_onClose",
|
|
111
|
+
value: function _onClose(_event) {
|
|
112
|
+
var _this$listeners$disco;
|
|
113
|
+
this.log('error', 'socket连接已关闭');
|
|
114
|
+
(_this$listeners$disco = this.listeners['disconnected']) === null || _this$listeners$disco === void 0 ? void 0 : _this$listeners$disco.forEach(function (handle) {
|
|
115
|
+
handle.call(undefined);
|
|
116
|
+
});
|
|
117
|
+
clearInterval(this.pingTimer);
|
|
118
|
+
}
|
|
119
|
+
}, {
|
|
120
|
+
key: "_onOpen",
|
|
121
|
+
value: function _onOpen(event) {
|
|
122
|
+
var _this$listeners$conne,
|
|
123
|
+
_this = this;
|
|
124
|
+
this.log('info', 'socket连接成功', event);
|
|
125
|
+
(_this$listeners$conne = this.listeners['connected']) === null || _this$listeners$conne === void 0 ? void 0 : _this$listeners$conne.forEach(function (handle) {
|
|
126
|
+
handle.call(undefined, _this.token);
|
|
127
|
+
});
|
|
128
|
+
this.log('info', 'clear catch', this.catch);
|
|
129
|
+
this.catch.forEach(function (_ref) {
|
|
130
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
131
|
+
event = _ref2[0],
|
|
132
|
+
payload = _ref2[1];
|
|
133
|
+
_this.emit(event, payload);
|
|
134
|
+
});
|
|
135
|
+
this.catch = [];
|
|
136
|
+
this.ping();
|
|
137
|
+
}
|
|
138
|
+
}, {
|
|
139
|
+
key: "onMessage",
|
|
140
|
+
value: function onMessage(event) {
|
|
141
|
+
var _this$listeners$Socke, _this$listeners$Socke2, _this$listeners$Socke3, _this$listeners$unkno;
|
|
142
|
+
var res = JSON.parse(event.data);
|
|
143
|
+
if (res.code) {
|
|
144
|
+
switch (Number(res.code)) {
|
|
145
|
+
case SocketClientTypes.ResponseCode.offline:
|
|
146
|
+
(_this$listeners$Socke = this.listeners[SocketClientTypes.EventType.offline]) === null || _this$listeners$Socke === void 0 ? void 0 : _this$listeners$Socke.forEach(function (handle) {
|
|
147
|
+
handle.call(undefined, res);
|
|
148
|
+
});
|
|
149
|
+
break;
|
|
150
|
+
case SocketClientTypes.ResponseCode.online:
|
|
151
|
+
(_this$listeners$Socke2 = this.listeners[SocketClientTypes.EventType.online]) === null || _this$listeners$Socke2 === void 0 ? void 0 : _this$listeners$Socke2.forEach(function (handle) {
|
|
152
|
+
handle.call(undefined, res);
|
|
153
|
+
});
|
|
154
|
+
break;
|
|
155
|
+
case SocketClientTypes.ResponseCode.exist:
|
|
156
|
+
(_this$listeners$Socke3 = this.listeners[SocketClientTypes.EventType.exist]) === null || _this$listeners$Socke3 === void 0 ? void 0 : _this$listeners$Socke3.forEach(function (handle) {
|
|
157
|
+
handle.call(undefined, res);
|
|
158
|
+
});
|
|
159
|
+
break;
|
|
160
|
+
case SocketClientTypes.ResponseCode.paramError:
|
|
161
|
+
this._onError(new Error('参数缺失或错误'));
|
|
162
|
+
default:
|
|
163
|
+
(_this$listeners$unkno = this.listeners['unknownCode']) === null || _this$listeners$unkno === void 0 ? void 0 : _this$listeners$unkno.forEach(function (handle) {
|
|
164
|
+
handle.call(undefined, res);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
} else if (res.type === SocketClientTypes.RequestType.pong) {
|
|
168
|
+
return;
|
|
169
|
+
} else {
|
|
170
|
+
var data = res.data;
|
|
171
|
+
if (this.listeners[data.event]) {
|
|
172
|
+
this.listeners[data.event].forEach(function (handle) {
|
|
173
|
+
handle.call(undefined, data.payload);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}, {
|
|
179
|
+
key: "ping",
|
|
180
|
+
value: function ping() {
|
|
181
|
+
var _this2 = this;
|
|
182
|
+
this.pingTimer = setInterval(function () {
|
|
183
|
+
var _this2$client;
|
|
184
|
+
(_this2$client = _this2.client) === null || _this2$client === void 0 ? void 0 : _this2$client.send(JSON.stringify({
|
|
185
|
+
type: SocketClientTypes.RequestType.ping
|
|
186
|
+
}));
|
|
187
|
+
}, 3000);
|
|
188
|
+
}
|
|
189
|
+
}, {
|
|
190
|
+
key: "removeAllListeners",
|
|
191
|
+
value: function removeAllListeners() {
|
|
192
|
+
this.listeners = {};
|
|
193
|
+
}
|
|
194
|
+
}, {
|
|
195
|
+
key: "removeListener",
|
|
196
|
+
value: function removeListener(event, handle) {
|
|
197
|
+
var _this3 = this;
|
|
198
|
+
if (handle) {
|
|
199
|
+
var _this$listeners$event;
|
|
200
|
+
(_this$listeners$event = this.listeners[event]) === null || _this$listeners$event === void 0 ? void 0 : _this$listeners$event.forEach(function (item, i) {
|
|
201
|
+
if (item === handle) {
|
|
202
|
+
_this3.listeners[event].splice(i, 1);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
} else {
|
|
206
|
+
this.listeners[event] = [];
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}, {
|
|
210
|
+
key: "_getToken",
|
|
211
|
+
value: function () {
|
|
212
|
+
var _getToken2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
213
|
+
var res;
|
|
214
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
215
|
+
while (1) switch (_context.prev = _context.next) {
|
|
216
|
+
case 0:
|
|
217
|
+
_context.next = 2;
|
|
218
|
+
return request(Apis.getSocketToken, {
|
|
219
|
+
method: 'get',
|
|
220
|
+
params: {
|
|
221
|
+
appKey: this.appkey
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
case 2:
|
|
225
|
+
res = _context.sent;
|
|
226
|
+
return _context.abrupt("return", res.data.socketToken);
|
|
227
|
+
case 4:
|
|
228
|
+
case "end":
|
|
229
|
+
return _context.stop();
|
|
230
|
+
}
|
|
231
|
+
}, _callee, this);
|
|
232
|
+
}));
|
|
233
|
+
function _getToken() {
|
|
234
|
+
return _getToken2.apply(this, arguments);
|
|
235
|
+
}
|
|
236
|
+
return _getToken;
|
|
237
|
+
}()
|
|
238
|
+
}, {
|
|
239
|
+
key: "open",
|
|
240
|
+
value: function open(url, params) {
|
|
241
|
+
var _this4 = this;
|
|
242
|
+
this._getToken().then(function (token) {
|
|
243
|
+
_this4.params = params || _this4.params;
|
|
244
|
+
_this4.token = token;
|
|
245
|
+
if (_this4.client) _this4.close();
|
|
246
|
+
var paramUrl = ["socketToken=".concat(token)];
|
|
247
|
+
if (_this4.params) {
|
|
248
|
+
var _Object$keys;
|
|
249
|
+
(_Object$keys = Object.keys(_this4.params || {})) === null || _Object$keys === void 0 ? void 0 : _Object$keys.forEach(function (key) {
|
|
250
|
+
if (_.isObject(_this4.params[key]) || _.isArray(_this4.params[key])) {
|
|
251
|
+
paramUrl.push("".concat(key, "=").concat(JSON.stringify(_this4.params[key])));
|
|
252
|
+
} else {
|
|
253
|
+
paramUrl.push("".concat(key, "=").concat(_this4.params[key]));
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
var client = new WebSocket("".concat(url || _this4.url, "?").concat(paramUrl.join('&')));
|
|
258
|
+
_this4.client = client;
|
|
259
|
+
client.onmessage = _this4.onMessage.bind(_this4);
|
|
260
|
+
client.onerror = _this4._onError.bind(_this4);
|
|
261
|
+
client.onclose = _this4._onClose.bind(_this4);
|
|
262
|
+
client.onopen = _this4._onOpen.bind(_this4);
|
|
263
|
+
}).catch(function (err) {
|
|
264
|
+
_this4.log('error', 'socket获取token信息异常');
|
|
265
|
+
_this4._onError(err);
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}, {
|
|
269
|
+
key: "close",
|
|
270
|
+
value: function close() {
|
|
271
|
+
var _this$client3;
|
|
272
|
+
(_this$client3 = this.client) === null || _this$client3 === void 0 ? void 0 : _this$client3.close();
|
|
273
|
+
this.log('info', '关闭socket连接');
|
|
274
|
+
}
|
|
275
|
+
}, {
|
|
276
|
+
key: "destroy",
|
|
277
|
+
value: function destroy() {
|
|
278
|
+
this.removeAllListeners();
|
|
279
|
+
this.close();
|
|
280
|
+
this.client = undefined;
|
|
281
|
+
}
|
|
282
|
+
}, {
|
|
283
|
+
key: "log",
|
|
284
|
+
value: function log(type) {
|
|
285
|
+
var _console;
|
|
286
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
287
|
+
args[_key - 1] = arguments[_key];
|
|
288
|
+
}
|
|
289
|
+
if (this.showLog) (_console = console).log.apply(_console, ["%c\u3010socketClient\u3011:".concat(type), "color: ".concat(type === 'error' ? 'red' : '#1890ff')].concat(args));
|
|
290
|
+
}
|
|
291
|
+
}, {
|
|
292
|
+
key: "openLog",
|
|
293
|
+
value: function openLog(open) {
|
|
294
|
+
this.showLog = open;
|
|
295
|
+
}
|
|
296
|
+
}, {
|
|
297
|
+
key: "getToken",
|
|
298
|
+
value: function getToken() {
|
|
299
|
+
return this.token;
|
|
300
|
+
}
|
|
301
|
+
}]);
|
|
302
|
+
return SocketClient;
|
|
303
|
+
}();
|
|
304
|
+
export default SocketClient;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
declare namespace SocketClientTypes {
|
|
2
|
+
enum EventType {
|
|
3
|
+
connected = "connected",
|
|
4
|
+
disconnected = "disconnected",
|
|
5
|
+
error = "error",
|
|
6
|
+
offline = "offline",
|
|
7
|
+
exist = "exist",
|
|
8
|
+
online = "online"
|
|
9
|
+
}
|
|
10
|
+
enum RequestType {
|
|
11
|
+
common = 0,
|
|
12
|
+
ping = 1,
|
|
13
|
+
pong = 2,
|
|
14
|
+
normal = 5,
|
|
15
|
+
img = 6
|
|
16
|
+
}
|
|
17
|
+
enum ResponseCode {
|
|
18
|
+
offline = 109001,
|
|
19
|
+
exist = 109002,
|
|
20
|
+
paramError = 109005,
|
|
21
|
+
online = 109006
|
|
22
|
+
}
|
|
23
|
+
type Message = {
|
|
24
|
+
type: RequestType;
|
|
25
|
+
data: {
|
|
26
|
+
event: string;
|
|
27
|
+
payload: Record<string, any> | string | number | boolean;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
interface ResponseData {
|
|
31
|
+
code: string;
|
|
32
|
+
data: {
|
|
33
|
+
type: RequestType;
|
|
34
|
+
[prop: string]: any;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export default SocketClientTypes;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var SocketClientTypes;
|
|
2
|
+
(function (SocketClientTypes) {
|
|
3
|
+
var EventType;
|
|
4
|
+
(function (EventType) {
|
|
5
|
+
EventType["connected"] = "connected";
|
|
6
|
+
EventType["disconnected"] = "disconnected";
|
|
7
|
+
EventType["error"] = "error";
|
|
8
|
+
EventType["offline"] = "offline";
|
|
9
|
+
EventType["exist"] = "exist";
|
|
10
|
+
EventType["online"] = "online";
|
|
11
|
+
})(EventType = SocketClientTypes.EventType || (SocketClientTypes.EventType = {}));
|
|
12
|
+
var RequestType;
|
|
13
|
+
(function (RequestType) {
|
|
14
|
+
RequestType[RequestType["common"] = 0] = "common";
|
|
15
|
+
RequestType[RequestType["ping"] = 1] = "ping";
|
|
16
|
+
RequestType[RequestType["pong"] = 2] = "pong";
|
|
17
|
+
RequestType[RequestType["normal"] = 5] = "normal";
|
|
18
|
+
RequestType[RequestType["img"] = 6] = "img";
|
|
19
|
+
})(RequestType = SocketClientTypes.RequestType || (SocketClientTypes.RequestType = {}));
|
|
20
|
+
var ResponseCode;
|
|
21
|
+
(function (ResponseCode) {
|
|
22
|
+
ResponseCode[ResponseCode["offline"] = 109001] = "offline";
|
|
23
|
+
ResponseCode[ResponseCode["exist"] = 109002] = "exist";
|
|
24
|
+
ResponseCode[ResponseCode["paramError"] = 109005] = "paramError";
|
|
25
|
+
ResponseCode[ResponseCode["online"] = 109006] = "online";
|
|
26
|
+
})(ResponseCode = SocketClientTypes.ResponseCode || (SocketClientTypes.ResponseCode = {}));
|
|
27
|
+
})(SocketClientTypes || (SocketClientTypes = {}));
|
|
28
|
+
export default SocketClientTypes;
|
|
@@ -97,33 +97,35 @@ var BizTargetDimension = function BizTargetDimension(props) {
|
|
|
97
97
|
overlayClassName: "".concat(classPrefix, "-dropmenu"),
|
|
98
98
|
placement: "bottom",
|
|
99
99
|
trigger: ['click'],
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
100
|
+
dropdownRender: function dropdownRender() {
|
|
101
|
+
return /*#__PURE__*/React.createElement(Menu, null, options.map(function (item) {
|
|
102
|
+
if (item.children) {
|
|
103
|
+
return /*#__PURE__*/React.createElement(SubMenu, {
|
|
104
|
+
popupClassName: "".concat(classPrefix, "-submenu"),
|
|
105
|
+
key: item.label,
|
|
106
|
+
title: item.label,
|
|
107
|
+
className: "".concat((dimensionParent === null || dimensionParent === void 0 ? void 0 : dimensionParent.label) === item.label ? 'active' : '')
|
|
108
|
+
}, item.children.map(function (sub) {
|
|
109
|
+
return /*#__PURE__*/React.createElement(Menu.Item, {
|
|
110
|
+
className: (dimensionParent === null || dimensionParent === void 0 ? void 0 : dimensionParent.value) === item.value && (dimension === null || dimension === void 0 ? void 0 : dimension.value) === sub.value ? 'active' : '',
|
|
111
|
+
title: sub.label,
|
|
112
|
+
key: "".concat(item.value, "-").concat(sub.value),
|
|
113
|
+
onClick: function onClick() {
|
|
114
|
+
return onChange(sub, item);
|
|
115
|
+
}
|
|
116
|
+
}, sub.label);
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
return /*#__PURE__*/React.createElement(Menu.Item, {
|
|
120
|
+
className: (dimension === null || dimension === void 0 ? void 0 : dimension.value) === item.value ? 'active' : '',
|
|
121
|
+
key: item.value,
|
|
122
|
+
onClick: function onClick() {
|
|
123
|
+
return onChange(item);
|
|
124
|
+
},
|
|
125
|
+
title: item.label
|
|
126
|
+
}, item.label);
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
127
129
|
}, /*#__PURE__*/React.createElement("div", {
|
|
128
130
|
className: "".concat(classPrefix, "-dimension")
|
|
129
131
|
}, /*#__PURE__*/React.createElement(SelectHandle, {
|
|
@@ -51,6 +51,7 @@ export default (function () {
|
|
|
51
51
|
max: 3
|
|
52
52
|
}, /*#__PURE__*/React.createElement(BizEventSelector, {
|
|
53
53
|
showAllEvent: true,
|
|
54
|
-
border: false
|
|
54
|
+
border: false,
|
|
55
|
+
showBuiltInTarget: true
|
|
55
56
|
}))), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("p", null, "\u5F53\u524D\u503C\uFF1A", JSON.stringify(target)));
|
|
56
57
|
});
|