.gitignore | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/App.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/assets/js/config.ts | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/assets/main.css | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/assets/style/examination.less | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/child.ts | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/hooks/public.ts | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/components/pomodoro.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/components/whiteBoard.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/readerPages/webHome.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
.gitignore
@@ -11,7 +11,7 @@ node_modules *.lock package-lock.json *.mp3 # 编译文件 dist dist-electron src/App.vue
@@ -142,7 +142,6 @@ </script> <style lang="less"> @import './assets/style/examination.less'; .updateDownloadInfo { position: fixed; top: 2px; src/assets/js/config.ts
@@ -1,14 +1,14 @@ // 测试 export const requestCtx = "https://jsek.bnuic.com"; //jsek export const appId = 3; // export const requestCtx = "http://182.92.203.7:3007"; //jsek // export const appId = 27 // export const requestCtx = "https://jsek.bnuic.com"; //jsek // export const appId = 3; export const requestCtx = "http://182.92.203.7:3007"; //jsek export const appId = 27 export const requestTimeOut = 300000; // 请求超时时间 export const tokenKey = "token"; export const userInfoKey = "website-front-userInfo"; // 用户信息key export const appRefCode = "jingshieke"; export const goodsStore = `defaultGoodsStore${appId}`; // 默认商品库(书城) export const digitalTextbooks = "jsek_digitalTextbooks";//数字教材 export const loginCtx = "http://jsysf.bnuic.com/home/#/digitalTextbooks?login=true"; //登录链接 export const loginCtx = "http://jsek.bnuic.com/home/#/digitalTextbooks?login=true"; //登录链接 // export const loginCtx = ""; //登录链接 src/assets/main.css
@@ -1,5 +1,5 @@ @import './base.css'; @import './style/examination.less'; #parentApp { width: 100%; height: 100%; @@ -248,6 +248,11 @@ .graphBox .graphSelect .lineSegment{ width:15px; } .acitveGraphType{ padding:4px; background-color: #e0e0e0; border-radius: 5px; } .el-input__inner { border: none !important; src/assets/style/examination.less
@@ -45,13 +45,13 @@ text-indent: 0em !important; margin-left: 20px; /deep/ .el-textarea__inner:focus { .el-textarea__inner:focus { border-color: #15c0f2; } } .input { /deep/ .el-input__inner { .el-input__inner { height: 26px; } } @@ -186,11 +186,11 @@ border-bottom: 1px solid #000; } /deep/ .el-textarea.is-disabled .el-textarea__inner { .el-textarea.is-disabled .el-textarea__inner { background-color: #fff; } /deep/ .el-input.is-disabled .el-input__inner { .el-input.is-disabled .el-input__inner { background-color: #fff; } @@ -199,11 +199,8 @@ align-items: center; } } ::v-deep { .el-input__wrapper { border-top: 0 !important; } .el-input__wrapper { border-top: 0 !important; } } @@ -232,12 +229,12 @@ white-space: pre-wrap !important; color: #000; /deep/ .el-checkbox__label { .el-checkbox__label { line-height: 1.5; } } /deep/ .el-radio__inner { .el-radio__inner { border-color: #a5a3a3; } @@ -262,7 +259,7 @@ /** 解析 */ .objective { /deep/ .el-collapse-item__header { .el-collapse-item__header { min-height: 48px; height: min-content; padding: 0 20px; @@ -332,11 +329,8 @@ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; ::v-deep { img { max-height: 48px; } img { max-height: 48px; } } } @@ -352,11 +346,11 @@ } } /deep/ .el-collapse-item__header:focus:not(:hover) { .el-collapse-item__header:focus:not(:hover) { color: #333; } /deep/ .el-collapse-item__content { .el-collapse-item__content { width: 93%; padding: 0 20px; background-color: #f4f4f4; @@ -364,7 +358,7 @@ color: #333; } /deep/ .el-collapse-item__arrow { .el-collapse-item__arrow { display: none; } @@ -378,7 +372,7 @@ } .subjective { /deep/ .el-collapse-item__header { .el-collapse-item__header { height: 80px; background-color: #f4f4f4; width: 100%; @@ -457,7 +451,7 @@ height: min-content; margin-bottom: 6px; /deep/ img { img { margin-left: 10px; object-fit: contain; vertical-align: middle; @@ -480,13 +474,11 @@ } .titleTextArea { ::v-deep { img, .el-image__inner { max-width: 150px !important; max-height: 100px !important; object-fit: contain; } img, .el-image__inner { max-width: 150px !important; max-height: 100px !important; object-fit: contain; } } @@ -636,9 +628,9 @@ object-fit: contain; } /deep/ .examination-math { .examination-math { display: flex; align-items: center; flex-wrap: wrap; } } } src/child.ts
@@ -106,6 +106,60 @@ entry: '//182.92.203.7:3007/books/book/botany', container: '#container', activeRule: '/home' //匹配所有以/subPath开头的为子应用 }, aurturingAndEducationAged0to3:{ name: 'app-content', entry: '//182.92.203.7:3007/books/book/aurturingAndEducationAged0to3', container: '#container', activeRule: '/home' //匹配所有以/subPath开头的为子应用 }, childcareInstitutionsManagement:{ name: 'app-content', entry: '//182.92.203.7:3007/books/book/childcareInstitutionsManagement', container: '#container', activeRule: '/home' //匹配所有以/subPath开头的为子应用 }, preschoolGameGuidance:{ name: 'app-content', entry: '//182.92.203.7:3007/books/book/preschoolGameGuidance', container: '#container', activeRule: '/home' }, kindergartenLanguageActivity:{ name: 'app-content', entry: '//182.92.203.7:3007/books/book/kindergartenLanguageActivity', container: '#container', activeRule: '/home' }, preschoolEvaluation:{ name: 'app-content', entry: '//182.92.203.7:3007/books/book/preschoolEvaluation', container: '#container', activeRule: '/home' }, preschoolBasicKnowledge:{ name: 'app-content', entry: '//182.92.203.7:3007/books/book/preschoolBasicKnowledge', container: '#container', activeRule: '/home' }, kindergartenActivitiesDesignGuidance:{ name: 'app-content', entry: '//182.92.203.7:3007/books/book/kindergartenActivitiesDesignGuidance', container: '#container', activeRule: '/home' }, policiesAndRegulations:{ name: 'app-content', entry: '//182.92.203.7:3007/books/book/policiesAndRegulations', container: '#container', activeRule: '/home' }, OralAndBroadcasting:{ name: 'app-content', entry: '//182.92.203.7:3007/books/book/OralAndBroadcasting', container: '#container', activeRule: '/home' } } src/hooks/public.ts
New file @@ -0,0 +1,21 @@ export const useFormatData = () => { const formatTime = (time:number) => { if(time == 0) return '00:00' const minutes = Math.floor(time / 60) const remainingSeconds = time % 60 return `${String(minutes).padStart(2, '0')}:${String(remainingSeconds).padStart(2, '0')}` } return { formatTime } } export const useCoordinateData = () => { const getPageXY = (e:MouseEvent) => { } return { getPageXY } } src/views/components/pomodoro.vue
New file @@ -0,0 +1,197 @@ <template> <el-dialog v-model="dialogVisable" title="番茄闹钟" width="500" > <div class="ring-box"> <span class="title-txt">响铃时长</span> <el-switch v-model="pageData.isRing" :disabled="isRuning" /> <el-input-number v-model="pageData.ringTime" :disabled="isRuning" :min="1" step-strictly /> </div> <p class="prompt-txt ring-title">以秒为单位</p> <div class="border" ></div> <ul class="sustain-box"> <li> <span class="title-txt">持续时间</span> <span class="label-txt" >专注时间</span> <el-input-number v-model="pageData.workTime" :disabled="isRuning" :min="1" step-strictly /> </li> <li> <span class="title-txt"></span> <span class="label-txt">短休息</span> <el-input-number v-model="pageData.shortTime" :disabled="isRuning" :min="0" step-strictly /> </li> <li> <span class="title-txt"></span> <span class="label-txt">长休息</span> <el-input-number v-model="pageData.longTime" :disabled="isRuning" :min="0" step-strictly /> </li> </ul> <p class="prompt-txt ring-title" >以分钟为单位</p> <div class="border" ></div> <div> <el-button type="primary" @click="startFun" >开始</el-button> <el-button type="primary" @click="pauseFun" >停止</el-button> <el-button @click="resetFun">重置</el-button> <el-button @click="handleRestFun(false)" >长休息</el-button> <el-button @click="handleRestFun(true)">短休息</el-button> </div> {{ formatTime(pageData.currentTime) }} </el-dialog> <!-- <video src="../../assets/audio/买辣椒也用券.mp3" ref="audioRef"></video> --> </template> <script setup lang="ts"> import { ElMessage } from 'element-plus' import { ref, reactive, defineExpose ,watchEffect } from 'vue' import {useFormatData} from '@/hooks/public' const isShow =ref<boolean>(false) // 悬浮框是否显示 const audioRef = ref<HTMLAudioElement>() // 音频实例 const dialogVisable = ref<boolean>(false) // 弹窗状态 const timerInterval = ref<any>(null) // 计时器实例 const isRuning = ref<boolean>(false) // 计时器是否运行 const isBreak = ref<boolean>(false) // true 休息 false 工作 const isShortTime = ref<boolean>(false) // 长短休息模式 const pageData = reactive({ isRing: true, // 是否响铃 ringTime: 5, // 响铃时长 秒 workTime: 25, // 工作时长 分钟 saveWorkTime: 0, // 剩余工作时间 shortTime: 5, // 短休息 longTime: 5, // 长休息 currentTime:0, // 显示时间 秒 }) const { formatTime } = useFormatData() watchEffect(() => { pageData.currentTime = pageData.workTime * 60 }) watchEffect(() => { if(!isBreak.value) pageData.saveWorkTime = pageData.currentTime }) const setDialogVisable = (value: boolean) => { dialogVisable.value = value } // 开始计时 const startFun = () => { isShow.value = true isRuning.value = true timerInterval.value = setInterval(() => { if(pageData.currentTime > 0) { pageData.currentTime-- } else { playAudio() if(isBreak.value) { // 工作时间赋值 isBreak.value = false if( pageData.saveWorkTime) { pageData.currentTime = pageData.saveWorkTime ElMessage.success('休息结束,开始学习吧!') } else { clearInterval(timerInterval.value) isRuning.value = false ElMessage.success('学习结束') } } else { // 休息时间赋值 isBreak.value = true pageData.currentTime = isShortTime.value ? pageData.shortTime * 60 : pageData.longTime * 60 ElMessage.success('休息一下吧!') } } }, 1000) dialogVisable.value = false } // 暂停计时 const pauseFun = () => { isRuning.value = false if(timerInterval.value) { clearInterval(timerInterval.value) } } // 重置计时器 const resetFun = () => { isRuning.value = false isBreak.value = false pauseFun() pageData.currentTime = pageData.workTime * 60 } // 休息按钮 const startBreak = () => { if(isRuning.value && !isBreak.value) { if(pageData.shortTime || pageData.longTime) { pageData.saveWorkTime = pageData.currentTime isBreak.value = true pageData.currentTime = isShortTime.value ? pageData.shortTime * 60 : pageData.longTime * 60 ElMessage.success('开始休息') } else { ElMessage.warning('暂未设置休息时间') } } } // 开始响铃 const playAudio = () => { audioRef.value!.currentTime = 0 audioRef.value?.play() setTimeout(() => { pauseAudio() },pageData.ringTime * 1000) } // 暂停响铃 const pauseAudio = () => { audioRef.value?.pause() } // 长短休息 const handleRestFun = (value:boolean) => { isShortTime.value = value startBreak() } defineExpose({ isShow, isRuning, pageData, setDialogVisable, startFun, pauseFun, resetFun, handleRestFun }) </script> <style lang="less" scoped> .prompt-txt { margin-top: 10px; font-size: 12px; color: #b7b7b7; } .title-txt { color: #2c2c2c; width: 4em; } .label-txt { width: 4em; color:#707070 ; } .ring-box { width: 300px; display: flex; justify-content: space-between; align-items: center; } .ring-title { padding-left: 150px; } .sustain-box { width: 300px; li { display: flex; justify-content: space-between; margin-bottom: 10px; } } .border { height: 1px; background-color:#cecece ; margin: 10px 0; } </style> src/views/components/whiteBoard.vue
New file @@ -0,0 +1,608 @@ <template> <div class="page-con"> <div class="canvas-box"> <div class="canvas-header"> <el-icon @click="closeDialog"><CloseBold /></el-icon> </div> <div class="canvas-body"> <canvas id="canvasBoard" width="1000" height="750"></canvas> </div> </div> <div class="canvas-tool"> <div class="brushBox"> <div class="toolList"> <el-popover placement="top" width="250" trigger="click"> <div class="popinnerBox"> <div class="brush"> <div class="thickness"> <div :class="toolData.thicknessActive == '1' ? 'small active hover' : 'small hover'" @click="selectThickness('1')" ></div> <div :class="toolData.thicknessActive == '3' ? 'middle active hover' : 'middle hover'" @click="selectThickness('3')" ></div> <div :class="toolData.thicknessActive == '5' ? 'large active hover' : 'large hover'" @click="selectThickness('5')" ></div> </div> <div class="lineStyle"> <div class="lineTypeBox"> <div :class=" toolData.lineTypeActive == 'solid' ? 'typeItem lineTypeActive hover' : 'typeItem hover' " @click="selectLineType('solid')" > <div class="solid"></div> <div class="activeIcon" v-if="toolData.lineTypeActive == 'solid'"> <img :src="xuanzhong" /> </div> </div> <div :class=" toolData.lineTypeActive == 'dashed' ? 'typeItem lineTypeActive hover' : 'typeItem hover' " @click="selectLineType('dashed')" > <div class="dashed"></div> <div class="activeIcon" v-if="toolData.lineTypeActive == 'dashed'"> <img :src="xuanzhong" /> </div> </div> </div> <div class="colorSelectBox"> <div v-for="item in colorList" :key="item.key" class="flex1 hover" @click="lineColorSelect(item)" > <div :style="{ background: item.key }" class="scribeItem"> <img :src="xuanzhong" v-if="item.key == toolData.lineColorActive" /> </div> </div> </div> </div> </div> </div> <template #reference> <div class="floatToolItem hover" @click="toolSelectHandle('huabi')"> <el-tooltip class="box-item" effect="dark" content="画笔" placement="bottom"> <img :src="huabi2" alt="" class="imgBox" /> </el-tooltip> </div> </template> </el-popover> <el-popover placement="top" width="250" trigger="click"> <div class="popinnerBox"> <div class="lineStyle"> <div class="lineTypeBox"> <div :class=" toolData.fontSizeActive == '12' ? 'typeItem lineTypeActive hover' : 'typeItem hover' " @click="selectfontSize('12')" > 小 <div class="activeIcon" v-if="toolData.fontSizeActive == '12'"> <img :src="xuanzhong" /> </div> </div> <div :class=" toolData.fontSizeActive == '16' ? 'typeItem lineTypeActive hover' : 'typeItem hover' " @click="selectfontSize('16')" > 中 <div class="activeIcon" v-if="toolData.fontSizeActive == '16'"> <img :src="xuanzhong" /> </div> </div> <div :class=" toolData.fontSizeActive == '20' ? 'typeItem lineTypeActive hover' : 'typeItem hover' " @click="selectfontSize('20')" > 大 <div class="activeIcon" v-if="toolData.fontSizeActive == '20'"> <img :src="xuanzhong" /> </div> </div> </div> <div class="lineStyle"> <div class="colorSelectBox"> <div v-for="item in colorList" :key="item.key" class="flex1 hover" @click="lineColorSelect(item)" > <div :style="{ background: item.key }" class="scribeItem"> <img :src="xuanzhong" v-if="item.key == toolData.lineColorActive" /> </div> </div> </div> </div> </div> </div> <template #reference> <div class="floatToolItem hover" @click="toolSelectHandle('wenzi')"> <el-tooltip class="box-item" effect="dark" content="文字" placement="bottom"> <img :src="wenzi2" alt="" class="imgBox" /> </el-tooltip> </div> </template> </el-popover> <el-popover placement="top" width="250" trigger="click"> <div class="popinnerBox"> <div class="graphBox"> <div class="graphSelect"> <div class="flex1"> <div :class="toolData.graphType == 'square' ? 'acitveGraphType' : ''"> <div class="square hover" @click="graphSelect('square')"></div> </div> </div> <div class="flex1"> <div :class="toolData.graphType == 'rotundity' ? 'acitveGraphType' : ''"> <div class="rotundity hover" @click="graphSelect('rotundity')"></div> </div> </div> <div class="flex1"> <div :class="toolData.graphType == 'triangle' ? 'acitveGraphType' : ''"> <div class="triangle hover" @click="graphSelect('triangle')"></div> </div> </div> <div class="flex1"> <div :class="toolData.graphType == 'lineSegment' ? 'acitveGraphType' : ''"> <div class="lineSegment hover" @click="graphSelect('lineSegment')">/</div> </div> </div> </div> <div class="lineStyle"> <div class="colorSelectBox"> <div v-for="item in colorList" :key="item.key" class="flex1 hover" @click="lineColorSelect(item)" > <div :style="{ background: item.key }" class="scribeItem"> <img :src="xuanzhong" v-if="item.key == toolData.lineColorActive" /> </div> </div> </div> </div> </div> </div> <template #reference> <div class="floatToolItem hover" @click="toolSelectHandle('tuxing')"> <el-tooltip class="box-item" effect="dark" content="图形" placement="bottom"> <img :src="tuxing" alt="" class="imgBox" /> </el-tooltip> </div> </template> </el-popover> <div class="floatToolItem hover" @click="toolSelectHandle('chexiao')"> <el-tooltip class="box-item" effect="dark" content="撤销" placement="bottom"> <img :src="clearPrevious" alt="" class="imgBox" /> </el-tooltip> </div> <!-- <div class="floatToolItem" @click="toolSelectHandle('xiangpi')"> <div class="imgBox"> <img :src="clear" alt="" /> </div> </div> --> <div class="floatToolItem hover" @click="toolSelectHandle('qingchu')"> <el-tooltip class="box-item" effect="dark" content="清除" placement="bottom"> <img :src="qingchu2" alt="" class="imgBox" /> </el-tooltip> </div> <div class="layOutTool"></div> <div class="floatToolItem hover" @click="toolSelectHandle('tuichu')"> <el-tooltip class="box-item" effect="dark" content="退出" placement="bottom"> <img :src="tuichu" alt="" class="imgBox" /> </el-tooltip> </div> </div> </div> </div> </div> </template> <script setup lang="ts"> import { requestCtx } from '../../assets/js/config' import { defineProps, inject, defineEmits, onMounted, reactive, ref, watch } from 'vue' import clearPrevious from '@/assets/images/operation/clearPrevious.png' import clear from '@/assets/images/operation/clear.png' import tuichu from '@/assets/images/operation/tuichu.png' import qingchu2 from '@/assets/images/operation/qingchu.png' import tuxing from '@/assets/images/operation/tuxing.png' import xuanzhong from '@/assets/images/operation/xuanzhong.png' import huabi2 from '@/assets/images/operation/huabi.svg' import wenzi2 from '@/assets/images/operation/wenzi.png' let canvas: any = null let text: any = null let activeEl: any = null function canvasOnMouseDownDel(opt) { // 右键,且在元素上右键 // button: 1-左键;2-中键;3-右键 // 在画布上右键,target 为 null if (opt.button === 1 && opt.target) { // 获取当前元素 activeEl = opt.target } } onMounted(() => { canvas = new fabric.Canvas('canvasBoard') // 按下鼠标 canvas.on('mouse:down', canvasOnMouseDownDel) canvas.setZoom(1); // 设置画布缩放比例为1 canvas.absolutePan({ x: 0, y: 0 }); }) const emit = defineEmits(['whiteBoardClose']) const closeDialog = () => { emit('whiteBoardClose', false) } //画笔操作栏事件 const toolData = reactive({ activeTool: '', fontSizeActive: '16', // 文字操作文字大小 thicknessActive: '3', //画笔选中粗细 lineTypeActive: 'solid', //画笔选中线类型 lineColorActive: '#333', //画笔选中线颜色 graphType: '' //图形类型,方形,圆形... }) const colorList = reactive([ { label: '黄色', key: '#F5E12A' }, { label: '绿色', key: '#76F0AE' }, { label: '蓝色', key: '#59CFF5' }, { label: '紫色', key: '#CAA5FC' }, { label: '粉色', key: '#F5A0B9' } ]) const toolSelectHandle = (title) => { toolData.activeTool = title toolData.lineColorActive = '' canvas.isDrawingMode = false switch (title) { case 'huabi': canvas.skipTargetFind = false canvas.isDrawingMode = true toolData.graphType = '' canvas.freeDrawingBrush.color = '#333' canvas.freeDrawingBrush.width = '3' canvas.on('mouse:down', '') // 鼠标在画布上按下 canvas.on('mouse:up', '') canvas.on('mouse:move', '') break case 'wenzi': canvas.skipTargetFind = false canvas.isDrawingMode = false toolData.graphType = '' text = new fabric.IText('请输入文本', { left: 50, top: 50, fontSize: toolData.fontSizeActive }) canvas.add(text) canvas.on('mouse:down', '') // 鼠标在画布上按下 canvas.on('mouse:up', '') canvas.on('mouse:move', '') break case 'tuxing': canvas.isDrawingMode = false canvas.selectionColor = 'transparent' canvas.skipTargetFind = true toolData.lineColorActive = '#000' break case 'chexiao': canvas.skipTargetFind = false canvas.isDrawingMode = false canvas.remove(activeEl) canvas.requestRenderAll() activeEl = null break case 'tuichu': canvas.skipTargetFind = false canvas.isDrawingMode = false emit('whiteBoardClose', false) break case 'qingchu': canvas.clear() break } } //选中画笔粗细 const selectThickness = (str) => { toolData.thicknessActive = str canvas.freeDrawingBrush.width = toolData.thicknessActive } //画笔线类型 const selectLineType = (str) => { toolData.lineTypeActive = str if (toolData.lineTypeActive == 'dashed') { canvas.freeDrawingBrush.strokeDashArray = [10] } else { canvas.freeDrawingBrush.strokeDashArray = null } } //画笔/文字/图形颜色选择 const lineColorSelect = (item) => { toolData.lineColorActive = item.key if ((toolData.activeTool == 'huabi')) { canvas.freeDrawingBrush.color = item.key } if ((toolData.activeTool == 'wenzi')) { text.fill = toolData.lineColorActive } } //文字大小 const selectfontSize = (str) => { toolData.fontSizeActive = str text.fontSize = toolData.fontSizeActive } //选择图形 const graphSelect = (type) => { toolData.graphType = type switch (type) { case 'square': canvas.on('mouse:down', canvasMouseDown) // 鼠标在画布上按下 canvas.on('mouse:up', canvasMouseUp) canvas.selectionBorderColor = toolData.lineColorActive break case 'rotundity': canvas.on('mouse:down', canvasMouseDown) // 鼠标在画布上按下 canvas.on('mouse:up', canvasMouseUp) canvas.on('mouse:move', canvasMouseMove) break case 'triangle': canvas.on('mouse:down', canvasMouseDown) // 鼠标在画布上按下 canvas.on('mouse:up', canvasMouseUp) canvas.on('mouse:move', canvasMouseMove) break case 'lineSegment': canvas.on('mouse:down', canvasMouseDown) // 鼠标在画布上按下 canvas.on('mouse:move', canvasMouseMove) // 鼠标在画布上移动 canvas.on('mouse:up', canvasMouseUp) break } } let downPoint = null // 鼠标按下的坐标 let upPoint = null let currentCircle = null // 临时圆,创建圆的时候使用 let currentTriangle = null // 临时三角形 let currentLine = null // 临时线段 // 鼠标在画布上按下 function canvasMouseDown(e) { downPoint = e.absolutePointer if (toolData.graphType === 'rotundity') { currentCircle = new fabric.Circle({ top: downPoint.y, left: downPoint.x, radius: 0, fill: 'transparent', stroke: toolData.lineColorActive }) canvas.add(currentCircle) } if (toolData.graphType === 'triangle') { currentTriangle = new fabric.Triangle({ top: downPoint.y, left: downPoint.x, width: 0, height: 0, fill: 'transparent', stroke: toolData.lineColorActive }) canvas.add(currentTriangle) } if (toolData.graphType === 'lineSegment') { currentLine = new fabric.Line( [ downPoint.x, downPoint.y, // 起始点坐标 downPoint.x, downPoint.y // 结束点坐标 ], { stroke: toolData.lineColorActive // 笔触颜色 } ) canvas.add(currentLine) } } // 鼠标在画布上松开 function canvasMouseUp(e) { if (toolData.graphType === 'square') { // 创建矩形 createRect(e.absolutePointer) } if (toolData.graphType === 'rotundity') { if (JSON.stringify(downPoint) === JSON.stringify(upPoint)) { canvas.remove(currentCircle) } else { if (currentCircle) { currentCircle.set('stroke', toolData.lineColorActive) } } currentCircle = null } if (toolData.graphType === 'triangle') { if (JSON.stringify(downPoint) === JSON.stringify(upPoint)) { canvas.remove(currentTriangle) } else { currentTriangle.set('stroke', toolData.lineColorActive) } currentTriangle = null } if (toolData.graphType === 'lineSegment') { if (JSON.stringify(downPoint) === JSON.stringify(upPoint)) { canvas.remove(currentLine) } else { currentLine.set('stroke', toolData.lineColorActive) } currentLine = null } } // 创建矩形 function createRect(pointer) { // 点击事件,不生成矩形 if (JSON.stringify(downPoint) === JSON.stringify(pointer)) { return } // 创建矩形 // 矩形参数计算 let top = Math.min(downPoint.y, pointer.y) let left = Math.min(downPoint.x, pointer.x) let width = Math.abs(downPoint.x - pointer.x) let height = Math.abs(downPoint.y - pointer.y) // 矩形对象 const rect = new fabric.Rect({ top, left, width, height, fill: 'transparent', stroke: toolData.lineColorActive }) // 将矩形添加到画布上 canvas.add(rect) downPoint = null } // 鼠标在画布上移动 function canvasMouseMove(e) { if (toolData.graphType === 'rotundity' && currentCircle) { const currentPoint = e.absolutePointer let radius = Math.min(Math.abs(downPoint.x - currentPoint.x), Math.abs(downPoint.y - currentPoint.y)) / 2 let top = currentPoint.y > downPoint.y ? downPoint.y : downPoint.y - radius * 2 let left = currentPoint.x > downPoint.x ? downPoint.x : downPoint.x - radius * 2 currentCircle.set('radius', radius) currentCircle.set('top', top) currentCircle.set('left', left) canvas.requestRenderAll() } if (toolData.graphType === 'triangle' && currentTriangle) { const currentPoint = e.absolutePointer let width = Math.abs(downPoint.x - currentPoint.x) let height = Math.abs(downPoint.y - currentPoint.y) let top = currentPoint.y > downPoint.y ? downPoint.y : currentPoint.y let left = currentPoint.x > downPoint.x ? downPoint.x : currentPoint.x currentTriangle.set('width', width) currentTriangle.set('height', height) currentTriangle.set('top', top) currentTriangle.set('left', left) canvas.requestRenderAll() } if (toolData.graphType === 'lineSegment' && currentLine) { const currentPoint = e.absolutePointer currentLine.set('x2', currentPoint.x) currentLine.set('y2', currentPoint.y) canvas.requestRenderAll() } } </script> <style scoped lang="less"> .page-con { height: 100%; width: 100%; // position: relative; .canvas-header { text-align: right; padding: 10px; background-color: #f1f1f1; border-radius: 5px 5px 0 0; } .canvas-box { width: 1000px; margin: 20px auto; background-color: #fff; border-radius: 5px; } .brushBox { width: 290px; margin: 0 auto; border-radius: 5px; background: #fff; overflow: hidden; box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, 0.3); .toolList { display: flex; justify-content: center; align-items: center; .floatToolItem { margin: 6px 8px; padding: 5px; width: 30px; border-radius: 5px; display: flex; justify-content: center; align-items: center; // flex: 1; font-size: 14px; .imgBox { height: 18px; width: 18px; text-align: center; margin: 0 auto; } } .floatToolItem:hover { background-color: rgba(44, 44, 44, 0.2); } .layOutTool { height: 20px; margin-right: 5px; border-left: 1px solid #e0e0e0; } } } } </style> src/views/readerPages/webHome.vue
@@ -119,8 +119,8 @@ <div>默认资源</div> <div :class="resourceType == 'default' ? 'text' : 'line'"></div> </div> <hr class="hr" /> <div class="tabItem hover" @click="selectResourceType('teacher')"> <hr class="hr" v-if="userInfo.role == 'Teacher'"/> <div class="tabItem hover" @click="selectResourceType('teacher')" v-if="userInfo.role == 'Teacher'"> <div>教师资源</div> <div :class="resourceType == 'teacher' ? 'text' : 'line'"></div> </div> @@ -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> @@ -645,6 +649,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> <!-- 画笔组件 --> @@ -793,16 +809,24 @@ <div class="graphBox"> <div class="graphSelect"> <div class="flex1"> <div class="square hover" @click="graphSelect('square')"></div> <div :class="toolSelectData.graphType == 'square' ? 'acitveGraphType' : ''"> <div class="square hover" @click="graphSelect('square')"></div> </div> </div> <div class="flex1"> <div class="rotundity hover" @click="graphSelect('rotundity')"></div> <div :class="toolSelectData.graphType == 'rotundity' ? 'acitveGraphType' : ''"> <div class="rotundity hover" @click="graphSelect('rotundity')"></div> </div> </div> <div class="flex1"> <div class="triangle hover" @click="graphSelect('triangle')"></div> <div :class="toolSelectData.graphType == 'triangle' ? 'acitveGraphType' : ''"> <div class="triangle hover" @click="graphSelect('triangle')"></div> </div> </div> <div class="flex1"> <div class="lineSegment hover" @click="graphSelect('lineSegment')">/</div> <div :class="toolSelectData.graphType == 'lineSegment' ? 'acitveGraphType' : ''"> <div class="lineSegment hover" @click="graphSelect('lineSegment')">/</div> </div> </div> </div> <div class="lineStyle"> @@ -1140,6 +1164,11 @@ </div> </div> <!-- 白板 --> <div v-if="whiteBoard" class="whiteBoardBox"> <whiteBoardBox @whiteBoardClose="whiteBoardClose"></whiteBoardBox> </div> <el-dialog title="资源" align-center @@ -1153,16 +1182,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 +1300,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 +1319,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 +1337,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') //获取路由器 @@ -1338,6 +1362,7 @@ import formula from '@/views/components/formula.vue' import wrongQuestion from '@/views/components/wrongQuestion.vue' import voiceReader from '@/views/components/voiceReader.vue' import whiteBoardBox from '@/views/components/whiteBoard.vue' import logo from '@/assets/images/header/logo.png' import mulu from '@/assets/images/menu/mulu.png' import biji from '@/assets/images/menu/biji.png' @@ -1436,7 +1461,7 @@ import { microApps } from '@/child.ts' import { open } from 'fs' let token = localStorage.getItem('token') const canvasWith = ref(1000) const canvasWith = ref(800) const canvasheight = ref(3000) const screenWidth = ref( window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth @@ -1495,7 +1520,6 @@ window.qiankunState.initTestBook(localStorage.getItem('bookId') + '', tryPageCount.value) } } }) // 定义父层方法 @@ -1585,7 +1609,6 @@ // if (window.qiankunState && window.qiankunState.getAnswers){ // window.qiankunState.getAnswers(localStorage.getItem("")) // } }) onBeforeUnmount(() => { @@ -1636,8 +1659,9 @@ } 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)) { if (res.datas[0].purchasedSaleMethodIdList.indexOf(res.datas[0].defaultSaleMethodId) > -1) { isBuy.value = true } else { isBuy.value = false @@ -1716,11 +1740,7 @@ name: '知识图谱', icon: zhishitupu, isShow: bookConfig.value.textbookComponents.indexOf('6BE6A3DC') > -1 }, { name: '截图', icon: jietu, isShow: bookConfig.value.textbookComponents.indexOf('CB0EACEC') > -1 // isShow: true }, { name: '书签', @@ -1735,6 +1755,11 @@ bookConfig.value.textbookComponents.indexOf('AFC1A288') > -1 || bookConfig.value.textbookComponents.indexOf('A434F2C0') > -1 || bookConfig.value.textbookComponents.indexOf('A4821F71') > -1 }, { name: '截图', icon: jietu, isShow: bookConfig.value.textbookComponents.indexOf('CB0EACEC') > -1 } ] teachToolsMenuData = [ @@ -1808,6 +1833,11 @@ icon: fanqiezhong, isShow: bookConfig.value.textbookComponents.indexOf('E4DC9777') > -1 } // { // name: '番茄闹钟', // icon: fanqiezhong, // isShow: true // } ] floatingToolBox = [ { @@ -1820,6 +1850,7 @@ icon: baiban, name: '白板', isShow: bookConfig.value.textbookComponents.indexOf('029DB3E0') > -1 // isShow: true }, { icon: biaozhu, @@ -1899,9 +1930,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 +1940,6 @@ }) .catch(function (error) { listLoading.value = false }) } const defaultProps = { @@ -2063,8 +2093,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 +2176,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 +2220,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 +2238,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 +2260,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 +2302,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 +2449,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) } } @@ -2596,6 +2644,7 @@ const menuItemClick = (name) => { searchText.value = '' allSearchReault.value = [] listLoading.value = false if (menuState.open && activeMenu.value == name) { menuState.open = false } else { @@ -2776,12 +2825,11 @@ getExercisesList() break case '检索': listLoading.value = true allSearchReault.value = [] console.log(window.qiankunState.searchBookByKeyword) if (window.qiankunState && window.qiankunState.searchBookByKeyword) { let searchReault = window.qiankunState.searchBookByKeyword(searchText.value) if (searchReault.length > 0) { listLoading.value = true let catalogueList = sortArr(catalogueData.value, 'chapter') if (catalogueList.length > 0) { catalogueList.forEach((item) => { @@ -2810,7 +2858,8 @@ } }) } console.log(allSearchReault.value, 444) listLoading.value = false }else{ listLoading.value = false } } @@ -2895,7 +2944,7 @@ break } } type pomodoroType = InstanceType<typeof Pomodoro> const baiduVisible = ref(false) const wendaVisible = ref(false) const cidianVisible = ref(false) @@ -2905,13 +2954,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 +2975,7 @@ siweiVisble.value = true break case '模型工具': modelTool.value = true modelTool.value = true break case '词典': cidianVisible.value = true @@ -2936,6 +2986,8 @@ break case '计算器': calculatorVisble.value = true case '番茄闹钟': pomodoroRef.value.setDialogVisable(true) break } } else { @@ -2984,7 +3036,7 @@ //画布悬浮操作 let canvas = null let canvasBox: any = null const floatingToolData = reactive({ activeToolData: '', //选中工具 activeBookmark: '', //选中书签 @@ -2995,6 +3047,10 @@ //画布 const canvasShow = ref(false) let textBox: any = null let activeElBox: any = null //白板 const whiteBoard = ref(false) //截图事件 const nameRef = ref() @@ -3021,10 +3077,17 @@ } canvasShow.value = false whiteBoard.value = false switch (floatingToolData.activeToolData) { case '画笔': canvasShow.value = true toolSelectData.activeTool = 'huabi' canvasBox = new fabric.Canvas('canvasRef') canvasBox.setZoom(1); // 设置画布缩放比例为1 canvasBox.absolutePan({ x: 0, y: 0 }); break case '白板': whiteBoard.value = true break case '标记': break @@ -3052,18 +3115,53 @@ const toolSelectHandle = (title) => { toolSelectData.activeTool = title toolSelectData.lineColorActive = '' canvasBox.isDrawingMode = false switch (title) { case 'huabi': init() canvasBox.skipTargetFind = false canvasBox.isDrawingMode = true toolSelectData.graphType = '' canvasBox.freeDrawingBrush.color = '#333' canvasBox.freeDrawingBrush.width = '3' canvasBox.on('mouse:down', '') // 鼠标在画布上按下 canvasBox.on('mouse:up', '') canvasBox.on('mouse:move', '') break case 'wenzi': canvasBox.skipTargetFind = false canvasBox.isDrawingMode = false toolSelectData.graphType = '' textBox = new fabric.IText('请输入文本', { left: 50, top: 50, fontSize: toolSelectData.fontSizeActive }) canvasBox.add(textBox) canvasBox.on('mouse:down', '') // 鼠标在画布上按下 canvasBox.on('mouse:up', '') canvasBox.on('mouse:move', '') break case 'tuxing': canvasBox.isDrawingMode = false canvasBox.selectionColor = 'transparent' canvasBox.skipTargetFind = true toolSelectData.lineColorActive = '#000' break case 'chexiao': canvasBox.skipTargetFind = false canvasBox.isDrawingMode = false canvasBox.remove(activeElBox) canvasBox.requestRenderAll() activeElBox = null break case 'tuichu': canvasBox.skipTargetFind = false canvasBox.isDrawingMode = false canvasShow.value = false floatingToolData.activeToolData = '' break case 'qingchu': canvas.clear() canvasBox.clear() break } } @@ -3071,31 +3169,32 @@ //选中画笔粗细 const selectThickness = (str) => { toolSelectData.thicknessActive = str canvas.freeDrawingBrush.color = toolSelectData.thicknessActive canvasBox.freeDrawingBrush.width = toolSelectData.thicknessActive } const selectLineType = (str) => { toolSelectData.lineTypeActive = str init() if (toolSelectData.lineTypeActive == 'dashed') { canvasBox.freeDrawingBrush.strokeDashArray = [10] } else { canvasBox.freeDrawingBrush.strokeDashArray = null } } //画笔颜色选择 const lineColorSelect = (item) => { toolSelectData.lineColorActive = item.key canvas.freeDrawingBrush.color = item.key } //画布属性 const isDrawing = ref(true) // 是否开启绘图,true 开启;false 关闭 const init = () => { canvas = new fabric.Canvas('canvasRef', { isDrawingMode: isDrawing.value // 启用绘画模式 }) canvas.freeDrawingBrush.color = toolSelectData.lineColorActive canvas.freeDrawingBrush.width = toolSelectData.thicknessActive if ((toolSelectData.activeTool == 'huabi')) { canvasBox.freeDrawingBrush.color = item.key } if ((toolSelectData.activeTool == 'wenzi')) { textBox.fill = toolSelectData.lineColorActive } } //文字大小 const selectfontSize = (str) => { toolSelectData.fontSizeActive = str textBox.fontSize = toolSelectData.fontSizeActive } //选择图形 @@ -3103,14 +3202,190 @@ toolSelectData.graphType = type switch (type) { case 'square': canvasBox.on('mouse:down', canvasMouseDown) // 鼠标在画布上按下 canvasBox.on('mouse:up', canvasMouseUp) canvasBox.selectionBorderColor = toolSelectData.lineColorActive break case 'rotundity': canvasBox.on('mouse:down', canvasMouseDown) // 鼠标在画布上按下 canvasBox.on('mouse:up', canvasMouseUp) canvasBox.on('mouse:move', canvasMouseMove) break case 'triangle': canvasBox.on('mouse:down', canvasMouseDown) // 鼠标在画布上按下 canvasBox.on('mouse:up', canvasMouseUp) canvasBox.on('mouse:move', canvasMouseMove) break case 'lineSegment': canvasBox.on('mouse:down', canvasMouseDown) // 鼠标在画布上按下 canvasBox.on('mouse:move', canvasMouseMove) // 鼠标在画布上移动 canvasBox.on('mouse:up', canvasMouseUp) break } } let downPoint = null // 鼠标按下的坐标 let upPoint = null let currentCircle = null // 临时圆,创建圆的时候使用 let currentTriangle = null // 临时三角形 let currentLine = null // 临时线段 function canvasOnMouseDownDel(opt) { // 右键,且在元素上右键 // button: 1-左键;2-中键;3-右键 // 在画布上右键,target 为 null if (opt.button === 1 && opt.target) { // 获取当前元素 activeElBox = opt.target } } // 鼠标在画布上按下 function canvasMouseDown(e) { downPoint = e.absolutePointer if (toolSelectData.graphType === 'rotundity') { currentCircle = new fabric.Circle({ top: downPoint.y, left: downPoint.x, radius: 0, fill: 'transparent', stroke: toolSelectData.lineColorActive }) canvasBox.add(currentCircle) } if (toolSelectData.graphType === 'triangle') { currentTriangle = new fabric.Triangle({ top: downPoint.y, left: downPoint.x, width: 0, height: 0, fill: 'transparent', stroke: toolSelectData.lineColorActive }) canvasBox.add(currentTriangle) } if (toolSelectData.graphType === 'lineSegment') { currentLine = new fabric.Line( [ downPoint.x, downPoint.y, // 起始点坐标 downPoint.x, downPoint.y // 结束点坐标 ], { stroke: toolSelectData.lineColorActive // 笔触颜色 } ) canvasBox.add(currentLine) } } // 鼠标在画布上松开 function canvasMouseUp(e) { if (toolSelectData.graphType === 'square') { // 创建矩形 createRect(e.absolutePointer) } if (toolSelectData.graphType === 'rotundity') { if (JSON.stringify(downPoint) === JSON.stringify(upPoint)) { canvasBox.remove(currentCircle) } else { if (currentCircle) { currentCircle.set('stroke', toolSelectData.lineColorActive) } } currentCircle = null } if (toolSelectData.graphType === 'triangle') { if (JSON.stringify(downPoint) === JSON.stringify(upPoint)) { canvasBox.remove(currentTriangle) } else { currentTriangle.set('stroke', toolSelectData.lineColorActive) } currentTriangle = null } if (toolSelectData.graphType === 'lineSegment') { if (JSON.stringify(downPoint) === JSON.stringify(upPoint)) { canvasBox.remove(currentLine) } else { currentLine.set('stroke', toolSelectData.lineColorActive) } currentLine = null } } // 创建矩形 function createRect(pointer) { // 点击事件,不生成矩形 if (JSON.stringify(downPoint) === JSON.stringify(pointer)) { return } // 创建矩形 // 矩形参数计算 let top = Math.min(downPoint.y, pointer.y) let left = Math.min(downPoint.x, pointer.x) let width = Math.abs(downPoint.x - pointer.x) let height = Math.abs(downPoint.y - pointer.y) // 矩形对象 const rect = new fabric.Rect({ top, left, width, height, fill: 'transparent', stroke: toolSelectData.lineColorActive }) // 将矩形添加到画布上 canvasBox.add(rect) downPoint = null } // 鼠标在画布上移动 function canvasMouseMove(e) { if (toolSelectData.graphType === 'rotundity' && currentCircle) { const currentPoint = e.absolutePointer let radius = Math.min(Math.abs(downPoint.x - currentPoint.x), Math.abs(downPoint.y - currentPoint.y)) / 2 let top = currentPoint.y > downPoint.y ? downPoint.y : downPoint.y - radius * 2 let left = currentPoint.x > downPoint.x ? downPoint.x : downPoint.x - radius * 2 currentCircle.set('radius', radius) currentCircle.set('top', top) currentCircle.set('left', left) canvasBox.requestRenderAll() } if (toolSelectData.graphType === 'triangle' && currentTriangle) { const currentPoint = e.absolutePointer let width = Math.abs(downPoint.x - currentPoint.x) let height = Math.abs(downPoint.y - currentPoint.y) let top = currentPoint.y > downPoint.y ? downPoint.y : currentPoint.y let left = currentPoint.x > downPoint.x ? downPoint.x : currentPoint.x currentTriangle.set('width', width) currentTriangle.set('height', height) currentTriangle.set('top', top) currentTriangle.set('left', left) canvasBox.requestRenderAll() } if (toolSelectData.graphType === 'lineSegment' && currentLine) { const currentPoint = e.absolutePointer currentLine.set('x2', currentPoint.x) currentLine.set('y2', currentPoint.y) canvasBox.requestRenderAll() } } //白板关闭 const whiteBoardClose = () => { whiteBoard.value = false floatingToolData.activeToolData = '' } //标记显示隐藏 const labelShow = (str) => { @@ -4215,6 +4490,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 +5263,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; } } } } } @@ -4997,7 +5322,7 @@ li > div { // height: 50px; padding: 10px 36px; padding: 10px 36px 10px 25px; font-size: 16px; display: flex; align-items: center; @@ -5372,11 +5697,22 @@ .wendabox { width: 100%; height: 82vh; padding:20px; iframe { width: 100%; height: 100%; } } .whiteBoardBox { width: 100%; height: 100%; position: fixed; top: 0; left: 0; z-index: 2000; background-color: rgba(2, 2, 2, 0.3); } .myDialogs, @@ -5404,9 +5740,9 @@ right: 0px !important; } .el-dialog__body { padding: 20px !important; } // .el-dialog__body { // padding: 20px !important; // } .el-dialog__footer { padding: 10px 20px 20px !important; @@ -5475,14 +5811,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 +5836,7 @@ left: 50px; } .iframe-box { width:100%; width: 100%; height: 800px; } </style>