@zero-library/common 2.5.0 → 3.0.0
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/dist/index.cjs.js +332 -138
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +2 -2
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +19 -8
- package/dist/index.d.ts +19 -8
- package/dist/index.esm.js +332 -138
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs.js
CHANGED
|
@@ -1121,6 +1121,10 @@ function createRequest(config) {
|
|
|
1121
1121
|
// 默认基础URL
|
|
1122
1122
|
timeout: 6e4,
|
|
1123
1123
|
// 请求超时时间设为60秒
|
|
1124
|
+
paramsSerializer: {
|
|
1125
|
+
// 自定义序列化参数,处理数组格式为 key=value&key=value
|
|
1126
|
+
serialize: (params) => buildUrlParams(params)
|
|
1127
|
+
},
|
|
1124
1128
|
...config
|
|
1125
1129
|
// 合并传入的配置项
|
|
1126
1130
|
});
|
|
@@ -1149,6 +1153,9 @@ function createRequest(config) {
|
|
|
1149
1153
|
return response;
|
|
1150
1154
|
},
|
|
1151
1155
|
function(err) {
|
|
1156
|
+
if (axios__default.default.isCancel(err)) {
|
|
1157
|
+
return Promise.reject(err);
|
|
1158
|
+
}
|
|
1152
1159
|
if (!err.response) {
|
|
1153
1160
|
if (showError(err?.config?.showError)) cachedMessage({ content: "\u7F51\u7EDC\u5F02\u5E38\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC", type: "error" });
|
|
1154
1161
|
} else {
|
|
@@ -1397,7 +1404,7 @@ var LazyComponent_default = ({ type, customComponents, unknownContent, ...rest }
|
|
|
1397
1404
|
lazyCache.set(type, component);
|
|
1398
1405
|
return component;
|
|
1399
1406
|
}, [loader]);
|
|
1400
|
-
if (!LazyComponent) return unknownContent || /* @__PURE__ */ jsxRuntime.jsx(antd.Alert, {
|
|
1407
|
+
if (!LazyComponent) return unknownContent || /* @__PURE__ */ jsxRuntime.jsx(antd.Alert, { title: `\u672A\u77E5\u7C7B\u578B\uFF1A${type}`, type: "warning" });
|
|
1401
1408
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1402
1409
|
React.Suspense,
|
|
1403
1410
|
{
|
|
@@ -1894,140 +1901,325 @@ var useThrottle_default = (func, wait) => {
|
|
|
1894
1901
|
throttle2.cancel = cancel;
|
|
1895
1902
|
return React.useCallback(throttle2, []);
|
|
1896
1903
|
};
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1904
|
+
|
|
1905
|
+
// src/hooks/webSocket/WebSocketManager.ts
|
|
1906
|
+
var WebSocketManager = class _WebSocketManager {
|
|
1907
|
+
/** 存储不同 URL 对应的 WebSocketManager 单例实例 */
|
|
1908
|
+
static instances = /* @__PURE__ */ new Map();
|
|
1909
|
+
/** 当前 WebSocket 的服务器地址 */
|
|
1910
|
+
url;
|
|
1911
|
+
/** WebSocket 原生实例 */
|
|
1912
|
+
socket = null;
|
|
1913
|
+
/** 当前连接状态 */
|
|
1914
|
+
readyState = null;
|
|
1915
|
+
/** 当前连接的所有订阅者(监听器)集合 */
|
|
1916
|
+
listeners = /* @__PURE__ */ new Set();
|
|
1917
|
+
// --- 配置参数 ---
|
|
1918
|
+
heartbeatInterval;
|
|
1919
|
+
heartbeatMessage;
|
|
1920
|
+
clientHeartbeat;
|
|
1921
|
+
reconnectInterval;
|
|
1922
|
+
maxReconnectAttempts;
|
|
1923
|
+
isReconnect;
|
|
1924
|
+
// --- 内部状态与定时器 ---
|
|
1925
|
+
/** 心跳定时器引用 */
|
|
1926
|
+
heartbeatIntervalRef = null;
|
|
1927
|
+
/** 重连定时器引用 */
|
|
1928
|
+
reconnectIntervalRef = null;
|
|
1929
|
+
/** 销毁防抖定时器引用(用于避免 React StrictMode 导致的连接抖动) */
|
|
1930
|
+
destroyTimeoutRef = null;
|
|
1931
|
+
/** 当前已尝试重连的次数 */
|
|
1932
|
+
reconnectAttempts = 0;
|
|
1933
|
+
/** 记录页面是否处于隐藏状态 */
|
|
1934
|
+
documentHide = document.visibilityState === "hidden";
|
|
1935
|
+
/** 标记实例是否已被销毁,防止销毁后继续重连 */
|
|
1936
|
+
isDestroy = false;
|
|
1937
|
+
/**
|
|
1938
|
+
* 私有构造函数,确保只能通过 getInstance 获取实例
|
|
1939
|
+
*/
|
|
1940
|
+
constructor(props) {
|
|
1941
|
+
this.url = props.url;
|
|
1942
|
+
this.heartbeatInterval = props.heartbeatInterval ?? 3e4;
|
|
1943
|
+
this.heartbeatMessage = props.heartbeatMessage ?? "ping";
|
|
1944
|
+
this.clientHeartbeat = props.clientHeartbeat ?? true;
|
|
1945
|
+
this.reconnectInterval = props.reconnectInterval ?? 5e3;
|
|
1946
|
+
this.maxReconnectAttempts = props.maxReconnectAttempts;
|
|
1947
|
+
this.isReconnect = props.isReconnect ?? true;
|
|
1948
|
+
window.addEventListener("visibilitychange", this.handleVisibilityChange);
|
|
1949
|
+
this.createAndListenWebSocket();
|
|
1950
|
+
}
|
|
1951
|
+
/**
|
|
1952
|
+
* 获取指定 URL 的 WebSocketManager 单例
|
|
1953
|
+
* @param props WebSocket 配置参数
|
|
1954
|
+
* @returns WebSocketManager 实例
|
|
1955
|
+
*/
|
|
1956
|
+
static getInstance(props) {
|
|
1957
|
+
if (!_WebSocketManager.instances.has(props.url)) {
|
|
1958
|
+
_WebSocketManager.instances.set(props.url, new _WebSocketManager(props));
|
|
1959
|
+
}
|
|
1960
|
+
return _WebSocketManager.instances.get(props.url);
|
|
1961
|
+
}
|
|
1962
|
+
/**
|
|
1963
|
+
* 添加监听器(组件挂载时调用)
|
|
1964
|
+
* @param listener 组件级别的监听器
|
|
1965
|
+
*/
|
|
1966
|
+
addListener(listener) {
|
|
1967
|
+
this.listeners.add(listener);
|
|
1968
|
+
if (this.destroyTimeoutRef) {
|
|
1969
|
+
clearTimeout(this.destroyTimeoutRef);
|
|
1970
|
+
this.destroyTimeoutRef = null;
|
|
1971
|
+
}
|
|
1972
|
+
listener.onStateChange(this.readyState);
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* 移除监听器(组件卸载时调用)
|
|
1976
|
+
* @param listener 组件级别的监听器
|
|
1977
|
+
*/
|
|
1978
|
+
removeListener(listener) {
|
|
1979
|
+
this.listeners.delete(listener);
|
|
1980
|
+
if (this.listeners.size === 0) {
|
|
1981
|
+
this.destroyTimeoutRef = setTimeout(() => {
|
|
1982
|
+
this.destroy();
|
|
1983
|
+
_WebSocketManager.instances.delete(this.url);
|
|
1984
|
+
}, 200);
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
/**
|
|
1988
|
+
* 更新连接状态并广播给所有监听器
|
|
1989
|
+
*/
|
|
1990
|
+
setSocketReadyState(state) {
|
|
1991
|
+
this.readyState = state;
|
|
1992
|
+
this.listeners.forEach((l) => l.onStateChange(state));
|
|
1993
|
+
}
|
|
1994
|
+
/**
|
|
1995
|
+
* 启动心跳机制
|
|
1996
|
+
*/
|
|
1997
|
+
startHeartbeat = (currentSocket) => {
|
|
1998
|
+
if (!this.clientHeartbeat) return;
|
|
1999
|
+
this.stopHeartbeat();
|
|
1920
2000
|
const intervalId = setInterval(() => {
|
|
1921
2001
|
if (currentSocket.readyState === WebSocket.OPEN) {
|
|
1922
|
-
currentSocket.send(heartbeatMessage);
|
|
2002
|
+
currentSocket.send(this.heartbeatMessage);
|
|
1923
2003
|
}
|
|
1924
|
-
}, heartbeatInterval);
|
|
1925
|
-
heartbeatIntervalRef
|
|
2004
|
+
}, this.heartbeatInterval);
|
|
2005
|
+
this.heartbeatIntervalRef = intervalId;
|
|
2006
|
+
};
|
|
2007
|
+
/**
|
|
2008
|
+
* 停止心跳机制
|
|
2009
|
+
*/
|
|
2010
|
+
stopHeartbeat = () => {
|
|
2011
|
+
if (this.heartbeatIntervalRef !== null) {
|
|
2012
|
+
clearInterval(this.heartbeatIntervalRef);
|
|
2013
|
+
this.heartbeatIntervalRef = null;
|
|
2014
|
+
}
|
|
1926
2015
|
};
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
2016
|
+
/**
|
|
2017
|
+
* 停止重连定时器
|
|
2018
|
+
*/
|
|
2019
|
+
stopReconnectTimer = () => {
|
|
2020
|
+
if (this.reconnectIntervalRef !== null) {
|
|
2021
|
+
clearTimeout(this.reconnectIntervalRef);
|
|
2022
|
+
this.reconnectIntervalRef = null;
|
|
1931
2023
|
}
|
|
1932
2024
|
};
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
2025
|
+
/**
|
|
2026
|
+
* 重置心跳定时器
|
|
2027
|
+
*/
|
|
2028
|
+
resetHeartbeat = (currentSocket = this.socket) => {
|
|
2029
|
+
if (!currentSocket) return;
|
|
2030
|
+
this.startHeartbeat(currentSocket);
|
|
2031
|
+
};
|
|
2032
|
+
/**
|
|
2033
|
+
* 广播消息给所有订阅者
|
|
2034
|
+
*/
|
|
2035
|
+
emitMessage = (message3) => {
|
|
2036
|
+
this.listeners.forEach((listener) => listener.onMessage(message3));
|
|
2037
|
+
};
|
|
2038
|
+
/**
|
|
2039
|
+
* 解析消息内容,JSON 解析失败时回退为原始字符串
|
|
2040
|
+
*/
|
|
2041
|
+
parseMessage = (data) => {
|
|
2042
|
+
try {
|
|
2043
|
+
return JSON.parse(data);
|
|
2044
|
+
} catch {
|
|
2045
|
+
return data;
|
|
1937
2046
|
}
|
|
1938
2047
|
};
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
2048
|
+
/**
|
|
2049
|
+
* 尝试重新连接
|
|
2050
|
+
*/
|
|
2051
|
+
tryReconnect = () => {
|
|
2052
|
+
if (this.isDestroy || this.listeners.size === 0) return;
|
|
2053
|
+
if (this.isReconnect && !this.documentHide) {
|
|
2054
|
+
if ((!isNumber(this.maxReconnectAttempts) || this.reconnectAttempts < this.maxReconnectAttempts) && this.reconnectIntervalRef === null) {
|
|
2055
|
+
this.reconnectIntervalRef = setTimeout(() => {
|
|
2056
|
+
this.reconnectIntervalRef = null;
|
|
2057
|
+
console.log(`\u5C1D\u8BD5\u7B2C ${this.reconnectAttempts + 1} \u6B21\u91CD\u8FDE...`, this.url);
|
|
2058
|
+
this.reconnectAttempts++;
|
|
2059
|
+
this.createAndListenWebSocket();
|
|
2060
|
+
}, this.reconnectInterval);
|
|
1949
2061
|
} else {
|
|
1950
|
-
if (isNumber(maxReconnectAttempts)) {
|
|
2062
|
+
if (isNumber(this.maxReconnectAttempts) && this.reconnectAttempts >= this.maxReconnectAttempts) {
|
|
1951
2063
|
console.log("\u8FBE\u5230\u6700\u5927\u91CD\u8FDE\u5C1D\u8BD5\u6B21\u6570\uFF0C\u505C\u6B62\u91CD\u8FDE");
|
|
1952
2064
|
}
|
|
1953
2065
|
}
|
|
1954
2066
|
}
|
|
1955
2067
|
};
|
|
1956
|
-
|
|
2068
|
+
/**
|
|
2069
|
+
* WebSocket onopen 事件处理
|
|
2070
|
+
*/
|
|
2071
|
+
handleOpen = (newSocket) => {
|
|
1957
2072
|
console.log("WebSocket \u8FDE\u63A5\u5DF2\u6253\u5F00");
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
2073
|
+
this.stopReconnectTimer();
|
|
2074
|
+
this.setSocketReadyState(newSocket.readyState);
|
|
2075
|
+
this.resetHeartbeat(newSocket);
|
|
2076
|
+
this.reconnectAttempts = 0;
|
|
1961
2077
|
};
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
} catch (error) {
|
|
1970
|
-
console.error("\u89E3\u6790\u6D88\u606F\u6570\u636E\u65F6\u51FA\u9519:", error);
|
|
1971
|
-
}
|
|
1972
|
-
}
|
|
2078
|
+
/**
|
|
2079
|
+
* WebSocket onmessage 事件处理
|
|
2080
|
+
*/
|
|
2081
|
+
handleMessage = (event) => {
|
|
2082
|
+
const message3 = this.parseMessage(event.data);
|
|
2083
|
+
this.emitMessage(message3);
|
|
2084
|
+
this.resetHeartbeat();
|
|
1973
2085
|
};
|
|
1974
|
-
|
|
2086
|
+
/**
|
|
2087
|
+
* WebSocket onclose 事件处理
|
|
2088
|
+
*/
|
|
2089
|
+
handleClose = (event) => {
|
|
1975
2090
|
console.log("WebSocket \u8FDE\u63A5\u5DF2\u5173\u95ED", event.code, event.reason);
|
|
1976
|
-
setSocketReadyState(
|
|
1977
|
-
stopHeartbeat();
|
|
1978
|
-
onClose?.();
|
|
1979
|
-
tryReconnect();
|
|
2091
|
+
this.setSocketReadyState(WebSocket.CLOSED);
|
|
2092
|
+
this.stopHeartbeat();
|
|
2093
|
+
this.listeners.forEach((l) => l.onClose?.());
|
|
2094
|
+
this.tryReconnect();
|
|
1980
2095
|
};
|
|
1981
|
-
|
|
2096
|
+
/**
|
|
2097
|
+
* WebSocket onerror 事件处理
|
|
2098
|
+
*/
|
|
2099
|
+
handleError = (error) => {
|
|
1982
2100
|
console.error("WebSocket \u53D1\u751F\u9519\u8BEF:", error);
|
|
1983
|
-
setSocketReadyState(null);
|
|
1984
|
-
stopHeartbeat();
|
|
1985
|
-
tryReconnect();
|
|
2101
|
+
this.setSocketReadyState(null);
|
|
2102
|
+
this.stopHeartbeat();
|
|
2103
|
+
this.tryReconnect();
|
|
2104
|
+
};
|
|
2105
|
+
/**
|
|
2106
|
+
* 清理当前的 WebSocket 实例,取消所有事件绑定并关闭连接
|
|
2107
|
+
*/
|
|
2108
|
+
cleanupSocket = (notifyClose = false) => {
|
|
2109
|
+
this.stopHeartbeat();
|
|
2110
|
+
if (this.socket) {
|
|
2111
|
+
this.socket.onopen = null;
|
|
2112
|
+
this.socket.onmessage = null;
|
|
2113
|
+
this.socket.onerror = null;
|
|
2114
|
+
if (!notifyClose) {
|
|
2115
|
+
this.socket.onclose = null;
|
|
2116
|
+
}
|
|
2117
|
+
if (this.socket.readyState === WebSocket.OPEN || this.socket.readyState === WebSocket.CONNECTING) {
|
|
2118
|
+
this.socket.close();
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
1986
2121
|
};
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
newSocket
|
|
1993
|
-
|
|
1994
|
-
newSocket.
|
|
2122
|
+
/**
|
|
2123
|
+
* 创建新的 WebSocket 实例并绑定事件
|
|
2124
|
+
*/
|
|
2125
|
+
createAndListenWebSocket = () => {
|
|
2126
|
+
this.cleanupSocket();
|
|
2127
|
+
const newSocket = new WebSocket(this.url);
|
|
2128
|
+
this.socket = newSocket;
|
|
2129
|
+
this.setSocketReadyState(newSocket.readyState);
|
|
2130
|
+
newSocket.onopen = () => this.handleOpen(newSocket);
|
|
2131
|
+
newSocket.onmessage = this.handleMessage;
|
|
2132
|
+
newSocket.onclose = this.handleClose;
|
|
2133
|
+
newSocket.onerror = this.handleError;
|
|
1995
2134
|
};
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2135
|
+
/**
|
|
2136
|
+
* 处理页面可见性变化
|
|
2137
|
+
* 页面隐藏时暂停部分活动,重新显示且断开时尝试重连
|
|
2138
|
+
*/
|
|
2139
|
+
handleVisibilityChange = () => {
|
|
2140
|
+
this.documentHide = document.visibilityState === "hidden";
|
|
2141
|
+
if (!this.documentHide && (this.readyState === WebSocket.CLOSED || this.readyState === null)) {
|
|
2142
|
+
this.tryReconnect();
|
|
2000
2143
|
}
|
|
2001
2144
|
};
|
|
2145
|
+
/**
|
|
2146
|
+
* 供外部调用的发送消息方法
|
|
2147
|
+
* @param message 要发送的消息内容(字符串)
|
|
2148
|
+
*/
|
|
2149
|
+
sendMessage = (message3) => {
|
|
2150
|
+
if (this.socket?.readyState === WebSocket.OPEN) {
|
|
2151
|
+
this.socket.send(message3);
|
|
2152
|
+
this.resetHeartbeat(this.socket);
|
|
2153
|
+
} else {
|
|
2154
|
+
console.warn("WebSocket \u672A\u8FDE\u63A5\uFF0C\u65E0\u6CD5\u53D1\u9001\u6D88\u606F:", message3);
|
|
2155
|
+
}
|
|
2156
|
+
};
|
|
2157
|
+
/**
|
|
2158
|
+
* 销毁当前实例,清理所有资源
|
|
2159
|
+
*/
|
|
2160
|
+
destroy = () => {
|
|
2161
|
+
this.isDestroy = true;
|
|
2162
|
+
window.removeEventListener("visibilitychange", this.handleVisibilityChange);
|
|
2163
|
+
if (this.destroyTimeoutRef) {
|
|
2164
|
+
clearTimeout(this.destroyTimeoutRef);
|
|
2165
|
+
this.destroyTimeoutRef = null;
|
|
2166
|
+
}
|
|
2167
|
+
this.cleanupSocket(true);
|
|
2168
|
+
this.stopHeartbeat();
|
|
2169
|
+
this.stopReconnectTimer();
|
|
2170
|
+
};
|
|
2171
|
+
};
|
|
2172
|
+
|
|
2173
|
+
// src/hooks/webSocket/useWebSocket.ts
|
|
2174
|
+
var useWebSocket_default = ({
|
|
2175
|
+
url,
|
|
2176
|
+
onMessage,
|
|
2177
|
+
onClose,
|
|
2178
|
+
heartbeatInterval = 3e4,
|
|
2179
|
+
heartbeatMessage = "ping",
|
|
2180
|
+
clientHeartbeat = true,
|
|
2181
|
+
reconnectInterval = 5e3,
|
|
2182
|
+
maxReconnectAttempts,
|
|
2183
|
+
isReconnect = true
|
|
2184
|
+
}) => {
|
|
2185
|
+
const [socketReadyState, setSocketReadyState] = React.useState(null);
|
|
2186
|
+
const onMessageRef = React.useRef(onMessage);
|
|
2187
|
+
React.useEffect(() => {
|
|
2188
|
+
onMessageRef.current = onMessage;
|
|
2189
|
+
}, [onMessage]);
|
|
2190
|
+
const onCloseRef = React.useRef(onClose);
|
|
2191
|
+
React.useEffect(() => {
|
|
2192
|
+
onCloseRef.current = onClose;
|
|
2193
|
+
}, [onClose]);
|
|
2194
|
+
const managerRef = React.useRef(null);
|
|
2002
2195
|
React.useEffect(() => {
|
|
2003
2196
|
if (!url) return;
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2197
|
+
const manager = WebSocketManager.getInstance({
|
|
2198
|
+
url,
|
|
2199
|
+
heartbeatInterval,
|
|
2200
|
+
heartbeatMessage,
|
|
2201
|
+
clientHeartbeat,
|
|
2202
|
+
reconnectInterval,
|
|
2203
|
+
maxReconnectAttempts,
|
|
2204
|
+
isReconnect
|
|
2205
|
+
});
|
|
2206
|
+
managerRef.current = manager;
|
|
2207
|
+
const listener = {
|
|
2208
|
+
onMessage: (msg) => onMessageRef.current?.(msg),
|
|
2209
|
+
onClose: () => onCloseRef.current?.(),
|
|
2210
|
+
onStateChange: (state) => setSocketReadyState(state)
|
|
2211
|
+
};
|
|
2212
|
+
manager.addListener(listener);
|
|
2007
2213
|
return () => {
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
if (socketRef.current) {
|
|
2011
|
-
socketRef.current.close();
|
|
2012
|
-
return;
|
|
2013
|
-
}
|
|
2014
|
-
stopHeartbeat();
|
|
2015
|
-
stopReconnectTimer();
|
|
2214
|
+
manager.removeListener(listener);
|
|
2215
|
+
managerRef.current = null;
|
|
2016
2216
|
};
|
|
2017
2217
|
}, [url]);
|
|
2018
|
-
const sendMessage = (message3) => {
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
stopHeartbeat();
|
|
2022
|
-
startHeartbeat(socketRef.current);
|
|
2023
|
-
} else {
|
|
2024
|
-
console.warn("WebSocket \u672A\u8FDE\u63A5\uFF0C\u65E0\u6CD5\u53D1\u9001\u6D88\u606F:", message3);
|
|
2025
|
-
}
|
|
2026
|
-
};
|
|
2218
|
+
const sendMessage = React.useCallback((message3) => {
|
|
2219
|
+
managerRef.current?.sendMessage(message3);
|
|
2220
|
+
}, []);
|
|
2027
2221
|
return {
|
|
2028
|
-
/** 发送消息方法 */
|
|
2029
2222
|
sendMessage,
|
|
2030
|
-
/** Socket 连接状态 */
|
|
2031
2223
|
socketReadyState
|
|
2032
2224
|
};
|
|
2033
2225
|
};
|
|
@@ -2260,7 +2452,7 @@ var ProtectedView = ({
|
|
|
2260
2452
|
});
|
|
2261
2453
|
};
|
|
2262
2454
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { justify: "center", align: "center", className: "height-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: 300 }, children: [
|
|
2263
|
-
passwordStatus === core$1.PasswordStatus.WrongPassword && /* @__PURE__ */ jsxRuntime.jsx(antd.Alert, {
|
|
2455
|
+
passwordStatus === core$1.PasswordStatus.WrongPassword && /* @__PURE__ */ jsxRuntime.jsx(antd.Alert, { title: "\u5BC6\u7801\u65E0\u6548\u3002\u8BF7\u518D\u8BD5\u4E00\u6B21\uFF01", type: "error" }),
|
|
2264
2456
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Form, { form, size: "large", className: "m-t-24", children: [
|
|
2265
2457
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { name: "password", rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u5BC6\u7801" }], children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input.Password, { autoComplete: "new-password", placeholder: "\u8BF7\u8F93\u5165\u5BC6\u7801" }) }),
|
|
2266
2458
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { justify: "center", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "primary", onClick: onSubmit, children: "\u63D0 \u4EA4" }) })
|
|
@@ -2370,7 +2562,7 @@ var PdfPreview_default = ({ password, fileUrl, pageNo = 1, scale = 1, isHasThumb
|
|
|
2370
2562
|
message3 = "\u65E0\u6CD5\u52A0\u8F7D\u6587\u6863";
|
|
2371
2563
|
break;
|
|
2372
2564
|
}
|
|
2373
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { className: "height-full", justify: "center", align: "center", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Alert, {
|
|
2565
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { className: "height-full", justify: "center", align: "center", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Alert, { title: message3, type: "error", showIcon: true }) });
|
|
2374
2566
|
};
|
|
2375
2567
|
const onPageChange = (e) => {
|
|
2376
2568
|
let newCurrentPage = e.currentPage;
|
|
@@ -2447,7 +2639,7 @@ var FilePreview_default = ({ suffix, fileUrl, pdfParams, password, searchValue,
|
|
|
2447
2639
|
case "JPG":
|
|
2448
2640
|
case "JPEG":
|
|
2449
2641
|
case "GIF":
|
|
2450
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Image, {
|
|
2642
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Image, { classNames: { root: styles_module_default.nsPreviewImage }, src: fileUrl, alt: "\u9884\u89C8\u56FE\u7247" });
|
|
2451
2643
|
case "PDF":
|
|
2452
2644
|
return /* @__PURE__ */ jsxRuntime.jsx(PdfPreview_default, { fileUrl, ...pdfParams, password, onSetPassword });
|
|
2453
2645
|
case "PDF_IMG":
|
|
@@ -2478,7 +2670,7 @@ var FilePreviewDrawer_default = ({ open, title = "\u6587\u4EF6\u9884\u89C8", onC
|
|
|
2478
2670
|
{
|
|
2479
2671
|
title,
|
|
2480
2672
|
push: false,
|
|
2481
|
-
|
|
2673
|
+
size: "100%",
|
|
2482
2674
|
open,
|
|
2483
2675
|
onClose,
|
|
2484
2676
|
children: /* @__PURE__ */ jsxRuntime.jsx(FilePreview_default, { ...props })
|
|
@@ -2486,8 +2678,10 @@ var FilePreviewDrawer_default = ({ open, title = "\u6587\u4EF6\u9884\u89C8", onC
|
|
|
2486
2678
|
);
|
|
2487
2679
|
};
|
|
2488
2680
|
|
|
2489
|
-
// src/components/MicroApp/styles.less
|
|
2490
|
-
var
|
|
2681
|
+
// src/components/MicroApp/styles.module.less
|
|
2682
|
+
var styles_module_default3 = {
|
|
2683
|
+
microApp: "styles_module_microApp"
|
|
2684
|
+
};
|
|
2491
2685
|
var MicroApp_default = ({ name, url, className, onMounted, onError, data, ...rest }) => {
|
|
2492
2686
|
const [loading, setLoading] = React.useState(false);
|
|
2493
2687
|
React.useEffect(() => {
|
|
@@ -2506,13 +2700,13 @@ var MicroApp_default = ({ name, url, className, onMounted, onError, data, ...res
|
|
|
2506
2700
|
return { mainSource: [...parentMainSource, name], ...data };
|
|
2507
2701
|
}, [data, name]);
|
|
2508
2702
|
const TagName = microApp__default.default.tagName || "micro-app";
|
|
2509
|
-
return /* @__PURE__ */ jsxCustomEvent__default.default(antd.Spin, { spinning: loading,
|
|
2703
|
+
return /* @__PURE__ */ jsxCustomEvent__default.default(antd.Spin, { spinning: loading, classNames: { root: "full-spin" }, description: "\u52A0\u8F7D\u4E2D..." }, /* @__PURE__ */ jsxCustomEvent__default.default(
|
|
2510
2704
|
TagName,
|
|
2511
2705
|
{
|
|
2512
2706
|
name,
|
|
2513
2707
|
url,
|
|
2514
2708
|
data: microAppData,
|
|
2515
|
-
class: classNames2__default.default(
|
|
2709
|
+
class: classNames2__default.default(styles_module_default3.microApp, className),
|
|
2516
2710
|
onMounted: handleLoad,
|
|
2517
2711
|
onError: handleError,
|
|
2518
2712
|
...rest
|
|
@@ -2549,7 +2743,7 @@ var Drawer_default = ({ name: podName }) => {
|
|
|
2549
2743
|
classNames: {
|
|
2550
2744
|
header: currentPod.title === false ? "hidden" : ""
|
|
2551
2745
|
},
|
|
2552
|
-
|
|
2746
|
+
size: "100%",
|
|
2553
2747
|
open: fullPodOpen,
|
|
2554
2748
|
onClose: () => setFullPodOpen(false),
|
|
2555
2749
|
children: /* @__PURE__ */ jsxRuntime.jsx(MicroApp_default, { iframe: true, name: podName, url: currentPod.url, "router-mode": "pure" }, currentPod.url)
|
|
@@ -2591,7 +2785,7 @@ var Window_default = ({ defaultUrl, name: appName }) => {
|
|
|
2591
2785
|
};
|
|
2592
2786
|
|
|
2593
2787
|
// src/components/Iframe/styles.module.less
|
|
2594
|
-
var
|
|
2788
|
+
var styles_module_default4 = {
|
|
2595
2789
|
iframe: "styles_module_iframe"
|
|
2596
2790
|
};
|
|
2597
2791
|
var Iframe_default = React.forwardRef(({ defaultMainSource, id, src, className, onLoad }, ref) => {
|
|
@@ -2606,13 +2800,13 @@ var Iframe_default = React.forwardRef(({ defaultMainSource, id, src, className,
|
|
|
2606
2800
|
React.useEffect(() => {
|
|
2607
2801
|
setLoading(true);
|
|
2608
2802
|
}, [src]);
|
|
2609
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading,
|
|
2803
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, classNames: { root: "full-spin" }, description: "\u52A0\u8F7D\u4E2D...", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2610
2804
|
"iframe",
|
|
2611
2805
|
{
|
|
2612
2806
|
id,
|
|
2613
2807
|
ref,
|
|
2614
2808
|
src: finalSrc,
|
|
2615
|
-
className: classNames2__default.default(
|
|
2809
|
+
className: classNames2__default.default(styles_module_default4.iframe, className),
|
|
2616
2810
|
onLoad: onHandleLoad,
|
|
2617
2811
|
allow: "clipboard-write"
|
|
2618
2812
|
}
|
|
@@ -2620,7 +2814,7 @@ var Iframe_default = React.forwardRef(({ defaultMainSource, id, src, className,
|
|
|
2620
2814
|
});
|
|
2621
2815
|
|
|
2622
2816
|
// src/components/MarkdownEditor/styles.module.less
|
|
2623
|
-
var
|
|
2817
|
+
var styles_module_default5 = {
|
|
2624
2818
|
editorParent: "styles_module_editorParent",
|
|
2625
2819
|
extraToolbar: "styles_module_extraToolbar",
|
|
2626
2820
|
editorFloatingToolbar: "styles_module_editorFloatingToolbar",
|
|
@@ -3311,7 +3505,7 @@ var ANNOTATION_KEY = "annotation";
|
|
|
3311
3505
|
var ANNOTATION_ATTRS = ["annotation-id", "user-name", "user-id", "update-time", "content"];
|
|
3312
3506
|
|
|
3313
3507
|
// src/components/MarkdownEditor/annotation/styles.module.less
|
|
3314
|
-
var
|
|
3508
|
+
var styles_module_default6 = {
|
|
3315
3509
|
annotations: "styles_module_annotations",
|
|
3316
3510
|
annotationItem: "styles_module_annotationItem",
|
|
3317
3511
|
annotationItemSelected: "styles_module_annotationItemSelected"
|
|
@@ -3374,7 +3568,7 @@ var AnnotationSidebar_default = ({
|
|
|
3374
3568
|
children: annotations.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3375
3569
|
antd.List,
|
|
3376
3570
|
{
|
|
3377
|
-
className: classNames2__default.default(
|
|
3571
|
+
className: classNames2__default.default(styles_module_default6.annotations, "height-full", "scroll-fade-in"),
|
|
3378
3572
|
dataSource: annotations,
|
|
3379
3573
|
renderItem: (annotation) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3380
3574
|
antd.List.Item,
|
|
@@ -3382,14 +3576,14 @@ var AnnotationSidebar_default = ({
|
|
|
3382
3576
|
ref: (el) => {
|
|
3383
3577
|
itemRefs.current[annotation[ANNOTATION_ATTRS[0]]] = el;
|
|
3384
3578
|
},
|
|
3385
|
-
className: classNames2__default.default(
|
|
3386
|
-
[
|
|
3579
|
+
className: classNames2__default.default(styles_module_default6.annotationItem, {
|
|
3580
|
+
[styles_module_default6.annotationItemSelected]: annotation[ANNOTATION_ATTRS[0]] === selectedAnnotationId
|
|
3387
3581
|
}),
|
|
3388
3582
|
onClick: () => {
|
|
3389
3583
|
handleSelectAnnotation(annotation[ANNOTATION_ATTRS[0]]);
|
|
3390
3584
|
},
|
|
3391
3585
|
children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, gap: 8, flex: 1, children: [
|
|
3392
|
-
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 8, justify: "space-between", className:
|
|
3586
|
+
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 8, justify: "space-between", className: styles_module_default6.annotationMeta, children: [
|
|
3393
3587
|
/* @__PURE__ */ jsxRuntime.jsx(Text, { strong: true, type: "secondary", children: annotation["user-name"] }),
|
|
3394
3588
|
/* @__PURE__ */ jsxRuntime.jsx(Text, { type: "secondary", children: formatDate(annotation["update-time"]) })
|
|
3395
3589
|
] }),
|
|
@@ -3993,7 +4187,7 @@ var CollectionPlugin = core.Extension.create({
|
|
|
3993
4187
|
});
|
|
3994
4188
|
|
|
3995
4189
|
// src/components/MarkdownEditor/collection/styles.module.less
|
|
3996
|
-
var
|
|
4190
|
+
var styles_module_default7 = {
|
|
3997
4191
|
collections: "styles_module_collections",
|
|
3998
4192
|
collectionItem: "styles_module_collectionItem",
|
|
3999
4193
|
collectionItemSelected: "styles_module_collectionItemSelected"
|
|
@@ -4039,7 +4233,7 @@ var collectionSidebar_default = ({
|
|
|
4039
4233
|
children: collections.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4040
4234
|
antd.List,
|
|
4041
4235
|
{
|
|
4042
|
-
className: classNames2__default.default(
|
|
4236
|
+
className: classNames2__default.default(styles_module_default7.collections, "height-full", "scroll-fade-in"),
|
|
4043
4237
|
dataSource: collections,
|
|
4044
4238
|
renderItem: (collection) => {
|
|
4045
4239
|
if (collectionConfig?.renderItem) {
|
|
@@ -4056,14 +4250,14 @@ var collectionSidebar_default = ({
|
|
|
4056
4250
|
ref: (el) => {
|
|
4057
4251
|
itemRefs.current[collection[COLLECTION_ATTRS[0]]] = el;
|
|
4058
4252
|
},
|
|
4059
|
-
className: classNames2__default.default(
|
|
4060
|
-
[
|
|
4253
|
+
className: classNames2__default.default(styles_module_default7.collectionItem, {
|
|
4254
|
+
[styles_module_default7.collectionItemSelected]: collection[COLLECTION_ATTRS[0]] === selectedCollectionId
|
|
4061
4255
|
}),
|
|
4062
4256
|
onClick: () => {
|
|
4063
4257
|
handleSelectCollection?.(collection[COLLECTION_ATTRS[0]]);
|
|
4064
4258
|
},
|
|
4065
4259
|
children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, gap: 8, flex: 1, children: [
|
|
4066
|
-
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 8, justify: "space-between", className:
|
|
4260
|
+
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 8, justify: "space-between", className: styles_module_default7.collectionMeta, children: [
|
|
4067
4261
|
/* @__PURE__ */ jsxRuntime.jsx(Text2, { strong: true, type: "secondary", children: collection["user-name"] }),
|
|
4068
4262
|
/* @__PURE__ */ jsxRuntime.jsx(Text2, { type: "secondary", children: formatDate(collection["update-time"]) })
|
|
4069
4263
|
] }),
|
|
@@ -8970,7 +9164,7 @@ var MarkdownEditor_default = React.forwardRef(
|
|
|
8970
9164
|
const fixedTools = React.useMemo(() => isArray(fixedToolbar) ? fixedToolbar : void 0, [fixedToolbar]);
|
|
8971
9165
|
const floatTools = React.useMemo(() => isArray(floatToolbar) ? floatToolbar : void 0, [floatToolbar]);
|
|
8972
9166
|
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { className: "height-full width-full", children: [
|
|
8973
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames2__default.default("height-full", "flex-1",
|
|
9167
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames2__default.default("height-full", "flex-1", styles_module_default5.editorParent), children: /* @__PURE__ */ jsxRuntime.jsxs(react.EditorContext.Provider, { value: { editor }, children: [
|
|
8974
9168
|
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8975
9169
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "end", align: "center", children: [
|
|
8976
9170
|
fixedToolbar !== false && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -8983,7 +9177,7 @@ var MarkdownEditor_default = React.forwardRef(
|
|
|
8983
9177
|
tools: fixedTools
|
|
8984
9178
|
}
|
|
8985
9179
|
),
|
|
8986
|
-
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 8, align: "center", className: classNames2__default.default(
|
|
9180
|
+
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 8, align: "center", className: classNames2__default.default(styles_module_default5.extraToolbar), children: [
|
|
8987
9181
|
annotationConfig?.enabled && annotationConfig?.showListButton !== false && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8988
9182
|
antd.Button,
|
|
8989
9183
|
{
|
|
@@ -9012,7 +9206,7 @@ var MarkdownEditor_default = React.forwardRef(
|
|
|
9012
9206
|
extraNav
|
|
9013
9207
|
] })
|
|
9014
9208
|
] }),
|
|
9015
|
-
!isMobile && floatToolbar !== false && /* @__PURE__ */ jsxRuntime.jsx(FloatingElement, { editor, zIndex: 188, resetTextSelectionOnClose: false, className:
|
|
9209
|
+
!isMobile && floatToolbar !== false && /* @__PURE__ */ jsxRuntime.jsx(FloatingElement, { editor, zIndex: 188, resetTextSelectionOnClose: false, className: styles_module_default5.editorFloatingToolbar, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9016
9210
|
EditorToolbar,
|
|
9017
9211
|
{
|
|
9018
9212
|
isBubble: true,
|
|
@@ -9023,17 +9217,17 @@ var MarkdownEditor_default = React.forwardRef(
|
|
|
9023
9217
|
}
|
|
9024
9218
|
) })
|
|
9025
9219
|
] }),
|
|
9026
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { id: "contentWrapper", className: classNames2__default.default(
|
|
9220
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { id: "contentWrapper", className: classNames2__default.default(styles_module_default5.contentWrapper, "scroll-fade-in"), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9027
9221
|
react.EditorContent,
|
|
9028
9222
|
{
|
|
9029
9223
|
editor,
|
|
9030
9224
|
role: "presentation",
|
|
9031
|
-
className: classNames2__default.default(
|
|
9225
|
+
className: classNames2__default.default(styles_module_default5.simpleEditorContent, "ns-markdown", { [styles_module_default5.noToolbar]: fixedToolbar === false })
|
|
9032
9226
|
}
|
|
9033
9227
|
) })
|
|
9034
9228
|
] }) }),
|
|
9035
9229
|
annotationConfig?.enabled && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9036
|
-
showAnnotation && /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames2__default.default("height-full",
|
|
9230
|
+
showAnnotation && /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames2__default.default("height-full", styles_module_default5.extraSidebarParent), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9037
9231
|
AnnotationSidebar_default,
|
|
9038
9232
|
{
|
|
9039
9233
|
disabled,
|
|
@@ -9048,7 +9242,7 @@ var MarkdownEditor_default = React.forwardRef(
|
|
|
9048
9242
|
) }),
|
|
9049
9243
|
showAnnotationModal && /* @__PURE__ */ jsxRuntime.jsx(AnnotationModal_default, { visible: showAnnotationModal, onCancel: closeAnnotationCreateModal, onConfirm: onCreateAnnotationConfirm })
|
|
9050
9244
|
] }),
|
|
9051
|
-
collectionConfig?.enabled && showCollection && /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames2__default.default("height-full",
|
|
9245
|
+
collectionConfig?.enabled && showCollection && /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames2__default.default("height-full", styles_module_default5.extraSidebarParent), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9052
9246
|
collectionSidebar_default,
|
|
9053
9247
|
{
|
|
9054
9248
|
disabled,
|
|
@@ -9065,7 +9259,7 @@ var MarkdownEditor_default = React.forwardRef(
|
|
|
9065
9259
|
);
|
|
9066
9260
|
|
|
9067
9261
|
// src/components/MarkDrawing/styles.module.less
|
|
9068
|
-
var
|
|
9262
|
+
var styles_module_default8 = {
|
|
9069
9263
|
container: "styles_module_container",
|
|
9070
9264
|
rect: "styles_module_rect",
|
|
9071
9265
|
score: "styles_module_score"
|
|
@@ -9089,7 +9283,7 @@ var MarkDrawing_default = ({ children, detections, originalSize, scopeRender })
|
|
|
9089
9283
|
}, []);
|
|
9090
9284
|
const scaleX = containerSize.width / originalSize.width;
|
|
9091
9285
|
const scaleY = containerSize.height / originalSize.height;
|
|
9092
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className:
|
|
9286
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: styles_module_default8.container, children: [
|
|
9093
9287
|
children,
|
|
9094
9288
|
detections?.map((det, idx) => {
|
|
9095
9289
|
const [x1, y1, x2, y2] = det.bbox;
|
|
@@ -9101,7 +9295,7 @@ var MarkDrawing_default = ({ children, detections, originalSize, scopeRender })
|
|
|
9101
9295
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9102
9296
|
"div",
|
|
9103
9297
|
{
|
|
9104
|
-
className:
|
|
9298
|
+
className: styles_module_default8.rect,
|
|
9105
9299
|
style: {
|
|
9106
9300
|
left,
|
|
9107
9301
|
top,
|
|
@@ -9113,7 +9307,7 @@ var MarkDrawing_default = ({ children, detections, originalSize, scopeRender })
|
|
|
9113
9307
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9114
9308
|
"div",
|
|
9115
9309
|
{
|
|
9116
|
-
className:
|
|
9310
|
+
className: styles_module_default8.score,
|
|
9117
9311
|
style: {
|
|
9118
9312
|
left,
|
|
9119
9313
|
top: Math.max(top - 20, 0)
|