闫增涛
2025-04-14 2cac4a0f4ea0b1cf7bff4759fae8136c72792563
src/views/readerPages/webHome.vue
@@ -440,7 +440,11 @@
                            @click="goPlay(item)"
                            size="20"
                            class="icon hover"
                            v-if="item.resourceType != '视频' && item.resourceType != '音频' && item.resourceType != '图片'"
                            v-if="
                              item.resourceType != '视频' &&
                              item.resourceType != '音频' &&
                              item.resourceType != '图片'
                            "
                          >
                            <View />
                          </el-icon>
@@ -644,6 +648,18 @@
            <!-- 画笔画布 -->
            <div class="canvas-box" v-show="canvasShow">
              <canvas id="canvasRef" :width="canvasWith" :height="canvasheight"></canvas>
            </div>
            <!-- 番茄闹钟组件 -->
            <div
              class="watch-box"
              v-if="pomodoroRef && pomodoroRef.isShow"
              :style="{ top:position.x + 'px', left:position.y + 'px'}"
            >
              <p @mousedown.native="mouseDown">{{ formatTime(pomodoroRef.pageData.currentTime) }}</p>
              <span @click="()=> pomodoroRef.isRuning ? pomodoroRef.pauseFun() : pomodoroRef.startFun()">{{pomodoroRef.isRuning ? '暂停': '开始'}}</span>
              <span @click="pomodoroRef.resetFun" >重置</span>
              <span @click="pomodoroRef.handleRestFun(false)">长休息</span>
              <span @click="pomodoroRef.handleRestFun(true)">短休息</span>
            </div>
          </div>
        </div>
@@ -1153,16 +1169,11 @@
    </div>
    <div class="wordBox" v-if="resourType == 'PDF' || resourType == 'PPT' || resourType == 'WORD'">
          <div
            v-for="(item, index) in showData"
            :key="index"
            class="pdfItem"
            :page="index + 1"
          >
            <img :src="item.showSrc" alt="" style="min-height: 550px" loading="lazy" />
            <el-divider content-position="center"> 第 {{ index + 1 }} 页 </el-divider>
          </div>
        </div>
      <div v-for="(item, index) in showData" :key="index" class="pdfItem" :page="index + 1">
        <img :src="item.showSrc" alt="" style="min-height: 550px" loading="lazy" />
        <el-divider content-position="center"> 第 {{ index + 1 }} 页 </el-divider>
      </div>
    </div>
  </el-dialog>
  <div class="audioBox" v-show="false">
    <!-- <video controls controlslist="nodownload" :src="testVideo"></video> -->
@@ -1276,7 +1287,7 @@
  </el-dialog>
  <el-dialog title="模型工具" align-center v-model="modelTool" width="80%" class="myDialogs">
    <div class="wendabox">
      <iframe src='https://adjam93.github.io/threejs-model-viewer/#' frameborder="0"></iframe>
      <iframe src="https://adjam93.github.io/threejs-model-viewer/#" frameborder="0"></iframe>
    </div>
  </el-dialog>
  <el-dialog title="生词卡片" align-center v-model="shengciVisble" width="800" class="myDialogs">
@@ -1295,12 +1306,7 @@
      <wrongQuestion />
    </div>
  </el-dialog>
  <el-dialog
    title="公式编辑"
    align-center
    v-model="formulaDialog"
    class="myDialogs"
  >
  <el-dialog title="公式编辑" align-center v-model="formulaDialog" class="myDialogs">
    <div class="wendabox">
      <formula />
    </div>
@@ -1318,14 +1324,19 @@
    <!-- <calculatorNew></calculatorNew> -->
    <iframe src="https://www.geogebra.org/scientific" frameborder="0" class="iframe-box"></iframe>
  </el-dialog>
  <!-- 番茄闹钟 -->
  <!-- <pomodoro ref="pomodoroRef" /> -->
</template>
<script setup lang="ts">
import examination from '@/views/examination/index.vue'
import pomodoro from '@/views/components/pomodoro.vue'
import { ref, reactive, watch, onMounted, onBeforeMount, onBeforeUnmount, inject } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { ElMessage, ElMessageBox, valueEquals } from 'element-plus'
import { useFormatData } from '@/hooks/public'
import useClipboard from 'vue-clipboard3'
const { toClipboard } = useClipboard()
const { formatTime } = useFormatData()
const MG: any = inject('MG')
const toolClass = inject('toolClass')
//获取路由器
@@ -1495,7 +1506,6 @@
        window.qiankunState.initTestBook(localStorage.getItem('bookId') + '', tryPageCount.value)
      }
    }
  })
  // 定义父层方法
@@ -1585,7 +1595,6 @@
  // if (window.qiankunState && window.qiankunState.getAnswers){
  //   window.qiankunState.getAnswers(localStorage.getItem(""))
  // }
})
onBeforeUnmount(() => {
@@ -1636,6 +1645,7 @@
  }
  MG.store.getProductList(obj).then((res) => {
    console.log(res.datas, '图书信息')
    if (!res.datas.length) return
    bookInfo.value = res.datas[0]
    if (res.datas[0].purchasedSaleMethodIdList.includes(res.datas[0].defaultSaleMethodId)) {
      isBuy.value = true
@@ -1808,6 +1818,11 @@
      icon: fanqiezhong,
      isShow: bookConfig.value.textbookComponents.indexOf('E4DC9777') > -1
    }
    // {
    //   name: '番茄闹钟',
    //   icon: fanqiezhong,
    //   isShow: true
    // }
  ]
  floatingToolBox = [
    {
@@ -1899,9 +1914,9 @@
      if (localStorage.getItem('chapter') && localStorage.getItem('startPage')) {
        let chapter = Number(localStorage.getItem('chapter'))
        let start = Number(localStorage.getItem('startPage'))
        if (window.qiankunState && window.qiankunState.gotoPage) {
          window.qiankunState.gotoPage(chapter,start)
          window.qiankunState.gotoPage(chapter, start)
          localStorage.removeItem('chapter')
          localStorage.removeItem('startPage')
        }
@@ -1909,7 +1924,6 @@
    })
    .catch(function (error) {
      listLoading.value = false
    })
}
const defaultProps = {
@@ -2063,8 +2077,12 @@
                if (resItem1.resourceType == classifySelectList.value[0].title) {
                  resourceDataList.value.push(resItem1)
                }
                if(activeClassify.value == 'other'){
                  if (resItem1.resourceType != '图片' && resItem1.resourceType != '视频' && resItem1.resourceType != '音频') {
                if (activeClassify.value == 'other') {
                  if (
                    resItem1.resourceType != '图片' &&
                    resItem1.resourceType != '视频' &&
                    resItem1.resourceType != '音频'
                  ) {
                    resourceDataList.value.push(resItem1)
                  }
                }
@@ -2142,8 +2160,12 @@
                if (resItem1.resourceType == classifySelectList.value[0].title) {
                  resourceDataList.value.push(resItem1)
                }
                if(activeClassify.value == 'other'){
                  if (resItem1.resourceType != '图片' && resItem1.resourceType != '视频' && resItem1.resourceType != '音频') {
                if (activeClassify.value == 'other') {
                  if (
                    resItem1.resourceType != '图片' &&
                    resItem1.resourceType != '视频' &&
                    resItem1.resourceType != '音频'
                  ) {
                    resourceDataList.value.push(resItem1)
                  }
                }
@@ -2182,7 +2204,7 @@
const sceneUrl = ref()
const showData = ref()
const goPlay = (data, index) => {
  console.log(data.resourceType,123)
  console.log(data.resourceType, 123)
  resourType.value = data.resourceType
  if (data.resourceType == '视频') {
    if (data.md5) {
@@ -2200,12 +2222,19 @@
    }
    autoPlay()
  } else if (data.resourceType == '模型') {
    console.log(data,222)
    console.log(data, 222)
    let file = bookConfig.value.requestCtx + '/file/api/ApiDownload?md5=' + data.md5
    console.log(file.exd,777)
    console.log(file.exd, 777)
    const ctx = 'https://jsek.bnuic.com'
    if (data.md5) {
      sceneUrl.value = 'https://jsek.bnuic.com/books/book/civilAviation/static/modelView/index.html?md5=' + data.md5 + '&name=je' + '&domain=' + ctx + '&exd=obj' + '&target=iframe'
      sceneUrl.value =
        'https://jsek.bnuic.com/books/book/civilAviation/static/modelView/index.html?md5=' +
        data.md5 +
        '&name=je' +
        '&domain=' +
        ctx +
        '&exd=obj' +
        '&target=iframe'
    } else {
      sceneUrl.value = bookConfig.value.resourceUrl + '/' + data.resourcePath
    }
@@ -2215,38 +2244,37 @@
    // } else if (data.resourcePath) {
    //   window.open(bookConfig.value.resourceUrl + '/' + data.resourcePath)
    // }
  }else if(data.resourceType == 'PPT' || data.resourceType == 'PDF'){
  } else if (data.resourceType == 'PPT' || data.resourceType == 'PDF') {
    let md5 = data.md5
    let dataList = []
      MG.file
        .getPdfInfo({
          md5
        })
        .then((res: any) => {
          console.log()
          if (res && res.totalPages) {
            for (let i = 0; i < res.totalPages; i++) {
              const src =
    MG.file
      .getPdfInfo({
        md5
      })
      .then((res: any) => {
        console.log()
        if (res && res.totalPages) {
          for (let i = 0; i < res.totalPages; i++) {
            const src =
              bookConfig.value.requestCtx +
                '/file/GetPdfPageImage?md5=' +
                md5 +
                '&index=' +
                (i + 1) +
                '&dpi=300'
              dataList.push({
                showSrc: src
              })
            }
            console.log(dataList)
            showData.value = dataList
            // 启动页码观察
            setTimeout(() => {
              resourVisble.value = true
            }, 500)
              '/file/GetPdfPageImage?md5=' +
              md5 +
              '&index=' +
              (i + 1) +
              '&dpi=300'
            dataList.push({
              showSrc: src
            })
          }
        })
  }else {
          console.log(dataList)
          showData.value = dataList
          // 启动页码观察
          setTimeout(() => {
            resourVisble.value = true
          }, 500)
        }
      })
  } else {
    if (data.md5) {
      window.open(bookConfig.value.requestCtx + '/file/api/ApiDownload?md5=' + data.md5)
    } else if (data.resourcePath) {
@@ -2258,7 +2286,7 @@
  //   testWord.value = bookConfig.value.resourceUrl + '/' + data.resourcePath
  // }
}
const goDownload =(data) =>{
const goDownload = (data) => {
  if (data.md5) {
    window.open(bookConfig.value.requestCtx + '/file/api/ApiDownload?md5=' + data.md5)
  } else if (data.resourcePath) {
@@ -2405,8 +2433,12 @@
                if (resItem1.resourceType == classifySelectList.value[0].title) {
                  resourceDataList.value.push(resItem1)
                }
                if(activeClassify.value == 'other'){
                  if (resItem1.resourceType != '图片' && resItem1.resourceType != '视频' && resItem1.resourceType != '音频') {
                if (activeClassify.value == 'other') {
                  if (
                    resItem1.resourceType != '图片' &&
                    resItem1.resourceType != '视频' &&
                    resItem1.resourceType != '音频'
                  ) {
                    resourceDataList.value.push(resItem1)
                  }
                }
@@ -2895,7 +2927,7 @@
      break
  }
}
type pomodoroType = InstanceType<typeof Pomodoro>
const baiduVisible = ref(false)
const wendaVisible = ref(false)
const cidianVisible = ref(false)
@@ -2905,13 +2937,14 @@
const modelTool = ref(false)
const shengciVisble = ref(false)
const calculatorVisble = ref(false)
const pomodoroRef = ref<pomodoroType>()
const activeTool = ref(0)
const toolState = reactive({
  open: true
})
const resourceUrl = ref('')
const selectTeachTools = (item) => {
const selectTeachTools = (item: any) => {
  if (token) {
    activeTool.value = item.name
    switch (item.name) {
@@ -2925,7 +2958,7 @@
        siweiVisble.value = true
        break
      case '模型工具':
      modelTool.value = true
        modelTool.value = true
        break
      case '词典':
        cidianVisible.value = true
@@ -2936,6 +2969,8 @@
        break
      case '计算器':
        calculatorVisble.value = true
      case '番茄闹钟':
        pomodoroRef.value.setDialogVisable(true)
        break
    }
  } else {
@@ -4215,6 +4250,29 @@
const openFormulaDialog = () => {
  formulaDialog.value = true
}
// 番茄钟移动
const isMove = ref<boolean>(false)
const position = reactive({x:100,y:100})
const dragOffset = reactive({x:0,y:0})
const mouseDown = (e: MouseEvent) => {
  isMove.value = true
  dragOffset.x = e.clientX - position.x
  dragOffset.y = e.clientY - position.y
  document.addEventListener('mousemove', mouseMove)
  document.addEventListener('mouseup', mouseUp)
}
const mouseUp = (e: MouseEvent) => {
  isMove.value = false
  document.removeEventListener('mousemove', mouseMove)
  document.removeEventListener('mouseup', mouseUp)
}
const mouseMove = (e: MouseEvent) => {
  if (isMove.value) {
    position.x = e.clientX - dragOffset.x
    position.y = e.clientY - dragOffset.y
  }
}
</script>
<style lang="less">
@@ -4965,6 +5023,33 @@
          z-index: 96;
          background: rgba(255, 255, 255, 0.2);
        }
        .watch-box {
          display: flex;
          align-items: center;
          position: absolute;
          background-color: #555;
          color: #fff;
          padding: 10px;
          border-radius: 5px;
          width: max-content;
          p {
            cursor: move;
            padding: 0 8px;
            font-size: 18px;
            border-radius: 4px;
            margin-right: 10px;
            background-color: #666;
          }
          span {
            cursor: pointer;
            border-right: 1px solid #fff;
            padding: 0 4px;
            font-size: 14px;
            &:last-child {
              border-right: none;
            }
          }
        }
      }
    }
@@ -5475,14 +5560,14 @@
  width: 100%;
  overflow-y: scroll;
    img {
      display: block;
      margin: 0 auto;
      width: 90%;
      height: auto;
      box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, 0.1);
      object-fit: contain;
    }
  img {
    display: block;
    margin: 0 auto;
    width: 90%;
    height: auto;
    box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, 0.1);
    object-fit: contain;
  }
}
.imgUrlBox {
@@ -5500,7 +5585,7 @@
  left: 50px;
}
.iframe-box {
  width:100%;
  width: 100%;
  height: 800px;
}
</style>