From d1851498866db87d7218d68d1150fe383f5178b5 Mon Sep 17 00:00:00 2001 From: litian <2804272236@qq.com> Date: 星期三, 15 五月 2024 18:54:18 +0800 Subject: [PATCH] 1 --- src/child.ts | 2 src/views/home.vue | 240 +++++++++-------------------------------------- 2 files changed, 50 insertions(+), 192 deletions(-) diff --git a/src/child.ts b/src/child.ts index 6badc7f..b2592b3 100644 --- a/src/child.ts +++ b/src/child.ts @@ -14,7 +14,7 @@ // - 蹇呴�夛紝寰簲鐢ㄧ殑鍚嶇О锛屽井搴旂敤涔嬮棿蹇呴』纭繚鍞竴 name: 'app-content', // - 蹇呴�夛紝寰簲鐢ㄧ殑鍏ュ彛 - entry: '//182.92.203.7:3007/books/book/1/', + entry: '//182.92.203.7:3007/books/book/1/?t=' + Date.parse(new Date()), // entry: '//192.168.3.203:8080', // - 蹇呴�夛紝寰簲鐢ㄧ殑瀹瑰櫒鑺傜偣鐨勯�夋嫨鍣ㄦ垨鑰� Element 瀹炰緥 container: '#container', diff --git a/src/views/home.vue b/src/views/home.vue index 6d0bb4a..c4febfb 100644 --- a/src/views/home.vue +++ b/src/views/home.vue @@ -328,7 +328,7 @@ </div> </div> <!-- 寰簲鐢ㄧ洅瀛� --> - <div class="pageBox-content" @scroll="pageScroll"> + <div class="pageBox-content"> <div class="content-box"> <div id="container" @@ -739,17 +739,17 @@ v-for="item in colorSelectList" :key="item.key" class="flex1 hover" - @click="clickSelect(item)" + @click="clickSelectColor(item)" > <div :style="{ background: item.key }" class="scribeItem"> - <img :src="xuanzhong" v-if="item.key == colorActive" /> + <img :src="xuanzhong" v-if="item.key == noteColorActive" /> </div> </div> </div> <template #footer> <span class="dialog-footer"> <el-button @click="handleClose">鍙� 娑�</el-button> - <el-button type="primary" @click="addNote">纭� 瀹�</el-button> + <el-button type="primary" @click="addUserKey">纭� 瀹�</el-button> </span> </template> </el-dialog> @@ -1724,22 +1724,9 @@ } } -const pageScroll = (e) => { - // window.qiankunActions.setGlobalState({ - // gotoPage: (t, s) => { - // // 缁戝畾瀛愬簲鐢ㄩ�夋嫨鐩戝惉浜嬩欢 - // console.log(t, s, '瀛愬簲鐢ㄦ粴鍔�') - // } - // }) - showToolBox.value = false - lineDelete.showLineDelete = false - // let scroll = e.target.scrollTop - // let offsetHeight = document.getElementById('container').offsetHeight - // headerData.process = Math.round((scroll / offsetHeight) * 100) -} - const toolActive = ref('') const colorActive = ref('') +const noteColorActive = ref('') const dialogToolList = reactive([ { icon: gaoliang, activeIcon: gaoliang1, name: '楂樹寒' }, { icon: huaxian, activeIcon: huaxian1, name: '鍒掔嚎' }, @@ -1906,6 +1893,10 @@ colorActive.value = item.key addUserKey() } +//绗旇閫夐鑹� +const clickSelectColor = (item) => { + noteColorActive.value = item.key +} const addUserKey = () => { let dom = '' @@ -1933,6 +1924,28 @@ color: colorActive.value }) break + case '绗旇': + if (!formData.desc.replace(/^\s*|\s*$/g, '')) { + ElMessage.error('绗旇鍐呭涓嶈兘涓虹┖!') + return + } + if (!noteColorActive.value) { + ElMessage.error('璇烽�夋嫨绗旇棰滆壊!') + return + } + dom = 'notes-' + bookId.value + data = dialogToolData.notesList.length != 0 ? dialogToolData.notesList[dialogToolData.chapter] : [] + data.push({ + id: toolClass.uuid(8), + txt: dialogToolData.txt, + page: dialogToolData.page, + type: 'Note', + color: noteColorActive.value, + createDate: new Date(), + note: formData.desc.replace(/^\s*|\s*$/g, '') + }) + + break } request({ url: '/identity/api/ApiAppUserSetKey', @@ -1949,6 +1962,7 @@ }).then((res) => { showToolBox.value = false colorActive.value = '' + noteColorActive.value = '' toolActive.value = '' getSignData() }) @@ -1980,7 +1994,6 @@ } }).then((res) => {}) } -const lock = ref(false) const getSignData = () => { request({ @@ -2029,180 +2042,25 @@ } } }) -} - -const addNote = () => { - const obj = { - desc: formData.desc - } - if (!colorActive.value) { - ElMessage.error('璇烽�夋嫨绗旇棰滆壊!') - return - } - if (!lock.value) { - lock.value = true - if (formData.desc.replace(/^\s*|\s*$/g, '')) { - dialogToolData.notesList.push({ - selectNode: selectNode.value, - selectText: selectText.value, - color: colorActive.value, - selectPage: selectPage.value, - chapter: dialogToolData.chapter, - createDate: new Date(), - note: formData.desc.replace(/^\s*|\s*$/g, '') - }) - request({ - url: '/identity/api/ApiAppUserSetKey', - method: 'post', - data: { - setKeyRequests: [ - { - domain: 'notes', - key: bookId.value, - value: JSON.stringify(dialogToolData.notesList) - } - ] - } - }).then((res) => { - showToolBox.value = false - addNoteVisble.value = false - colorActive.value = '' - toolActive.value = '' - getNotesList() - setTimeout(() => { - lock.value = false - }, 1000) - }) - } else { - ElMessage.error('绗旇鍐呭涓嶈兘涓虹┖!') - lock.value = false - } - } -} -//绗旇 -const getNotesList = () => { - scribeData.noteList = [] - scribeData.loading = true request({ url: '/identity/api/ApiGetAppUserKey', method: 'post', data: { - domain: 'notes', - keys: [bookId.value] - } - }) - .then((res) => { - if (res && res.length > 0 && res[0].value) { - dialogToolData.notesList = JSON.parse(res[0].value) - let list = JSON.parse(res[0].value) - let textDom1 = document.querySelector('.temp-book') - if (list.length > 0) { - list.forEach((item, index) => { - item.createDate = moment(item.createDate).format('YYYY-MM-DD') - if (searchText.value) { - searchText.value = searchText.value.replace(/^\s*|\s*$/g, '') - let text = searchText.value.replace(/^\s*|\s*$/g, '') - if (item.text.indexOf(text) > -1) { - if (menuState.notesColor == 'all') { - scribeData.noteList.push(item) - } else if (menuState.notesColor == item.color) { - scribeData.noteList.push(item) - } - } - } else { - if (menuState.notesColor == 'all') { - scribeData.noteList.push(item) - } else if (menuState.notesColor == item.color) { - scribeData.noteList.push(item) - } - } - //椤甸潰娣诲姞绗旇 - let rReg1 = new RegExp(`${item.selectText}`, 'ig') - let text1 = textDom1.innerHTML - let nHtmlText1 = item.selectNode - - let nHtml1 = '' - nHtml1 = nHtmlText1.replace( - rReg1, - `<span style="padding-bottom:2px; border-bottom: 2px solid;border-bottom-color:${item.color}" class="notesline">${item.selectText}</span><img src="${biji1}" style="cursor: pointer" onclick="notesVisbleShow('${item.selectText}')"/>` - ) - let rHtml1 = '' - rHtml1 = text1.replace(nHtmlText1, nHtml1) - textDom1.innerHTML = rHtml1 - }) - } - } - scribeData.loading = false - }) - .catch((err) => { - scribeData.loading = false - }) -} -//鍒掔嚎 -const getScribeList = () => { - scribeData.scribeDataList = [] - request({ - url: '/identity/api/ApiGetAppUserKey', - method: 'post', - data: { - domain: 'underline', - keys: [bookId.value] + domain: 'note-' + bookId.value, + keys: activeCatalog.value.map((item) => item + '') } }).then((res) => { - if (res && res.length > 0 && res[0].value) { - dialogToolData.scribeList = JSON.parse(res[0].value) - scribeData.scribeDataList = JSON.parse(res[0].value) - let textDom1 = document.querySelector('.temp-book') - if (scribeData.scribeDataList.length > 0) { - for (let i = 0; i < scribeData.scribeDataList.length; i++) { - let item = scribeData.scribeDataList[i] - let rReg1 = new RegExp(`${item.selectText}`, 'ig') - let text1 = textDom1.innerHTML - let nHtmlText1 = item.selectNode - - let nHtml1 = '' - nHtml1 = nHtmlText1.replace( - rReg1, - `<span style="text-decoration:underline;text-decoration-style: wavy;text-underline-thickness:2px;text-decoration-color:${item.color};cursor: pointer" class="underline" onclick="deleteScribeShow('${item.selectText}')">${item.selectText}</span>` - ) - let rHtml1 = '' - rHtml1 = text1.replace(nHtmlText1, nHtml1) - textDom1.innerHTML = rHtml1 - } - } - } - }) -} -//楂樹寒 -const getlineHeightList = () => { - scribeData.lineHeightList = [] - request({ - url: '/identity/api/ApiGetAppUserKey', - method: 'post', - data: { - domain: 'highLight', - keys: [bookId.value] - } - }).then((res) => { - if (res && res.length > 0 && res[0].value) { - dialogToolData.lineHeight = JSON.parse(res[0].value) - scribeData.lineHeightList = JSON.parse(res[0].value) - let textDom = document.querySelector('.temp-book') - if (scribeData.lineHeightList.length > 0) { - for (let i = 0; i < scribeData.lineHeightList.length; i++) { - let item = scribeData.lineHeightList[i] - let rReg = new RegExp(`${item.selectText}`, 'ig') - let text = textDom.innerHTML - let nHtmlText = item.selectNode - let nHtml = '' - nHtml = nHtmlText.replace( - rReg, - `<span style="background: ${item.color};padding:3px;cursor: pointer" class="highLight" onclick="deletelineHeightShow('${item.selectText}')">${item.selectText}</span>` - ) - // nHtmlText = nHtml - let rHtml = '' - rHtml = text.replace(nHtmlText, nHtml) - textDom.innerHTML = rHtml + if (res && res.length > 0) { + for (let i = 0; i < res.length; i++) { + const item = res[i] + const data = JSON.parse(item.value) + // 鍌ㄥ�� + dialogToolData.notesList[item.key] = data + // 娓叉煋 + for (let j = 0; j < data.length; j++) { + const citem = data[j] + if (window.qiankunState && window.qiankunState.renderSign) + window.qiankunState.renderSign(citem.type, citem) } } } @@ -2315,10 +2173,10 @@ dialogToolData.notesList.findIndex((itemData) => itemData.selectText == item.selectText), 1 ) - selectNode.value = item.selectNode - selectText.value = item.selectText - selectPage.value = item.selectPage - colorActive.value = item.color + dialogToolData.txt = item.txt + dialogToolData.page = item.page + dialogToolData.chapter = item.chapterNum + noteColorActive.value = item.color dialogToolData.chapter = item.chapter formData.desc = item.note addNoteVisble.value = true -- Gitblit v1.9.1