YM
2024-05-15 c4a189b86db7328d537a7218d5c5a8cb0c95a320
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,18 @@
        <!-- 目录 -->
        <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="暂无数据" />
          </div>
        </div>
        <!-- 笔记 -->
        <div class="notesBox" v-if="activeMenu == 1">
@@ -154,8 +160,8 @@
                    </div>
                  </div>
                  <div
                    class="noteText hover"
                    @click="jumpContent('note' + index)"
                    class="noteText hover 123456"
                    @click="jumpContent(item)"
                    :style="{
                      background:
                        item.color == '#F5E12A'
@@ -171,7 +177,9 @@
                                  : item.color
                    }"
                  >
                    <div class="con">{{ item.note }}</div>
                    <div class="con hover">
                      {{ item.note }}
                    </div>
                  </div>
                  <div class="chapter">{{ item.selectText }}</div>
                </div>
@@ -221,10 +229,27 @@
                <el-col :span="12" v-for="(item, index) in resourceDataList" :key="item">
                  <div class="resourceItem hover" @click="goResourceDetail(item)">
                    <div class="resourceImg">
                      <img :src="video" mode="" />
                      <img :src="item.icon" mode="" v-if="item.icon" />
                      <el-icon v-else-if="activeClassify == 'image'" size="30"><Picture /></el-icon>
                      <el-icon v-else-if="activeClassify == 'audio'" size="30"><Headset /></el-icon>
                      <el-icon v-else-if="activeClassify == 'video'" size="30"
                        ><VideoCamera
                      /></el-icon>
                      <el-icon
                        v-else-if="activeClassify == 'other' && item.fileType == 'PDF'"
                        size="30"
                        ><Files
                      /></el-icon>
                      <el-icon
                        v-else-if="activeClassify == 'other' && item.fileType == ''"
                        size="30"
                        ><Tickets
                      /></el-icon>
                    </div>
                    <div class="rName" v-if="searchText != ''" v-html="item.name"></div>
                    <div class="rName" v-else>{{ item.name }}</div>
                    <div class="rName" v-else :title="item.resourceName">
                      {{ item.resourceName }}
                    </div>
                  </div>
                </el-col>
              </el-row>
@@ -246,16 +271,19 @@
        <div class="" v-if="activeMenu == 4">
          <div class="list-box">
            <div class="screenshot" v-if="screenshotList.length > 0">
              <div
                v-for="(item, index) in screenshotList"
                :key="item"
                class="captureItem"
                @click="getCapture(item)"
              >
              <div v-for="(item, index) in screenshotList" :key="item" class="captureItem">
                <div class="imgBox">
                  <img :src="item.imgUrl" class="capture" mode="aspectFill" />
                  <img
                    :src="item.imgUrl"
                    class="capture"
                    mode="aspectFill"
                    @click="getCapture(item)"
                  />
                  <div class="deleteBox hover" @click="deleteScreenshot(item, 'capture')">
                    <img :src="shanchu" />
                  </div>
                </div>
                <div class="captureName">{{ item.name }}</div>
                <div class="captureName" :title="item.name">{{ item.name }}</div>
              </div>
            </div>
            <div v-else>
@@ -285,7 +313,7 @@
            <div class="">已上课:{{ headerData.classTime }}</div>
          </div>
          <div class="progress">
            <div class="bookName">学前儿童卫生与保健(第三版)</div>
            <div class="bookName">{{ bookName }}</div>
            <div>{{ headerData.process }}%</div>
          </div>
          <div class="rightBox">
@@ -295,18 +323,20 @@
              <div><img :src="zoomOut" @click="changePageSize('reduce')" /></div>
            </div>
            <div class="brushImgBox">
              <div><img :src="huabi2" class="brushImg" />画笔</div>
              <div @click="jumpContent('note' + index)">
                <img :src="huabi2" class="brushImg" />画笔
              </div>
            </div>
          </div>
        </div>
        <!-- 微应用盒子 -->
        <div class="pageBox-content" @scroll="pageScroll">
        <div class="pageBox-content">
          <div class="content-box">
            <div
              id="container"
              @mousedown="handleMouseDown"
              @mousemove="handleMousemove"
              @mouseup="handleMouseUp"
              :style="{ background: settingForm.bgColorActive }"
            ></div>
            <!-- 画笔画布 -->
            <div class="canvas-box" v-show="canvasShow">
@@ -407,14 +437,34 @@
              </div>
            </div>
            <template #reference>
              <div :class="floatingToolData.activeToolData == item.name ? 'floatToolActive floatToolItem' : 'floatToolItem'">
                <img :src="floatingToolData.activeToolData == item.name ? item.activeIcon : item.icon" alt="" />
              <div
                :class="
                  floatingToolData.activeToolData == item.name
                    ? 'floatToolActive floatToolItem'
                    : 'floatToolItem'
                "
              >
                <img
                  :src="floatingToolData.activeToolData == item.name ? item.activeIcon : item.icon"
                  alt=""
                />
                <div class="text">{{ item.name }}</div>
              </div>
            </template>
          </el-popover>
          <div :class="floatingToolData.activeToolData == item.name ? 'floatToolActive floatToolItem' : 'floatToolItem'" v-else @click="floatItemHandle(item)">
            <img :src="floatingToolData.activeToolData == item.name ? item.activeIcon : item.icon" alt="" />
          <div
            :class="
              floatingToolData.activeToolData == item.name
                ? 'floatToolActive floatToolItem'
                : 'floatToolItem'
            "
            v-else
            @click="floatItemHandle(item)"
          >
            <img
              :src="floatingToolData.activeToolData == item.name ? item.activeIcon : item.icon"
              alt=""
            />
            <div class="text">{{ item.name }}</div>
          </div>
        </div>
@@ -423,7 +473,7 @@
        <div class="toolList">
          <el-popover placement="top" width="250" trigger="click">
            <div class="popinnerBox">
              <div class="brush" >
              <div class="brush">
                <div class="thickness">
                  <div
                    :class="toolSelectData.thicknessActive == '1' ? 'small active' : 'small'"
@@ -533,7 +583,7 @@
            <template #reference>
              <div class="floatToolItem" @click="toolSelectHandle('wenzi')">
                <div class="imgBox">
                <img :src="wenzi2" alt="" />
                  <img :src="wenzi2" alt="" />
                </div>
                <div class="text">文字</div>
              </div>
@@ -579,7 +629,7 @@
              </div>
            </div>
            <template #reference>
              <div class="floatToolItem"  @click="toolSelectHandle('tuxing')">
              <div class="floatToolItem" @click="toolSelectHandle('tuxing')">
                <div class="imgBox">
                  <img :src="tuxing" alt="" />
                </div>
@@ -587,7 +637,7 @@
              </div>
            </template>
          </el-popover>
          <div class="floatToolItem"  @click="toolSelectHandle('xiangpi')">
          <div class="floatToolItem" @click="toolSelectHandle('xiangpi')">
            <div class="imgBox">
              <img :src="clearPrevious" alt="" />
            </div>
@@ -654,9 +704,18 @@
      </div>
    </div>
  </div>
  <!-- 划线,高亮删除 -->
  <div
    class="lineDeleteBox"
    v-show="lineDelete.showLineDelete"
    :style="{ top: `${lineDelete.top}px`, left: `${lineDelete.left}px` }"
  >
    <el-button @click="lineDeleteBtn">删除</el-button>
  </div>
  <el-dialog title="资源" align-center v-model="resourVisble" width="845" class="resourDialog">
    <div class="videoBox" v-if="resourType == 'video'">
      <video controls object-fit="fill" :src="testVideo"></video>
    <div class="videoBox" v-if="resourType == '视频'">
      <video controls controlslist="nodownload" :src="testVideo"></video>
    </div>
    <div class="wordBox" v-if="resourType == 'word'">
      <vue-office-docx :src="testWord" />
@@ -682,17 +741,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>
@@ -714,7 +773,7 @@
    v-model="screenshotVisble"
    :before-close="screenshotClose"
    width="400"
    class="resourDialog"
    class="resourDialog screenshotDialog"
  >
    <div class="formBox">
      <el-input v-model="nameData" placeholder="请输入截图名称"></el-input>
@@ -722,7 +781,9 @@
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="screenshotClose">取 消</el-button>
        <el-button type="primary" @click="addScreenshot">确 定</el-button>
        <el-button type="primary" @click="addScreenshot" :loading="screenshotLoading"
          >确 定</el-button
        >
      </span>
    </template>
  </el-dialog>
@@ -766,12 +827,13 @@
</template>
<script setup lang="ts">
import { ref, reactive, watch, onMounted, inject } from 'vue'
import { ctxUrl } from '@/assets/js/config'
import { ref, reactive, watch, onMounted, onBeforeMount, inject } from 'vue'
import { ctxUrl, resourceUrl, requestCtx } from '@/assets/js/config'
import { useRouter, useRoute } from 'vue-router'
import useClipboard from 'vue-clipboard3'
const { toClipboard } = useClipboard()
const request = inject('request')
const toolClass = inject('toolClass')
const qiankunActions = inject('qiankunActions')
//获取路由器
let router = useRouter()
@@ -779,7 +841,7 @@
let route = useRoute()
import moment from 'moment'
import dictionary from '@/views/components/dictionary.vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ElMessage, ElMessageBox, valueEquals } from 'element-plus'
import logo from '@/assets/images/header/logo.png'
import mulu from '@/assets/images/menu/mulu.png'
import biji from '@/assets/images/menu/biji.png'
@@ -871,25 +933,26 @@
import { start } from 'qiankun'
import axios from 'axios'
import { fabric } from 'fabric'
import { loadMicroApp } from 'qiankun'
import { microApps } from '@/child.ts'
const canvasWith = ref(1000)
const canvasheight = ref(3000)
const screenWidth = ref(
  window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
)
let microApp = null // 微应用实例
const bookName = ref('')
const bookId = ref(1)
const activeCatalog = ref()
onMounted(() => {
  console.log(1111)
  // canvasWith.value = window.innerWidth - 540
  // canvasheight.value = window.innerHeight - 110
  getNotesList() // 获取高亮
  getlineHeightList() //获取高亮
  getScribeList() //获取划线
  getCatalogueData()
  getResourceData()
  getScreenshotList()
  // setTimeout(() => {
  //   canvasWith.value = document.getElementById('container').offsetWidth
  //   canvasheight.value = document.getElementById('container').offsetHeight
  // }, 5000)
  setTimeout(() => {
    canvasWith.value = document.querySelector('.content-box').offsetWidth
    canvasheight.value = document.querySelector('.content-box').offsetHeight
  }, 5000)
  if (screenWidth.value < 1180) {
    menuState.open = false
    toolState.open = false
@@ -901,13 +964,49 @@
    })()
  }
  console.log(qiankunActions, 'qiankunActions')
  // 加载微应用
  microApp = loadMicroApp(microApps.book1, {
    sandbox: {
      strictStyleIsolation: true
      // experimentalStyleIsolation: true
    },
    singular: true
  })
  qiankunActions.setGlobalState({
    cc: (data) => {
      console.log(data)
  window.qiankunActions.onGlobalStateChange((state, prev) => {
    console.log('父层state变化', state)
    bookName.value = state.bookName
    bookId.value = state.bookId
    window.qiankunState = state
  })
  // 定义父层方法
  console.log(window.qiankunActions)
  window.qiankunActions.setGlobalState({
    state: 1, // 加载子应用
    windowSelection: (data) => {
      // 绑定子应用选择监听事件
      console.log(data, '子应用选择')
      getSelection(data)
    },
    catalogChange: (data) => {
      activeCatalog.value = data.showCatalogList
      getSignData()
      console.log(data, '章节切换:目前显示的三个章节')
    },
    pageChange: (data) => {
      // {
      //   page: 100,
      //   catalog: 5,
      //   catalogId: "",
      //   catalogName: "",
      // }
      console.log(data, '页面切换:目前显示页面和对应的章节信息')
    }
  })
  // 调用子层方法
  // if (window.qiankunState && window.qiankunState.aa) window.qiankunState.aa(1)
})
watch(
@@ -920,15 +1019,25 @@
    }
  }
)
watch(
  () => bookId.value,
  (val) => {
    // getNotesList() // 获取笔记
    // getlineHeightList() //获取高亮
    // getScribeList() //获取划线
    // getScreenshotList() //截图
  }
)
//获取目录
const catalogueData = ref([])
const getCatalogueData = () => {
  axios
    .get(ctxUrl + '/books/test/information.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)
@@ -938,9 +1047,15 @@
  children: 'children',
  label: 'label'
}
const filterNode = (value, data) => {
  if (!value) return true
  return data.label.indexOf(value) !== -1
}
const handleNodeClick = (data) => {
  console.log(data.id, 12)
  document.getElementById(data.id).scrollIntoView()
  console.log(data)
  if (window.qiankunState && window.qiankunState.gotoPage)
    window.qiankunState.gotoPage(data.chapter, data.start)
}
//获取资源
@@ -971,23 +1086,38 @@
const searchShow = ref(true)
const resourceData = ref({})
const resourceDataList = ref([])
const resourceImgList = ref([])
const resourceVideoList = ref([])
const resourceAudioList = ref([])
const resourceDocList = ref([])
const resourVisble = ref(false)
const resourType = ref('')
const testVideo = ref('') //视频链接
const testWord = ref('') //word链接
const getResourceData = () => {
  axios
    .get(ctxUrl + '/books/test/resource.json')
    .get(resourceUrl + '/1/resource.json')
    .then(function (response) {
      var json = response.data
      // 处理获取到的json数据
      console.log(json, '资源')
      resourceData.value = json
      resourceDataList.value = json.imgList
      classifySelectList[0].count = json.imgList.length
      classifySelectList[1].count = json.audioList.length
      classifySelectList[2].count = json.videoList.length
      classifySelectList[3].count = json.attachmentList.length
      if (json.length > 0) {
        json.forEach((item) => {
          if (item.fileType == '图片') {
            resourceImgList.value.push(item)
          } else if (item.fileType == '视频') {
            resourceVideoList.value.push(item)
          } else if (item.fileType == '音频') {
            resourceAudioList.value.push(item)
          } else {
            resourceDocList.value.push(item)
          }
        })
      }
      resourceDataList.value = resourceImgList.value
      classifySelectList[0].count = resourceImgList.value.length
      classifySelectList[1].count = resourceAudioList.value.length
      classifySelectList[2].count = resourceVideoList.value.length
      classifySelectList[3].count = resourceDocList.value.length
    })
    .catch(function (error) {
      console.log(error)
@@ -995,12 +1125,13 @@
}
const goResourceDetail = (data) => {
  resourVisble.value = true
  resourType.value = data.type
  if (data.type == 'video') {
    testVideo.value = ctxUrl + '/books/test/resourceData/' + data.name
  } else if (data.type == 'word') {
    testWord.value = ctxUrl + '/books/test/resourceData/' + data.name
  resourType.value = data.fileType
  if (data.fileType == '视频') {
    resourVisble.value = true
    testVideo.value = requestCtx + '/file/api/ApiDownload?md5=' + data.md5
  } else if (data.fileType == 'PDF') {
    window.open(requestCtx + '/file/api/ApiDownload?md5=' + data.md5)
    // testWord.value = resourceUrl + '/resourceData/' + data.name
  }
}
@@ -1010,19 +1141,18 @@
  searchText.value = ''
  switch (item.key) {
    case 'image':
      resourceDataList.value = resourceData.value.imgList
      resourceDataList.value = resourceImgList.value
      break
    case 'audio':
      resourceDataList.value = resourceData.value.audioList
      resourceDataList.value = resourceAudioList.value
      break
    case 'video':
      resourceDataList.value = resourceData.value.videoList
      resourceDataList.value = resourceVideoList.value
      break
    case 'other':
      resourceDataList.value = resourceData.value.attachmentList
      resourceDataList.value = resourceDocList.value
      break
  }
  console.log(resourceDataList.value)
}
const searchBtn = () => {
  if (searchShow.value) {
@@ -1061,7 +1191,6 @@
// 选中菜单
const activeMenu = ref(0)
//资源类型
const resourceType = ref('default')
// 菜单点击
const menuItemClick = (index) => {
@@ -1086,6 +1215,17 @@
//刷新当前页面
const reload = () => {
  location.reload()
  // if (microApp) {
  //   microApp.unmount() // 卸载微应用
  //   microApp = loadMicroApp(microApps.book1, {
  //     sandbox: {
  //       strictStyleIsolation: true,
  //       experimentalStyleIsolation: true
  //     }
  //   })
  // } else {
  //   location.reload()
  // }
}
const selectResourceType = (type) => {
@@ -1110,7 +1250,7 @@
    {
      lable: '大',
      key: '20'
      key: '18'
    }
  ],
  fontSizeActive: '16',
@@ -1138,6 +1278,7 @@
})
const fontSizeSelect = (item) => {
  settingForm.fontSizeActive = item.key
  document.getElementById('app').style.fontSize = item.key + 'px'
}
const bgColorSelect = (item) => {
  settingForm.bgColorActive = item.key
@@ -1151,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()
  }
@@ -1304,7 +1449,7 @@
    name: '截屏'
  }
])
const canvas = ref(null)
let canvas = null
const floatingToolData = reactive({
  activeToolData: '', //选中工具
  elLeft: 400,
@@ -1367,8 +1512,10 @@
const confirmDialog = ref<Boolean>(false)
const screenshotVisble = ref<Boolean>(false)
const nameData = ref('') //截图名称
const screenshotLoading = ref(false)
const urlData = ref('') //截图base64
const screenshotList = ref([])
const screenshotData = ref([])
//浮窗工具栏点击事件
const floatItemHandle = (item) => {
@@ -1376,6 +1523,12 @@
  switch (item.name) {
    case '画笔':
      canvasShow.value = true
      toolSelectData.activeTool = 'huabi'
      break
    case '标注':
      break
    case '标签':
      reMark()
      break
    case '截屏':
      jitT()
@@ -1391,13 +1544,12 @@
  }
}
const dragstart = (e) => {
  console.log(e)
  floatingToolData.startclientx = e.clientX
  floatingToolData.startclienty = e.clientY
}
//画笔操作栏事件
const toolSelectData = reactive({
  activeTool:'',
  activeTool: '',
  fontSizeActive: '16',
  thicknessActive: '3', //画笔选中粗细
  lineTypeActive: 'solid', //画笔选中线类型
@@ -1407,9 +1559,16 @@
  toolSelectData.activeTool = title
  switch (title) {
    case 'huabi':
    init()
      init()
      break
    case 'wenzi':
      break
    case 'tuichu':
      canvasShow.value = false
      floatingToolData.activeToolData = ''
      break
    case 'qingchu':
      canvas.clear()
      break
  }
}
@@ -1417,7 +1576,7 @@
//选中画笔粗细
const selectThickness = (str) => {
  toolSelectData.thicknessActive = str
  init()
  canvas.freeDrawingBrush.color = toolSelectData.thicknessActive
}
const selectLineType = (str) => {
@@ -1427,26 +1586,28 @@
//画笔颜色选择
const lineColorSelect = (item) => {
  toolSelectData.lineColorActive = item.key
  init()
  canvas.freeDrawingBrush.color = item.key
}
//画布属性
const isDrawing = ref(true) // 是否开启绘图,true 开启;false 关闭
const init = () => {
  canvas.value = new fabric.Canvas('canvasRef', {
    isDrawingMode: true // 启用绘画模式
  canvas = new fabric.Canvas('canvasRef', {
    isDrawingMode: isDrawing.value // 启用绘画模式
  })
  canvas.value.freeDrawingBrush.color = toolSelectData.lineColorActive
  canvas.value.freeDrawingBrush.width = toolSelectData.thicknessActive
  canvas.freeDrawingBrush.color = toolSelectData.lineColorActive
  canvas.freeDrawingBrush.width = toolSelectData.thicknessActive
}
//标签显示隐藏
const labelShow = (str) => {}
//文字大小
const selectfontSize = (str) => {
  toolSelectData.fontSizeActive = str
}
//标注显示隐藏
const labelShow = (str) => {}
//标签
const reMark = () => {}
//截图
//截图事件
function jitT() {
@@ -1465,14 +1626,17 @@
//取消回调
const closeFn = (base64: any) => {
  console.log(base64)
  floatingToolData.activeToolData = ''
}
//保存截图
const addScreenshot = () => {
  if (nameData.value) {
    screenshotList.value.push({
    screenshotData.value.push({
      createDate: new Date(),
      imgUrl: urlData.value,
      name: nameData.value
    })
    screenshotLoading.value = true
    request({
      url: '/identity/api/ApiAppUserSetKey',
      method: 'post',
@@ -1480,15 +1644,23 @@
        setKeyRequests: [
          {
            domain: 'screenshot',
            key: '2358',
            value: JSON.stringify(screenshotList.value)
            key: bookId.value,
            value: JSON.stringify(screenshotData.value)
          }
        ]
      }
    }).then((res) => {
      getScreenshotList()
      screenshotVisble.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('截图名称不能为空!')
  }
@@ -1503,74 +1675,73 @@
    method: 'post',
    data: {
      domain: 'screenshot',
      keys: ['2358']
      keys: [bookId.value]
    }
  }).then((res) => {
    if (res && res.length > 0 && res[0].value) {
      screenshotList.value = JSON.parse(res[0].value)
      screenshotData.value = JSON.parse(res[0].value)
    }
  })
}
//查看截图
const getCapture = (item) => {
  imgUrl.value = item.imgUrl
  confirmDialog.value = true
}
//删除截图
const deleteScreenshot = (item) => {
  let list = screenshotList.value.filter((itemData) => itemData.imgUrl !== item.imgUrl)
  request({
    url: '/identity/api/ApiAppUserSetKey',
    method: 'post',
    data: {
      setKeyRequests: [
        {
          domain: 'screenshot',
          key: bookId.value,
          value: JSON.stringify(list)
        }
      ]
    }
  }).then((res) => {
    ElMessage({
      message: '删除截图成功!',
      type: 'success'
    })
    getScreenshotList()
  })
}
//选中文字工具栏
const selectText = ref('') //选中文字
const selectNode = ref(null)
const showToolBox = ref(false)
const dialogToolData = reactive({
  left: 500,
  top: 300,
  txt: '',
  page: '',
  chapter: '', //选中文字所在章节
  parentNode: null,
  lineHeight: [], //高亮
  scribeList: [], //划线
  notesList: [] //笔记
})
///内容选中
const isMouseDown = ref(false)
const move = ref(false)
const handleMouseDown = () => {
  isMouseDown.value = true
  showToolBox.value = false
  colorActive.value = ''
  toolActive.value = ''
}
const handleMousemove = () => {
  if (isMouseDown.value) {
    move.value = true
const getSelection = (data) => {
  if (data.txt) {
    dialogToolData.txt = data.txt
    dialogToolData.page = data.page
    dialogToolData.chapter = data.chapterNum
    dialogToolData.left = data.x
    dialogToolData.top = data.y
    showToolBox.value = true
  }
}
const handleMouseUp = (e) => {
  if (move.value) {
    const txt = window.getSelection()?.toString()
    selectText.value = txt
    const node = window.getSelection()
    let html = node.anchorNode.parentNode.parentNode
    dialogToolData.chapter = html.firstChild.innerHTML
    if (txt) {
      showToolBox.value = true
      dialogToolData.top = e.y
      dialogToolData.left = e.x
    }
    isMouseDown.value = false
  }
  move.value = false
}
const pageScroll = (e) => {
  showToolBox.value = 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: '划线' },
@@ -1735,224 +1906,177 @@
const clickSelect = (item) => {
  colorActive.value = item.key
  if (toolActive.value == '高亮') {
    dialogToolData.lineHeight.push({
      selectNode: selectNode.value,
      selectText: selectText.value,
      color: colorActive.value,
      chapter: dialogToolData.chapter,
      createDate: new Date()
    })
    request({
      url: '/identity/api/ApiAppUserSetKey',
      method: 'post',
      data: {
        setKeyRequests: [
          {
            domain: 'highLight',
            key: '2358',
            value: JSON.stringify(dialogToolData.lineHeight)
          }
        ]
      }
    }).then((res) => {
      showToolBox.value = false
      colorActive.value = ''
      toolActive.value = ''
      getlineHeightList()
    })
  }
  if (toolActive.value == '划线') {
    dialogToolData.scribeList.push({
      selectNode: selectNode.value,
      selectText: selectText.value,
      color: colorActive.value,
      chapter: dialogToolData.chapter,
      createDate: new Date()
    })
    request({
      url: '/identity/api/ApiAppUserSetKey',
      method: 'post',
      data: {
        setKeyRequests: [
          {
            domain: 'underline',
            key: '2358',
            value: JSON.stringify(dialogToolData.scribeList)
          }
        ]
      }
    }).then((res) => {
      colorActive.value = ''
      showToolBox.value = false
      toolActive.value = ''
      getScribeList()
    })
  }
  addUserKey()
}
//笔记选颜色
const clickSelectColor = (item) => {
  noteColorActive.value = item.key
}
const lock = ref(false)
const addNote = () => {
  const obj = {
    desc: formData.desc
  }
  if (!lock.value) {
    lock.value = true
    if (formData.desc.replace(/^\s*|\s*$/g, '')) {
      dialogToolData.notesList.push({
        selectText: selectText.value,
        color: colorActive.value,
        chapter: dialogToolData.chapter,
const addUserKey = () => {
  let dom = ''
  let data = null
  switch (toolActive.value) {
    case '高亮':
      dom = 'highLightData-' + bookId.value
      data = dialogToolData.lineHeight[dialogToolData.chapter]
      data.push({
        id: toolClass.uuid(8),
        txt: dialogToolData.txt,
        page: dialogToolData.page,
        type: 'Highlight',
        color: colorActive.value
      })
      break
    case '划线':
      dom = 'underline-' + bookId.value
      data = dialogToolData.scribeList[dialogToolData.chapter]
      data.push({
        id: toolClass.uuid(8),
        txt: dialogToolData.txt,
        page: dialogToolData.page,
        type: 'Dashing',
        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, '')
      })
      request({
        url: '/identity/api/ApiAppUserSetKey',
        method: 'post',
        data: {
          setKeyRequests: [
            {
              domain: 'notes',
              key: '2358',
              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
    }
      break
  }
}
//笔记
const getNotesList = () => {
  scribeData.noteList = []
  scribeData.loading = true
  request({
    url: '/identity/api/ApiGetAppUserKey',
    url: '/identity/api/ApiAppUserSetKey',
    method: 'post',
    data: {
      domain: 'notes',
      keys: ['2358']
      setKeyRequests: [
        {
          domain: dom,
          key: dialogToolData.chapter,
          value: JSON.stringify(data)
        }
      ]
    }
  }).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.getElementById('container')
      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 containerElement = document.createElement('span')
          containerElement.style.textDecoration = 'underline'
          containerElement.innerText = item.selectText
          let rReg1 = new RegExp(`${item.selectText}`, 'ig')
          let text1 = textDom1.innerHTML
          let rHtml1 = ''
          rHtml1 = text1.replace(
            rReg1,
            `<span style="padding-bottom:2px; border-bottom: 2px solid;border-bottom-color:${item.color}" class="underline">${item.selectText}</span><img src="${biji1}" style="cursor: pointer" onclick="notesVisbleShow('${item.selectText}')"/>`
          )
          textDom1.innerHTML = rHtml1
        })
      }
    }
    scribeData.loading = false
    showToolBox.value = false
    colorActive.value = ''
    noteColorActive.value = ''
    toolActive.value = ''
    getSignData()
  })
}
//划线
const getScribeList = () => {
  scribeData.scribeDataList = []
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 = () => {
  request({
    url: '/identity/api/ApiGetAppUserKey',
    method: 'post',
    data: {
      domain: 'underline',
      keys: ['2358']
      domain: 'highLightData-' + 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.getElementById('container')
      console.log(scribeData.scribeDataList, '划线')
      if (scribeData.scribeDataList.length > 0) {
        for (let i = 0; i < scribeData.scribeDataList.length; i++) {
          let item = scribeData.scribeDataList[i]
          let containerElement = document.createElement('span')
          containerElement.style.textDecoration = 'underline'
          containerElement.innerText = item.selectText
          let rReg1 = new RegExp(`${item.selectText}`, 'ig')
          let text1 = textDom1.innerHTML
          let rHtml1 = ''
          rHtml1 = text1.replace(
            rReg1,
            `<span style="text-decoration:underline;text-decoration-style: wavy;text-underline-thickness:2px;text-decoration-color:${item.color};cursor: pointer">${item.selectText}</span>`
          )
          textDom1.innerHTML = rHtml1
    if (res && res.length > 0) {
      for (let i = 0; i < res.length; i++) {
        const item = res[i]
        const data = JSON.parse(item.value)
        // 储值
        dialogToolData.lineHeight[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)
        }
      }
    }
  })
}
//高亮
const getlineHeightList = () => {
  scribeData.lineHeightList = []
  request({
    url: '/identity/api/ApiGetAppUserKey',
    method: 'post',
    data: {
      domain: 'highLight',
      keys: ['2358']
      domain: 'underline-' + bookId.value,
      keys: activeCatalog.value.map((item) => item + '')
    }
  }).then((res) => {
    if (res && res.length > 0 && res[0].value) {
      dialogToolData.lineHeight = JSON.parse(res[0].value)
      scribeData.lineHeightList = JSON.parse(res[0].value)
      console.log(scribeData.lineHeightList, '高亮')
      let textDom = document.getElementById('container')
      if (scribeData.lineHeightList.length > 0) {
        for (let i = 0; i < scribeData.lineHeightList.length; i++) {
          let item = scribeData.lineHeightList[i]
          let heightLightElement = document.createElement('i')
          heightLightElement.style.backgroundColor = item.color
          heightLightElement.innerText = item.selectText
          let rReg = new RegExp(`${item.selectText}`, 'ig')
          let text = textDom.innerHTML
          let rHtml = ''
          rHtml = text.replace(
            rReg,
            `<span style="background: ${item.color};padding: 2px;cursor: pointer">${item.selectText}</span>`
          )
          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.scribeList[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)
        }
      }
    }
  })
  request({
    url: '/identity/api/ApiGetAppUserKey',
    method: 'post',
    data: {
      domain: 'note-' + bookId.value,
      keys: activeCatalog.value.map((item) => item + '')
    }
  }).then((res) => {
    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)
        }
      }
    }
@@ -1960,62 +2084,120 @@
}
//正文中删除高亮,划线,笔记操作框
const lineDelete = reactive({
  showLineDelete: false,
  top: 0,
  left: 0,
  deleteType: '',
  deleteTxt: ''
})
// 划线、笔记、高亮点击回调
window.signClick = (type, id) => {
  console.log('signClick点击事件回调的实例', type, id)
}
window.notesVisbleShow = function (txt) {
  addNoteVisble.value = true
  let notes = dialogToolData.notesList.find((item) => item.selectText == txt)
  formData.desc = notes.note
  colorActive.value = notes.color
  selectNode.value = notes.selectNode
  selectText.value = notes.selectText
  selectPage.value = notes.selectPage
  dialogToolData.chapter = notes.chapter
}
window.deleteScribeShow = function (txt) {
  console.log(txt, 2)
  let list = scribeData.scribeDataList.filter((item) => item.selectText != txt)
  request({
    url: '/identity/api/ApiAppUserSetKey',
    method: 'post',
    data: {
      setKeyRequests: [
        {
          domain: 'underline',
          key: '2358',
          value: JSON.stringify(list)
        }
      ]
    }
  }).then((res) => {
    getScribeList()
  })
  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) {
  console.log(txt, 1)
  let list = scribeData.lineHeightList.filter((item) => item.selectText != txt)
  request({
    url: '/identity/api/ApiAppUserSetKey',
    method: 'post',
    data: {
      setKeyRequests: [
        {
          domain: 'highLight',
          key: '2358',
          value: JSON.stringify(list)
  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 lineDeleteBtn = () => {
  if (lineDelete.deleteType == 'underline') {
    let list = scribeData.scribeDataList.filter((item) => item.selectText != lineDelete.deleteTxt)
    request({
      url: '/identity/api/ApiAppUserSetKey',
      method: 'post',
      data: {
        setKeyRequests: [
          {
            domain: 'underline',
            key: bookId.value,
            value: JSON.stringify(list)
          }
        ]
      }
    }).then((res) => {
      lineDelete.showLineDelete = false
      let list = document.querySelectorAll('.underline')
      list.forEach((itemNode) => {
        if (itemNode.innerText == lineDelete.deleteTxt) {
          itemNode.removeAttribute('style')
          itemNode.className = ''
          itemNode.removeAttribute('onclick')
        }
      ]
    }
  }).then((res) => {
    getlineHeightList()
  })
      })
      getScribeList()
    })
  } else if (lineDelete.deleteType == 'highLight') {
    let list = scribeData.lineHeightList.filter((item) => item.selectText != lineDelete.deleteTxt)
    request({
      url: '/identity/api/ApiAppUserSetKey',
      method: 'post',
      data: {
        setKeyRequests: [
          {
            domain: 'highLight',
            key: bookId.value,
            value: JSON.stringify(list)
          }
        ]
      }
    }).then((res) => {
      lineDelete.showLineDelete = false
      let list = document.querySelectorAll('.highLight')
      list.forEach((itemNode) => {
        if (itemNode.innerText == lineDelete.deleteTxt) {
          itemNode.removeAttribute('style')
          itemNode.className = ''
          itemNode.removeAttribute('onclick')
        }
      })
      getlineHeightList()
    })
  }
}
const jumpContent = (id) => {
  document.getElementById(id).scrollIntoView()
//笔记跳转
const jumpContent = (item) => {
  console.log(item)
  if (window.qiankunState && window.qiankunState.gotoPage) window.qiankunState.gotoPage(5, 100)
}
//笔记编辑
const update = (item, type) => {
  dialogToolData.notesList.splice(
    dialogToolData.notesList.findIndex((itemData) => itemData.selectText == item.selectText),
    1
  )
  selectText.value = item.selectText
  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
@@ -2033,7 +2215,7 @@
        setKeyRequests: [
          {
            domain: 'notes',
            key: '2358',
            key: bookId.value,
            value: JSON.stringify(list)
          }
        ]
@@ -2042,6 +2224,15 @@
      ElMessage({
        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()
        }
      })
      getNotesList()
    })
@@ -2366,11 +2557,14 @@
            padding: 10px 0;
            align-items: center;
            .resourceImg {
              width: 130px;
              // width: 130px;
              height: 80px;
              background: #fff;
              border-radius: 5px;
              overflow: hidden;
              display: flex;
              align-items: center;
              justify-content: center;
              img {
                height: 100%;
                width: 100%;
@@ -2399,11 +2593,22 @@
          .captureItem {
            margin-bottom: 10px;
            width: 46%;
            position: relative;
            .imgBox {
              border: 1px solid #d8d8d8;
              width: 100%;
              height: 80px;
              margin-bottom: 5px;
            }
            .deleteBox {
              position: absolute;
              top: 2px;
              right: 2px;
              width: 20px;
              height: 20px;
              background: rgba(44, 44, 44, 0.3);
              text-align: center;
              padding: 2px;
            }
            // .capture {
            //   width: 100%;
@@ -2473,9 +2678,7 @@
            margin: 10px 10px 10px 15px;
            border-radius: 3px;
            padding: 2px 5px;
            // opacity: 0.1;
            .con {
              all: initial;
              max-height: 65px;
              display: -webkit-box;
              -webkit-box-orient: vertical;
@@ -2565,14 +2768,17 @@
      }
      .pageBox-content {
        height: calc(100% - 57px);
        overflow-y: auto;
        background: #fbf9f4;
        .content-box {
          height: 100%;
          position: relative;
        }
        #container {
          background: #fbf9f4;
          // height: 100%;
          #container {
            background: #fbf9f4;
            height: 100%;
            #__qiankun_microapp_wrapper_for_app_content__ {
              height: 100%;
            }
          }
        }
        .canvas-box {
          height: 100%;
@@ -2729,45 +2935,44 @@
          margin-right: 5px;
        }
      }
      .floatToolItem:hover ,.floatToolActive{
      .floatToolItem:hover,
      .floatToolActive {
        background-color: #fff;
        color: #0093ff;
      }
    }
    .brushBox{
    .brushBox {
      position: fixed;
      left: 500px;
      bottom:20px;
      bottom: 20px;
      z-index: 99;
      border-radius: 5px;
      background:#fff;
      background: #fff;
      // padding: 10px;
      overflow: hidden;
      border:1px solid #0093FF;
      .toolList{
        display:flex;
      border: 1px solid #0093ff;
      .toolList {
        display: flex;
        justify-content: center;
        align-items: center;
        .floatToolItem {
          margin:10px;
          width:48px;
          margin: 10px;
          width: 48px;
          border-radius: 5px;
          text-align:center;
          flex:1;
          .imgBox{
            height:22px;
            width:22px;
            text-align:center;
            margin:0 auto;
            margin-bottom:5px;
          text-align: center;
          flex: 1;
          .imgBox {
            height: 22px;
            width: 22px;
            text-align: center;
            margin: 0 auto;
            margin-bottom: 5px;
          }
        }
        .layOutTool{
          padding-left:15px;
          border-left:1px solid #E0E0E0
        .layOutTool {
          padding-left: 15px;
          border-left: 1px solid #e0e0e0;
        }
      }
    }
@@ -2775,7 +2980,6 @@
    .dialogToolBox {
      position: fixed;
      z-index: 2;
      .toolSelectBox {
        height: 57px;
        display: flex;
@@ -2836,6 +3040,14 @@
    }
  }
}
.lineDeleteBox {
  position: fixed;
  z-index: 2;
  border: 1px solid #0093ff;
  padding: 20px 8px;
  background: #fff;
  border-radius: 5px;
}
.wendabox {
  width: 100%;
  height: 700px;
@@ -2882,6 +3094,9 @@
.myNoteDialogs {
  width: 500px !important;
}
.screenshotDialog {
  width: 400px !important;
}
.noteColorSelectBox {
  margin-top: 10px;
  width: 190px;