zdg_dev #127

Merged
zhengdegang merged 13 commits from zdg_dev into main 2024-12-12 17:29:44 +08:00
2 changed files with 46 additions and 31 deletions
Showing only changes of commit 80b66ffb28 - Show all commits

View File

@ -208,6 +208,18 @@ const insertImageElement = (files: FileList) => {
// })
}
//
const getTime=()=>{
const now = new Date();
const year = now.getFullYear();
const month = ('0' + (now.getMonth() + 1)).slice(-2);
const day = ('0' + now.getDate()).slice(-2);
const hours = ('0' + now.getHours()).slice(-2);
const minutes = ('0' + now.getMinutes()).slice(-2);
const seconds = ('0' + now.getSeconds()).slice(-2);
return `${year}-${month}-${day}_${hours}:${minutes}:${seconds}`;
};
/**
* base64转图片File
* @param {String} base64 图片base64
@ -234,9 +246,10 @@ const base64ToFile = (base64: string, fileName = '试题图片') => {
// charCodeAt() UTF-16
u8arr[n] = bstr.charCodeAt(n)
}
const filename = fileName+getTime()
// File
// new File(bits, name, options)
const file = new File([u8arr], `${fileName}.${suffix}`, {
const file = new File([u8arr], `${filename}.${suffix}`, {
type: type
})
// file

View File

@ -714,37 +714,39 @@ const closeDialog = () => {
// im
const msgHandle = (msg) => {
const { type, data } = msg
switch(type) {
case MsgEnum.HEADS.MSG_closed: // :
if (typeof msg === 'object'){
const { head, content, ...other } = msg
switch(head) {
case MsgEnum.HEADS.MSG_closed: // :
window.close() //
break
case MsgEnum.HEADS.MSG_finishHomework: // :
const data = JSON.parse(localStorage.getItem('teachClassWorkItem'));
openDialog(data, false);
break
case MsgEnum.HEADS.MSG_slideFlapping: //
window.close() //
break
case MsgEnum.HEADS.MSG_finishHomework: // :
const data = JSON.parse(localStorage.getItem('teachClassWorkItem'));
openDialog(data, false);
break
case MsgEnum.HEADS.MSG_slideFlapping: //
window.close() //
break
// case 'TIMAddRecvNewMsgCallback': // data=[]
// {
// (data||[]).forEach(o => {
// const msgArr = o?.message_elem_array||[]
// msgArr.forEach(info => {
// const msgType = info?.elem_type // TIMElemType
// const msgData = !!info.text_elem_content ? JSON.parse(info.text_elem_content)||'' : ''
// //
// //console.log('msgData->', msgData);
// if (msgData.msgKey == "finishHomework"){
// //
// const data = JSON.parse(localStorage.getItem('teachClassWorkItem'));
// //console.log('data->', data);
// openDialog(data, false);
// }
// })
// })
// }
// break
break
// case 'TIMAddRecvNewMsgCallback': // data=[]
// {
// (data||[]).forEach(o => {
// const msgArr = o?.message_elem_array||[]
// msgArr.forEach(info => {
// const msgType = info?.elem_type // TIMElemType
// const msgData = !!info.text_elem_content ? JSON.parse(info.text_elem_content)||'' : ''
// //
// //console.log('msgData->', msgData);
// if (msgData.msgKey == "finishHomework"){
// //
// const data = JSON.parse(localStorage.getItem('teachClassWorkItem'));
// //console.log('data->', data);
// openDialog(data, false);
// }
// })
// })
// }
// break
}
}
}