diff --git a/package.json b/package.json index 89cc4f2..bc9457a 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "xlsx": "^0.18.5", "less": "^4.2.0", "less-loader": "^7.3.0", - "whiteboard_lyc": "^0.0.8" + "whiteboard_lyc": "^0.1.3" }, "devDependencies": { "@electron-toolkit/eslint-config": "^1.0.2", diff --git a/src/renderer/src/components/whiteboard/whiteboard.vue b/src/renderer/src/components/whiteboard/whiteboard.vue index 16dfc93..fdd15fc 100644 --- a/src/renderer/src/components/whiteboard/whiteboard.vue +++ b/src/renderer/src/components/whiteboard/whiteboard.vue @@ -60,10 +60,12 @@ {{ type == 'design' ? '形状' : '工具' }} + 正方形 矩形 菱形 三角形 圆形 + 椭圆形 线段 箭头 @@ -397,7 +399,7 @@ const scroll = reactive({ // 切换显示网格 const showGrid = ref(false) // 模式切换 -// const readonly = ref(false) +const readonly = ref(false) // 设置单个元素是否只读 const elReadonly = ref(false) @@ -675,8 +677,8 @@ const getCanvasBase64 = async () =>{ let base64 = await app.exportImage({ type: 'image/jpeg', renderBg: exportRenderBackground.value, - paddingX: 0, - paddingY: 0, + paddingX: 10, + paddingY: 10, onlySelected: exportOnlySelected.value, backgroundColor: '#ffffff' }) diff --git a/src/renderer/src/utils/comm.js b/src/renderer/src/utils/comm.js index 29e7a48..a0d457f 100644 --- a/src/renderer/src/utils/comm.js +++ b/src/renderer/src/utils/comm.js @@ -310,3 +310,44 @@ export function timeToStr(time,str = '时分秒', isPad = false) { if (isPad) return `${h?toStr(h)+arr[0]:''}${m?toStr(m)+arr[1]:''}${toStr(s)}${arr[2]||''}` return `${h?h+arr[0]:''}${m?m+arr[1]:''}${s?s+arr[2]||'':''}` } + +/** + * 防抖:一定时间内,如果函数被连续调用,则只执行最后一次调用。 + * debounce(() => { + console.log('Input event handled'); + }, 300); + * @param {*} func + * @param {*} wait + * @returns + */ +export function debounce(func, wait) { + let timeout; + return function() { + const context = this; + const args = arguments; + clearTimeout(timeout); + timeout = setTimeout(() => func.apply(context, args), wait); + }; +} + +/** + * 节流:一定时间内,函数最多只执行一次 + * throttle(() => { + console.log('Scroll event handled'); + }, 300); + * @param {*} func + * @param {*} wait + * @returns + */ +export function throttle(func, wait) { + let lastTime = 0; + return function() { + const context = this; + const args = arguments; + const now = new Date(); + if (now - lastTime >= wait) { + func.apply(context, args); + lastTime = now; + } + }; +} diff --git a/src/renderer/src/utils/date.js b/src/renderer/src/utils/date.js index 29b0f44..d967f24 100644 --- a/src/renderer/src/utils/date.js +++ b/src/renderer/src/utils/date.js @@ -100,6 +100,17 @@ export const getCurrentTime = (format)=> { if(format == 'MMDD'){ return `${month}${day}`; } + if(format == 'HH'){ + return `${hours}`; + } + if(format == 'HH+3'){ + //往后延时3个小时 + const hours = (now.getHours()+3).toString().padStart(2, '0'); + return `${hours}` + } + if(format == 'mm'){ + return `${minutes}`; + } } /** * diff --git a/src/renderer/src/views/classTask/classTask.vue b/src/renderer/src/views/classTask/classTask.vue index 504d49b..158f202 100644 --- a/src/renderer/src/views/classTask/classTask.vue +++ b/src/renderer/src/views/classTask/classTask.vue @@ -72,6 +72,7 @@ import { getCurrentTime, getTomorrow } from '@/utils/date' import useUserStore from '@/store/modules/user' import useClassTaskStore from "@/store/modules/classTask"; import {sessionStore, createWindow} from '@/utils/tool' +import {throttle,debounce } from '@/utils/comm' const toolState = useToolState(); @@ -377,7 +378,10 @@ const closeDialog = () => { getStudentClassWorkDataPolling() } -const openDialogTime = ref(null);//弹窗 +const debounceOpenWin = debounce(() => { + toolState.isTaskWin=true; // 设置打开批改窗口 + createWindow('open-taskwin',{url:'/teachClassTask'}); // 调用新窗口批改页面 +}, 1000); /** * 开启新批改弹窗 * @param item 作业对象 @@ -385,17 +389,10 @@ const openDialogTime = ref(null);//弹窗 const onClickItem = (item) => { console.log('开启弹窗,关闭作业进度轮询') clearInterval(pollingST.value) - // itemDialogRef.value.openDialog(item) - if(openDialogTime.value) return; - clearTimeout(openDialogTime.value) - openDialogTime.value = setTimeout(() => { - openDialogTime.value = null; - toolState.isTaskWin=true; // 设置打开批改窗口 - sessionStore.set('teachClassWorkItem', item); // 缓存点击的item - // 调用新窗口批改页面 - createWindow('open-taskwin',{url:'/teachClassTask'}) - }, 1000) + console.log('防抖开启弹窗') + sessionStore.set('teachClassWorkItem', item); // 缓存点击的item + debounceOpenWin(); } diff --git a/src/renderer/src/views/classTask/classTaskAssign.vue b/src/renderer/src/views/classTask/classTaskAssign.vue index d5738a9..2de08e4 100644 --- a/src/renderer/src/views/classTask/classTaskAssign.vue +++ b/src/renderer/src/views/classTask/classTaskAssign.vue @@ -92,7 +92,7 @@ - {{scope.row.status == '10'? '推送' : '已推送'}} + {{scope.row.status == '10'? '推送' : '已推送'}} @@ -149,21 +149,103 @@ @click="submitWorkTitle('submit')">确 定 + + + + + + + + + + + + + + + + + + + + + + + {{ item.name }} + + + + + + + + + + + 必做 + 选做 + + + + + + + + + + + + + 点 + 分 + + + + + + + 分钟 + + + + + + + + + + + + + + + + + +