浏览代码

路由模式更改,题卡自动保存修改

zhangjie 1 年之前
父节点
当前提交
36d416d15c

+ 0 - 12
card/components/CardDesign.vue

@@ -259,7 +259,6 @@ import PageNumber from "../components/PageNumber";
 import CardHeadSample from "../elements/card-head/CardHead";
 import TopicSelectDialog from "../components/TopicSelectDialog";
 import ElemUndertaking from "../elements/undertaking/ElemUndertaking.vue";
-import timeMixin from "../mixins/timeMixin";
 
 export default {
   name: "card-design",
@@ -278,7 +277,6 @@ export default {
       default: true,
     },
   },
-  mixins: [timeMixin],
   components: {
     CardConfigPropEdit,
     TopicElementEdit,
@@ -321,11 +319,9 @@ export default {
   },
   mounted() {
     this.initCard();
-    // this.openAutoSave();
   },
   beforeDestroy() {
     this.initState();
-    this.clearSetTs();
   },
   methods: {
     ...mapMutations("card", [
@@ -349,14 +345,6 @@ export default {
       "initTopicsFromPages",
       "scrollToElementPage",
     ]),
-    openAutoSave() {
-      this.clearSetTs();
-
-      this.addSetTime(async () => {
-        await this.toSave();
-        this.openAutoSave();
-      }, 2 * 60 * 1000);
-    },
     async initCard() {
       const { cardConfig, pages } = this.content;
       this.setCardConfig(cardConfig);

+ 0 - 12
card/modules/free/components/CardFreeDesign.vue

@@ -214,7 +214,6 @@ import HelpDialog from "../components/HelpDialog";
 import EditPage from "../../../elements/page/EditPage";
 
 import PageNumber from "../../../components/PageNumber";
-import timeMixin from "../../../mixins/timeMixin";
 
 export default {
   name: "card-free-design",
@@ -233,7 +232,6 @@ export default {
       default: true,
     },
   },
-  mixins: [timeMixin],
   components: {
     TopicColumnEdit,
     PagePropEdit,
@@ -268,11 +266,9 @@ export default {
   },
   mounted() {
     this.initCard();
-    this.openAutoSave();
   },
   beforeDestroy() {
     this.initState();
-    this.clearSetTs();
   },
   methods: {
     ...mapMutations("free", [
@@ -290,14 +286,6 @@ export default {
       "addElement",
       "modifyElement",
     ]),
-    openAutoSave() {
-      this.clearSetTs();
-
-      this.addSetTime(async () => {
-        await this.toSave();
-        this.openAutoSave();
-      }, 2 * 60 * 1000);
-    },
     async initCard() {
       const { cardConfig, pages } = this.content;
       this.setCardConfig(cardConfig);

+ 6 - 0
src/constants/enumerate.js

@@ -347,3 +347,9 @@ export const QUESTION_TYPE_LIST = [
     optionCount: null,
   },
 ];
+
+export const QUESTION_SCORE_TYPE = {
+  NONE: "无",
+  ALL: "任选给分",
+  LEAK: "漏选给分",
+};

+ 9 - 8
src/modules/card/views/CardEdit.vue

@@ -30,6 +30,7 @@ import CardPreviewDialog from "../components/CardPreviewDialog.vue";
 import { examRuleDetail } from "../../base/api";
 import { getEnums } from "../../login/api";
 import { UNDERTAKING_BODY } from "../../../../card/enumerate";
+import timeMixin from "@/mixins/timeMixin";
 
 export default {
   name: "card-edit",
@@ -44,6 +45,7 @@ export default {
       default: false,
     },
   },
+  mixins: [timeMixin],
   data() {
     return {
       cardId: this.$route.params.cardId || this.$ls.get("cardId"),
@@ -80,14 +82,13 @@ export default {
     this.initCard();
   },
   methods: {
-    initFrameStyle() {
-      this.dialogFrameStyle = {
-        width: window.innerWidth + "px",
-        height: window.innerHeight + "px",
-        overflow: "auto",
-        border: "none",
-        outline: "none",
-      };
+    openAutoSave() {
+      this.clearSetTs();
+
+      this.addSetTime(async () => {
+        await this.$refs.CardDesign.toSave();
+        this.openAutoSave();
+      }, 1 * 60 * 1000);
     },
     async initCard() {
       this.dataReady = false;

+ 10 - 12
src/plugins/utils.js

@@ -398,21 +398,19 @@ export function blobToText(blob) {
   });
 }
 
-export function parseHrefParam(href, paramName = null) {
-  if (!href) return;
-  let paramStr = href.split("?")[1];
-  if (!paramStr) return;
+export function parseHrefParam(urlStr, paramName = null) {
+  if (!urlStr) return;
+  const url = new URL(urlStr);
 
-  paramStr = paramStr.split("#")[0];
-  if (!paramStr) return;
+  const urlParams = new URLSearchParams(url.search);
 
-  let params = {};
-  paramStr.split("&").forEach((item) => {
-    const con = item.split("=");
-    params[con[0]] = con[1];
-  });
+  if (paramName) return urlParams.get(paramName);
 
-  return paramName ? params[paramName] : params;
+  let params = {};
+  for (const kv of urlParams.entries()) {
+    params[kv[0]] = kv[1];
+  }
+  return params;
 }
 
 export function objFilterNull(obj) {

+ 18 - 10
src/router.js

@@ -19,21 +19,29 @@ import card from "./modules/card/router";
 import admin from "./modules/admin/router";
 
 // ignore NavigationDuplicated. https://github.com/vuejs/vue-router/issues/2881
-const originalPush = Router.prototype.push;
-Router.prototype.push = function push(location, onResolve, onReject) {
-  if (onResolve || onReject)
-    return originalPush.call(this, location, onResolve, onReject);
-  try {
-    return originalPush.call(this, location).catch((err) => err);
-  } catch (error) {
-    console.log(error);
-  }
-};
+// const originalPush = Router.prototype.push;
+// Router.prototype.push = function push(location, onResolve, onReject) {
+//   if (onResolve || onReject)
+//     return originalPush.call(this, location, onResolve, onReject);
+//   try {
+//     return originalPush.call(this, location).catch((err) => err);
+//   } catch (error) {
+//     console.log(error);
+//   }
+// };
 // end ignore
 
 Vue.use(Router);
 
+/*
+history模式 nginx配置
+location / {
+  try_files $uri $uri/ /index.html;
+}
+*/
+
 let router = new Router({
+  mode: "history",
   routes: [
     {
       path: "/",