@fmdeui/fmui 1.0.24 → 1.0.26

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/index.mjs CHANGED
@@ -34,9 +34,9 @@ export { initBackEndControlRoutes, setDynamicViewsModules } from './packages/rou
34
34
  export { initFrontEndControlRoutes } from './packages/router/frontEnd.mjs';
35
35
  export { judgementIdCard, verifiyNumberInteger, verifyAccount, verifyAndSpace, verifyCarNum, verifyCnAndSpace, verifyEmail, verifyEnAndSpace, verifyFullName, verifyIPAddress, verifyIdCard, verifyNumberCnUppercase, verifyNumberComma, verifyNumberIntegerAndFloat, verifyNumberPercentage, verifyNumberPercentageFloat, verifyPassword, verifyPasswordPowerful, verifyPasswordStrength, verifyPhone, verifyPostalCode, verifyTelPhone, verifyTextColor, verifyUrl } from './packages/utils/toolsValidate.mjs';
36
36
  export { loadSysInfo, updateFavicon } from './packages/hooks/sysInfo.mjs';
37
+ export { restartSignalR, signalR } from './packages/utils/signalR.mjs';
37
38
  export { router } from './packages/router/createRouter.mjs';
38
39
  export { saulVModel } from './packages/utils/saulVModel.mjs';
39
- export { signalR } from './packages/utils/signalR.mjs';
40
40
  export { signatureByKSort } from './packages/utils/data-signature.mjs';
41
41
  export { useApi, useBaseApi } from './packages/api/base/index.mjs';
42
42
  export { useChangeColor } from './packages/utils/theme.mjs';
@@ -18,4 +18,4 @@ export { saulVModel } from './saulVModel.mjs';
18
18
  export { Local, Session } from './storage.mjs';
19
19
  export { useChangeColor } from './theme.mjs';
20
20
  export { judgementIdCard, verifiyNumberInteger, verifyAccount, verifyAndSpace, verifyCarNum, verifyCnAndSpace, verifyEmail, verifyEnAndSpace, verifyFullName, verifyIPAddress, verifyIdCard, verifyNumberCnUppercase, verifyNumberComma, verifyNumberIntegerAndFloat, verifyNumberPercentage, verifyNumberPercentageFloat, verifyPassword, verifyPasswordPowerful, verifyPasswordStrength, verifyPhone, verifyPostalCode, verifyTelPhone, verifyTextColor, verifyUrl } from './toolsValidate.mjs';
21
- export { signalR } from './signalR.mjs';
21
+ export { restartSignalR, signalR } from './signalR.mjs';
@@ -2,8 +2,13 @@ import * as SignalR from '@microsoft/signalr';
2
2
  import { ElNotification } from 'element-plus';
3
3
  import { getToken } from './request.mjs';
4
4
 
5
- if (!window.__SIGNALR_INSTANCE__) {
6
- const connection = new SignalR.HubConnectionBuilder().configureLogging(SignalR.LogLevel.Warning).withUrl(`${window.__env__.VITE_API_URL}/hubs/onlineUser?token=${getToken()}`, { transport: SignalR.HttpTransportType.WebSockets, skipNegotiation: true }).withAutomaticReconnect({
5
+ const initSignalR = () => {
6
+ const token = getToken();
7
+ if (!token) return null;
8
+ const connection = new SignalR.HubConnectionBuilder().configureLogging(SignalR.LogLevel.Warning).withUrl(`${window.__env__.VITE_API_URL}/hubs/onlineUser?token=${token}`, {
9
+ transport: SignalR.HttpTransportType.WebSockets,
10
+ skipNegotiation: true
11
+ }).withAutomaticReconnect({
7
12
  nextRetryDelayInMilliseconds: () => {
8
13
  return 5e3;
9
14
  }
@@ -11,6 +16,8 @@ if (!window.__SIGNALR_INSTANCE__) {
11
16
  connection.keepAliveIntervalInMilliseconds = 15 * 1e3;
12
17
  connection.serverTimeoutInMilliseconds = 30 * 1e3;
13
18
  connection.start().then(() => {
19
+ }).catch((err) => {
20
+ console.error("SignalR \u8FDE\u63A5\u5931\u8D25:", err);
14
21
  });
15
22
  connection.onclose(async () => {
16
23
  });
@@ -44,8 +51,65 @@ if (!window.__SIGNALR_INSTANCE__) {
44
51
  duration: 5e3
45
52
  });
46
53
  });
47
- window.__SIGNALR_INSTANCE__ = connection;
54
+ return connection;
55
+ };
56
+ const getSignalR = () => {
57
+ return window.__SIGNALR_INSTANCE__;
58
+ };
59
+ if (!window.__SIGNALR_INSTANCE__) {
60
+ const instance = initSignalR();
61
+ if (instance) {
62
+ window.__SIGNALR_INSTANCE__ = instance;
63
+ }
64
+ }
65
+ if (!window.__SIGNALR_INSTANCE__) {
66
+ const instance = initSignalR();
67
+ if (instance) {
68
+ window.__SIGNALR_INSTANCE__ = instance;
69
+ } else {
70
+ }
48
71
  }
49
- const signalR = window.__SIGNALR_INSTANCE__;
72
+ const signalR = {
73
+ on: (event, callback) => {
74
+ const instance = getSignalR();
75
+ if (instance) {
76
+ instance.on(event, callback);
77
+ } else {
78
+ console.warn(`SignalR \u672A\u8FDE\u63A5\uFF0C\u65E0\u6CD5\u76D1\u542C\u4E8B\u4EF6: ${event}`);
79
+ }
80
+ },
81
+ off: (event, callback) => {
82
+ const instance = getSignalR();
83
+ if (instance) {
84
+ instance.off(event, callback);
85
+ }
86
+ },
87
+ send: (method, ...args) => {
88
+ const instance = getSignalR();
89
+ if (instance) {
90
+ return instance.invoke(method, ...args);
91
+ } else {
92
+ console.warn("SignalR \u672A\u8FDE\u63A5\uFF0C\u65E0\u6CD5\u53D1\u9001\u6D88\u606F");
93
+ return Promise.reject("SignalR \u672A\u8FDE\u63A5");
94
+ }
95
+ },
96
+ stop: () => {
97
+ const instance = getSignalR();
98
+ if (instance) {
99
+ return instance.stop();
100
+ }
101
+ return Promise.resolve();
102
+ }
103
+ };
104
+ const restartSignalR = async () => {
105
+ const instance = getSignalR();
106
+ if (instance) {
107
+ await instance.stop();
108
+ }
109
+ const newInstance = initSignalR();
110
+ if (newInstance) {
111
+ window.__SIGNALR_INSTANCE__ = newInstance;
112
+ }
113
+ };
50
114
 
51
- export { signalR };
115
+ export { restartSignalR, signalR };
@@ -1,5 +1,12 @@
1
1
  import * as SignalR from '@microsoft/signalr';
2
- export declare const signalR: SignalR.HubConnection;
2
+ declare const signalR: {
3
+ on: (event: any, callback: any) => void;
4
+ off: (event: any, callback: any) => void;
5
+ send: (method: any, ...args: any[]) => Promise<any>;
6
+ stop: () => Promise<void>;
7
+ };
8
+ declare const restartSignalR: () => Promise<void>;
9
+ export { signalR, restartSignalR };
3
10
  declare global {
4
11
  interface Window {
5
12
  __SIGNALR_INSTANCE__: SignalR.HubConnection;
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! fmdeui-fmui v1.0.24 */
1
+ /*! fmdeui-fmui v1.0.26 */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('pinia'), require('crypto-js'), require('xlsx-js-style'), require('element-plus'), require('vue'), require('@element-plus/icons-vue'), require('axios'), require('js-cookie'), require('@microsoft/signalr'), require('vxe-table'), require('@vxe-ui/plugin-render-element'), require('@vxe-ui/plugin-export-xlsx'), require('vxe-pc-ui'), require('vue-i18n'), require('exceljs'), require('lodash-es'), require('@vueuse/core'), require('mitt'), require('vue-router'), require('nprogress')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', 'pinia', 'crypto-js', 'xlsx-js-style', 'element-plus', 'vue', '@element-plus/icons-vue', 'axios', 'js-cookie', '@microsoft/signalr', 'vxe-table', '@vxe-ui/plugin-render-element', '@vxe-ui/plugin-export-xlsx', 'vxe-pc-ui', 'vue-i18n', 'exceljs', 'lodash-es', '@vueuse/core', 'mitt', 'vue-router', 'nprogress'], factory) :
@@ -1690,8 +1690,13 @@
1690
1690
  return entity;
1691
1691
  }
1692
1692
 
1693
- if (!window.__SIGNALR_INSTANCE__) {
1694
- const connection = new SignalR__namespace.HubConnectionBuilder().configureLogging(SignalR__namespace.LogLevel.Warning).withUrl(`${window.__env__.VITE_API_URL}/hubs/onlineUser?token=${getToken()}`, { transport: SignalR__namespace.HttpTransportType.WebSockets, skipNegotiation: true }).withAutomaticReconnect({
1693
+ const initSignalR = () => {
1694
+ const token = getToken();
1695
+ if (!token) return null;
1696
+ const connection = new SignalR__namespace.HubConnectionBuilder().configureLogging(SignalR__namespace.LogLevel.Warning).withUrl(`${window.__env__.VITE_API_URL}/hubs/onlineUser?token=${token}`, {
1697
+ transport: SignalR__namespace.HttpTransportType.WebSockets,
1698
+ skipNegotiation: true
1699
+ }).withAutomaticReconnect({
1695
1700
  nextRetryDelayInMilliseconds: () => {
1696
1701
  return 5e3;
1697
1702
  }
@@ -1699,6 +1704,8 @@
1699
1704
  connection.keepAliveIntervalInMilliseconds = 15 * 1e3;
1700
1705
  connection.serverTimeoutInMilliseconds = 30 * 1e3;
1701
1706
  connection.start().then(() => {
1707
+ }).catch((err) => {
1708
+ console.error("SignalR \u8FDE\u63A5\u5931\u8D25:", err);
1702
1709
  });
1703
1710
  connection.onclose(async () => {
1704
1711
  });
@@ -1732,9 +1739,65 @@
1732
1739
  duration: 5e3
1733
1740
  });
1734
1741
  });
1735
- window.__SIGNALR_INSTANCE__ = connection;
1742
+ return connection;
1743
+ };
1744
+ const getSignalR = () => {
1745
+ return window.__SIGNALR_INSTANCE__;
1746
+ };
1747
+ if (!window.__SIGNALR_INSTANCE__) {
1748
+ const instance = initSignalR();
1749
+ if (instance) {
1750
+ window.__SIGNALR_INSTANCE__ = instance;
1751
+ }
1736
1752
  }
1737
- const signalR = window.__SIGNALR_INSTANCE__;
1753
+ if (!window.__SIGNALR_INSTANCE__) {
1754
+ const instance = initSignalR();
1755
+ if (instance) {
1756
+ window.__SIGNALR_INSTANCE__ = instance;
1757
+ }
1758
+ }
1759
+ const signalR = {
1760
+ on: (event, callback) => {
1761
+ const instance = getSignalR();
1762
+ if (instance) {
1763
+ instance.on(event, callback);
1764
+ } else {
1765
+ console.warn(`SignalR \u672A\u8FDE\u63A5\uFF0C\u65E0\u6CD5\u76D1\u542C\u4E8B\u4EF6: ${event}`);
1766
+ }
1767
+ },
1768
+ off: (event, callback) => {
1769
+ const instance = getSignalR();
1770
+ if (instance) {
1771
+ instance.off(event, callback);
1772
+ }
1773
+ },
1774
+ send: (method, ...args) => {
1775
+ const instance = getSignalR();
1776
+ if (instance) {
1777
+ return instance.invoke(method, ...args);
1778
+ } else {
1779
+ console.warn("SignalR \u672A\u8FDE\u63A5\uFF0C\u65E0\u6CD5\u53D1\u9001\u6D88\u606F");
1780
+ return Promise.reject("SignalR \u672A\u8FDE\u63A5");
1781
+ }
1782
+ },
1783
+ stop: () => {
1784
+ const instance = getSignalR();
1785
+ if (instance) {
1786
+ return instance.stop();
1787
+ }
1788
+ return Promise.resolve();
1789
+ }
1790
+ };
1791
+ const restartSignalR = async () => {
1792
+ const instance = getSignalR();
1793
+ if (instance) {
1794
+ await instance.stop();
1795
+ }
1796
+ const newInstance = initSignalR();
1797
+ if (newInstance) {
1798
+ window.__SIGNALR_INSTANCE__ = newInstance;
1799
+ }
1800
+ };
1738
1801
 
1739
1802
  const setWatermark = (str) => {
1740
1803
  const id = "1.23452384164.123412416";
@@ -23142,6 +23205,7 @@
23142
23205
  exports.refreshAccessTokenKey = refreshAccessTokenKey;
23143
23206
  exports.removeDuplicate = removeDuplicate;
23144
23207
  exports.request2 = request2;
23208
+ exports.restartSignalR = restartSignalR;
23145
23209
  exports.roles = roles;
23146
23210
  exports.router = router;
23147
23211
  exports.saulVModel = saulVModel;