From c4a189b86db7328d537a7218d5c5a8cb0c95a320 Mon Sep 17 00:00:00 2001 From: YM <479443481@qq.com> Date: 星期三, 15 五月 2024 21:24:52 +0800 Subject: [PATCH] 目录与搜索 --- src/views/home.vue | 62 +++++++++++++++++++------------ 1 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/views/home.vue b/src/views/home.vue index 2e5faef..00fc423 100644 --- a/src/views/home.vue +++ b/src/views/home.vue @@ -92,9 +92,9 @@ <div class="menuContent" v-if="menuState.open"> <div class="searchBox"> <div class="inputBox" v-if="activeMenu !== 2"> - <el-input class="custom-input" placeholder="璇疯緭鍏ュ唴瀹�" v-model="searchText"> + <el-input class="custom-input" placeholder="璇疯緭鍏ュ唴瀹�" v-model="searchText" @keyup.enter="searchBook"> <template #prefix> - <el-icon @click="searchBook"><Search /></el-icon> + <el-icon><Search /></el-icon> </template> </el-input> </div> @@ -113,12 +113,14 @@ <!-- 鐩綍 --> <div class="menuList" v-if="activeMenu == 0"> <el-tree + ref="catalogTree" style="max-width: 600px" default-expand-all="true" :data="catalogueData" :props="defaultProps" v-if="catalogueData.length > 0" @node-click="handleNodeClick" + :filter-node-method="filterNode" /> <div v-if="catalogueData.length == 0"> <el-empty :image-size="60" description="鏆傛棤鏁版嵁" /> @@ -779,7 +781,9 @@ <template #footer> <span class="dialog-footer"> <el-button @click="screenshotClose">鍙� 娑�</el-button> - <el-button type="primary" @click="addScreenshot" :loading="screenshotLoading">纭� 瀹�</el-button> + <el-button type="primary" @click="addScreenshot" :loading="screenshotLoading" + >纭� 瀹�</el-button + > </span> </template> </el-dialog> @@ -1030,7 +1034,7 @@ axios .get(resourceUrl + '/1/information.json?t=123') .then(function (response) { - console.log(response.data); + console.log(response.data) var json = response.data // 澶勭悊鑾峰彇鍒扮殑json鏁版嵁 catalogueData.value = json.data @@ -1043,8 +1047,15 @@ children: 'children', label: 'label' } +const filterNode = (value, data) => { + if (!value) return true + return data.label.indexOf(value) !== -1 +} + const handleNodeClick = (data) => { - document.getElementById(data.id).scrollIntoView() + console.log(data) + if (window.qiankunState && window.qiankunState.gotoPage) + window.qiankunState.gotoPage(data.chapter, data.start) } //鑾峰彇璧勬簮 @@ -1281,7 +1292,11 @@ } getNotesList() } +const catalogTree = ref() const searchBook = async () => { + if (activeMenu.value == 0) { + if (catalogTree) catalogTree.value.filter(searchText.value) + } if (activeMenu.value == 1) { getNotesList() } @@ -1592,10 +1607,7 @@ const labelShow = (str) => {} //鏍囩 -const reMark =() => { - - -} +const reMark = () => {} //鎴浘 //鎴浘浜嬩欢 function jitT() { @@ -1637,16 +1649,18 @@ } ] } - }).then((res) => { - screenshotLoading.value = false - getScreenshotList() - nameData.value = '' - urlData.value = '' - floatingToolData.activeToolData = '' - screenshotVisble.value = false - }).catch(function (error) { - screenshotLoading.value = false }) + .then((res) => { + screenshotLoading.value = false + getScreenshotList() + nameData.value = '' + urlData.value = '' + floatingToolData.activeToolData = '' + screenshotVisble.value = false + }) + .catch(function (error) { + screenshotLoading.value = false + }) } else { ElMessage.error('鎴浘鍚嶇О涓嶈兘涓虹┖!') } @@ -1928,14 +1942,15 @@ case '绗旇': if (!formData.desc.replace(/^\s*|\s*$/g, '')) { ElMessage.error('绗旇鍐呭涓嶈兘涓虹┖!') - return + return } if (!noteColorActive.value) { ElMessage.error('璇烽�夋嫨绗旇棰滆壊!') return } dom = 'notes-' + bookId.value - data = dialogToolData.notesList.length != 0 ? dialogToolData.notesList[dialogToolData.chapter] : [] + data = + dialogToolData.notesList.length != 0 ? dialogToolData.notesList[dialogToolData.chapter] : [] data.push({ id: toolClass.uuid(8), txt: dialogToolData.txt, @@ -1945,7 +1960,7 @@ createDate: new Date(), note: formData.desc.replace(/^\s*|\s*$/g, '') }) - + break } request({ @@ -2078,8 +2093,8 @@ }) // 鍒掔嚎銆佺瑪璁般�侀珮浜偣鍑诲洖璋� -window.signClick = (type, id)=>{ - console.log("signClick鐐瑰嚮浜嬩欢鍥炶皟鐨勫疄渚�", type, id); +window.signClick = (type, id) => { + console.log('signClick鐐瑰嚮浜嬩欢鍥炶皟鐨勫疄渚�', type, id) } window.notesVisbleShow = function (txt) { @@ -2223,7 +2238,6 @@ }) } } - //鍐呭鍖哄煙椤堕儴鏄剧ず -- Gitblit v1.9.1