From 8dbe0a9a507d193e55abfa16cf64caffbeb7a108 Mon Sep 17 00:00:00 2001
From: 10396 <1039655633@qq.com>
Date: Fri, 26 Sep 2025 08:55:45 +0800
Subject: [PATCH] =?UTF-8?q?```=20feat(utils):=20=E6=96=B0=E5=A2=9E?=
=?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E6=95=B0=E6=8D=AE=E4=B8=BA=E5=B8=A6?=
=?UTF-8?q?=E7=BC=A9=E8=BF=9B=E7=9A=84HTML=E5=AD=97=E7=AC=A6=E4=B8=B2?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
新增 `formatDataWithDivBr` 工具函数,支持将数组、对象等嵌套结构格式化为带缩进和换行的 HTML 字符串,便于在页面中展示结构化数据。refactor(reqMap): 移除冗余的作业票编号配置项清理 `reqMap.js` 中不再使用的 `workNumber` 相关字段及选项,保持配置文件简洁。
```
---
src/assets/js/utils.js | 33 +
src/views/api/index.vue | 30630 ++++++++++++++++++---
src/views/data_directory/basic/reqMap.js | 2 -
3 files changed, 26987 insertions(+), 3678 deletions(-)
diff --git a/src/assets/js/utils.js b/src/assets/js/utils.js
index 9ea3c33..925b9b0 100644
--- a/src/assets/js/utils.js
+++ b/src/assets/js/utils.js
@@ -445,3 +445,36 @@ export function getFileUrl() {
export function getBaseUrl() {
return import.meta.env[import.meta.env.DEV ? "VITE_PROXY" : "VITE_BASE_URL"];
}
+
+export function formatDataWithDivBr(data, indentLevel = 0) {
+ const indent = " ".repeat(indentLevel * 2); // 缩进空格数
+ let html = "";
+
+ if (Array.isArray(data)) {
+ html += `[
`;
+ data.forEach((item, index) => {
+ html += `${indent} ${formatDataWithDivBr(
+ item,
+ indentLevel + 1
+ )}`;
+ if (index < data.length - 1) html += ",
"; // 数组元素间换行
+ });
+ html += `
${indent}]`;
+ return html;
+ }
+
+ if (typeof data === "object" && data !== null) {
+ html += `{
`;
+ const keys = Object.keys(data);
+ keys.forEach((key, index) => {
+ const value = formatDataWithDivBr(data[key], indentLevel + 1);
+ html += `${indent} ${key}: ${value}`;
+ if (index < keys.length - 1) html += ",
"; // 键值对间换行
+ });
+ html += `
${indent}}`;
+ return html;
+ }
+
+ // 基础类型处理(字符串加引号,其他直接转字符串)
+ return typeof data === "string" ? `"${data}"` : String(data);
+}
diff --git a/src/views/api/index.vue b/src/views/api/index.vue
index 231a184..fc134c3 100644
--- a/src/views/api/index.vue
+++ b/src/views/api/index.vue
@@ -51,103 +51,108 @@
{{ item.title }}
-