@oinone/kunlun-vue-admin-base 7.2.2 → 7.2.3

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.
@@ -204,6 +204,9 @@ declare const __default__: import("vue").DefineComponent<import("vue").ExtractPr
204
204
  footerMethod: {
205
205
  type: FunctionConstructor;
206
206
  };
207
+ contentMethod: {
208
+ type: FunctionConstructor;
209
+ };
207
210
  spanMethod: {
208
211
  type: FunctionConstructor;
209
212
  };
@@ -534,6 +537,9 @@ declare const __default__: import("vue").DefineComponent<import("vue").ExtractPr
534
537
  footerMethod: {
535
538
  type: FunctionConstructor;
536
539
  };
540
+ contentMethod: {
541
+ type: FunctionConstructor;
542
+ };
537
543
  spanMethod: {
538
544
  type: FunctionConstructor;
539
545
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oinone/kunlun-vue-admin-base",
3
- "version": "7.2.2",
3
+ "version": "7.2.3",
4
4
  "type": "module",
5
5
  "main": "dist/oinone-kunlun-vue-admin-base.esm.js",
6
6
  "scripts": {
@@ -17,13 +17,13 @@
17
17
  "doc": "typedoc --out docs src/index.ts"
18
18
  },
19
19
  "dependencies": {
20
- "@oinone/kunlun-vue-admin-layout": "7.2.2",
21
- "@oinone/kunlun-vue-router": "7.2.2",
22
- "@oinone/kunlun-vue-ui": "7.2.2",
23
- "@oinone/kunlun-vue-ui-antd": "7.2.2",
24
- "@oinone/kunlun-vue-ui-common": "7.2.2",
25
- "@oinone/kunlun-vue-ui-el": "7.2.2",
26
- "@oinone/kunlun-vue-widget": "7.2.2",
20
+ "@oinone/kunlun-vue-admin-layout": "7.2.3",
21
+ "@oinone/kunlun-vue-router": "7.2.3",
22
+ "@oinone/kunlun-vue-ui": "7.2.3",
23
+ "@oinone/kunlun-vue-ui-antd": "7.2.3",
24
+ "@oinone/kunlun-vue-ui-common": "7.2.3",
25
+ "@oinone/kunlun-vue-ui-el": "7.2.3",
26
+ "@oinone/kunlun-vue-widget": "7.2.3",
27
27
  "@wangeditor/editor": "5.1.23",
28
28
  "@wangeditor/editor-for-vue": "5.1.11",
29
29
  "@wangeditor/plugin-upload-attachment": "1.1.0",
@@ -50,9 +50,9 @@
50
50
  </template>
51
51
 
52
52
  <script lang="ts">
53
- import { ref, computed, watch, defineComponent, PropType } from 'vue';
54
- import { isString } from 'lodash-es';
55
53
  import { OioIcon, OioSelect } from '@oinone/kunlun-vue-ui-antd';
54
+ import { isString } from 'lodash-es';
55
+ import { computed, defineComponent, PropType, ref, watch } from 'vue';
56
56
 
57
57
  interface JsonLine {
58
58
  indent: number;
@@ -98,6 +98,19 @@ export default defineComponent({
98
98
  */
99
99
  const URL_REGEX = /\b(https?:\/\/|ftp:\/\/|sftp:\/\/)([^\s<>"]+)(\.[a-zA-Z0-9]{2,10})([^\s<>"]*)?\b/g;
100
100
 
101
+ const escapeHtml = (value: string): string => {
102
+ return value
103
+ .replace(/&/g, '&amp;')
104
+ .replace(/</g, '&lt;')
105
+ .replace(/>/g, '&gt;')
106
+ .replace(/"/g, '&quot;')
107
+ .replace(/'/g, '&#039;');
108
+ };
109
+
110
+ const stringifyJsonText = (value: unknown): string => {
111
+ return escapeHtml(JSON.stringify(value) ?? String(value));
112
+ };
113
+
101
114
  /**
102
115
  * 将JSON对象解析为带语法高亮和链接的HTML行数据
103
116
  * @param obj 要解析的JSON对象
@@ -113,13 +126,25 @@ export default defineComponent({
113
126
  * @returns 处理后的HTML字符串
114
127
  */
115
128
  const replaceUrlWithLink = (str: string): string => {
116
- // 先通过JSON.stringify转义,再替换URL
117
- const escapedStr = JSON.stringify(str).slice(1, -1); // 去掉首尾的引号
118
- return escapedStr.replace(URL_REGEX, (match) => {
119
- // 对匹配到的URL进行转义,防止XSS
120
- const encodedUrl = encodeURI(match);
121
- return `<a href="${encodedUrl}" target="_blank" class="text-blue-500 underline hover:text-blue-700">${match}</a>`;
122
- });
129
+ // 先通过JSON.stringify处理JSON转义,再对要注入v-html的文本做HTML转义。
130
+ const stringifiedStr = JSON.stringify(str).slice(1, -1);
131
+ let result = '';
132
+ let lastIndex = 0;
133
+ let matchResult: RegExpExecArray | null;
134
+
135
+ URL_REGEX.lastIndex = 0;
136
+ matchResult = URL_REGEX.exec(stringifiedStr);
137
+ while (matchResult) {
138
+ const url = matchResult[0];
139
+ result += escapeHtml(stringifiedStr.slice(lastIndex, matchResult.index));
140
+ result += `<a href="${escapeHtml(encodeURI(url))}" target="_blank" class="text-blue-500 underline hover:text-blue-700">${escapeHtml(
141
+ url
142
+ )}</a>`;
143
+ lastIndex = matchResult.index + url.length;
144
+ matchResult = URL_REGEX.exec(stringifiedStr);
145
+ }
146
+
147
+ return result + escapeHtml(stringifiedStr.slice(lastIndex));
123
148
  };
124
149
 
125
150
  if (Array.isArray(obj)) {
@@ -143,7 +168,7 @@ export default defineComponent({
143
168
  itemHtml = `<span class="text-green-600">"${replaceUrlWithLink(item)}"</span>`;
144
169
  } else {
145
170
  // 非字符串类型:直接JSON.stringify
146
- itemHtml = `<span class="text-green-600">${JSON.stringify(item)}</span>`;
171
+ itemHtml = `<span class="text-green-600">${stringifyJsonText(item)}</span>`;
147
172
  }
148
173
  // 添加逗号
149
174
  itemHtml += isLast ? '' : '<span class="text-gray-600">,</span>';
@@ -186,11 +211,13 @@ export default defineComponent({
186
211
  // 处理嵌套对象/数组
187
212
  lines.push({
188
213
  indent: indent + 1,
189
- html: `<span class="text-blue-600">"${key}"</span><span class="text-gray-600">: </span>`,
214
+ html: `<span class="text-blue-600">${stringifyJsonText(key)}</span><span class="text-gray-600">: </span>`,
190
215
  collapsible: false
191
216
  });
192
217
  const childLines = parseJSON(value, indent + 1);
193
- childLines[0].html = `<span class="text-blue-600">"${key}"</span><span class="text-gray-600">: </span>${childLines[0].html}`;
218
+ childLines[0].html = `<span class="text-blue-600">${stringifyJsonText(
219
+ key
220
+ )}</span><span class="text-gray-600">: </span>${childLines[0].html}`;
194
221
  childLines[childLines.length - 1].html += isLast ? '' : '<span class="text-gray-600">,</span>';
195
222
  lines.pop();
196
223
  lines.push(...childLines);
@@ -204,13 +231,15 @@ export default defineComponent({
204
231
  valueHtml = `"${replaceUrlWithLink(value)}"`;
205
232
  } else {
206
233
  // 非字符串类型:直接序列化
207
- valueHtml = JSON.stringify(value);
234
+ valueHtml = stringifyJsonText(value);
208
235
  }
209
236
 
210
237
  // 拼接最终HTML
211
238
  lines.push({
212
239
  indent: indent + 1,
213
- html: `<span class="text-blue-600">"${key}"</span><span class="text-gray-600">: </span><span class="${valueColor}">${valueHtml}</span>${
240
+ html: `<span class="text-blue-600">${stringifyJsonText(
241
+ key
242
+ )}</span><span class="text-gray-600">: </span><span class="${valueColor}">${valueHtml}</span>${
214
243
  isLast ? '' : '<span class="text-gray-600">,</span>'
215
244
  }`,
216
245
  collapsible: false
@@ -258,12 +287,7 @@ export default defineComponent({
258
287
  const regx = /<[^/]*?>/g;
259
288
  const closeAble = regx.test(line);
260
289
 
261
- const lineHtml = line
262
- .replace(/&/g, '&amp;')
263
- .replace(/</g, '&lt;')
264
- .replace(/>/g, '&gt;')
265
- .replace(/"/g, '&quot;')
266
- .replace(/'/g, '&#039;');
290
+ const lineHtml = escapeHtml(line);
267
291
 
268
292
  lines.push({
269
293
  indent,
@@ -282,7 +306,7 @@ export default defineComponent({
282
306
  const lines: JsonLine[] = [];
283
307
  lines.push({
284
308
  indent: 1,
285
- html: `<span class="text-gray-600">${str}</span>`,
309
+ html: `<span class="text-gray-600">${escapeHtml(str)}</span>`,
286
310
  collapsible: false
287
311
  });
288
312
  return lines;
@@ -327,6 +327,9 @@ export default defineComponent({
327
327
  footerMethod: {
328
328
  type: Function
329
329
  },
330
+ contentMethod: {
331
+ type: Function
332
+ },
330
333
  spanMethod: {
331
334
  type: Function
332
335
  },
@@ -900,6 +903,7 @@ export default defineComponent({
900
903
 
901
904
  showFooter,
902
905
  footerMethod,
906
+ contentMethod,
903
907
  spanMethod,
904
908
  mergeCells,
905
909
 
@@ -1090,7 +1094,7 @@ export default defineComponent({
1090
1094
  data: showDataSource,
1091
1095
  scrollX,
1092
1096
  scrollY,
1093
- tooltipConfig: { enterable: true },
1097
+ tooltipConfig: { enterable: true, contentMethod },
1094
1098
  height: 'auto',
1095
1099
  rowConfig: { isCurrent, isHover },
1096
1100
  sortConfig,