eoss-ui 0.4.98 → 0.5.10

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 (56) hide show
  1. package/lib/button-group.js +117 -27
  2. package/lib/button.js +118 -28
  3. package/lib/checkbox-group.js +198 -96
  4. package/lib/data-table-form.js +117 -31
  5. package/lib/data-table.js +173 -75
  6. package/lib/date-picker.js +117 -27
  7. package/lib/dialog.js +127 -41
  8. package/lib/eoss-ui.common.js +1006 -707
  9. package/lib/flow-group.js +117 -27
  10. package/lib/flow-list.js +136 -36
  11. package/lib/flow.js +147 -41
  12. package/lib/form.js +682 -434
  13. package/lib/handle-user.js +142 -52
  14. package/lib/handler.js +117 -27
  15. package/lib/icons.js +2 -2
  16. package/lib/index.js +1 -1
  17. package/lib/input-number.js +118 -28
  18. package/lib/input.js +120 -30
  19. package/lib/layout.js +2 -2
  20. package/lib/login.js +123 -36
  21. package/lib/main.js +232 -151
  22. package/lib/nav.js +117 -27
  23. package/lib/page.js +117 -27
  24. package/lib/player.js +119 -29
  25. package/lib/qr-code.js +117 -27
  26. package/lib/radio-group.js +146 -54
  27. package/lib/retrial-auth.js +117 -27
  28. package/lib/select-ganged.js +118 -28
  29. package/lib/select.js +142 -52
  30. package/lib/selector-panel.js +171 -74
  31. package/lib/selector.js +117 -27
  32. package/lib/sizer.js +120 -30
  33. package/lib/steps.js +117 -27
  34. package/lib/switch.js +118 -28
  35. package/lib/table-form.js +182 -76
  36. package/lib/tabs.js +117 -27
  37. package/lib/tips.js +117 -27
  38. package/lib/tree-group.js +117 -27
  39. package/lib/tree.js +117 -27
  40. package/lib/upload.js +206 -109
  41. package/lib/utils/util.js +97 -19
  42. package/lib/wujie.js +117 -27
  43. package/lib/wxlogin.js +117 -27
  44. package/package.json +1 -1
  45. package/packages/button/src/main.vue +1 -10
  46. package/packages/data-table/src/column.vue +6 -0
  47. package/packages/flow/src/main.vue +20 -3
  48. package/packages/flow-list/src/main.vue +4 -3
  49. package/packages/form/src/main.vue +60 -1
  50. package/packages/form/src/table.vue +6 -0
  51. package/packages/login/src/main.vue +1 -0
  52. package/packages/main/src/main.vue +117 -97
  53. package/packages/radio-group/src/main.vue +1 -0
  54. package/packages/upload/src/main.vue +0 -1
  55. package/src/index.js +1 -1
  56. package/src/utils/util.js +94 -20
package/src/utils/util.js CHANGED
@@ -7,10 +7,12 @@
7
7
 
8
8
  /* eslint-disable indent */
9
9
  const sm2 = require('sm-crypto').sm2;
10
- import { authCenter } from '../config/api';
10
+ import { authCenter, wss, topic } from '../config/api';
11
11
  import axios from 'axios';
12
12
  import qs from 'qs';
13
13
  import JSONbig from 'json-bigint';
14
+ import SockJS from 'sockjs-client';
15
+ import Stomp from 'stompjs';
14
16
 
15
17
  const win = window.__WUJIE_RAW_WINDOW__ ? window.__WUJIE_RAW_WINDOW__ : window;
16
18
 
@@ -1685,7 +1687,7 @@ const getWeekday = function (date, type = 0) {
1685
1687
  * @param {String} [url] - url地址
1686
1688
  **/
1687
1689
 
1688
- const handlerUrl = function (url, before) {
1690
+ const handlerUrl = function (url, param, before) {
1689
1691
  let arry = url.split('?');
1690
1692
  if (arry.length > 2) {
1691
1693
  let ary = arry.splice(1, arry.length);
@@ -1707,6 +1709,10 @@ const handlerUrl = function (url, before) {
1707
1709
  } else {
1708
1710
  url += '?_tt=' + new Date().getTime();
1709
1711
  }
1712
+ if (param) {
1713
+ let str = queryParams(param);
1714
+ url += ('&' + str);
1715
+ }
1710
1716
  if (before && before === arry[0]) {
1711
1717
  let pathname = win.location.pathname;
1712
1718
  if (pathname === '/') {
@@ -1875,29 +1881,29 @@ const isLogined = function ({
1875
1881
  loginPage,
1876
1882
  redirect
1877
1883
  }) {
1878
- const logined = getStorage('logined');
1879
1884
  if (cookie === undefined) {
1880
1885
  cookie = getParams({ name: 'cookie' });
1881
1886
  }
1882
- // eslint-disable-next-line eqeqeq
1883
- if (logined || cookie == true || cookie == 1) {
1884
- if (loginPage) {
1885
- sessionStorage.setItem('loginPage', loginPage);
1886
- if (!startWith(loginPage, ['http', '/'], true)) {
1887
- let pathname = win.top.location.pathname;
1888
- if (pathname !== '/') {
1889
- pathname = pathname.split('/');
1890
- pathname.splice(pathname.length - 1);
1891
- pathname = pathname.join('/');
1892
- loginPage = pathname + '/' + loginPage.replace('./', '');
1893
- } else {
1894
- loginPage = pathname + loginPage.replace('./', '');
1895
- }
1887
+ if (loginPage) {
1888
+ sessionStorage.setItem('loginPage', loginPage);
1889
+ if (!startWith(loginPage, ['http', '/'], true)) {
1890
+ let pathname = win.top.location.pathname;
1891
+ if (pathname !== '/') {
1892
+ pathname = pathname.split('/');
1893
+ pathname.splice(pathname.length - 1);
1894
+ pathname = pathname.join('/');
1895
+ loginPage = pathname + '/' + loginPage.replace('./', '');
1896
+ } else {
1897
+ loginPage = pathname + loginPage.replace('./', '');
1896
1898
  }
1897
1899
  }
1898
- next();
1900
+ }
1901
+ const token = getStorage('token') || getStorage('Authorization');
1902
+ const logined = getStorage('logined');
1903
+ // eslint-disable-next-line eqeqeq
1904
+ if (token || logined || cookie == true || cookie == 1) {
1905
+ next && next();
1899
1906
  } else {
1900
- const token = getStorage('token') || getStorage('Authorization');
1901
1907
  if (
1902
1908
  !token && Object.prototype.hasOwnProperty.call(to.query, 'serverId') &&
1903
1909
  Object.prototype.hasOwnProperty.call(to.query, 'authType')
@@ -2474,6 +2480,74 @@ const setStorage = function ({ type, key, value }) {
2474
2480
  }
2475
2481
  };
2476
2482
 
2483
+ /**
2484
+ * socket
2485
+ * @desc:webSocket
2486
+ * @author huangbo
2487
+ * @date 2022年5月7日
2488
+ * @param {String} [url] - 连接地址
2489
+ * @param {String} [take] - 订阅地址
2490
+ * @param {String} [debug] - 调试
2491
+ * @param {String} [interval] - 重连间隔时间
2492
+ **/
2493
+ function socket(options) {
2494
+ let nextDate = 0;
2495
+ let connect = 1;
2496
+ return new Promise((resolve, reject) => {
2497
+ let wshost = getStorage('wshost') || '';
2498
+ let option = {
2499
+ url: wshost + wss,
2500
+ take: topic,
2501
+ debug: true,
2502
+ interval: 20
2503
+ };
2504
+ let websocket = win.websocket || {};
2505
+ if (options && isObject(options)) {
2506
+ option = { ...option, ...options };
2507
+ }
2508
+ let key = window.btoa(option.url);
2509
+ if (!websocket[key]) {
2510
+ websocket[key] = { socket: new SockJS(option.url) };
2511
+ win.websocket = websocket;
2512
+ }
2513
+
2514
+ let client = websocket[key] ? websocket[key].client : null;
2515
+ if (!client) {
2516
+ client = websocket[key].client = Stomp.over(websocket[key].socket);
2517
+ !option.debug && (client.debug = null);
2518
+ }
2519
+ client.connect(
2520
+ {},
2521
+ () => {
2522
+ client.subscribe(option.take, (response) => {
2523
+ let res = JSON.parse(response.body);
2524
+ resolve(res, () => {
2525
+ client.disconnect();
2526
+ win.top.websocket && win.top.websocket[key] && delete win.top.websocket[key];
2527
+ }, client, websocket[key]);
2528
+ });
2529
+ },
2530
+ (error) => {
2531
+ let diffSecond = parseInt((new Date() - nextDate) / 1000, 10);
2532
+ if (connect > 5 && diffSecond < option.interval) {
2533
+ client.disconnect();
2534
+ if (win.top.websocket) {
2535
+ if (Object.keys(win.top.websocket).length > 1) {
2536
+ delete win.top.websocket[key];
2537
+ } else {
2538
+ delete win.top.websocket;
2539
+ }
2540
+ }
2541
+ } else {
2542
+ win.top.websocket && win.top.websocket[key] && setTimeout(() => {
2543
+ socket(options);
2544
+ }, 5000);
2545
+ }
2546
+ reject(error);
2547
+ }
2548
+ );
2549
+ });
2550
+ }
2477
2551
  /**
2478
2552
  * sum
2479
2553
  * @desc 求和
@@ -2725,7 +2799,6 @@ const urlJoinParams = function ({ url, param, timestamp }) {
2725
2799
  params[items[0]] = items[1];
2726
2800
  });
2727
2801
  }
2728
- '&_tt=' + new Date().getTime();
2729
2802
  params = extend(true, params, param);
2730
2803
  let str = queryParams(params);
2731
2804
  if (str) {
@@ -2879,6 +2952,7 @@ export default {
2879
2952
  sendMessage,
2880
2953
  setFavicon,
2881
2954
  setStorage,
2955
+ socket,
2882
2956
  startWith,
2883
2957
  sum,
2884
2958
  takeLeft,