明树Git Lab

Commit 107054d7 authored by zhanghan's avatar zhanghan

项目档案库问题处理\

parent 89cfb09f
Pipeline #109491 passed with stage
in 21 seconds
...@@ -9,30 +9,32 @@ export default { ...@@ -9,30 +9,32 @@ export default {
// 使用 nextTick 确保 DOM 完全渲染 // 使用 nextTick 确保 DOM 完全渲染
setTimeout(() => { setTimeout(() => {
// 获取所有 el-collapse-item 元素 // 获取所有 el-collapse-item 元素
const collapseItems = el.querySelectorAll('.el-collapse-item'); const collapseItems = el.querySelectorAll(".el-collapse-item");
const navItems = []; const navItems = [];
collapseItems.forEach((item, index) => { collapseItems.forEach((item, index) => {
// 获取标题 // 获取标题
const titleEl = item.querySelector('.el-collapse-item__header'); const titleEl = item.querySelector(".el-collapse-item__header");
const title = titleEl ? titleEl.textContent.trim() : `项目${index + 1}`; const title = titleEl
? titleEl.textContent.trim()
: `项目${index + 1}`;
// 尝试从多个来源获取 name // 尝试从多个来源获取 name
let name = ''; let name = "";
// 1. 优先从已有的 id 属性获取 // 1. 优先从已有的 id 属性获取
const existingId = item.getAttribute('id'); const existingId = item.getAttribute("id");
if (existingId && existingId.startsWith('collapse-')) { if (existingId && existingId.startsWith("collapse-")) {
name = existingId.replace('collapse-', ''); name = existingId.replace("collapse-", "");
} else { } else {
// 2. 尝试从 data-name 属性获取(Element Plus 可能会将 name 存储在这里) // 2. 尝试从 data-name 属性获取(Element Plus 可能会将 name 存储在这里)
const dataName = item.getAttribute('data-name'); const dataName = item.getAttribute("data-name");
if (dataName) { if (dataName) {
name = dataName; name = dataName;
} else { } else {
// 3. 尝试从 name 属性获取 // 3. 尝试从 name 属性获取
const nameAttr = item.getAttribute('name'); const nameAttr = item.getAttribute("name");
if (nameAttr) { if (nameAttr) {
name = nameAttr; name = nameAttr;
} else { } else {
...@@ -42,33 +44,35 @@ export default { ...@@ -42,33 +44,35 @@ export default {
} }
// 设置 id // 设置 id
item.setAttribute('id', `collapse-${name}`); item.setAttribute("id", `collapse-${name}`);
} }
console.log('Navigation item:', { console.log("Navigation item:", {
name, name,
title, title,
id: item.getAttribute('id'), id: item.getAttribute("id"),
allAttrs: Array.from(item.attributes).map(attr => `${attr.name}="${attr.value}"`) allAttrs: Array.from(item.attributes).map(
(attr) => `${attr.name}="${attr.value}"`,
),
}); });
navItems.push({ navItems.push({
name, name,
label: title, label: title,
index index,
}); });
}); });
console.log('All navigation items:', navItems); console.log("All navigation items:", navItems);
// 更新绑定值 // 更新绑定值
if (binding.value) { if (binding.value) {
if (typeof binding.value === 'function') { if (typeof binding.value === "function") {
binding.value(navItems); binding.value(navItems);
} else if (Array.isArray(binding.value)) { } else if (Array.isArray(binding.value)) {
// 先清空数组,再添加新元素 // 先清空数组,再添加新元素
binding.value.length = 0; binding.value.length = 0;
navItems.forEach(navItem => { navItems.forEach((navItem) => {
binding.value.push(navItem); binding.value.push(navItem);
}); });
} }
...@@ -82,8 +86,9 @@ export default { ...@@ -82,8 +86,9 @@ export default {
// 使用 MutationObserver 监听 DOM 变化(处理动态内容) // 使用 MutationObserver 监听 DOM 变化(处理动态内容)
const observer = new MutationObserver((mutations) => { const observer = new MutationObserver((mutations) => {
// 只在节点变化时更新,避免无限循环 // 只在节点变化时更新,避免无限循环
const hasRelevantMutation = mutations.some(mutation => const hasRelevantMutation = mutations.some(
mutation.type === 'childList' && mutation.addedNodes.length > 0 (mutation) =>
mutation.type === "childList" && mutation.addedNodes.length > 0,
); );
if (hasRelevantMutation) { if (hasRelevantMutation) {
updateNavItems(); updateNavItems();
...@@ -92,7 +97,7 @@ export default { ...@@ -92,7 +97,7 @@ export default {
observer.observe(el, { observer.observe(el, {
childList: true, childList: true,
subtree: false subtree: false,
}); });
// 保存 observer 到元素上,方便后续清理 // 保存 observer 到元素上,方便后续清理
...@@ -105,7 +110,7 @@ export default { ...@@ -105,7 +110,7 @@ export default {
el._collapseNavObserver.disconnect(); el._collapseNavObserver.disconnect();
delete el._collapseNavObserver; delete el._collapseNavObserver;
} }
} },
}; };
/** /**
......
...@@ -267,6 +267,15 @@ const handleSubItemClick = async (item) => { ...@@ -267,6 +267,15 @@ const handleSubItemClick = async (item) => {
::v-deep .add-project-back { ::v-deep .add-project-back {
display: none; display: none;
} }
::v-deep .navigation-wrapper {
display: none;
}
::v-deep .tab-content {
padding-top: 16px;
}
::v-deep .el-tabs__header {
padding: 8px 0 0 16px;
}
} }
.main-tab-wrapper { .main-tab-wrapper {
...@@ -459,7 +468,7 @@ const handleSubItemClick = async (item) => { ...@@ -459,7 +468,7 @@ const handleSubItemClick = async (item) => {
.detail-content { .detail-content {
flex: 1; flex: 1;
overflow-y: auto; overflow-y: auto;
padding: 20px; // padding: 20px;
min-height: 500px; min-height: 500px;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment