@zero-library/common 2.1.9 → 2.1.11
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 +81 -61
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +231 -40
- package/dist/index.d.ts +231 -40
- package/dist/index.esm.js +84 -64
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -97,24 +97,8 @@ var AudioPlayer_default = ({ fileUrl }) => {
|
|
|
97
97
|
"\u60A8\u7684\u6D4F\u89C8\u5668\u4E0D\u652F\u6301 audio \u6807\u7B7E\u3002"
|
|
98
98
|
] });
|
|
99
99
|
};
|
|
100
|
-
|
|
101
|
-
// src/utils/theme.ts
|
|
102
|
-
var getPrimaryColor = () => {
|
|
103
|
-
const searchParams = new URLSearchParams(location.search);
|
|
104
|
-
const mainSource = searchParams.get("mainSource") || "cube-uc";
|
|
105
|
-
if (mainSource === "cube-uc") {
|
|
106
|
-
return "#34AFBE";
|
|
107
|
-
} else if (mainSource === "uc") {
|
|
108
|
-
return "#FA541C";
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
var LgPrimaryColor = getPrimaryColor();
|
|
112
|
-
var themeConfig = {
|
|
113
|
-
token: { colorPrimary: LgPrimaryColor, colorLink: LgPrimaryColor },
|
|
114
|
-
cssVar: true
|
|
115
|
-
};
|
|
116
100
|
var FileIcon_default = ({ suffix, fontSize = 22 }) => {
|
|
117
|
-
const styles = { fontSize, color:
|
|
101
|
+
const styles = { fontSize, color: "var(--ant-color-primary)" };
|
|
118
102
|
const Icon = React16.useMemo(() => {
|
|
119
103
|
switch (suffix?.toUpperCase()) {
|
|
120
104
|
case "TXT":
|
|
@@ -209,7 +193,7 @@ function highlightKeywords(html, keywords) {
|
|
|
209
193
|
function makePlaceholder(id) {
|
|
210
194
|
return `__ALERT_DATA_${id}__`;
|
|
211
195
|
}
|
|
212
|
-
function
|
|
196
|
+
function alertMarkClean(src) {
|
|
213
197
|
let pos = 0;
|
|
214
198
|
let id = 0;
|
|
215
199
|
let out = "";
|
|
@@ -223,19 +207,15 @@ function extractAlertPlaceholders(src) {
|
|
|
223
207
|
out += src.slice(pos, start);
|
|
224
208
|
const afterStart = src.slice(start);
|
|
225
209
|
const relAfter = afterStart.slice(":::alert".length);
|
|
226
|
-
const matchLineEnd = relAfter.search(/\
|
|
210
|
+
const matchLineEnd = relAfter.search(/\s*:::\s*/);
|
|
227
211
|
let endIdx = -1;
|
|
212
|
+
let isNoEnd = 1;
|
|
228
213
|
if (matchLineEnd !== -1) {
|
|
229
|
-
endIdx = start + ":::alert".length + matchLineEnd
|
|
214
|
+
endIdx = start + ":::alert".length + matchLineEnd;
|
|
215
|
+
isNoEnd = 0;
|
|
230
216
|
} else {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
out += src.slice(start);
|
|
234
|
-
pos = src.length;
|
|
235
|
-
break;
|
|
236
|
-
} else {
|
|
237
|
-
endIdx = fallback;
|
|
238
|
-
}
|
|
217
|
+
endIdx = src.length;
|
|
218
|
+
isNoEnd = 1;
|
|
239
219
|
}
|
|
240
220
|
const inner = src.slice(start + ":::alert".length, endIdx).trim();
|
|
241
221
|
const typeMatch = inner.match(/type\s*=\s*(?:(['"])(.*?)\1|(\S+))/);
|
|
@@ -247,8 +227,8 @@ function extractAlertPlaceholders(src) {
|
|
|
247
227
|
}
|
|
248
228
|
const ph = makePlaceholder(id++);
|
|
249
229
|
placeholders.set(ph, rawData);
|
|
250
|
-
const typeText = type ? `
|
|
251
|
-
out += `:::alert${typeText} data="${ph}" :::`;
|
|
230
|
+
const typeText = type ? `type=${JSON.stringify(type)}` : "";
|
|
231
|
+
out += `:::alert ${typeText} data="${ph}" loading="${isNoEnd}" :::`;
|
|
252
232
|
const realClose = src.indexOf(":::", endIdx);
|
|
253
233
|
pos = realClose === -1 ? endIdx : realClose + 3;
|
|
254
234
|
}
|
|
@@ -277,33 +257,23 @@ try {
|
|
|
277
257
|
var RenderMarkdown_default = ({ content = "", searchValue, customComponents, onChange, onPartialChange }) => {
|
|
278
258
|
const reactContent = React16.useMemo(() => {
|
|
279
259
|
if (!content) return null;
|
|
280
|
-
|
|
281
|
-
const openCount = (fixedContent.match(/:::alert\b/g) || []).length;
|
|
282
|
-
const closeCount = (fixedContent.match(/\s*:::\s*/gm) || []).length - openCount;
|
|
283
|
-
let incomplete = false;
|
|
284
|
-
if (openCount > closeCount) {
|
|
285
|
-
incomplete = true;
|
|
286
|
-
fixedContent += ":::";
|
|
287
|
-
}
|
|
288
|
-
const { text: preprocessed, placeholders } = extractAlertPlaceholders(fixedContent);
|
|
260
|
+
const { text: preprocessed, placeholders } = alertMarkClean(content);
|
|
289
261
|
let rawHtml = md.render(preprocessed);
|
|
290
262
|
rawHtml = searchValue ? highlightKeywords(rawHtml, [searchValue]) : rawHtml;
|
|
291
263
|
let lazyIndex = -1;
|
|
292
|
-
const allLazyMatches = [...rawHtml.matchAll(/<lazy-component/gi)];
|
|
293
|
-
const lastLazyIndex = allLazyMatches.length - 1;
|
|
294
264
|
return parse__default.default(rawHtml, {
|
|
295
265
|
replace: (domNode) => {
|
|
296
266
|
if (domNode.name === "lazy-component") {
|
|
297
267
|
lazyIndex++;
|
|
298
268
|
const el = domNode;
|
|
299
269
|
const type = el.attribs.type;
|
|
270
|
+
const loading = !!Number(el.attribs.loading);
|
|
300
271
|
const dataAttr = el.attribs.data || "";
|
|
301
272
|
let data = {};
|
|
302
273
|
if (/^__ALERT_DATA_\d+__$/.test(dataAttr)) {
|
|
303
274
|
const raw = placeholders.get(dataAttr) ?? "";
|
|
304
275
|
data = parseData(raw);
|
|
305
276
|
}
|
|
306
|
-
const loading = incomplete && lazyIndex === lastLazyIndex;
|
|
307
277
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
308
278
|
LazyComponent_default,
|
|
309
279
|
{
|
|
@@ -500,8 +470,9 @@ function useCreateValtioContext() {
|
|
|
500
470
|
};
|
|
501
471
|
return {
|
|
502
472
|
ValtioProvider,
|
|
503
|
-
useValtioStore
|
|
504
|
-
// Context
|
|
473
|
+
useValtioStore,
|
|
474
|
+
// 导出 Context 以便外部使用
|
|
475
|
+
Context
|
|
505
476
|
};
|
|
506
477
|
}
|
|
507
478
|
function useDebounce(func, wait = 400) {
|
|
@@ -540,8 +511,6 @@ function useDebounce(func, wait = 400) {
|
|
|
540
511
|
debounce.cancel = cancel;
|
|
541
512
|
return React16.useCallback(debounce, []);
|
|
542
513
|
}
|
|
543
|
-
|
|
544
|
-
// src/utils/common.ts
|
|
545
514
|
var deepCopy = (obj, isJson = true) => {
|
|
546
515
|
if (!isArray(obj) && !isObject(obj)) return obj;
|
|
547
516
|
if (isJson) return JSON.parse(JSON.stringify(obj));
|
|
@@ -644,9 +613,13 @@ var genNonDuplicateID = () => {
|
|
|
644
613
|
idStr += Math.random().toString(36).substr(2);
|
|
645
614
|
return idStr;
|
|
646
615
|
};
|
|
647
|
-
var copyText = (text) => {
|
|
616
|
+
var copyText = (text, prompt = "\u590D\u5236\u6210\u529F") => {
|
|
648
617
|
if (navigator.clipboard && window.isSecureContext) {
|
|
649
|
-
|
|
618
|
+
navigator.clipboard.writeText(text).then(() => {
|
|
619
|
+
if (prompt) {
|
|
620
|
+
antd.message.success(prompt);
|
|
621
|
+
}
|
|
622
|
+
});
|
|
650
623
|
} else {
|
|
651
624
|
const textArea = document.createElement("textarea");
|
|
652
625
|
textArea.value = text;
|
|
@@ -657,10 +630,11 @@ var copyText = (text) => {
|
|
|
657
630
|
document.body.appendChild(textArea);
|
|
658
631
|
textArea.focus();
|
|
659
632
|
textArea.select();
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
}
|
|
633
|
+
const bol = document.execCommand("copy");
|
|
634
|
+
if (bol && prompt) {
|
|
635
|
+
antd.message.success(prompt);
|
|
636
|
+
}
|
|
637
|
+
textArea.remove();
|
|
664
638
|
}
|
|
665
639
|
};
|
|
666
640
|
function formatNumberWithCommas(number) {
|
|
@@ -932,6 +906,24 @@ var isInteger = (num) => {
|
|
|
932
906
|
var isNegative = (num) => {
|
|
933
907
|
return new Decimal__default.default(num).isNegative();
|
|
934
908
|
};
|
|
909
|
+
|
|
910
|
+
// src/utils/theme.ts
|
|
911
|
+
var getPrimaryColor = () => {
|
|
912
|
+
const searchParams = new URLSearchParams(location.search);
|
|
913
|
+
const mainSource = searchParams.get("mainSource") || "cube-uc";
|
|
914
|
+
if (mainSource === "cube-uc") {
|
|
915
|
+
return "#34AFBE";
|
|
916
|
+
} else if (mainSource === "uc") {
|
|
917
|
+
return "#FA541C";
|
|
918
|
+
}
|
|
919
|
+
};
|
|
920
|
+
var LgPrimaryColor = getPrimaryColor();
|
|
921
|
+
var themeConfig = {
|
|
922
|
+
token: { colorPrimary: LgPrimaryColor, colorLink: LgPrimaryColor },
|
|
923
|
+
cssVar: true
|
|
924
|
+
};
|
|
925
|
+
|
|
926
|
+
// src/utils/message.ts
|
|
935
927
|
var cacheMessage = () => {
|
|
936
928
|
const contents = {};
|
|
937
929
|
return ({ title = "\u63D0\u793A", content, type = "warning", duration = 3, onClose, isCache = true, isOnly = false }) => {
|
|
@@ -1062,18 +1054,46 @@ function createRequest(baseURL = "/api") {
|
|
|
1062
1054
|
}
|
|
1063
1055
|
);
|
|
1064
1056
|
return {
|
|
1057
|
+
/**
|
|
1058
|
+
* GET 请求方法
|
|
1059
|
+
* @param url - 请求地址
|
|
1060
|
+
* @param params - 查询参数
|
|
1061
|
+
* @param options - Axios 配置选项
|
|
1062
|
+
* @returns 响应数据
|
|
1063
|
+
*/
|
|
1065
1064
|
get: async (url, params, options) => {
|
|
1066
1065
|
const res = await instance({ method: "get", url, params, ...options });
|
|
1067
1066
|
return res.data;
|
|
1068
1067
|
},
|
|
1068
|
+
/**
|
|
1069
|
+
* POST 请求方法
|
|
1070
|
+
* @param url - 请求地址
|
|
1071
|
+
* @param data - 请求数据
|
|
1072
|
+
* @param options - Axios 配置选项
|
|
1073
|
+
* @returns 响应数据
|
|
1074
|
+
*/
|
|
1069
1075
|
post: async (url, data, options) => {
|
|
1070
1076
|
const res = await instance({ method: "post", url, data, ...options });
|
|
1071
1077
|
return res.data;
|
|
1072
1078
|
},
|
|
1079
|
+
/**
|
|
1080
|
+
* PUT 请求方法
|
|
1081
|
+
* @param url - 请求地址
|
|
1082
|
+
* @param data - 请求数据
|
|
1083
|
+
* @param options - Axios 配置选项
|
|
1084
|
+
* @returns 响应数据
|
|
1085
|
+
*/
|
|
1073
1086
|
put: async (url, data, options) => {
|
|
1074
1087
|
const res = await instance({ method: "put", url, data, ...options });
|
|
1075
1088
|
return res.data;
|
|
1076
1089
|
},
|
|
1090
|
+
/**
|
|
1091
|
+
* DELETE 请求方法
|
|
1092
|
+
* @param url - 请求地址
|
|
1093
|
+
* @param data - 请求数据
|
|
1094
|
+
* @param options - Axios 配置选项
|
|
1095
|
+
* @returns 响应数据
|
|
1096
|
+
*/
|
|
1077
1097
|
delete: async (url, data, options) => {
|
|
1078
1098
|
const res = await instance({ method: "delete", url, data, ...options });
|
|
1079
1099
|
return res.data;
|
|
@@ -1205,9 +1225,9 @@ var useWebSocket = ({
|
|
|
1205
1225
|
stopReconnectTimer();
|
|
1206
1226
|
};
|
|
1207
1227
|
}, [url]);
|
|
1208
|
-
const sendMessage = (
|
|
1228
|
+
const sendMessage = (message3) => {
|
|
1209
1229
|
if (socketRef.current?.readyState === WebSocket.OPEN) {
|
|
1210
|
-
socketRef.current.send(
|
|
1230
|
+
socketRef.current.send(message3);
|
|
1211
1231
|
stopHeartbeat();
|
|
1212
1232
|
startHeartbeat(socketRef.current);
|
|
1213
1233
|
}
|
|
@@ -1290,25 +1310,25 @@ var PdfPreview_default = ({ password, fileUrl, pageNo = 1, scale = 1, isHasThumb
|
|
|
1290
1310
|
}, 0);
|
|
1291
1311
|
}, [pageNo]);
|
|
1292
1312
|
const renderError = (error) => {
|
|
1293
|
-
let
|
|
1313
|
+
let message3 = "";
|
|
1294
1314
|
switch (error.name) {
|
|
1295
1315
|
case "InvalidPDFException":
|
|
1296
|
-
|
|
1316
|
+
message3 = "\u6587\u4EF6\u65E0\u6548\u6216\u5DF2\u635F\u574F";
|
|
1297
1317
|
break;
|
|
1298
1318
|
case "MissingPDFException":
|
|
1299
|
-
|
|
1319
|
+
message3 = "\u6587\u4EF6\u4E0D\u5B58\u5728";
|
|
1300
1320
|
break;
|
|
1301
1321
|
case "UnexpectedResponseException":
|
|
1302
|
-
|
|
1322
|
+
message3 = "\u610F\u5916\u7684\u670D\u52A1\u5668\u54CD\u5E94";
|
|
1303
1323
|
break;
|
|
1304
1324
|
// case 'CMapReaderFactory not initialized':
|
|
1305
1325
|
// message = '字体映射文件加载失败,请刷新页面重试'
|
|
1306
1326
|
// break
|
|
1307
1327
|
default:
|
|
1308
|
-
|
|
1328
|
+
message3 = "\u65E0\u6CD5\u52A0\u8F7D\u6587\u6863";
|
|
1309
1329
|
break;
|
|
1310
1330
|
}
|
|
1311
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { className: "height-full", justify: "center", align: "center", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Alert, { message:
|
|
1331
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { className: "height-full", justify: "center", align: "center", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Alert, { message: message3, type: "error", showIcon: true }) });
|
|
1312
1332
|
};
|
|
1313
1333
|
const onPageChange = (e) => {
|
|
1314
1334
|
let newCurrentPage = e.currentPage;
|
|
@@ -5269,7 +5289,7 @@ function propsMerge(control, props) {
|
|
|
5269
5289
|
return null;
|
|
5270
5290
|
}
|
|
5271
5291
|
var UserAvatar_default = ({ size, avatarSrc, userName }) => {
|
|
5272
|
-
return avatarSrc ? /* @__PURE__ */ jsxRuntime.jsx(antd.Avatar, { size, src: avatarSrc }) : /* @__PURE__ */ jsxRuntime.jsx(antd.Avatar, { size, className: "cursor-pointer", style: { backgroundColor:
|
|
5292
|
+
return avatarSrc ? /* @__PURE__ */ jsxRuntime.jsx(antd.Avatar, { size, src: avatarSrc }) : /* @__PURE__ */ jsxRuntime.jsx(antd.Avatar, { size, className: "cursor-pointer", style: { backgroundColor: "var(--ant-color-primary)" }, children: userName?.slice(0, 1)?.toLocaleUpperCase() });
|
|
5273
5293
|
};
|
|
5274
5294
|
|
|
5275
5295
|
exports.AudioPlayer = AudioPlayer_default;
|