Przeglądaj źródła

1、固定并隐藏服务器地址 2、填空题输入字体问题修复

dsy 2 miesięcy temu
rodzic
commit
c68ac8e8da

+ 84 - 43
packages/BookEep.vue

@@ -77,53 +77,11 @@ export default {
     },
   },
   data() {
-    const processHtmlString = this.processHtmlString;
-    const cList = this.componentList || [];
-    cList.forEach((x) => {
-      if (x.component_type === 'audio') {
-        let _c = JSON.parse(x.content);
-        let p = _c.property || {};
-        if (!p.file_name_display_mode) p.file_name_display_mode = 'true';
-        if (p.view_method === 'independent' && !p.style_mode) {
-          p.style_mode = 'middle';
-        }
-        if (!p.style_mode) p.style_mode = 'big';
-        if (p.view_method === 'icon') {
-          p.file_name_display_mode = 'false';
-          p.view_method = 'independent';
-          p.style_mode = 'small';
-        }
-
-        x.content = JSON.stringify(_c);
-      } else if (x.component_type === 'richtext') {
-        if (!processHtmlString) return;
-        let _c = JSON.parse(x.content);
-        let p = _c.property || {};
-        let lev = Number(p.title_style_level);
-        if (p.is_title !== 'true' || lev < 1 || !_c.content) return;
-
-        let style = this.title_list.find((y) => y.level === lev) || {};
-        if (style && style.style) {
-          style = JSON.parse(style.style);
-          let c_text = _c.content;
-
-          const parser = new DOMParser();
-          const doc = parser.parseFromString(c_text, 'text/html');
-          const body = doc.body;
-          const pElements = body.querySelectorAll('p');
-          processHtmlString(pElements, style);
-          _c.content = body.innerHTML;
-
-          x.content = JSON.stringify(_c);
-        }
-      }
-    });
-
     return {
       background: this.bookBackground.length > 0 ? JSON.parse(this.bookBackground) : {},
       groupRowList: this.contentGroupRowList.length > 0 ? JSON.parse(this.contentGroupRowList) : [],
       data: this.content.length > 0 ? JSON.parse(this.content) : { row_list: [] },
-      cList,
+      cList: this.handleComponentList(),
       curSelectId: this.id,
       isTrue,
       sidebarShow: true,
@@ -150,6 +108,44 @@ export default {
       return buildCoursewareStyle(this.background, 'commonPreview');
     },
   },
+  watch: {
+    componentList: {
+      handler(newVal) {
+        if (newVal && newVal.length > 0) {
+          this.cList = this.handleComponentList();
+        }
+      },
+      deep: true,
+    },
+    bookBackground: {
+      handler(newVal) {
+        if (newVal && newVal.length > 0) {
+          this.background = JSON.parse(newVal);
+        }
+      },
+    },
+    content: {
+      handler(newVal) {
+        if (newVal && newVal.length > 0) {
+          this.data = JSON.parse(newVal);
+        }
+      },
+    },
+    contentGroupRowList: {
+      handler(newVal) {
+        if (newVal && newVal.length > 0) {
+          this.groupRowList = JSON.parse(newVal);
+        }
+      },
+    },
+    id: {
+      handler(newVal) {
+        if (newVal && newVal.length > 0) {
+          this.curSelectId = newVal;
+        }
+      },
+    },
+  },
   methods: {
     backTop() {
       this.$refs.previewMain.scrollTo({
@@ -163,6 +159,51 @@ export default {
       return text;
     },
 
+    handleComponentList() {
+      const processHtmlString = this.processHtmlString;
+      const cList = this.componentList || [];
+      cList.forEach((x) => {
+        if (x.component_type === 'audio') {
+          let _c = JSON.parse(x.content);
+          let p = _c.property || {};
+          if (!p.file_name_display_mode) p.file_name_display_mode = 'true';
+          if (p.view_method === 'independent' && !p.style_mode) {
+            p.style_mode = 'middle';
+          }
+          if (!p.style_mode) p.style_mode = 'big';
+          if (p.view_method === 'icon') {
+            p.file_name_display_mode = 'false';
+            p.view_method = 'independent';
+            p.style_mode = 'small';
+          }
+
+          x.content = JSON.stringify(_c);
+        } else if (x.component_type === 'richtext') {
+          if (!processHtmlString) return;
+          let _c = JSON.parse(x.content);
+          let p = _c.property || {};
+          let lev = Number(p.title_style_level);
+          if (p.is_title !== 'true' || lev < 1 || !_c.content) return;
+
+          let style = this.title_list.find((y) => y.level === lev) || {};
+          if (style && style.style) {
+            style = JSON.parse(style.style);
+            let c_text = _c.content;
+
+            const parser = new DOMParser();
+            const doc = parser.parseFromString(c_text, 'text/html');
+            const body = doc.body;
+            const pElements = body.querySelectorAll('p');
+            processHtmlString(pElements, style);
+            _c.content = body.innerHTML;
+
+            x.content = JSON.stringify(_c);
+          }
+        }
+      });
+      return cList;
+    },
+
     processHtmlString(pElements, styleConfig, isClear = false) {
       const _pElements = pElements || [];
       _pElements.forEach((pElement) => {

+ 1 - 1
packages/package.json

@@ -1,6 +1,6 @@
 {
   "name": "eep-ui",
-  "version": "0.0.3",
+  "version": "0.0.4",
   "main": "eep/eep-ui.umd.js",
   "style": "eep/eep-ui.css",
   "exports": {

+ 2 - 2
src/utils/auth.js

@@ -1,7 +1,7 @@
 /**
  * 设置带过期时间的数据
  * @param {string} key - 存储的键
- * @param {array} value - 存储的值
+ * @param {any} value - 存储的值
  * @param {number} expiryDays - 过期天数
  * @returns {void}
  */
@@ -20,7 +20,7 @@ function setItemWithExpiry(key, value, expiryDays) {
 /**
  * 获取数据时判断是否过期
  * @param {string} key - 存储的键
- * @returns {Object|null}
+ * @returns {any|null} 返回存储的值或null
  */
 function getItemWithExpiry(key) {
   const itemStr = localStorage.getItem(key);

+ 2 - 1
src/views/book/courseware/preview/components/fill/FillPreview.vue

@@ -35,7 +35,7 @@
                   :class="[...computedAnswerClass(li.mark)]"
                   :style="[
                     {
-                      fontFamily: data.property.fill_font,
+                      '--fill-font-family': data.property.fill_font,
                       width: (inputWidthMap[li.mark] || data.property.input_default_width) + 'px',
                     },
                   ]"
@@ -578,6 +578,7 @@ export default {
 
       :deep .el-input__inner {
         padding: 0;
+        font-family: var(--fill-font-family, 'arial'), sans-serif;
         font-size: 16pt;
         color: $font-color;
         text-align: center;

+ 28 - 5
src/views/login/index.vue

@@ -128,7 +128,7 @@
             </div>
           </div>
           <el-form ref="loginForm" :model="form" :rules="rules" label-position="right">
-            <el-form-item prop="server_address" label="服务器地址">
+            <el-form-item v-show="isShowServerAddress" prop="server_address" label="服务器地址">
               <el-input
                 v-model="form.server_address"
                 placeholder="请输入服务器地址"
@@ -230,15 +230,17 @@ export default {
   data() {
     return {
       isAgree: getLocalStore('isAgree'), // 是否同意用户协议
+      fixedServerAddress: 'https://eep.utschool.cn', // 固定服务器地址
       form: {
         user_type: 'USER',
         user_name: '',
         password: '',
         is_password_md5: 'true',
-        server_address: getLocalStore('server_address') || '', // 服务器地址
+        server_address: getLocalStore('server_address') || 'https://eep.utschool.cn', // 服务器地址
         verification_code_image_id: '',
         verification_code_image_text: '',
       },
+      isShowServerAddress: false, // 是否显示服务器地址输入框
       rules: {
         user_name: [
           {
@@ -262,10 +264,30 @@ export default {
     };
   },
   created() {
-    this.updateVerificationCode();
-    this.getLogo();
+    this.init();
+  },
+  mounted() {
+    window.addEventListener('keydown', this.handleServerAddressShortcut);
+  },
+  beforeDestroy() {
+    window.removeEventListener('keydown', this.handleServerAddressShortcut);
   },
   methods: {
+    init() {
+      const isInitSeverAddress = getLocalStore('isInitSeverAddress');
+      if (!isInitSeverAddress) {
+        setLocalStore('server_address', this.fixedServerAddress);
+        setLocalStore('isInitSeverAddress', true);
+      }
+      this.updateVerificationCode();
+      this.getLogo();
+    },
+    handleServerAddressShortcut(event) {
+      const isShortcut = event.ctrlKey && event.shiftKey && event.key.toUpperCase() === 'K';
+      if (!isShortcut) return;
+      event.preventDefault();
+      this.isShowServerAddress = !this.isShowServerAddress;
+    },
     updateVerificationCode() {
       GetVerificationCodeImage()
         .then(({ image_id, image_content_base64: image }) => {
@@ -348,12 +370,13 @@ export default {
   background: #f7f9fe;
 
   &-container {
+    position: relative;
     display: flex;
     height: 100vh;
     min-height: 100vh;
     overflow: hidden;
 
-    position:relative .title {
+    .title {
       margin-bottom: 28px;
       font-size: 24px;
       color: #fff;