diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 55db58d..517a19c 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -10,6 +10,7 @@ module.exports = { ], rules: { 'vue/require-default-prop': 'off', - 'vue/multi-word-component-names': 'off' + 'vue/multi-word-component-names': 'off', + 'prettier/prettier': 'off' } } diff --git a/electron.vite.config.mjs b/electron.vite.config.mjs index c48cc00..d5d6421 100644 --- a/electron.vite.config.mjs +++ b/electron.vite.config.mjs @@ -25,6 +25,7 @@ export default defineConfig({ proxy: { '/dev-api': { target: 'http://27.128.240.72:7865', + // target: 'http://36.134.181.164:7863', // target: 'http://192.168.2.52:7863', changeOrigin: true, rewrite: (p) => p.replace(/^\/dev-api/, '') diff --git a/package.json b/package.json index d5b805b..5e6e438 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,9 @@ "@electron/remote": "^2.1.2", "@element-plus/icons-vue": "^2.3.1", "@vitejs/plugin-vue-jsx": "^4.0.0", + "@vue-office/docx": "^1.6.2", + "@vue-office/excel": "^1.7.11", + "@vue-office/pdf": "^2.0.2", "@vueuse/core": "^10.11.0", "cropperjs": "^1.6.2", "crypto-js": "^4.2.0", @@ -33,6 +36,7 @@ "electron-log": "^5.1.7", "electron-store": "8.0.0", "electron-updater": "^6.1.7", + "element-china-area-data": "^6.1.0", "element-plus": "^2.7.6", "fabric": "^5.3.0", "im_electron_sdk": "^8.0.5904", @@ -65,5 +69,6 @@ "vite-plugin-windicss": "^1.9.3", "vue": "^3.4.30", "windicss": "^3.5.6" - } + }, + "packageManager": "pnpm@9.9.0+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1" } diff --git a/src/renderer/src/api/classManage/index.js b/src/renderer/src/api/classManage/index.js index 14471ee..6b82a81 100644 --- a/src/renderer/src/api/classManage/index.js +++ b/src/renderer/src/api/classManage/index.js @@ -187,3 +187,14 @@ export function getClassInfo(id) { params: {id} }) } +//加入班级 +export function addClasses(data) { + return request({ + url: '/smarttalk/audit/applyAddClass', + method: 'post', + data: data, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + } + }) +} diff --git a/src/renderer/src/api/classTask/index.js b/src/renderer/src/api/classTask/index.js new file mode 100644 index 0000000..cd13685 --- /dev/null +++ b/src/renderer/src/api/classTask/index.js @@ -0,0 +1,49 @@ +// 查询evaluation列表 +import request from '@/utils/request' + +// 查询反馈列表 + +// 查询classworkdata列表 班级作业列表 +export function listClassworkdata(query) { + return request({ + url: '/education/classworkdata/list', + method: 'get', + params: query + }) +} + +// 查询entpcoursework列表 课程作业列表 +export function listEntpcoursework(query) { + return request({ + url: '/education/entpcoursework/list', + method: 'get', + params: query + }) +} + +// 查询classworkeval列表 课堂作业列表 +export function listClassworkeval(query) { + return request({ + url: '/education/classworkeval/list', + method: 'get', + params: query + }) +} + +// 修改classworkeval +export function updateClassworkeval(data) { + return request({ + url: '/education/classworkeval', + method: 'put', + data: data + }) +} + +// 修改classworkdata +export function updateClassworkdata(data) { + return request({ + url: '/education/classworkdata', + method: 'put', + data: data + }) +} diff --git a/src/renderer/src/api/education/entpCourseWork.js b/src/renderer/src/api/education/entpCourseWork.js new file mode 100644 index 0000000..0ba694c --- /dev/null +++ b/src/renderer/src/api/education/entpCourseWork.js @@ -0,0 +1,111 @@ +import request from '@/utils/request' + +// 查询entpcoursework列表 +export function listEntpcoursework(query) { + return request({ + url: '/education/entpcoursework/list', + method: 'get', + params: query + }) +} + +// 查询entpcoursework详细 +export function getEntpcoursework(id) { + return request({ + url: '/education/entpcoursework/' + id, + method: 'get' + }) +} + +// 新增entpcoursework +export function addEntpcoursework(data) { + return request({ + url: '/education/entpcoursework', + method: 'post', + data: data + }) +} + +// 修改entpcoursework +export function updateEntpcoursework(data) { + return request({ + url: '/education/entpcoursework', + method: 'put', + data: data + }) +} + +// 删除entpcoursework +export function delEntpcoursework(id) { + return request({ + url: '/education/entpcoursework/' + id, + method: 'delete' + }) +} + + +// xuekubaoapi +export function xuekubaoAPI(data) { + return request({ + url: '/education/entpcoursework/xuekubaoapi', + method: 'post', + data: data + }) +} + +// PPT文件上传 +export function uploadEntpcourseworkFile(data) { + return request({ + url: '/education/entpcoursework/uploadWord', + method: 'post', + data: data + }) +} + + +// 查询entpcoursework列表 +export function listEntpcourseworkNew(query) { + return request({ + url: '/education/entpcoursework/new/list', + method: 'get', + params: query + }) +} + + +/** + * @desc: 学科网接口api + * @return: {*} + * @param {*} path 请求路径 /xopqbm/questions(无需全拼, 后端学科网sdk自动处理) + * @param {*} method 请求方式 post/get + * @param {*} params 请求参数 {key: value,} + */ +export function xkwAPI(path, method, isPostBody, params) { + return request({ + url: '/xkw/post', + method: 'post', + data: { + path: path, + method: method, + isPostBody: isPostBody, + params: params, + } + }) +} + +/** + * @desc: 图文识别接口 python_OCR_api + * @return: {*} + * @param {*} path 请求路径 /ocrApi/data + * @param {*} method 请求方式 post + * @param {*} params 请求参数 {key: value,} + */ +export function pyOCRAPI(path) { + return request({ + url: '/ocrApi/data', + method: 'post', + data: { + imageBas64: path, + } + }) +} \ No newline at end of file diff --git a/src/renderer/src/api/education/entpcoursefile.js b/src/renderer/src/api/education/entpcoursefile.js new file mode 100644 index 0000000..c6c26c5 --- /dev/null +++ b/src/renderer/src/api/education/entpcoursefile.js @@ -0,0 +1,162 @@ +import request from '@/utils/request' + +// 查询entpcoursefile列表 +export function listEntpcoursefile(query) { + return request({ + url: '/education/entpcoursefile/list', + method: 'get', + params: query + }) +} +// zdg:查询entpcoursefile列表-新 +export function listEntpcoursefileNew(query) { + return request({ + url: '/education/entpcoursefile/new/list', + method: 'get', + params: query + }) +} +// 查询entpcoursefile详细 +export function getEntpcoursefile(id) { + return request({ + url: '/education/entpcoursefile/' + id, + method: 'get' + }) +} + +// 新增entpcoursefile +export function addEntpcoursefile(data) { + return request({ + url: '/education/entpcoursefile', + method: 'post', + data: data + }) +} + +// 新增entpcoursefile +export function addEntpcoursefileReturnId(data) { + return request({ + url: '/education/entpcoursefile/addReturnId', + method: 'post', + data: data + }) +} + + +// addFromId +export function addFromId(fromid, toid, entpid, entpcourseid, edituserid) { + return request({ + url: '/education/entpcoursefile/addFromId/'+fromid+'/'+toid+'/'+entpid+'/'+entpcourseid+'/'+edituserid, + method: 'post' + }) +} + +// 修改entpcoursefile +export function updateEntpcoursefile(data) { + return request({ + url: '/education/entpcoursefile', + method: 'put', + data: data + }) +} +// 新增 修改接口 +export function updateEntpcoursefileNew(data) { + return request({ + url: '/education/entpcoursefile/newUpdateFile', + method: 'post', + data: data + }) +} + +// updateFileByIds +export function updateFileByIds(data) { + return request({ + url: '/education/entpcoursefile/updateFileByIds', + method: 'post', + data: data + }) +} + +// updateFileByArray +export function updateFileByArray(data) { + return request({ + url: '/education/entpcoursefile/updateFileByArray', + method: 'post', + data: data + }) +} + +// 修改entpcoursefile +export function updateFile2Redis(data) { + return request({ + url: '/education/entpcoursefile/updateFile2Redis', + method: 'post', + data: data + }) +} + +// 删除entpcoursefile +export function delEntpcoursefile(id) { + return request({ + url: '/education/entpcoursefile/' + id, + method: 'delete' + }) +} + +// 保存base64图片,返回url +export function saveEntpCourseBase64File(data) { + return request({ + url: '/education/entpcoursefile/saveBase64File', + method: 'post', + data: data + }) +} + + +// 文件上传 +export function saveEntpCourseBase64File2(data) { + return request({ + url: '/education/entpcoursefile/saveBase64File2', + method: 'post', + data: data + }) +} + +// 保存PPT页面预览base64图片,返回url +export function savePPTPreviewBase64File(data) { + return request({ + url: '/education/entpcoursefile/savePreviewBase64', + method: 'post', + data: data + }) +} + + +// PPT文件上传 +export function saveEntpCoursePPT(data) { + return request({ + url: '/education/entpcoursefile/importPPT', + method: 'post', + data: data + }) +} + +// PPT文件解析 +export function parsePPT(data) { + return request({ + url: '/education/entpcoursefile/parsePPT', + method: 'post', + data: data + }) +} + + +// 修改ppt.slide.index +export function updateSlideIndex(data) { + return request({ + url: '/education/entpcoursefile/saveSlideOrder', + method: 'post', + data: data + }) +} + diff --git a/src/renderer/src/api/file/index.js b/src/renderer/src/api/file/index.js index 5bfe721..e655614 100644 --- a/src/renderer/src/api/file/index.js +++ b/src/renderer/src/api/file/index.js @@ -9,6 +9,14 @@ export const getSmarttalkPage = (params) => { }) } +export const creatAPT = (params) => { + return request({ + url: '/smarttalk/file/createApt', + method: 'post', + params + }) +} + export const getPrepareById = (id) => { return request({ url: '/smarttalk/file/' + id, diff --git a/src/renderer/src/api/login.js b/src/renderer/src/api/login.js index 649f59c..308e95c 100644 --- a/src/renderer/src/api/login.js +++ b/src/renderer/src/api/login.js @@ -56,4 +56,68 @@ export function getCodeImg() { method: 'get', timeout: 20000 }) +} + +// 注册模块-生成人机验证 +export function captchaImg(data) { + return request({ + url: '/captchaImg', + headers: { + isToken: false + }, + method: 'get', + params: data + }) +} + +//注册模块-发送验证码 +export function sendCode(data) { + return request({ + url: '/smarttalk/register/authSendCode', + method: 'post', + data:data + }) +} + +//注册模块-申请注册 +export function signIn(data) { + return request({ + url: '/smarttalk/register/authSignIn', + method: 'post', + data:data + }) +} + +//注册模块-获取学校 +export function deptTree(data) { + return request({ + url: '/smarttalk/register/authDeptTree', + method: 'get', + params:data + }) +} +// 查询部门详细 +export function getDept(query) { + return request({ + url: '/system/dept/detail', + method: 'get', + params: query + }) +} + +// 查询classmain列表 +export function listClassmain(query) { + return request({ + url: '/education/classmain/list', + method: 'get', + params: query + }) +} +// 查询evaluation列表 +export function listEvaluation(query) { + return request({ + url: '/smarttalk/register/authEvaluationList', + method: 'get', + params: query + }) } \ No newline at end of file diff --git a/src/renderer/src/assets/styles/JYStyle.css b/src/renderer/src/assets/styles/JYStyle.css new file mode 100644 index 0000000..f44e280 --- /dev/null +++ b/src/renderer/src/assets/styles/JYStyle.css @@ -0,0 +1,99 @@ +body{font-family: "微软雅黑", Arial,"宋体"; color: #333;} +a{ text-decoration: none; color: #2489f6;} +dl, ul, ol, ul { list-style: none; padding: 0; margin: 0; } +.wrapper{ width: 1200px; margin: 0 auto; } +.ques-detail{} +.ques-detail ul li{margin-bottom: 20px;border: 1px solid #dadada;background: #fff;border-radius: 10px;} +.ques-detail ul li:last-child{ margin-bottom: 0; } + +table.edittable{ border-collapse: collapse; text-align: center; margin: 2px; } +table.edittable th, table.edittable td{ line-height: 30px; padding: 5px; white-space: normal; word-break: break-all; border: 1px solid #000; vertical-align: middle; } +table.composition{ border-collapse: collapse; text-align: left; margin: 2px; width: 98%; } +table.composition th, table.composition td{ line-height: 30px; white-space: normal; word-break: break-all; border-width: 0px; vertical-align: middle; } +table.composition2{ border-collapse: collapse;width:auto } +table.composition2 th, table.composition2 td{text-align:left;line-height:30px; white-space:normal;word-break:break-all;border:none;border-width: 0px;vertical-align: middle; } +.MathJye{ border: 0 none; direction: ltr; line-height: normal; display: inline-block; float: none; font-family: 'Times New Roman','宋体'; font-size: 15px; font-style: normal; font-weight: normal; letter-spacing: 1px; line-height: normal; margin: 0; padding: 0; text-align: left; text-indent: 0; text-transform: none; white-space: nowrap; word-spacing: normal; word-wrap: normal; -webkit-text-size-adjust: none; } +.MathJye div, .MathJye span{ border: 0 none; margin: 0; padding: 0; line-height: normal; text-align: left; height: auto; _height: auto; white-space: normal; } +.MathJye table{ border-collapse: collapse; margin: 0; padding: 0; text-align: center; vertical-align: middle; line-height: normal; font-size: inherit; *font-size: 100%; _font-size: 100%; font-style: normal; font-weight: normal; border: 0; float: none; display: inline-block; *display: inline; zoom: 0; } +.MathJye table td{ padding: 0; font-size: inherit; line-height: normal; white-space: nowrap; border: 0 none; width: auto; _height: auto; } +.MathJye_mi{ font-style: italic; } +.flipv{-ms-transform: scaleX(-1);-moz-transform: scaleX(-1);-webkit-transform: scaleX(-1);-o-transform: scaleX(-1);transform: scaleX(-1);filter: FlipH;} +.fliph{-ms-transform: scaleY(-1);-moz-transform: scaleY(-1);-webkit-transform: scaleY(-1);-o-transform: scaleY(-1);transform: scaleY(-1);filter: FlipV;} +.mathjye-bold{font-weight:800} +.mathjye-del{text-decoration:line-through} +.mathjye-underline{border-bottom:1px solid #000;padding-bottom:2px;} +@-moz-document url-prefix() {.mathjye-underline{padding-bottom:0px;}} +.mathjye-underpline{border-bottom:2px dotted #000; padding-bottom:3px;} +@-moz-document url-prefix() {.mathjye-underpline {padding-bottom:1px;}} +.mathjye-underpoint{background: url(http://img.jyeoo.net/images/formula/point.png) no-repeat center bottom; padding-bottom:4px;} +.mathjye-underpoint2{border-bottom:2px dotted #000; padding-bottom:3px;} +@-moz-document url-prefix() {.mathjye-underpoint{padding-bottom:1px;}} +.mathjye-underwave{background: url(http://img.jyeoo.net/images/formula/wave.png) bottom repeat-x; padding-bottom:4px;} +@-moz-document url-prefix() {.mathjye-underwave {padding-bottom:1px;}} +.mathjye-alignleft{display:block;text-align:left;} +.mathjye-aligncenter{display:block;text-align:center;} +.mathjye-alignright{display:block;text-align:right;} + + +/*试题*/ +.artpreview fieldset { padding-top: 10px; font-size: 14px; clear: both; overflow: hidden; zoom: 1; line-height: 24px; font-family: 'Times New Roman',宋体,sans-serif; position: relative; } +.artpreview fieldset legend { padding: 5px 0; display: block; margin: 5px; background: #f1f1f1; color: #000; overflow: hidden; zoom: 1; } +.queserror { border: 1px dotted #f00; padding: 2px; } +fieldset.quesborder {display: block;padding: 0;line-height: 25px;letter-spacing: 1px;word-break: break-all;margin: 0;} +fieldset.queserror { border: 1px solid #f00; font-size: 12px; padding: 2px; margin-bottom: 1px; } +fieldset.quesborder td, fieldset.queserror td { line-height: 16px; } +fieldset.quesborder em, fieldset.queserror em { font-style: normal; font-weight: bold; position: absolute; left: 20px; } +fieldset.thiserror1 { border: 1px solid #f00; } +fieldset.thiserror1 legend { border: 4px solid #f00; } +fieldset.thiserror2 { border: 1px solid #ADCD3C; } +fieldset.thiserror2 legend { border: 4px solid #ADCD3C; } +fieldset.thisques { border: 1px solid blue; } +fieldset.thison { border: 1px solid #A9C9E2; } +fieldset.thison div.border { border: 1px solid #ADCD3C; background-color: #F2FDDB; } +fieldset, img { border: 0 none; } +table.thison { border: 1px solid #00F; } +table.thiserr { border: 1px solid #F00; } +fieldset.thisvip1 { border: 1px solid #00F; } +fieldset.thisvip1 legend { border: 4px solid #00F; } +fieldset.status17 { border: 1px solid #ff00ff; } +fieldset.status17 legend { border: 4px solid #ff00ff; } +.selectoption { vertical-align: middle; font-size: 14px; padding: 2px; } +.selectoption:hover { color: #EA8511; } +.selectoption label { padding: 4px; line-height: 24px; } +fieldset.quesbordere { border: 2px dotted #f00; } +.answer { border: 1px dotted #ffffff; } +ol.answer li, ul.answer li { padding: 1px; font-size: 14px; } +ol.answer li:hover { background: #f2f2f2; } +.collapseContainerPanel { border: 0; } +.collapsePanelHeader { height: 30px; font-weight: bold; padding: 6px 0 0 0; } +.collapseHeaderContent { float: left; padding-left: 5px; } +.collapseContent { margin: 0; padding: 0; border: 1px solid #ccc; border-top: 0; } +.pt0 { padding: 2px 0 5px 0; font-size: 14px; font-family: "黑体",sans-serif; font-weight: 700; } +.pt1 {overflow: hidden;zoom: 1;clear: both;line-height: 25px;font-size: 14px;padding: 20px;position: relative;word-break: break-word;} +fieldset.quesborder .pt1 em { position: static; } +.pt1 img { position: relative; } +.pt2 {padding: 20px;padding-top: 0;} +.pt3, .pt4, .pt5, .pt6, .pt7 { clear: both; zoom: 1; position: relative; padding: 0px 20px 20px 80px; } +.pt8 a:link, .pt8 a:visited { margin-right: 10px; padding: 2px 5px; } +.pt8 a:hover { background: #fc0; } +.pt9 { padding: 20px; border: 0 none; color: #999999; font-size: 12px; } +.fieldtip {height: 36px;line-height: 36px;background-color: #f4f4f4;border-top: 1px solid #dadada;padding: 0 20px;color: #666666;position: relative;font-size: 12px;border-radius: 0 0 10px 10px;} +.newFieldtip .pt1, .newFieldtip .pt2, .newFieldtip .pt3, .newFieldtip .pt4, .newFieldtip .pt5, .newFieldtip .pt6, .newFieldtip .pt7, .newFieldtip .pt8, .newFieldtip.pt9, .newFieldtip + .fieldtip { padding: 0; } +fieldset img { max-width: 100%; } + +.fieldtip-left {float: left;} +.fieldtip-left >* {margin-right: 20px;} +.fieldtip-right { float: right; } +.fieldtip-right>* { margin-left: 20px; display: inline-block; color: #666666; } +.fieldtip .btn {display: inline-block;margin-bottom: 0;font-weight: normal;text-align: center;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;background-image: none;border: 1px solid transparent;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;font-size: 14px;border-radius: 4px;color: #ffffff;background-color: #ff8a00;line-height: 18px;min-width: 28px;padding: 0 5px;} +.fieldtip .btn:hover, .fieldtip .btn:active, .fieldtip .btn:active:hover, .fieldtip .btn:hover { color: #ffffff; background-color: #faad4a; } + +/*填空题*/ +div.quizPutTag { display: inline-block; *display: inline; padding: 3px 10px 1px 10px; margin: 0 3px; font-size: 14px; min-width: 1em; min-height: 16px; line-height: 18px; height: auto; border-bottom: 1px solid #0033FF; text-decoration: none; zoom: 1; color: #127176; word-break: break-all; } +div.quizPutTag:hover { color: #f60; } +div.quizPutTag img { cursor: pointer; width: 200px; margin-left: 10px; } +.sanwser { padding: 4px 10px; margin: 0px; border: 1px solid #ADCD3C; background-color: #F2FDDB; color: #000; display: none; } +/*答案*/ +.selectoption label.s, div.s { border: 1px solid #91cbed; background-color: #deeeff; display: inline-block; } +.selectoption label.s.sh, div.s.sh { margin: 1px; border: none; background: none; } +del { text-decoration: none; color: #f00; font-style: normal; font-weight: normal; } \ No newline at end of file diff --git a/src/renderer/src/components/file-preview/index.vue b/src/renderer/src/components/file-preview/index.vue index 198f9b4..9b2326d 100644 --- a/src/renderer/src/components/file-preview/index.vue +++ b/src/renderer/src/components/file-preview/index.vue @@ -1,5 +1,5 @@ + + + + diff --git a/src/renderer/src/components/refile-preview/types.ts b/src/renderer/src/components/refile-preview/types.ts new file mode 100644 index 0000000..167bbff --- /dev/null +++ b/src/renderer/src/components/refile-preview/types.ts @@ -0,0 +1,7 @@ +export interface FileProps { + id?: number; + type?: string; + fileType?: string; + raw?: File; + filePath?: string; +} diff --git a/src/renderer/src/components/refile-preview/useReadFile.ts b/src/renderer/src/components/refile-preview/useReadFile.ts new file mode 100644 index 0000000..d93e785 --- /dev/null +++ b/src/renderer/src/components/refile-preview/useReadFile.ts @@ -0,0 +1,261 @@ +import type { FileProps } from "@/components/refile-preview/types"; +import { onUnmounted, ref } from "vue"; +import axios from "axios"; + +export function useHooks(props: FileProps) { + const excelOptions = { + xls: props.fileType !== "xlsx", //预览xlsx文件设为false;预览xls文件设为true + minColLength: 0, // excel最少渲染多少列,如果想实现xlsx文件内容有几列,就渲染几列,可以将此值设置为0. + minRowLength: 0, // excel最少渲染多少行,如果想实现根据xlsx实际函数渲染,可以将此值设置为0. + widthOffset: 10, //如果渲染出来的结果感觉单元格宽度不够,可以在默认渲染的列表宽度上再加 Npx宽 + heightOffset: 10, //在默认渲染的列表高度上再加 Npx高 + beforeTransformData: workbookData => { + return workbookData; + }, //底层通过exceljs获取excel文件内容,通过该钩子函数,可以对获取的excel文件内容进行修改,比如某个单元格的数据显示不正确,可以在此自行修改每个单元格的value值。 + transformData: workbookData => { + return workbookData; + } //将获取到的excel数据进行处理之后且渲染到页面之前,可通过transformData对即将渲染的数据及样式进行修改,此时每个单元格的text值就是即将渲染到页面上的内容 + }; + const src = ref(); + const filePreviewRef = ref(); + /** + * 渲染完成 + */ + const renderedHandler = () => { + console.log("渲染完成"); + }; + /** + * 渲染失败 + * @param e + */ + const errorHandler = e => { + console.log("渲染失败", e); + }; + + /** + * 渲染文件 + */ + async function renderTheFile() { + if (props.type === "local") { + console.log("本地文件" + props.fileType); + isImage(props.fileType) && localImagePreview(props.raw); + isDoc(props.fileType) && localOfficePreview(props.raw); + isText(props.fileType) && localTextPreview(props.raw); + isVideo(props.fileType) && localVideoPreview(props.raw); + isAudio(props.fileType) && localAudioPreview(props.raw); + } else { + if (isVideo(props.fileType)) { + src.value = + import.meta.env.VITE_APP_BASE_URL + + "/upload/attachments/getTeamOfVideo?id=" + + props.id; + return; + } + if (isText(props.fileType)) { + const response = await axios.get( + import.meta.env.VITE_STATIC_URL + props.filePath, + { + responseType: "text" + } + ); + src.value = response.data; + return; + } + src.value = import.meta.env.VITE_STATIC_URL + props.filePath; + } + } + + /** + * 校验图片类型 + * @param type + */ + function isImage(type: string) { + const types = [ + "jpg", + "png", + "gif", + "jpeg", + "bmp", + "webp", + "svg", + "tiff", + "tif", + "jpeg", + "jfif", + "pjpeg", + "pjp" + ]; + return types.includes(type); + } + + /** + * 校验文档类型 + * @param type + */ + function isDoc(type: string) { + const types = ["docx", "doc", "xlsx", "xls", "pdf"]; + return types.includes(type); + } + + /** + * 校验文本类型 + * @param type + */ + function isText(type: string) { + const types = [ + "txt", + "md", + "log", + "json", + "xml", + "html", + "css", + "js", + "java", + "c", + "cpp", + "h", + "hpp", + "py", + "rb", + "go", + "sh", + "bat", + "ps1", + "psm1", + "ps1xml", + "psc1", + "psd1", + "psm1", + "ps1xml", + "psc1", + "psd1", + "ps1xml", + "psc1", + "ps1xml", + "psc1", + "psd1" + ]; + return types.includes(type); + } + + // 检验视频格式 + function isVideo(type: string) { + const types = [ + "mp4", + "avi", + "rmvb", + "mkv", + "flv", + "wmv", + "mov", + "webm", + "m4v", + "mpg", + "mpeg", + "3gp", + "3g2", + "vob", + "ogv", + "ogg", + "mts", + "m2ts", + "ts", + "m2v", + "mpe", + "mpv", + "m4p", + "m4v", + "mpv2", + "m4v", + "m4p", + "m4v", + "m4p" + ]; + return types.includes(type); + } + + // 检验音频文件 + function isAudio(type: string) { + const types = ["mp3", "wav", "ogg", "flac", "aac", "wma", "m4a", "wma"]; + return types.includes(type); + } + + /** + * 预览本地Office文件 + * @param file + */ + function localOfficePreview(file: File) { + const reader = new FileReader(); + reader.readAsArrayBuffer(file); + reader.onload = loadEvent => { + const arrayBuffer = loadEvent.target.result; + const blob = new Blob([arrayBuffer], { + type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" + }); + src.value = URL.createObjectURL(blob); + }; + } + + /** + * 预览本地图片 + * @param file + */ + function localImagePreview(file: File) { + const reader = new FileReader(); + reader.onload = e => { + src.value = e.target.result; + }; + reader.readAsDataURL(file); + } + + /** + * 预览本地文本 + * @param file + */ + function localTextPreview(file: File) { + const reader = new FileReader(); + reader.onload = e => { + src.value = e.target.result; + }; + reader.readAsText(file); + } + + /** + * 预览本地视频 + * @param file + */ + function localVideoPreview(file: File) { + src.value = URL.createObjectURL(file); + } + + function localAudioPreview(file: File) { + const reader = new FileReader(); + reader.onloadend = () => { + const blob = new Blob([reader.result], { type: "audio/mpeg" }); + src.value = URL.createObjectURL(blob); + }; + reader.readAsArrayBuffer(file); + } + + // 清理工作:当组件卸载时释放URL对象 + onUnmounted(() => { + if (src.value) { + isVideo(props.fileType) && URL.revokeObjectURL(src.value); + isAudio(props.fileType) && URL.revokeObjectURL(src.value); + } + }); + return { + excelOptions, + src, + filePreviewRef, + isImage, + renderedHandler, + errorHandler, + renderTheFile, + isVideo, + isText, + isAudio + }; +} + diff --git a/src/renderer/src/hooks/useProcessList.js b/src/renderer/src/hooks/useProcessList.js new file mode 100644 index 0000000..d53f73e --- /dev/null +++ b/src/renderer/src/hooks/useProcessList.js @@ -0,0 +1,514 @@ +export const isJson = (str) => { + if (typeof str == 'string') { + try { + let obj = JSON.parse(str) + if (typeof obj == 'object' && obj) { + return true + } else { + return false + } + } catch (e) { + return false + } + } +} + +/** + * @description processList 格式化试题 + * @param {*} row + */ +export const processList = (row) => { + for (var i = 0; i < row.length; i++) { + if (isJson(row[i].workanalysis)) { + //1、先默认格式化 格式化各项内容(待优化, 后续界面显示的为format的值) + row[i].titleFormat = row[i].title // 题目 + row[i].examdateFormat = row[i].examdate // ?考试日期 eg: 2024-07-11 14:39:27" + row[i].workdescFormat = row[i].workdesc // 题目选项 + row[i].workanswerFormat = row[i].workanswer // 题目正确答案 + if (row[i].workanswerFormat == null || row[i].workanswerFormat == '') { + row[i].workanswerFormat = '见试题解答内容' + } + + // workanalysis 解析内容(analyse:解答; method:分析; discuss:点评; ) + var jjj = JSON.parse(row[i].workanalysis) + row[i].analyse = jjj.analyse + row[i].method = jjj.method + row[i].discuss = jjj.discuss + //row[i].discusscollapse = false; + if (row[i].examdate !== null && row[i].examdate !== undefined) { + row[i].examdate = row[i].examdate.substring(0, 10) + } + + // 具体题型数据结构处理 + if (row[i].worktype == '复合题') { + // 旧类型 + if (row[i].title.indexOf('!@#$%') !== -1) { + // 1.选项解析替换 + const options = JSON.parse(row[i].workdesc) + // 题目(背景材料+复合题目) + const bjTitle = row[i].title.split('!@#$%')[0] + const tmTitles = row[i].title.split('!@#$%').filter((it, ix) => ix > 0) + // console.log(bjTitle,'背景标题'); + // console.log(tmTitles,'复合题目'); + let titls = [] + options.forEach((element, index1) => { + const workDescArr = element.split('#&') + let tmp = '' + let j = 0 + for (; j < workDescArr.length; j++) { + if (j % 2 == 0) { + tmp += `
` + } + const char = String.fromCharCode(65 + j) + tmp += `
${char}.${workDescArr[j]}
` + if (j % 2 == 1) { + tmp += '
' + } + } + // j此刻已自增1, 故当选项为单数时, 需要补充结束标签 + if (j % 2 == 1) { + tmp += '' + } + + // workDescArr为 [''] 表示为 判断题或者填空题,这里不需要选项 + if (workDescArr[0] != '') { + titls.splice(index1, 1, tmp) + } else { + titls.splice(index1, 1, '') + } + }) + const s = [] + tmTitles.map((it, ix) => { + s.push(it) + titls.map((it2, ix2) => { + if (ix == ix2) { + s.push(it2) + } + }) + }) + // console.log(s,'?????????????????') + + row[i].titleFormat = bjTitle + s.join('') + row[i].workdescFormat = '' + + //2.答案 - 数字转为ABCD + const answerArr = JSON.parse(row[i].workanswer) + let indexLabel = 1 + let arr = [] + answerArr.forEach((item) => { + const arrTmp = item.answer.split('#&') + let value = `(${indexLabel})` + arrTmp.forEach((element, i) => { + if (item.type == '单选题' || item.type == '多选题') { + value += `${String.fromCharCode(65 + Number(element))}` + } + if (item.type == '判断题' || item.type == '填空题') { + // 去除下 html标签 + value += `${element.replace(/<[^>]+>/g, '')}` + (i == arrTmp.length - 1 ? '' : '、') + } + if (item.type == '主观题') { + if (element) { + console.log(element, 'element') + value += item.answer + } else { + value += '答案不唯一,请参考分析解答点评!' + } + } + }) + arr.push(value) + indexLabel++ + }) + const answer = arr.join('
') + + row[i].workanswerFormat = answer + } else { + // 处理[题干显示] - 不再需要处理 + // row[i].titleFormat = row[i].title; // 仅占位提示 + + /** + * 处理[选项显示] - 特殊结构 + * [ + * {type: '单选题', title: '题目1', options: ['ABC123','ABC123']}, + * {type: '多选题', title: '题目1', options: ['ABC123','ABC123']}, + * {type: '填空题', title: '题目1', options: []}, + * {type: '判断题', title: '题目1', options: []}, + * {type: '主观题', title: '题目1', options: []}, + * ] + */ + let workDescArr = JSON.parse(row[i].workdesc) + let workDescHtml = `
${index + 1}. ${item.title}
` + let tmp = '' + let j = 0 + let optionsArr = item.options + for (; j < optionsArr.length; j++) { + if (j % 2 == 0) { + tmp += `
` + } + const char = String.fromCharCode(65 + j) + tmp += `
${char}.${optionsArr[j]}
` + if (j % 2 == 1) { + tmp += '
' + } + } + // j此刻已自增1, 故当选项为单数时, 需要补充结束标签 + if (j % 2 == 1) { + tmp += '' + } + + workDescHtml += tmp + } else if (item.type == '填空题' || item.type == '判断题' || item.type == '主观题') { + workDescHtml += `
${index + 1}. ${item.title}
` + } + }) + workDescHtml += '' + row[i].workdescFormat = workDescHtml + + /** + * 处理[答案显示] - 特殊结构 + * [ + * {type: '单选题', answer: ['0']}, + * {type: '多选题', answer: ['0','1']}, + * {type: '填空题', answer: ['填空1','填空2']}, + * {type: '判断题', answer: ['0'/'1']}, + * {type: '主观题', answer: [xxxx]}, + * ] + */ + let workAnswerArr = JSON.parse(row[i].workanswer) + let workAnswerHtml = `` + workAnswerArr.map((item, index) => { + const answerArr = item.answer //JSON.parse(item.answer); + if (item.type == '单选题' || item.type == '多选题') { + const answer = answerArr + .map((item) => { + return String.fromCharCode(65 + Number(item)) + }) + .join('') + workAnswerHtml += `
${index + 1}. ${answer}
` + } else if (item.type == '填空题') { + const answer = answerArr.join('、') + workAnswerHtml += `
${index + 1}. ${answer}
` + } else if (item.type == '判断题') { + const answer = answerArr + .map((item) => { + return item === '1' ? '正确' : '错误' + }) + .join('、') + workAnswerHtml += `
${index + 1}. ${answer}
` + } else if (item.type == '主观题') { + // 复合题里面的主观题只有一个答案,或没填 + const answer = answerArr.join('、') + if (answerArr[0]) { + workAnswerHtml += `
${index + 1}. ${answer}
` + } else { + workAnswerHtml += `
${index + 1}. ${answer}答案不唯一,请参考分析解答点评!
` + } + } + }) + row[i].workanswerFormat = workAnswerHtml + } + } else if ( + row[i].worktype == '主观题' || + (row[i].worktype !== '单选题' && + row[i].worktype !== '多选题' && + row[i].worktype !== '填空题' && + row[i].worktype !== '判断题') + ) { + // 处理[选项显示] - 主观题中无选项, 故置空 + row[i].workdescFormat = '' + row[i].workanswerFormat = '' + // 答案处理- eg: "\"不唯一的答案,参考\"" + if (row[i].workanswer && row[i].workanswer != '') { + row[i].workanswerFormat = JSON.parse(row[i].workanswer) + } + } else { + // 单选题|多选题|填空题|判断题|主观题?(待确认是否归在这里) + // 通用选项结构 ['ABC123','ABC123'] | ['ABC123','ABC123'] | [](填空题无选项) | [](判断题无选项) + let workDescArr = [] + if ( + row[i].workdesc.charAt(0) === '[' && + row[i].workdesc.charAt(row[i].workdesc.length - 1) === ']' + ) { + //123会直接被转换, 且不是数组对象, 故手动判断是否有[和]两个字符 + workDescArr = JSON.parse(row[i].workdesc) + } else if (row[i].workdesc.indexOf('#&') !== -1) { + workDescArr = row[i].workdesc.split('#&') + } else if (row[i].workdesc.indexOf(',') !== -1) { + workDescArr = row[i].workdesc.split(',') + } else { + // 单字符串直接添加至空数组(待考虑确认) + workDescArr.push(row[i].workdesc) + } + + // 单选题|多选题|填空题|判断题|主观题?(待确认是否归在这里) + // 通用答案结构 ['0'] | ['0','1'] | ['填空1','填空2'] | ['0'/'1'] + let workAnswerArr = [] + if ( + row[i].workanswer.charAt(0) === '[' && + row[i].workanswer.charAt(row[i].workanswer.length - 1) === ']' + ) { + // 123会直接被转换, 且不是数组对象, 故手动判断是否有[和]两个字符 + workAnswerArr = JSON.parse(row[i].workanswer) + } else if (row[i].workanswer.indexOf('#&') !== -1) { + workAnswerArr = row[i].workanswer.split('#&') + } else if (row[i].workanswer.indexOf(',') !== -1) { + workAnswerArr = row[i].workanswer.split(',') + } else { + // 单字符串直接添加至空数组(待考虑确认) + workAnswerArr.push(row[i].workanswer) + } + + // 具体题型处理 + if (row[i].worktype == '单选题' || row[i].worktype == '多选题') { + // 处理[选项显示] - 拼接ABCD首序号 + let tmp = '' + let j = 0 + for (; j < workDescArr.length; j++) { + if (j % 2 == 0) { + tmp += `
` + } + const char = String.fromCharCode(65 + j) + tmp += `
${char}.${workDescArr[j]}
` + if (j % 2 == 1) { + tmp += '
' + } + } + if (j % 2 == 0) { + tmp += '' + } + row[i].workdescFormat = tmp + + // 处理[答案显示] - 转换ABCD + let arr2Char = workAnswerArr + .map((item) => { + return String.fromCharCode(65 + Number(item)) + }) + .join('') + row[i].workanswerFormat = arr2Char + } else if (row[i].worktype == '填空题') { + // 处理[选项显示] - 填空题中无选项, 故置空 + row[i].workdescFormat = '' + + // 处理[答案显示] - 逗号连接 + row[i].workanswerFormat = workAnswerArr.join('、') + } else if (row[i].worktype == '判断题') { + // 处理[选项显示] - 判断题中无选项, 故置空 + row[i].workdescFormat = '' + + // 处理[答案显示] - 1-正常 0-错误 + const answer = workAnswerArr + .map((item) => { + return item === '1' ? '正确' : '错误' + }) + .join('、') + row[i].workanswerFormat = answer + } + } + + /* + //2、处理单选题 + if(row[i].worktype == '单选题' || row[i].worktype == '多选题' ){ + //1.选项前增加ABCD workdesc: "①②#&①③#&②④#&③④" || "
为了活着
#&
为了填报肚子
#&
为了吃饭而吃饭
" + let workDescArr = []; + if(row[i].workdesc.indexOf('[')!==-1 && row[i].workdesc.indexOf(']')!==-1) { + //123会直接被转换, 且不是数组对象, 故手动判断是否有[和]两个字符 + workDescArr = JSON.parse(row[i].workdesc); + } + else if(row[i].workdesc.indexOf('#&')) { + workDescArr = row[i].workdesc.split('#&'); + } + else if(row[i].workdesc.indexOf(',')){ + workDescArr = row[i].workdesc.split(','); + } + else { + // 待考虑 + workDescArr.push(item.workdesc) + } + + + + //2.答案 - 数字转为ABCD + if(row[i].worktype == '单选题') { + const str2Char = String.fromCharCode(65+Number(row[i].workanswer)); + row[i].workanswerFormat = str2Char; + } else if (row[i].worktype == '多选题') { + const answerArr = row[i].workanswer.split('#&'); + let arr2Char = ''; + for(let k=0; k]*>/g, "").split('#&'),'????') + // 填空题答案 + row[i].workanswerFormat = row[i].workanswer.replace(/#&/g,", "); + // 填空选项不需要展示, + row[i].workdescFormat = ''; + } + else if(row[i].worktype == '判断题'){ + // console.log(row[i].workanswer.replace(/<[^>]*>/g, "").split('#&'),'????') + // 判断题答案 + row[i].workanswerFormat = row[i].workanswer.replace(/#&/g,", "); + // 判断选项不需要展示, + row[i].workdescFormat = ''; + } + else if(row[i].worktype == '复合题') { + // 1.选项解析替换 + const options = JSON.parse(row[i].workdesc); + // 题目(背景材料+复合题目) + const bjTitle = row[i].title.split('!@#$%')[0]; + const tmTitles = row[i].title.split('!@#$%').filter((it,ix)=>ix>0); + // console.log(bjTitle,'背景标题'); + // console.log(tmTitles,'复合题目'); + let titls = []; + options.forEach((element,index1) => { + const workDescArr = element.split('#&'); + let tmp = ''; + let j=0; + for(; j`; + } + const char = String.fromCharCode(65+j); + tmp += `
${char}.${jsonArr[j]}
`; + if(j%2 == 1){ + tmp += ''; + } + } + + if(j%2== 0){ + tmp += ''; + } + workdesc = tmp; + } + + row[i].workdescFormat = workdesc; // 题目选项 + + + // 答案处理 + let workanswer = ''; + if(row[i].workanswer && row[i].workanswer != '') { + // 因答案内容存在多种格式: 1.["123","1234"] 2.123#&1234 3.123 + if(row[i].workanswer.indexOf('[')!==-1 && row[i].workanswer.indexOf(']')!==-1) { + //123会直接被转换, 且不是数组对象, 故手动判断是否有[和]两个字符 + let json = JSON.parse(row[i].workanswer); + // 单选、多选 需要 数字转为ABCD + if(row[i].worktype == '单选题') { + const str2Char = String.fromCharCode(65+Number(json[0])); + workanswer = str2Char; + } else if (row[i].worktype == '多选题') { + // const answerArr = row[i].workanswer.split('#&'); + let arr2Char = ''; + for(let k=0; k'; + } + workanswer = arr2Char; + row[i].titleFormat = row[i].titleFormat.replace(/!@#\$%/g, ''); + } else { + workanswer = json.join('、'); + } + } else if(row[i].workanswer.indexOf('#&')) { + // 意味着多个答案或者填空内容 + let workanswerList = row[i].workanswer.split('#&'); + if(row[i].worktype == '多选题') { + // 数字转为ABCD + let arr2Char = ''; + for(let k=0; k { + const arrTmp = item.answer.split('#&'); + let value = `(${indexLabel})`; + arrTmp.forEach((element,i) => { + if(item.type == '单选题' || item.type == '多选题'){ + value += `${String.fromCharCode(65+Number(element))}`; + } + if(item.type == '判断题' || item.type == '填空题'){ + // 去除下 html标签 + value += `${element.replace(/<[^>]+>/g, '')}`+ (i==arrTmp.length-1?'':'、'); + } + }) + arr.push(value); + indexLabel++; + }) + const answer = arr.join('
'); + + row[i].workanswerFormat = answer; + } + else if(row[i].worktype == '主观题') { + // 1.选项解析替换---主观题没选项 + // 题目(背景材料+主观题目) + const bjTitle = row[i].title.split('!@#$%')[0]; + const tmTitles = row[i].title.split('!@#$%').filter((it,ix)=>ix>0); + // console.log(bjTitle,'背景标题'); + // console.log(tmTitles,'主观题目'); + let titls = []; + const s = []; + tmTitles.map((it,ix)=>{ + s.push(it); + }) + // console.log(s,'?????????????????') + + row[i].titleFormat = bjTitle + s.join(''); + // 填空选项不需要展示, + row[i].workdescFormat = ''; + + //2.答案 + // 填空题答案 + const workanswerList = JSON.parse(row[i].workanswer); + let tmp=''; + workanswerList&&workanswerList.map((item,index)=>{ + tmp += '
'+(index+1)+'.'+item.replace(/#&/g, ',')+'
'; + }) + row[i].workanswerFormat = tmp; + + } + else { + //处理答案 + row[i].workanswerFormat = '见试题解答内容'; + } + */ + } + } +} diff --git a/src/renderer/src/layout/components/AppMain.vue b/src/renderer/src/layout/components/AppMain.vue index d9e0681..5e4720d 100644 --- a/src/renderer/src/layout/components/AppMain.vue +++ b/src/renderer/src/layout/components/AppMain.vue @@ -72,8 +72,9 @@ const title = reactive([ child1: [] }, { - name: '高考研究', - url: '/education/colentrance', + name: '考试分析', + url: '/examReport', + type: 'hash', img: 'iconfont icon-icon_kaoshifenxi', child1: [] } diff --git a/src/renderer/src/layout/components/Header.vue b/src/renderer/src/layout/components/Header.vue index 1111510..8501952 100644 --- a/src/renderer/src/layout/components/Header.vue +++ b/src/renderer/src/layout/components/Header.vue @@ -87,7 +87,7 @@ const handleOutLink = (path, type, name) => { fullPath = fullPath.replaceAll('//', '/') const { levelFirstId, levelSecondId } = JSON.parse(localStorage.getItem('unitId')) let unitId = levelSecondId ? levelSecondId :levelFirstId - if(name == '教材分析' || name == '高考研究'){ + if(name == '教材分析' || name == '考试分析'){ fullPath += `?unitId=${unitId}` } // 通知主进程 diff --git a/src/renderer/src/main.js b/src/renderer/src/main.js index da34555..b5fb488 100644 --- a/src/renderer/src/main.js +++ b/src/renderer/src/main.js @@ -8,6 +8,7 @@ import 'element-plus/dist/index.css' import './assets/iconfont/iconfont.css' import './assets/iconfont/iconfont' import 'virtual:windi.css' +import request from "@/utils/request"; import { store } from '@/store' import App from './App.vue' @@ -20,6 +21,20 @@ if(process.env.NODE_ENV != 'development') { // 非开发环境,将日志打印 const app = createApp(App) + +//专为菁优网配置的请求转发 +app.config.globalProperties.$requestGetJYW = (url,config)=>{ + config.params = config.params?config.params:{} + config.params["getjypath"] = url; + return request({ + url: "/jy/proxy", + method: config.method||"get", + params: config.params + }) +} + + + app.use(router) .use(store) .use(ElementPlus, { locale: zhLocale }).mount('#app') \ No newline at end of file diff --git a/src/renderer/src/router/index.js b/src/renderer/src/router/index.js index 36f0125..4a8a2f4 100644 --- a/src/renderer/src/router/index.js +++ b/src/renderer/src/router/index.js @@ -1,3 +1,8 @@ +/* + * @Author: 苦逼程序猿 + * @Date: 2024-09-06 16:15:32 + * @Warning: 千行代码,Bug露锋芒。 + */ import { createRouter, createWebHashHistory } from 'vue-router' import Layout from '../layout/index.vue' @@ -63,6 +68,18 @@ export const constantRoutes = [ name: 'class', meta: {title: '班级中心'}, }, + { + path: '/classTask', + component: () => import('@/views/classTask/classTask.vue'), + name: 'class', + meta: {title: '作业批改'}, + }, + { + path: '/examReport', + component: () => import('@/views/examReport/index.vue'), + name: 'examReport', + meta: {title: '考试分析'} + }, ] }, ...toolRouters diff --git a/src/renderer/src/store/modules/overview.js b/src/renderer/src/store/modules/overview.js new file mode 100644 index 0000000..46f58f6 --- /dev/null +++ b/src/renderer/src/store/modules/overview.js @@ -0,0 +1,18 @@ +import { defineStore } from 'pinia' +const overviewStore = defineStore( + 'overview', + { + state: () => { + return { + tableList:[] + } + }, + actions: { + getTableList(data){ + this.tableList = [...data] + } + } + }) +export default overviewStore + + diff --git a/src/renderer/src/utils/date.js b/src/renderer/src/utils/date.js index f70414b..2a178ca 100644 --- a/src/renderer/src/utils/date.js +++ b/src/renderer/src/utils/date.js @@ -108,4 +108,29 @@ export const getAfterMinutes = (m) => { let minutes = afterMinutes.getMinutes(); minutes = minutes < 10 ? ('0' + minutes) : minutes return `${hours}:${minutes}`; +} + +/** + * 表格时间格式化 + */ +export function formatDate(cellValue) { + if (cellValue == null || cellValue == "") return ""; + var date = new Date(cellValue) + var year = date.getFullYear() + var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1 + var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() + var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours() + var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes() + var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds() + return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds +} +export function getTimeDate() { + var date = new Date() + var year = date.getFullYear() + var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1 + var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() + var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours() + var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes() + var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds() + return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds } \ No newline at end of file diff --git a/src/renderer/src/utils/examQuestion/jyeoo.js b/src/renderer/src/utils/examQuestion/jyeoo.js new file mode 100644 index 0000000..8fb0a67 --- /dev/null +++ b/src/renderer/src/utils/examQuestion/jyeoo.js @@ -0,0 +1,262 @@ +const JY_TOKEN = 'CA82641DA86072DEFD39E287335E035FDA6AEEC0549B58F54F4408734C8683FFAF0585CFA3B25091E588A03A65C66A80F5FF613F539D600954007A35DFFBFDC3C7BB982771C5E13F0918642CFD7596CE3718F06E5579238D92EC809AC6F4C82A9FE4B0E232A67DD3594D4DAC1C219CCBC4A7A093344446107EB11DC317526D0594249DEBBD82B740C794CF5A7065E1982B7779AF16AD25D7'; +const JY_SUBJECT = [ + {id: 10, subject: 'math3', name: '小学数学'}, + {id: 11, subject: 'chinese3', name: '小学语文'}, + {id: 12, subject: 'english3', name: '小学英语'}, + {id: 14, subject: 'science3', name: '小学科学'}, + {id: 15, subject: 'politics3', name: '小学道德与法治'}, + {id: 20, subject: 'math', name: '初中数学'}, + {id: 21, subject: 'physics', name: '初中物理'}, + {id: 22, subject: 'chemistry', name: '初中化学'}, + {id: 23, subject: 'bio', name: '初中生物'}, + {id: 24, subject: 'science', name: '初中科学'}, + {id: 25, subject: 'geography', name: '初中地理'}, + {id: 26, subject: 'chinese', name: '初中语文'}, + {id: 27, subject: 'english', name: '初中英语'}, + {id: 28, subject: 'politics', name: '初中道德与法治'}, + {id: 29, subject: 'history', name: '初中历史'}, + {id: 30, subject: 'math2', name: '高中数学'}, + {id: 31, subject: 'physics2', name: '高中物理'}, + {id: 32, subject: 'chemistry2', name: '高中化学'}, + {id: 33, subject: 'bio2', name: '高中生物'}, + {id: 35, subject: 'geography2', name: '高中地理'}, + {id: 36, subject: 'chinese2', name: '高中语文'}, + {id: 37, subject: 'english2', name: '高中英语'}, + {id: 38, subject: 'politics2', name: '高中政治'}, + {id: 39, subject: 'history2', name: '高中历史'}, +]; + + +export const JYApiListCT = async (_this, name = '高中历史') => { + if (name === '初中政治') { + name = '初中道德与法治'; + } + const obj = JY_SUBJECT.filter(item => item.name == name); + if(obj.length < 1) { + return []; + } + const res = await _this.$requestGetJYW(`/${obj[0].subject}/common`, { + headers: { + authorization: `Token ${JY_TOKEN}` + }, + params: { + tp: 1, + }, + }); + if (res.code !== 200) { + return []; + } + let arrCT = [{ + label: "不限", + value: 0 + }] + res.data.forEach(item=> { + if (item.Value === '选择题') { + item.Value = '单选题'; + } + const tmp = { + label: item.Value, + value: item.Key, + } + arrCT.push(tmp); + }) + return arrCT; +} + +export const JYApiListOriginYear = () => { + const arrYear = [{label: '不限', value: '-1'}]; + let i = 0; + for( ; i < 10; i++) { + const year = new Date().getFullYear(); + const s ={ + label: `${year - i}`, + value: `${year - i}`, + } + arrYear.push(s); + }; + //arrYear.push({label: '更早', value: '0'}) + return arrYear; +} + +export const JYApiListSO = async (_this, name = '高中历史') => { + if (name === '初中政治') { + name = '初中道德与法治'; + } + + const obj = JY_SUBJECT.filter(item => item.name == name); + if(obj.length < 1) { + return []; + } + const res = await _this.$requestGetJYW(`/${obj[0].subject}/common`, { + headers: { + authorization: `Token ${JY_TOKEN}` + }, + params: { + tp: 2, + }, + }); + if (res.code !== 200) { + return []; + } + const arrSO = [{"Value": "不限", "Key": 0}, ...res.data]; + return arrSO; +} + + + +export const JYApiListPoint = async (_this, name = '高中历史') => { + if (name === '初中政治') { + name = '初中道德与法治'; + } + + const obj = JY_SUBJECT.filter(item => item.name == name); + if(obj.length < 1) { + return []; + } + const res = await _this.$requestGetJYW(`/${obj[0].subject}/point`, { + headers: { + authorization: `Token ${JY_TOKEN}` + }, + }); + if (res.code !== 200) { + return []; + } + return res.data; +} + + +/** + * @desc: 获取菁优网的版本内容 + * @return: {*} + */ +export const JYApiListVersion = async (_this, query, hasPoints=true) => { + const listVersion = { + status: 0, + msg: '', + data: [], + }; + if (query.stage === '' || query.subject === '') { + listVersion.msg = '未选中学段或学科!'; + return listVersion; + } + let name = `${query.stage}${query.subject}`; + if (name === '初中政治') { + name = '初中道德与法治'; + } + const result = JY_SUBJECT.filter( item => item.name===name); + if (result.length === 0) { + listVersion.msg = `[${name}]未找到对应菁优网教材版本, 请检查学段或学科是否匹配!`; + return listVersion; + } + const JYBook = await _this.$requestGetJYW(`/${result[0].subject}/book2`, { + headers: { + // JYToken仅占位, 实际后续已未使用该token + authorization: `Token ${JY_TOKEN}` + }, + }); + if (JYBook.code !== 200) { + listVersion.msg = `[${name}]获取菁优网教材版本失败!`; + return listVersion; + } + query.list.forEach(ele => { + if (ele.thirdkey == null) { + listVersion.msg = `[${name}-${ele.itemtitle}]菁优网教材字段标识未设置!`; + return; + } + let nPos = ele.thirdkey.indexOf('-'); + if (nPos === -1) { + listVersion.msg = `[${name}-${ele.itemtitle}-${ele.thirdkey}]菁优网教材字段标识设置有误!`; + return; + } + let editionName = ele.thirdkey.substring(0, nPos); + let typeName = ele.thirdkey.substring(nPos+1); + const resVersion = JYBook.data.filter( item => { + // 高中以typeName为标识, 而小学/初中以Name为标识 + const JYTypeName = query.stage=='高中' ? item.TypeName : item.Name; + if (item.EditionName.trim() === editionName.trim() && JYTypeName.trim() === typeName.trim()) { + return true; + } + }) + + if (resVersion.length === 0) { + listVersion.msg = `[${name}-${ele.thirdkey}]菁优网教材字段标识查询不存在!`; + return; + } + if (resVersion[0].Children.length === 0) { + listVersion.msg = `[${name}]菁优网教材字段标识查询单元内容为空!`; + return; + } + const children = JYApiListLession(resVersion[0], hasPoints); + // 高中以typeName为标识, 而小学/初中以Name为标识 + let JYTypeName = query.stage=='高中' ? resVersion[0].TypeName : resVersion[0].Name; + JYTypeName = JYTypeName.trim(); + const reset = { + id: resVersion[0].ID, + label: resVersion[0].Name.trim(), + nodeType: 'version', + children: children, + editionName: resVersion[0].EditionName.trim(), + typeName: JYTypeName, + } + listVersion.data.push(reset); + }) + + if(listVersion.data.length > 0){ + listVersion.status = 1; + } + return listVersion; +} + + +const JYApiListLession = (item, hasPoints) => { + const list = []; + item.Children.forEach(element => { + const tempList = formatCurJYLession(element, hasPoints); + list.push(tempList); + }); + return list; +} + +const formatCurJYLession = (item, hasPoints) => { + const obj = { + id: item.ID, + label: item.Name.trim(), + nodeType: 'unit', + children: [], + } + if(hasPoints) { + if (item.Children.length === 0 && !item.hasOwnProperty('Points')) { + obj.nodeType = 'points'; + obj.id = item.No; + return obj; + } + else if (item.Children.length > 0 ){ + for(let i=0; i 0){ + obj.nodeType = 'lession'; + for(let i=0; i 0 ){ + for(let i=0; i{ + if (typeof str == 'string') { + try { + let obj=JSON.parse(str); + if(typeof obj == 'object' && obj ){ + return true; + }else{ + return false; + } + } catch(e) { + return false; + } + } +}; + + +/** + * @description processExamQuestion 格式化试题 + * @param {*} row + */ +export const processExamQuestion = (row) => { + for (var i=0; iix>0); + // console.log(bjTitle,'背景标题'); + // console.log(tmTitles,'复合题目'); + let titls = []; + options.forEach((element,index1) => { + const workDescArr = element.split('#&'); + let tmp = ''; + let j=0; + for(; j`; + } + const char = String.fromCharCode(65+j); + tmp += `
${char}.${workDescArr[j]}
`; + if(j%2 == 1){ + tmp += ''; + } + + } + // j此刻已自增1, 故当选项为单数时, 需要补充结束标签 + if(j%2 == 1){ + tmp += ''; + } + + // workDescArr为 [''] 表示为 判断题或者填空题,这里不需要选项 + if(workDescArr[0] != ''){ + titls.splice(index1, 1, tmp); + }else{ + titls.splice(index1, 1, ''); + } + }); + const s = []; + tmTitles.map((it,ix)=>{ + s.push(it); + titls.map((it2,ix2)=>{ + if(ix == ix2){ + s.push(it2); + } + }) + }) + // console.log(s,'?????????????????') + + row[i].titleFormat = bjTitle + s.join(''); + row[i].workdescFormat = ''; + + + //2.答案 - 数字转为ABCD + const answerArr = JSON.parse(row[i].workanswer); + let indexLabel = 1; + let arr = []; + answerArr.forEach(item => { + const arrTmp = item.answer.split('#&'); + let value = `(${indexLabel})`; + arrTmp.forEach((element,i) => { + if(item.type == '单选题' || item.type == '多选题'){ + value += `${String.fromCharCode(65+Number(element))}`; + } + if(item.type == '判断题' || item.type == '填空题'){ + // 去除下 html标签 + value += `${element.replace(/<[^>]+>/g, '')}`+ (i==arrTmp.length-1?'':'、'); + } + if(item.type == '主观题') { + if(element){ + console.log(element,'element') + value += item.answer; + }else{ + value += '答案不唯一,请参考分析解答点评!'; + } + } + }) + arr.push(value); + indexLabel++; + }) + const answer = arr.join('
'); + + row[i].workanswerFormat = answer; + } + else { + // 处理[题干显示] - 不再需要处理 + // row[i].titleFormat = row[i].title; // 仅占位提示 + + /** + * 处理[选项显示] - 特殊结构 + * [ + * {type: '单选题', title: '题目1', options: ['ABC123','ABC123']}, + * {type: '多选题', title: '题目1', options: ['ABC123','ABC123']}, + * {type: '填空题', title: '题目1', options: []}, + * {type: '判断题', title: '题目1', options: []}, + * {type: '主观题', title: '题目1', options: []}, + * ] + */ + let workDescArr = JSON.parse(row[i].workdesc); + let workDescHtml = `
${index+1}. ${item.title}
`; + let tmp = ''; + let j=0; + let optionsArr = item.options; + for(; j`; + } + const char = String.fromCharCode(65+j); + tmp += `
${char}.${optionsArr[j]}
`; + if(j%2 == 1){ + tmp += ''; + } + } + // j此刻已自增1, 故当选项为单数时, 需要补充结束标签 + if(j%2 == 1){ + tmp += ''; + } + + workDescHtml += tmp; + } + else if(item.type == '填空题' || item.type == '判断题' || item.type == '主观题'){ + workDescHtml += `
${index+1}. ${item.title}
`; + } + }) + workDescHtml += ''; + row[i].workdescFormat = workDescHtml; + + /** + * 处理[答案显示] - 特殊结构 + * [ + * {type: '单选题', answer: ['0']}, + * {type: '多选题', answer: ['0','1']}, + * {type: '填空题', answer: ['填空1','填空2']}, + * {type: '判断题', answer: ['0'/'1']}, + * {type: '主观题', answer: [xxxx]}, + * ] + */ + let workAnswerArr = JSON.parse(row[i].workanswer); + let workAnswerHtml = ``; + workAnswerArr.map( (item, index) => { + const answerArr = item.answer; //JSON.parse(item.answer); + if(item.type == '单选题' || item.type == '多选题'){ + const answer = answerArr.map( (item) => { + return String.fromCharCode(65+Number(item)) + }).join(''); + workAnswerHtml += `
${index+1}. ${answer}
`; + } + else if(item.type == '填空题' ){ + const answer = answerArr.join('、'); + workAnswerHtml += `
${index+1}. ${answer}
`; + } + else if(item.type == '判断题' ){ + const answer = answerArr.map( (item) => { + return item === '1' ? '正确' : '错误' + }).join('、'); + workAnswerHtml += `
${index+1}. ${answer}
`; + } + else if(item.type == '主观题' ){ + // 复合题里面的主观题只有一个答案,或没填 + const answer = answerArr.join('、'); + if(answerArr[0]){ + workAnswerHtml += `
${index+1}. ${answer}
`; + }else{ + workAnswerHtml += `
${index+1}. ${answer}答案不唯一,请参考分析解答点评!
`; + } + } + }) + row[i].workanswerFormat = workAnswerHtml; + } + + } + else if(row[i].worktype == '主观题' || (row[i].worktype!=='单选题' && row[i].worktype!=='多选题' && row[i].worktype!=='填空题' && row[i].worktype!=='判断题')) { + // 处理[选项显示] - 主观题中无选项, 故置空 + row[i].workdescFormat = ''; + row[i].workanswerFormat = ''; + // 答案处理- eg: "\"不唯一的答案,参考\"" + if (row[i].workanswer && row[i].workanswer != '') { + row[i].workanswerFormat = JSON.parse(row[i].workanswer); + } + } + else { + // 单选题|多选题|填空题|判断题|主观题?(待确认是否归在这里) + // 通用选项结构 ['ABC123','ABC123'] | ['ABC123','ABC123'] | [](填空题无选项) | [](判断题无选项) + let workDescArr = []; + if (row[i].workdesc.charAt(0) === '[' && row[i].workdesc.charAt(row[i].workdesc.length - 1) === ']') { + //123会直接被转换, 且不是数组对象, 故手动判断是否有[和]两个字符 + workDescArr = JSON.parse(row[i].workdesc); + } + else if(row[i].workdesc.indexOf('#&') !== -1) { + workDescArr = row[i].workdesc.split('#&'); + } + else if(row[i].workdesc.indexOf(',') !== -1){ + workDescArr = row[i].workdesc.split(','); + } + else { + // 单字符串直接添加至空数组(待考虑确认) + workDescArr.push(row[i].workdesc); + } + + // 单选题|多选题|填空题|判断题|主观题?(待确认是否归在这里) + // 通用答案结构 ['0'] | ['0','1'] | ['填空1','填空2'] | ['0'/'1'] + let workAnswerArr = []; + if (row[i].workanswer.charAt(0) === '[' && row[i].workanswer.charAt(row[i].workanswer.length - 1) === ']') { + // 123会直接被转换, 且不是数组对象, 故手动判断是否有[和]两个字符 + workAnswerArr = JSON.parse(row[i].workanswer); + } + else if(row[i].workanswer.indexOf('#&') !== -1) { + workAnswerArr = row[i].workanswer.split('#&'); + } + else if(row[i].workanswer.indexOf(',') !== -1){ + workAnswerArr = row[i].workanswer.split(','); + } + else { + // 单字符串直接添加至空数组(待考虑确认) + workAnswerArr.push(row[i].workanswer); + } + + // 具体题型处理 + if(row[i].worktype == '单选题' || row[i].worktype == '多选题' ){ + // 处理[选项显示] - 拼接ABCD首序号 + let tmp = ''; + let j=0; + for(; j`; + } + const char = String.fromCharCode(65+j); + tmp += `
${char}.${workDescArr[j]}
`; + if(j%2 == 1){ + tmp += ''; + } + } + if(j%2== 0){ + tmp += ''; + } + row[i].workdescFormat = tmp; + + // 处理[答案显示] - 转换ABCD + let arr2Char = workAnswerArr.map( (item) => { + return String.fromCharCode(65+Number(item)) + }).join(''); + row[i].workanswerFormat = arr2Char; + } + else if(row[i].worktype == '填空题'){ + // 处理[选项显示] - 填空题中无选项, 故置空 + row[i].workdescFormat = ''; + + // 处理[答案显示] - 逗号连接 + row[i].workanswerFormat = workAnswerArr.join('、'); + } + else if(row[i].worktype == '判断题'){ + // 处理[选项显示] - 判断题中无选项, 故置空 + row[i].workdescFormat = ''; + + // 处理[答案显示] - 1-正常 0-错误 + const answer = workAnswerArr.map( (item) => { + return item === '1' ? '正确' : '错误' + }).join('、'); + row[i].workanswerFormat = answer; + } + } + } + } +} \ No newline at end of file diff --git a/src/renderer/src/views/classBegins/index.vue b/src/renderer/src/views/classBegins/index.vue index ccc2af4..9e9c83d 100644 --- a/src/renderer/src/views/classBegins/index.vue +++ b/src/renderer/src/views/classBegins/index.vue @@ -104,6 +104,9 @@ const switchPageMode = () => { } } onMounted(async () => { + window.addEventListener('focus', () => { + console.log(11111111111111) + }) const isDev = process.env.NODE_ENV == 'development' // toolState.showBoardAll = false // 隐藏画板 toolState.isPdfWin=true //设置打开pdf窗口 diff --git a/src/renderer/src/views/classManage/aside.vue b/src/renderer/src/views/classManage/aside.vue index 941134f..2855249 100644 --- a/src/renderer/src/views/classManage/aside.vue +++ b/src/renderer/src/views/classManage/aside.vue @@ -8,7 +8,7 @@