Explorar o código

Merge remote-tracking branch 'origin/main'

# Conflicts:
#	src/api/axios.config.js
#	src/views/Bok/Main/Check.vue
mjh %!s(int64=5) %!d(string=hai) anos
pai
achega
a7c2bd680c

+ 1 - 1
package.json

@@ -15,7 +15,7 @@
     "mockjs": "^1.1.0",
     "node-sass": "^4.14.1",
     "typescript": "^4.3.5",
-    "vue": "^3.0.0",
+    "vue": "^3.2.0",
     "vue-router": "^4.0.0-0",
     "vuex": "^4.0.0-0"
   },

+ 6 - 1
src/api/axios.config.js

@@ -27,7 +27,7 @@ export default function axiosConfig() {
         function(error) {
             if (process.env.NODE_ENV === 'development') {
                 // mjh change
-                // console.error('[AXIOS] response error: ', error.response)
+                // console.error('[AXIOS] response error: ', error)
             }
 
             if (error.response) {
@@ -69,12 +69,17 @@ export default function axiosConfig() {
 axiosConfig()
 
 const portal = 'http://p.seec.seecoder.cn'
+// const portal = 'http://p.seecoder.cn' //如果新门户出问题就是用老门户,注意修改后端密钥
 
 export const getLoginUrl = () => {
     const location = window.location
     return `${portal}/interaction?client_id=seec-mooc&redirect_uri=${encodeURIComponent(
         location.origin + '/'
     )}&scope=openid`
+
+    // return `${portal}/api/interaction?client_id=seec-mooc&redirect_uri=${encodeURIComponent(
+    //     location.origin + '/'
+    // )}&scope=openid` //如果新门户出问题就是用老门户
 }
 
 /**

+ 6 - 1
src/api/index.js

@@ -6,6 +6,7 @@ import {
     getStateQuestion,
     updateQuestion,
     requestQuestion,
+    createBokQuestion
 } from "./question";
 
 import {getUserById,
@@ -16,9 +17,9 @@ import {createRecord,
     getRecordByQid,
 } from "./operation_record";
 
-
 const api = {
     createQuestion: createQuestion,
+    createBokQuestion: createBokQuestion,
     deleteQuestionById: deleteQuestionById,
     getTargetQuestionList: getTargetQuestionList,
     getStateQuestion: getStateQuestion,
@@ -31,4 +32,8 @@ const api = {
     getRecordByQid: getRecordByQid,
 }
 
+export function useApi(){
+    return api;
+}
+
 export {api}

+ 11 - 0
src/api/question.js

@@ -88,4 +88,15 @@ export function getStateQuestion(states, offset, pageSize) {
         }});
 }
 
+// /**
+//  * 上传题目列表到线上Bok
+//  * @param questions
+//  * @returns {Promise<AxiosResponse<any>>}
+//  */
+// export function createBokQuestion(questions){
+//     return axios.post("/two/api/questions", questions);
+// }
+
+
+
 

+ 3 - 2
src/api/user.js

@@ -1,4 +1,5 @@
 import axios from "axios";
+// import {axios} from "@/api/axios.config";
 
 /**
  * 根据用户ID获得用户对象
@@ -6,13 +7,13 @@ import axios from "axios";
  * @returns {Promise<AxiosResponse<any>>}
  */
 export function getUserById(id) {
-    return axios.get("api/api/user/uid", {params:{
+    return axios.get("/api/api/user/uid", {params:{
             uid: id
         }});
 }
 
 
 export function getUserInfo(){
-    return axios.get("api/api/user");
+    return axios.get("/api/api/user");
 }
 

+ 5 - 1
src/components/QuestionGroupCreater.vue

@@ -49,6 +49,10 @@
             submitQuestions(){
                 console.log(JSON.parse(this.questionJson));
                 let questions = JSON.parse(this.questionJson).questions;
+              for (let question of questions) {
+                question.state = "CHECKING";
+                question.savedUserId = this.$store.state.user.id;
+              }
                 axios.post("/api/api/questions", questions)
                     .then(res => {
                         console.log(res);
@@ -72,7 +76,7 @@
                 reader.readAsText(file.raw);
                 reader.onload = () => {
                     this.questionJson = reader.result;
-                    console.log(this.questionJson);
+                    // console.log(this.questionJson);
                 }
 
             }

+ 5 - 1
src/router/index.js

@@ -44,6 +44,11 @@ const routes = [
         name: "Check",
         component: () => import("../views/Bok/Main/Check"),
       },
+      {
+        path: "operation",
+        name: "Operation",
+        component: () => import("../views/Bok/Main/Operation"),
+      },
       {
         path: "setting",
         name: "Setting",
@@ -99,7 +104,6 @@ router.beforeEach((to, from , next) =>{
     }else{
       next();
     }
-
   }
 })
 

+ 90 - 0
src/views/Bok/Main/Operation.vue

@@ -0,0 +1,90 @@
+<template>
+  <h1>This is Operation Page!</h1>
+  <el-tabs v-model="data.activeName" @tab-click="handleClick">
+    <el-tab-pane label="新建题目" name="create">
+      <div>新建题目</div>
+    </el-tab-pane>
+    <el-tab-pane label="批量新建题目" name="groupCreate">
+      <div>
+        <div class="creator-mode-body">
+          <el-upload
+              class="upload-demo"
+              :auto-upload="false"
+              :on-change="openFile"
+              drag
+              action=""
+              multiple>
+            <i class="el-icon-upload"></i>
+            <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
+            <template #tip>
+              <div class="el-upload__tip">
+                上传 json 文件,且不超过 500kb
+              </div>
+            </template>
+          </el-upload>
+        </div>
+
+        <div class="question-drawer__footer">
+<!--          <el-button @click="cancelForm">取 消</el-button>-->
+          <el-button type="primary" @click="submitQuestions">确 定</el-button>
+        </div>
+      </div>
+    </el-tab-pane>
+  </el-tabs>
+</template>
+
+<script setup>
+import {reactive} from "vue";
+import {useApi} from "@/api";
+
+let data = reactive({
+  activeName: "create",
+  questionJson: null,
+  questions: [],
+})
+
+const api = useApi();
+
+function handleClick(tab, event) {
+  switch (tab.props.name) {
+    case "create":
+      break;
+    case "refused":
+      break;
+  }
+}
+
+function openFile(file, fileList){
+  let reader = new FileReader();
+  reader.readAsText(file.raw);
+  reader.onload = () => {
+    data.questionJson = reader.result;
+  }
+}
+
+function submitQuestions(){
+  console.log(JSON.parse(data.questionJson));
+  data.questions = JSON.parse(data.questionJson).content;
+  if(data.questions.length === 0){
+    alert("请先选择文件");
+  }else {
+    api.createBokQuestion(data.questions)
+        .then(res => {
+          alert("创建成功");
+          console.log(res);
+        }).catch(err => {
+      alert("创建失败");
+      console.log(err);
+    })
+  }
+
+}
+
+</script>
+
+<style scoped>
+  .creator-mode-body{
+    margin: 20px;
+  }
+
+</style>

+ 4 - 0
src/views/Bok/SideBar.vue

@@ -17,6 +17,10 @@
         <i class="el-icon-box"></i>
         <template #title>题库</template>
       </el-menu-item>
+      <el-menu-item index="operation">
+        <i class="el-icon-box"></i>
+        <template #title>操作</template>
+      </el-menu-item>
       <el-menu-item index="knowledgePoint">
         <i class="el-icon-menu"></i>
         <template #title>知识点</template>

+ 1 - 2
vue.config.js

@@ -8,8 +8,7 @@ module.exports = {
     devServer: {
         proxy: {
             "/api": {
-                target: "http://localhost:8080",
-                ws: true,
+                target: "http://127.0.0.1:8080",
                 changeOrigin: true,
                 pathRewrite: {
                     "^/api": ""