1
YM
2024-05-15 e4bbe681c35e9f8f2d2ef6a3e40f3645239987ac
src/views/home.vue
@@ -92,9 +92,14 @@
      <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 +118,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="暂无数据" />
@@ -144,7 +151,7 @@
            </div>
          </div>
          <div class="list-box">
            <div v-if="scribeData.noteList.length > 0 && !scribeData.loading">
            <div v-if="scribeData.noteList.length > 0">
              <div v-for="(item, index) in scribeData.noteList" :key="item.key" class="listItem">
                <div class="textBox">
                  <div class="title">
@@ -153,8 +160,8 @@
                      <span>{{ item.createDate }}</span>
                    </div>
                    <div>
                      <img :src="bianji" @click="update(item, 'note')" />
                      <img :src="shanchu" @click="deleteBtn(item, 'note')" />
                      <img :src="bianji" @click="update(item)" />
                      <img :src="shanchu" @click="deleteBtn(item)" />
                    </div>
                  </div>
                  <div
@@ -179,11 +186,11 @@
                      {{ item.note }}
                    </div>
                  </div>
                  <div class="chapter">{{ item.selectText }}</div>
                  <div class="chapter">{{ item.txt }}</div>
                </div>
              </div>
            </div>
            <div v-if="scribeData.noteList.length == 0 && !scribeData.loading">
            <div v-if="scribeData.noteList.length == 0">
              <el-empty :image-size="60" description="暂无数据" />
            </div>
          </div>
@@ -708,7 +715,7 @@
    v-show="lineDelete.showLineDelete"
    :style="{ top: `${lineDelete.top}px`, left: `${lineDelete.left}px` }"
  >
    <el-button @click="lineDeleteBtn">删除</el-button>
    <el-button @click="delUserKey">删除</el-button>
  </div>
  <el-dialog title="资源" align-center v-model="resourVisble" width="845" class="resourDialog">
@@ -779,7 +786,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>
@@ -983,7 +992,11 @@
    windowSelection: (data) => {
      // 绑定子应用选择监听事件
      console.log(data, '子应用选择')
      getSelection(data)
      if (data.txt) {
        getSelection(data)
      } else {
        showToolBox.value = false
      }
    },
    catalogChange: (data) => {
      activeCatalog.value = data.showCatalogList
@@ -1000,7 +1013,6 @@
      console.log(data, '页面切换:目前显示页面和对应的章节信息')
    }
  })
  // 调用子层方法
  // if (window.qiankunState && window.qiankunState.aa) window.qiankunState.aa(1)
})
@@ -1028,11 +1040,12 @@
const catalogueData = ref([])
const getCatalogueData = () => {
  axios
    .get(ctxUrl + '/catalog.json')
    .get(resourceUrl + '/1/information.json?t=123')
    .then(function (response) {
      console.log(response.data)
      var json = response.data
      // 处理获取到的json数据
      catalogueData.value = json
      catalogueData.value = json.data
    })
    .catch(function (error) {
      console.log(error)
@@ -1042,8 +1055,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)
}
//获取资源
@@ -1084,7 +1104,7 @@
const testWord = ref('') //word链接
const getResourceData = () => {
  axios
    .get(ctxUrl + '/resource.json')
    .get(resourceUrl + '/1/resource.json')
    .then(function (response) {
      var json = response.data
      // 处理获取到的json数据
@@ -1188,7 +1208,7 @@
    case '0':
      break
    case '1':
      getNotesList()
      // getSignData()
      break
    case '2':
      break
@@ -1278,11 +1298,16 @@
  } else {
    menuState.notesColor = 'all'
  }
  getNotesList()
  // getNotesList()
}
const catalogTree = ref()
const searchBook = async () => {
  if (activeMenu.value == 0) {
    if (catalogTree) catalogTree.value.filter(searchText.value)
  }
  if (activeMenu.value == 1) {
    getNotesList()
    // getNotesList()
    getSignData()
  }
  if (activeMenu.value == 2) {
    let dataList = JSON.parse(JSON.stringify(resourceDataList.value))
@@ -1591,10 +1616,7 @@
const labelShow = (str) => {}
//标签
const reMark =() => {
}
const reMark = () => {}
//截图
//截图事件
function jitT() {
@@ -1636,16 +1658,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('截图名称不能为空!')
  }
@@ -1905,6 +1929,7 @@
    case '高亮':
      dom = 'highLightData-' + bookId.value
      data = dialogToolData.lineHeight[dialogToolData.chapter]
      if (!data) data = []
      data.push({
        id: toolClass.uuid(8),
        txt: dialogToolData.txt,
@@ -1916,6 +1941,7 @@
    case '划线':
      dom = 'underline-' + bookId.value
      data = dialogToolData.scribeList[dialogToolData.chapter]
      if (!data) data = []
      data.push({
        id: toolClass.uuid(8),
        txt: dialogToolData.txt,
@@ -1927,14 +1953,16 @@
    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] : []
      if (!data) data = []
      data.push({
        id: toolClass.uuid(8),
        txt: dialogToolData.txt,
@@ -1944,7 +1972,7 @@
        createDate: new Date(),
        note: formData.desc.replace(/^\s*|\s*$/g, '')
      })
      break
  }
  request({
@@ -1961,38 +1989,12 @@
    }
  }).then((res) => {
    showToolBox.value = false
    addNoteVisble.value = false
    colorActive.value = ''
    noteColorActive.value = ''
    toolActive.value = ''
    getSignData()
  })
}
const delUserKey = (type, ids) => {
  switch (type) {
    case 'Highlight':
      dom = 'highLightData-' + bookId.value
      data = dialogToolData.lineHeight
      break
    case 'Dashing':
      dom = 'underline-' + bookId.value
      data = dialogToolData.scribeList
      break
  }
  data = data.filter((item) => ids.indexOf(item.id) == -1)
  request({
    url: '/identity/api/ApiAppUserSetKey',
    method: 'post',
    data: {
      setKeyRequests: [
        {
          domain: dom,
          key: '',
          value: JSON.stringify(data)
        }
      ]
    }
  }).then((res) => {})
}
const getSignData = () => {
@@ -2046,7 +2048,7 @@
    url: '/identity/api/ApiGetAppUserKey',
    method: 'post',
    data: {
      domain: 'note-' + bookId.value,
      domain: 'notes-' + bookId.value,
      keys: activeCatalog.value.map((item) => item + '')
    }
  }).then((res) => {
@@ -2055,7 +2057,9 @@
        const item = res[i]
        const data = JSON.parse(item.value)
        // 储值
        scribeData.noteList = data
        dialogToolData.notesList[item.key] = data
        console.log(dialogToolData.notesList, 'notesList')
        // 渲染
        for (let j = 0; j < data.length; j++) {
          const citem = data[j]
@@ -2073,12 +2077,29 @@
  top: 0,
  left: 0,
  deleteType: '',
  deleteTxt: ''
  id: ''
})
// 划线、笔记、高亮点击回调
window.signClick = (type, id) => {
  console.log('signClick点击事件回调的实例', type, id)
  // if (window.qiankunState && window.qiankunState.delSign) window.qiankunState.delSign({ids:[id]})
  if (type == 'Note') {
    let data = dialogToolData.notesList.filter((item) => id.indexOf(item.id) == -1)
    console.log(data)
    formData.desc = notes.note
    noteColorActive.value = notes.color
    addNoteVisble.value = true
  } else {
    lineDelete.showLineDelete = true
    lineDelete.deleteType = type
    lineDelete.id = id
  }
}
window.notesVisbleShow = function (txt) {
  addNoteVisble.value = true
  let notes = dialogToolData.notesList.find((item) => item.selectText == txt)
  let notes = dialogToolData.notesList.find((item) => item.id == id)
  formData.desc = notes.note
  colorActive.value = notes.color
  selectNode.value = notes.selectNode
@@ -2086,23 +2107,42 @@
  selectPage.value = notes.selectPage
  dialogToolData.chapter = notes.chapter
}
window.deleteScribeShow = function (txt) {
  let lines = scribeData.scribeDataList.find((item) => item.selectText == txt)
  lineDelete.deleteType = 'underline'
  lineDelete.deleteTxt = txt
  lineDelete.top = event.screenY
  lineDelete.left = event.screenX
  lineDelete.showLineDelete = true
}
window.deletelineHeightShow = function (txt) {
  let lines = scribeData.lineHeightList.find((item) => item.selectText == txt)
  lineDelete.deleteType = 'highLight'
  lineDelete.deleteTxt = txt
  lineDelete.top = event.screenY
  lineDelete.left = event.screenX
  lineDelete.showLineDelete = true
const delUserKey = () => {
  let type = lineDelete.deleteType
  let ids = lineDelete.id
  let dom = ''
  let data = null
  switch (type) {
    case 'Highlight':
      dom = 'highLightData-' + bookId.value
      data = dialogToolData.lineHeight
      break
    case 'Dashing':
      dom = 'underline-' + bookId.value
      data = dialogToolData.scribeList
      break
  }
  data = data.filter((item) => ids.indexOf(item.id) == -1)
  console.log(data[0])
  let list = data[0].filter((item) => item.id != ids)
  console.log(list)
  request({
    url: '/identity/api/ApiAppUserSetKey',
    method: 'post',
    data: {
      setKeyRequests: [
        {
          domain: dom,
          key: dialogToolData.chapter,
          value: JSON.stringify(list)
        }
      ]
    }
  }).then((res) => {
    if (window.qiankunState && window.qiankunState.delSign)
      window.qiankunState.delSign({ ids: [ids] })
    getSignData()
  })
}
const lineDeleteBtn = () => {
@@ -2183,10 +2223,10 @@
}
//删除
const deleteBtn = (item, type) => {
const deleteBtn = (item) => {
  if (type == 'note') {
    // 移除
    let list = scribeData.noteList.filter((itemData) => itemData.selectText !== item.selectText)
    let list = dialogToolData.noteList.filter((itemData) => itemData.id !== item.id)
    request({
      url: '/identity/api/ApiAppUserSetKey',
      method: 'post',
@@ -2204,20 +2244,12 @@
        message: '删除笔记成功!',
        type: 'success'
      })
      console.log(document.querySelectorAll('.notesline'))
      let list = document.querySelectorAll('.notesline')
      list.forEach((itemNode) => {
        if (itemNode.innerText == item.selectText) {
          console.log(itemNode.nextSibling)
          itemNode.removeAttribute('style')
          itemNode.nextSibling?.remove()
        }
      })
      if (window.qiankunState && window.qiankunState.delSign)
        window.qiankunState.delSign({ ids: [id] })
      getNotesList()
    })
  }
}
//内容区域顶部显示