|
@@ -67,6 +67,17 @@ function getQueryParams() {
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 根据文档路径获取展示名称(仅保留最后一段)
|
|
|
|
|
+function getDocDisplayName(docName) {
|
|
|
|
|
+ if (!docName || typeof docName !== 'string') {
|
|
|
|
|
+ return '';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const segments = docName.split(/[\\\/]/);
|
|
|
|
|
+ const name = segments.pop();
|
|
|
|
|
+ return name || docName;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 加载文档列表
|
|
// 加载文档列表
|
|
|
async function loadDocList() {
|
|
async function loadDocList() {
|
|
|
const { category } = getQueryParams();
|
|
const { category } = getQueryParams();
|
|
@@ -86,7 +97,10 @@ async function loadDocList() {
|
|
|
if (!response.ok) throw new Error('获取文档列表失败');
|
|
if (!response.ok) throw new Error('获取文档列表失败');
|
|
|
|
|
|
|
|
const categoryData = await response.json();
|
|
const categoryData = await response.json();
|
|
|
- docList = categoryData.docs;
|
|
|
|
|
|
|
+ docList = categoryData.docs.map(doc => ({
|
|
|
|
|
+ ...doc,
|
|
|
|
|
+ displayName: getDocDisplayName(doc.name)
|
|
|
|
|
+ }));
|
|
|
|
|
|
|
|
renderDocNav(docList);
|
|
renderDocNav(docList);
|
|
|
|
|
|
|
@@ -119,7 +133,8 @@ function renderDocNav(docs) {
|
|
|
const link = document.createElement('a');
|
|
const link = document.createElement('a');
|
|
|
link.href = '#';
|
|
link.href = '#';
|
|
|
link.className = 'nav-link';
|
|
link.className = 'nav-link';
|
|
|
- link.textContent = doc.name;
|
|
|
|
|
|
|
+ link.textContent = doc.displayName || getDocDisplayName(doc.name);
|
|
|
|
|
+ link.title = doc.name;
|
|
|
|
|
|
|
|
item.appendChild(link);
|
|
item.appendChild(link);
|
|
|
nav.appendChild(item);
|
|
nav.appendChild(item);
|
|
@@ -400,7 +415,8 @@ function updateDocNavigation() {
|
|
|
const setupNavButton = (button, doc) => {
|
|
const setupNavButton = (button, doc) => {
|
|
|
if (doc) {
|
|
if (doc) {
|
|
|
button.style.display = 'flex';
|
|
button.style.display = 'flex';
|
|
|
- button.querySelector('.nav-doc-name').textContent = doc.name;
|
|
|
|
|
|
|
+ const displayName = doc.displayName || getDocDisplayName(doc.name);
|
|
|
|
|
+ button.querySelector('.nav-doc-name').textContent = displayName;
|
|
|
button.onclick = () => {
|
|
button.onclick = () => {
|
|
|
loadDocument(doc.name);
|
|
loadDocument(doc.name);
|
|
|
updateURL(currentCategory, doc.name);
|
|
updateURL(currentCategory, doc.name);
|