|
@@ -1139,7 +1139,9 @@ export default {
|
|
|
const directoryAttrs = module.attrs
|
|
|
.filter(attr => attr.type === "Directory")
|
|
|
.sort((a, b) => {
|
|
|
+ // 首先按层级排序
|
|
|
if (a.level !== b.level) return a.level - b.level;
|
|
|
+ // 同层级按编号自然排序
|
|
|
return a.number.localeCompare(b.number, undefined, { numeric: true });
|
|
|
});
|
|
|
|
|
@@ -1159,6 +1161,7 @@ export default {
|
|
|
if (attr.level === 1) {
|
|
|
catalogData.push(catalogItem);
|
|
|
} else {
|
|
|
+ // 查找父级目录并添加为子项
|
|
|
const parent = this.findParentDirectory(catalogData, attr.number);
|
|
|
if (parent) {
|
|
|
parent.children.push(catalogItem);
|
|
@@ -1171,13 +1174,13 @@ export default {
|
|
|
this.$nextTick(() => this.$forceUpdate());
|
|
|
},
|
|
|
|
|
|
- // 查找父级目录的辅助方法
|
|
|
+ // 添加 findParentDirectory 辅助方法
|
|
|
findParentDirectory(catalogData, number) {
|
|
|
- const parentNumber = number.split(".").slice(0, -1).join(".");
|
|
|
-
|
|
|
+ const parentNumber = number.split('.').slice(0, -1).join('.');
|
|
|
+
|
|
|
const findInChildren = (items) => {
|
|
|
for (let item of items) {
|
|
|
- if (item.label.startsWith(parentNumber + " ")) {
|
|
|
+ if (item.label.startsWith(parentNumber + ' ')) {
|
|
|
return item;
|
|
|
}
|
|
|
if (item.children) {
|
|
@@ -2428,7 +2431,6 @@ export default {
|
|
|
return (moduleIndex + 1).toString();
|
|
|
}
|
|
|
|
|
|
- // 在当前模块中查找上一级目录的编号
|
|
|
const module = this.coms[moduleIndex];
|
|
|
if (!module || !module.attrs) return '';
|
|
|
|
|
@@ -2468,7 +2470,7 @@ export default {
|
|
|
|
|
|
return {
|
|
|
number,
|
|
|
- content: `第${number}章` // 默认内容,可以根据需要修改
|
|
|
+ content: `第${number}章` // 默认内容
|
|
|
};
|
|
|
},
|
|
|
|