@oinone/kunlun-vue-admin-base 6.4.10 → 6.4.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oinone/kunlun-vue-admin-base",
3
- "version": "6.4.10",
3
+ "version": "6.4.12",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "prebuild": "rimraf dist",
@@ -14,13 +14,13 @@
14
14
  "doc": "typedoc --out docs src/index.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@oinone/kunlun-vue-admin-layout": "6.4.10",
18
- "@oinone/kunlun-vue-router": "6.4.10",
19
- "@oinone/kunlun-vue-ui": "6.4.10",
20
- "@oinone/kunlun-vue-ui-antd": "6.4.10",
21
- "@oinone/kunlun-vue-ui-common": "6.4.10",
22
- "@oinone/kunlun-vue-ui-el": "6.4.10",
23
- "@oinone/kunlun-vue-widget": "6.4.10",
17
+ "@oinone/kunlun-vue-admin-layout": "6.4.12",
18
+ "@oinone/kunlun-vue-router": "6.4.12",
19
+ "@oinone/kunlun-vue-ui": "6.4.12",
20
+ "@oinone/kunlun-vue-ui-antd": "6.4.12",
21
+ "@oinone/kunlun-vue-ui-common": "6.4.12",
22
+ "@oinone/kunlun-vue-ui-el": "6.4.12",
23
+ "@oinone/kunlun-vue-widget": "6.4.12",
24
24
  "@wangeditor/editor": "5.1.23",
25
25
  "@wangeditor/editor-for-vue": "5.1.11",
26
26
  "@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;
@@ -1,4 +1,4 @@
1
- import { BASIC_CONFIG_KEY, OINONE_HOMEPAGE_KEY, translateValueByKey } from '@oinone/kunlun-engine';
1
+ import { ClearCache, OINONE_HOMEPAGE_KEY, translateValueByKey } from '@oinone/kunlun-engine';
2
2
  import { SYSTEM_MODULE_NAME } from '@oinone/kunlun-meta';
3
3
  import {
4
4
  gql,
@@ -396,7 +396,7 @@ export class LoginWidget extends BaseLoginWidget {
396
396
  } else {
397
397
  const parameters = (await homepageMaybeRuntimeContext(undefined, true)) as any;
398
398
  localStorage.setItem(OINONE_HOMEPAGE_KEY, JSON.stringify(parameters));
399
-
399
+ ClearCache.clear();
400
400
  this.router.push({
401
401
  segments: [
402
402
  {