@zgfe/business-lib 1.1.31-alpha.3 → 1.1.32

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.
Files changed (60) hide show
  1. package/es/assets/colorIcon/demo.css +539 -0
  2. package/es/assets/colorIcon/demo_index.html +741 -0
  3. package/es/assets/colorIcon/iconfont.css +112 -0
  4. package/es/assets/colorIcon/iconfont.js +43 -0
  5. package/es/assets/colorIcon/iconfont.json +177 -0
  6. package/es/assets/colorIcon/iconfont.svg +67 -0
  7. package/es/assets/colorIcon/iconfont.ttf +0 -0
  8. package/es/assets/colorIcon/iconfont.woff +0 -0
  9. package/es/assets/colorIcon/iconfont.woff2 +0 -0
  10. package/es/assets/iconfont/demo_index.html +95 -3
  11. package/es/assets/iconfont/iconfont.css +19 -3
  12. package/es/assets/iconfont/iconfont.js +1 -1
  13. package/es/assets/iconfont/iconfont.json +28 -0
  14. package/es/assets/iconfont/iconfont.ttf +0 -0
  15. package/es/assets/iconfont/iconfont.woff +0 -0
  16. package/es/assets/iconfont/iconfont.woff2 +0 -0
  17. package/es/assets/styles/resetAntd.less +12 -36
  18. package/es/attrConditions/components/stringList.js +0 -1
  19. package/es/attrConditions/utils/operates.d.ts +0 -50
  20. package/es/attrConditions/utils/operates.js +0 -126
  21. package/es/colorIcon/demo/index.d.ts +3 -0
  22. package/es/colorIcon/demo/index.js +10 -0
  23. package/es/colorIcon/index.d.ts +9 -0
  24. package/es/colorIcon/index.js +19 -0
  25. package/es/constants/apis.d.ts +1 -0
  26. package/es/constants/apis.js +2 -1
  27. package/es/datePicker/index.d.ts +1 -1
  28. package/es/datePicker/index.js +1 -1
  29. package/es/datePicker/styles/index.less +1 -1
  30. package/es/demoWrapper/content.d.ts +2 -1
  31. package/es/demoWrapper/content.js +23 -12
  32. package/es/demoWrapper/demo/index.js +5 -3
  33. package/es/demoWrapper/head.d.ts +3 -1
  34. package/es/demoWrapper/head.js +17 -5
  35. package/es/demoWrapper/index.js +18 -10
  36. package/es/eventSelector/listPanel.js +11 -4
  37. package/es/index.d.ts +3 -1
  38. package/es/index.js +3 -1
  39. package/es/socket/demo/demo.d.ts +2 -0
  40. package/es/socket/demo/demo.js +145 -0
  41. package/es/socket/demo/index.less +27 -0
  42. package/es/socket/index.d.ts +31 -0
  43. package/es/socket/index.js +291 -0
  44. package/es/socket/types.d.ts +38 -0
  45. package/es/socket/types.js +28 -0
  46. package/es/userCondition/conditionTypeList.js +1 -17
  47. package/es/userCondition/conditions/constants.d.ts +0 -1
  48. package/es/userCondition/conditions/constants.js +1 -2
  49. package/es/userCondition/conditions/eventCondition.js +2 -77
  50. package/es/userCondition/orConditions.js +0 -15
  51. package/es/userCondition/types.d.ts +3 -34
  52. package/es/userCondition/util.d.ts +1 -1
  53. package/es/userCondition/util.js +0 -29
  54. package/package.json +61 -61
  55. package/es/userCondition/conditions/businessCondition.d.ts +0 -11
  56. package/es/userCondition/conditions/businessCondition.js +0 -416
  57. package/es/userCondition/conditions/dataAttribute.d.ts +0 -10
  58. package/es/userCondition/conditions/dataAttribute.js +0 -447
  59. package/es/userCondition/conditions/timeDimension.d.ts +0 -9
  60. package/es/userCondition/conditions/timeDimension.js +0 -200
package/es/index.js CHANGED
@@ -12,6 +12,7 @@ import BizDialog from './dialog';
12
12
  import BizChart from './chart';
13
13
  import BizTable from './table';
14
14
  import IconFont from './icon/iconFont';
15
+ import ColorIcon from './colorIcon';
15
16
  import { util, ajax } from './utils';
16
17
  import theme from './assets/theme.js';
17
18
  import convertAttributeData from './attributeSelector/util';
@@ -27,4 +28,5 @@ import BizDnd from './dnd';
27
28
  import BizDetailLayout from './layout/detail';
28
29
  import BizLoginForm from './loginForm';
29
30
  import DemoWrapper from './demoWrapper';
30
- export { BizSearchInput, BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizDetailLayout, BizUserGroup, IconFont, BizTargetSelector, BizEventSelector, BizAttributeSelector, BizGlobalDataContext, BizTargetCondition, BizDatePicker, BizConditionItem, BizConditionGroup, BizUserCondition, BizAddToScene, BizAddToPanel, BizCycleTime, BizDnd, BizLoginForm, DemoWrapper, ajax, util, theme, convertAttributeData, BizUserTagsSelect, setGlobalConfig };
31
+ import SocketClient from './socket';
32
+ export { BizSearchInput, BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizDetailLayout, BizUserGroup, IconFont, ColorIcon, BizTargetSelector, BizEventSelector, BizAttributeSelector, BizGlobalDataContext, BizTargetCondition, BizDatePicker, BizConditionItem, BizConditionGroup, BizUserCondition, BizAddToScene, BizAddToPanel, BizCycleTime, BizDnd, BizLoginForm, DemoWrapper, SocketClient, ajax, util, theme, convertAttributeData, BizUserTagsSelect, setGlobalConfig };
@@ -0,0 +1,2 @@
1
+ declare const _default: () => JSX.Element;
2
+ export default _default;
@@ -0,0 +1,145 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
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
+ import React, { useContext, useEffect, useRef, useState } from 'react';
12
+ import { SocketClient } from '@zgfe/business-lib';
13
+ import { Button, Card, Form, Input, notification } from 'antd';
14
+ import styles from './index.less';
15
+ import { DemoWrapper, BizGlobalDataContext } from '@zgfe/business-lib';
16
+ var ChatPanel = function ChatPanel(_ref) {
17
+ var name = _ref.name,
18
+ param = _ref.param;
19
+ var _useState = useState(),
20
+ _useState2 = _slicedToArray(_useState, 2),
21
+ client = _useState2[0],
22
+ setClient = _useState2[1];
23
+ var _useState3 = useState([]),
24
+ _useState4 = _slicedToArray(_useState3, 2),
25
+ history = _useState4[0],
26
+ setHistory = _useState4[1];
27
+ var _useState5 = useState(true),
28
+ _useState6 = _slicedToArray(_useState5, 2),
29
+ online = _useState6[0],
30
+ setOnline = _useState6[1];
31
+ var formRef = useRef();
32
+ var historyRef = useRef();
33
+ var _useContext = useContext(BizGlobalDataContext),
34
+ currentApp = _useContext.currentApp;
35
+ useEffect(function () {
36
+ var socket = new SocketClient('wss://rt2.zhugeio.com/eventtracking/ws', currentApp === null || currentApp === void 0 ? void 0 : currentApp.appKey, param);
37
+ setClient(socket);
38
+ return function () {
39
+ console.log('销毁chat', param);
40
+ if (!client) return;
41
+ client.destroy();
42
+ setClient(undefined);
43
+ };
44
+ }, []);
45
+ useEffect(function () {
46
+ var _historyRef$current;
47
+ if (historyRef.current) historyRef.current.scrollTop = (_historyRef$current = historyRef.current) === null || _historyRef$current === void 0 ? void 0 : _historyRef$current.scrollHeight;
48
+ }, [history]);
49
+ useEffect(function () {
50
+ if (!client) return;
51
+ client.openLog(true);
52
+ client.onConnected(onConnected);
53
+ client.onError(onError);
54
+ client.on('offline', function () {
55
+ setHistory(function (list) {
56
+ return [].concat(_toConsumableArray(list), [{
57
+ type: 'he',
58
+ message: '对方已下线'
59
+ }]);
60
+ });
61
+ });
62
+ client.on('exist', function () {
63
+ console.log('连接已存在');
64
+ });
65
+ client.on('message', function (message) {
66
+ setHistory(function (list) {
67
+ return [].concat(_toConsumableArray(list), [{
68
+ type: 'he',
69
+ message: message
70
+ }]);
71
+ });
72
+ });
73
+ }, [client]);
74
+ function onConnected() {
75
+ notification.success({
76
+ message: '连接成功'
77
+ });
78
+ }
79
+ function onError(err) {
80
+ notification.error({
81
+ message: '连接失败',
82
+ description: err.message
83
+ });
84
+ }
85
+ return /*#__PURE__*/React.createElement(Card, {
86
+ title: name
87
+ }, /*#__PURE__*/React.createElement("div", {
88
+ className: styles.history,
89
+ ref: historyRef
90
+ }, history.map(function (item, i) {
91
+ return /*#__PURE__*/React.createElement("div", {
92
+ className: styles[item.type],
93
+ key: i
94
+ }, item.type, ": ", item.message);
95
+ })), /*#__PURE__*/React.createElement("div", {
96
+ className: styles.footer
97
+ }, /*#__PURE__*/React.createElement(Form, {
98
+ ref: formRef,
99
+ autoComplete: "off",
100
+ onFinish: function onFinish(_ref2) {
101
+ var _formRef$current;
102
+ var message = _ref2.message;
103
+ client.emit('message', message);
104
+ setHistory(function (list) {
105
+ return [].concat(_toConsumableArray(list), [{
106
+ type: 'me',
107
+ message: message
108
+ }]);
109
+ });
110
+ (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.resetFields();
111
+ }
112
+ }, /*#__PURE__*/React.createElement(Form.Item, {
113
+ name: "message"
114
+ }, /*#__PURE__*/React.createElement(Input, {
115
+ placeholder: "\u56DE\u8F66\u53D1\u9001\u4FE1\u606F",
116
+ autoFocus: true
117
+ })), /*#__PURE__*/React.createElement(Form.Item, null, /*#__PURE__*/React.createElement(Button, {
118
+ onClick: function onClick() {
119
+ if (online) {
120
+ client.close();
121
+ } else {
122
+ client.open();
123
+ }
124
+ setOnline(!online);
125
+ }
126
+ }, online ? '下线' : '上线')))));
127
+ };
128
+ export default (function () {
129
+ return /*#__PURE__*/React.createElement(DemoWrapper, {
130
+ defaultApp: 334
131
+ }, /*#__PURE__*/React.createElement(BizGlobalDataContext.Consumer, null, function (_ref3) {
132
+ var currentApp = _ref3.currentApp;
133
+ console.log('当前应用', currentApp.id);
134
+ return /*#__PURE__*/React.createElement("div", {
135
+ className: styles.container,
136
+ key: currentApp.id
137
+ }, /*#__PURE__*/React.createElement(ChatPanel, {
138
+ name: "\u5F20\u4E09",
139
+ param: {
140
+ appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.id,
141
+ origin: 3
142
+ }
143
+ }));
144
+ }));
145
+ });
@@ -0,0 +1,27 @@
1
+ @import '../../assets/styles/inner.less';
2
+ .container {
3
+ display: flex;
4
+ flex-direction: row;
5
+ border: 1px solid red;
6
+ & > :global(.ant-card) {
7
+ flex: 1;
8
+ margin: @margin-md;
9
+ }
10
+ }
11
+ .history {
12
+ height: 400px;
13
+ overflow: auto;
14
+ }
15
+ .he,
16
+ .me {
17
+ margin-bottom: @margin-sm;
18
+ padding: @padding-sm;
19
+ line-height: 24px;
20
+ background: @background-color-base;
21
+ }
22
+ .he {
23
+ text-align: left;
24
+ }
25
+ .me {
26
+ text-align: right;
27
+ }
@@ -0,0 +1,31 @@
1
+ import SocketClientTypes from './types';
2
+ declare class SocketClient {
3
+ private client?;
4
+ private url;
5
+ private params?;
6
+ private listeners;
7
+ private catch;
8
+ private showLog;
9
+ private pingTimer?;
10
+ private appkey?;
11
+ constructor(url: string, appkey: string, params?: Record<string, any>);
12
+ emit(event: string, payload?: SocketClientTypes.Message['data']['payload']): void;
13
+ on<T>(type: SocketClientTypes.EventType | string, handle: (data?: T) => void): void;
14
+ onConnected(handle: () => void): void;
15
+ onDisconnected(handle: () => void): void;
16
+ onError(handle: (data?: Error) => void): void;
17
+ private _onError;
18
+ private _onClose;
19
+ private _onOpen;
20
+ private onMessage;
21
+ private ping;
22
+ removeAllListeners(): void;
23
+ removeListener(event: string, handle?: (data?: any) => void): void;
24
+ private getToken;
25
+ open(url?: string, params?: Record<string, any>): void;
26
+ close(): void;
27
+ destroy(): void;
28
+ private log;
29
+ openLog(open: boolean): void;
30
+ }
31
+ export default SocketClient;
@@ -0,0 +1,291 @@
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.appkey = appkey;
33
+ this.url = url;
34
+ this.params = params;
35
+ this.open();
36
+ }
37
+ _createClass(SocketClient, [{
38
+ key: "emit",
39
+ value: function emit(event, payload) {
40
+ var _this$client, _this$client2;
41
+ this.log('info', 'emit message', [event, payload]);
42
+ if (!this.client) {
43
+ this.log('info', '缓存消息', [event, payload]);
44
+ this.catch.push([event, payload]);
45
+ return;
46
+ }
47
+ switch ((_this$client = this.client) === null || _this$client === void 0 ? void 0 : _this$client.readyState) {
48
+ case WebSocket.CLOSED:
49
+ notification.warn({
50
+ message: '连接已关闭'
51
+ });
52
+ break;
53
+ case WebSocket.CLOSING:
54
+ notification.warn({
55
+ message: '正在关闭连接'
56
+ });
57
+ break;
58
+ case WebSocket.CONNECTING:
59
+ notification.warn({
60
+ message: '连接中'
61
+ });
62
+ this.log('info', '缓存消息', [event, payload]);
63
+ this.catch.push([event, payload]);
64
+ break;
65
+ case WebSocket.OPEN:
66
+ (_this$client2 = this.client) === null || _this$client2 === void 0 ? void 0 : _this$client2.send(JSON.stringify({
67
+ type: SocketClientTypes.RequestType.normal,
68
+ data: {
69
+ event: event,
70
+ payload: payload
71
+ }
72
+ }));
73
+ break;
74
+ }
75
+ }
76
+ }, {
77
+ key: "on",
78
+ value: function on(type, handle) {
79
+ if (!this.listeners[type]) {
80
+ this.listeners[type] = [];
81
+ }
82
+ this.listeners[type].push(handle);
83
+ }
84
+ }, {
85
+ key: "onConnected",
86
+ value: function onConnected(handle) {
87
+ this.on(SocketClientTypes.EventType.connected, handle);
88
+ }
89
+ }, {
90
+ key: "onDisconnected",
91
+ value: function onDisconnected(handle) {
92
+ this.on(SocketClientTypes.EventType.disconnected, handle);
93
+ }
94
+ }, {
95
+ key: "onError",
96
+ value: function onError(handle) {
97
+ this.on(SocketClientTypes.EventType.error, handle);
98
+ }
99
+ }, {
100
+ key: "_onError",
101
+ value: function _onError(error) {
102
+ var _this$listeners$error;
103
+ this.log('error', 'socket连接异常', error);
104
+ (_this$listeners$error = this.listeners['error']) === null || _this$listeners$error === void 0 ? void 0 : _this$listeners$error.forEach(function (handle) {
105
+ handle.call(undefined, error);
106
+ });
107
+ }
108
+ }, {
109
+ key: "_onClose",
110
+ value: function _onClose(_event) {
111
+ var _this$listeners$disco;
112
+ this.log('error', 'socket连接已关闭');
113
+ (_this$listeners$disco = this.listeners['disconnected']) === null || _this$listeners$disco === void 0 ? void 0 : _this$listeners$disco.forEach(function (handle) {
114
+ handle.call(undefined);
115
+ });
116
+ clearInterval(this.pingTimer);
117
+ }
118
+ }, {
119
+ key: "_onOpen",
120
+ value: function _onOpen(event) {
121
+ var _this$listeners$conne,
122
+ _this = this;
123
+ this.log('info', 'socket连接成功', event);
124
+ (_this$listeners$conne = this.listeners['connected']) === null || _this$listeners$conne === void 0 ? void 0 : _this$listeners$conne.forEach(function (handle) {
125
+ handle.call(undefined);
126
+ });
127
+ this.log('info', 'clear catch', this.catch);
128
+ this.catch.forEach(function (_ref) {
129
+ var _ref2 = _slicedToArray(_ref, 2),
130
+ event = _ref2[0],
131
+ payload = _ref2[1];
132
+ _this.emit(event, payload);
133
+ });
134
+ this.catch = [];
135
+ this.ping();
136
+ }
137
+ }, {
138
+ key: "onMessage",
139
+ value: function onMessage(event) {
140
+ var _this$listeners$Socke, _this$listeners$Socke2, _this$listeners$Socke3;
141
+ var res = JSON.parse(event.data);
142
+ if (res.code) {
143
+ switch (Number(res.code)) {
144
+ case SocketClientTypes.ResponseCode.offline:
145
+ (_this$listeners$Socke = this.listeners[SocketClientTypes.EventType.offline]) === null || _this$listeners$Socke === void 0 ? void 0 : _this$listeners$Socke.forEach(function (handle) {
146
+ handle.call(undefined, res);
147
+ });
148
+ break;
149
+ case SocketClientTypes.ResponseCode.online:
150
+ (_this$listeners$Socke2 = this.listeners[SocketClientTypes.EventType.online]) === null || _this$listeners$Socke2 === void 0 ? void 0 : _this$listeners$Socke2.forEach(function (handle) {
151
+ handle.call(undefined, res);
152
+ });
153
+ break;
154
+ case SocketClientTypes.ResponseCode.exist:
155
+ (_this$listeners$Socke3 = this.listeners[SocketClientTypes.EventType.exist]) === null || _this$listeners$Socke3 === void 0 ? void 0 : _this$listeners$Socke3.forEach(function (handle) {
156
+ handle.call(undefined, res);
157
+ });
158
+ break;
159
+ case SocketClientTypes.ResponseCode.paramError:
160
+ this._onError(new Error('参数缺失或错误'));
161
+ }
162
+ } else if (res.type === SocketClientTypes.RequestType.pong) {
163
+ return;
164
+ } else {
165
+ var data = res.data;
166
+ if (this.listeners[data.event]) {
167
+ this.listeners[data.event].forEach(function (handle) {
168
+ handle.call(undefined, data.payload);
169
+ });
170
+ }
171
+ }
172
+ }
173
+ }, {
174
+ key: "ping",
175
+ value: function ping() {
176
+ var _this2 = this;
177
+ this.pingTimer = setInterval(function () {
178
+ var _this2$client;
179
+ (_this2$client = _this2.client) === null || _this2$client === void 0 ? void 0 : _this2$client.send(JSON.stringify({
180
+ type: SocketClientTypes.RequestType.ping
181
+ }));
182
+ }, 3000);
183
+ }
184
+ }, {
185
+ key: "removeAllListeners",
186
+ value: function removeAllListeners() {
187
+ this.listeners = {};
188
+ }
189
+ }, {
190
+ key: "removeListener",
191
+ value: function removeListener(event, handle) {
192
+ var _this3 = this;
193
+ if (handle) {
194
+ this.listeners[event].forEach(function (item, i) {
195
+ if (item === handle) {
196
+ _this3.listeners[event].splice(i, 1);
197
+ }
198
+ });
199
+ } else {
200
+ this.listeners[event] = [];
201
+ }
202
+ }
203
+ }, {
204
+ key: "getToken",
205
+ value: function () {
206
+ var _getToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
207
+ var res;
208
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
209
+ while (1) switch (_context.prev = _context.next) {
210
+ case 0:
211
+ _context.next = 2;
212
+ return request(Apis.getSocketToken, {
213
+ method: 'get',
214
+ params: {
215
+ appKey: this.appkey
216
+ }
217
+ });
218
+ case 2:
219
+ res = _context.sent;
220
+ return _context.abrupt("return", res.data.socketToken);
221
+ case 4:
222
+ case "end":
223
+ return _context.stop();
224
+ }
225
+ }, _callee, this);
226
+ }));
227
+ function getToken() {
228
+ return _getToken.apply(this, arguments);
229
+ }
230
+ return getToken;
231
+ }()
232
+ }, {
233
+ key: "open",
234
+ value: function open(url, params) {
235
+ var _this4 = this;
236
+ this.getToken().then(function (token) {
237
+ _this4.params = params || _this4.params;
238
+ if (_this4.client) _this4.close();
239
+ var paramUrl = ["socketToken=".concat(token)];
240
+ if (_this4.params) {
241
+ Object.keys(_this4.params || {}).forEach(function (key) {
242
+ if (_.isObject(_this4.params[key]) || _.isArray(_this4.params[key])) {
243
+ paramUrl.push("".concat(key, "=").concat(JSON.stringify(_this4.params[key])));
244
+ } else {
245
+ paramUrl.push("".concat(key, "=").concat(_this4.params[key]));
246
+ }
247
+ });
248
+ }
249
+ var client = new WebSocket("".concat(url || _this4.url, "?").concat(paramUrl.join('&')));
250
+ _this4.client = client;
251
+ client.onmessage = _this4.onMessage.bind(_this4);
252
+ client.onerror = _this4._onError.bind(_this4);
253
+ client.onclose = _this4._onClose.bind(_this4);
254
+ client.onopen = _this4._onOpen.bind(_this4);
255
+ }).catch(function (err) {
256
+ _this4.log('error', 'socket获取token信息异常');
257
+ _this4._onError(err);
258
+ });
259
+ }
260
+ }, {
261
+ key: "close",
262
+ value: function close() {
263
+ var _this$client3;
264
+ (_this$client3 = this.client) === null || _this$client3 === void 0 ? void 0 : _this$client3.close();
265
+ this.log('info', '关闭socket连接');
266
+ }
267
+ }, {
268
+ key: "destroy",
269
+ value: function destroy() {
270
+ this.removeAllListeners();
271
+ this.close();
272
+ this.client = undefined;
273
+ }
274
+ }, {
275
+ key: "log",
276
+ value: function log(type) {
277
+ var _console;
278
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
279
+ args[_key - 1] = arguments[_key];
280
+ }
281
+ if (this.showLog) (_console = console).log.apply(_console, ["%c\u3010socketClient\u3011:".concat(type), "color: ".concat(type === 'error' ? 'red' : '#1890ff')].concat(args));
282
+ }
283
+ }, {
284
+ key: "openLog",
285
+ value: function openLog(open) {
286
+ this.showLog = open;
287
+ }
288
+ }]);
289
+ return SocketClient;
290
+ }();
291
+ 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;
@@ -69,23 +69,7 @@ var ConditionTypeList = function ConditionTypeList(props) {
69
69
  title: cdpTip
70
70
  }, /*#__PURE__*/React.createElement(IconFont, {
71
71
  type: "tishiicon"
72
- })) : null)) : null, /*#__PURE__*/React.createElement("li", {
73
- className: "condition-type",
74
- key: "business",
75
- onClick: function onClick() {
76
- return onAdd('business');
77
- }
78
- }, /*#__PURE__*/React.createElement(Space, {
79
- key: "business"
80
- }, /*#__PURE__*/React.createElement(PlusOutlined, null), /*#__PURE__*/React.createElement("span", null, "\u4E1A\u52A1\u6570\u636E"))), /*#__PURE__*/React.createElement("li", {
81
- className: "condition-type",
82
- key: "order",
83
- onClick: function onClick() {
84
- return onAdd('order');
85
- }
86
- }, /*#__PURE__*/React.createElement(Space, {
87
- key: "order"
88
- }, /*#__PURE__*/React.createElement(PlusOutlined, null), /*#__PURE__*/React.createElement("span", null, "\u8BA2\u5355\u6570\u636E")))));
72
+ })) : null)) : null));
89
73
  };
90
74
  ConditionTypeList.defaultProps = {
91
75
  show: true
@@ -22,7 +22,6 @@ export declare const operatorMap: {
22
22
  gt: string;
23
23
  ge: string;
24
24
  le: string;
25
- between: string;
26
25
  };
27
26
  export declare const durationHandler: {
28
27
  [key: string]: any;
@@ -21,8 +21,7 @@ export var operatorMap = {
21
21
  lt: '<',
22
22
  gt: '>',
23
23
  ge: '≥',
24
- le: '≤',
25
- between: '区间'
24
+ le: '≤'
26
25
  };
27
26
  export var durationHandler = {
28
27
  1: {