From 7fdb04a5ea126a57cff7c75491aec6f3bb4d2a26 Mon Sep 17 00:00:00 2001 From: zhaowenkang Date: Wed, 18 Dec 2024 21:58:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5=EF=BC=8C?= =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- work/src/api/LoginApi.js | 12 +++++++++ work/src/api/UpdateWorkApi.js | 2 +- work/src/views/AddWork.vue | 46 ++++++++++++++++++++++++++-------- work/src/views/HomeWork.vue | 26 +++++++++++++++---- work/src/views/Login.vue | 47 +++++++++++++++++++++++++++++++---- work/src/views/UpdateWork.vue | 35 ++++++++++++++++++-------- work/src/views/WorkDetail.vue | 58 +++++++++++++++++++++++++++---------------- work/vite.config.js | 2 +- 8 files changed, 173 insertions(+), 55 deletions(-) create mode 100644 work/src/api/LoginApi.js diff --git a/work/src/api/LoginApi.js b/work/src/api/LoginApi.js new file mode 100644 index 0000000..d022cd6 --- /dev/null +++ b/work/src/api/LoginApi.js @@ -0,0 +1,12 @@ +import service from "."; +const LoginApi={ + //登录 + login(username,password){ + return service.post("/api/login",username,password) + }, + //退出登录 + logout(token){ + return service.post("/api/logout",token) + } +} +export default LoginApi; \ No newline at end of file diff --git a/work/src/api/UpdateWorkApi.js b/work/src/api/UpdateWorkApi.js index d86cc0e..5a4d45e 100644 --- a/work/src/api/UpdateWorkApi.js +++ b/work/src/api/UpdateWorkApi.js @@ -14,7 +14,7 @@ const UpdateWorkApi={ }, //数据导出 excelexport(data){ - return service.post("/api/homework_manage/excelexport",data) + return service.post("/api/homework_manage/exceleexport",data) } } export default UpdateWorkApi; \ No newline at end of file diff --git a/work/src/views/AddWork.vue b/work/src/views/AddWork.vue index 458c4a8..a0ebbb8 100644 --- a/work/src/views/AddWork.vue +++ b/work/src/views/AddWork.vue @@ -3,7 +3,7 @@ 抢点班作业后台管理 - 退出登录 + 退出登录
@@ -92,6 +92,11 @@ import AddWorkApi from '../api/AddWorkApi'; import _ from 'lodash'; import dayjs from 'dayjs'; import { ElMessage } from 'element-plus' +import LoginApi from '../api/LoginApi'; +import axios from 'axios'; +import { useRouter } from 'vue-router'; + +const router = useRouter(); const options = ref([ { id: 1, name: '牧民俱乐部' }, @@ -232,20 +237,31 @@ const addBlank = () => { }); }; +// const addOption = (questionIndex) => { +// const currentQuestion = questions.value[questionIndex]; +// const currentContent = JSON.parse(currentQuestion.content); +// currentContent.push({ "id": "", "text": "" }); +// currentQuestion.content = JSON.stringify(currentContent); +// }; + +// const removeOption = (questionIndex, optionIndex) => { +// const currentQuestion = questions.value[questionIndex]; +// const currentContent = JSON.parse(currentQuestion.content); +// currentContent.splice(optionIndex, 1); +// currentQuestion.content = JSON.stringify(currentContent); +// }; const addOption = (questionIndex) => { - const currentQuestion = questions.value[questionIndex]; - const currentContent = JSON.parse(currentQuestion.content); - currentContent.push({ "id": "", "text": "" }); - currentQuestion.content = JSON.stringify(currentContent); + const currentQuestion = questions.value[questionIndex]; + // 如果当前题目没有content属性,则初始化一个空数组 + if (!currentQuestion.content) { + currentQuestion.content = []; + } + currentQuestion.content.push({ id: "", text: "" }); }; - const removeOption = (questionIndex, optionIndex) => { - const currentQuestion = questions.value[questionIndex]; - const currentContent = JSON.parse(currentQuestion.content); - currentContent.splice(optionIndex, 1); - currentQuestion.content = JSON.stringify(currentContent); + const currentQuestion = questions.value[questionIndex]; + currentQuestion.content.splice(optionIndex, 1); }; - const removeQuestion = (questionIndex) => { questions.value.splice(questionIndex, 1); }; @@ -271,6 +287,14 @@ const handleMouseLeave = (index) => { onMounted(() => { isHovered.value = Array(questions.value.length).fill(false); }); + +//退出登录 +const logout = () => { + LoginApi.logout().then(res => { + console.log(res) + }) + router.push('/') +}