From b4ef6600c41dc51e9374981eb658f0c0889bad2b Mon Sep 17 00:00:00 2001 From: Frost-ZX Date: Sun, 1 Sep 2024 01:10:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E5=96=84=E7=BD=91=E5=9D=80?= =?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=A8=A1=E5=9D=97=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/js/nav-links.js | 48 ++++++++++ src/views/NavView/NavView.vue | 159 +++++++++++++++++++++++++++++++++- 2 files changed, 204 insertions(+), 3 deletions(-) create mode 100644 src/assets/js/nav-links.js diff --git a/src/assets/js/nav-links.js b/src/assets/js/nav-links.js new file mode 100644 index 0000000..481d20e --- /dev/null +++ b/src/assets/js/nav-links.js @@ -0,0 +1,48 @@ +/** 处理导航链接列表 */ +export function formatNavLinks() { + + /** @type {NavLinkItem[]} */ + let list0 = JSON.parse(JSON.stringify(window['NAV_LINK_LIST'])); + + /** @type {NavLinkItem[]} */ + let list1 = []; + + let index = 0; + + (function fn(treeData, target) { + for (let i = 0; i < treeData.length; i++) { + + let { + title, children, date, desc, + icon, isInvalid, showOnly, url, + } = treeData[i]; + + /** @type {NavLinkItem} */ + let data = { + title: (typeof title === 'string' ? title : ''), + children: [], + date: (typeof date === 'string' ? date : ''), + desc: (typeof desc === 'string' ? desc : ''), + icon: (typeof icon === 'string' ? icon : ''), + isInvalid: (typeof isInvalid === 'boolean' ? isInvalid : false), + showOnly: (typeof showOnly === 'boolean' ? showOnly : false), + url: (typeof url === 'string' ? url : ''), + _key: `item_${++index}`, + }; + + // 添加项 + target && target.push(data); + + // 递归处理 + if (children) { + fn(children, data.children); + } else { + data.children = null; + } + + } + })(list0, list1); + + return list1; + +} diff --git a/src/views/NavView/NavView.vue b/src/views/NavView/NavView.vue index 3982c8a..f61eba8 100644 --- a/src/views/NavView/NavView.vue +++ b/src/views/NavView/NavView.vue @@ -1,18 +1,171 @@ -