瀏覽代碼

解决换行符导致加载类别设置页bug

laiguoran 3 年之前
父節點
當前提交
90fe46342f
共有 2 個文件被更改,包括 7 次插入2 次删除
  1. 5 0
      app/public/js/setting.js
  2. 2 2
      app/view/setting/category.ejs

+ 5 - 0
app/public/js/setting.js

@@ -79,6 +79,11 @@ $(document).ready(() => {
             if (!/^[0-9a-zA-Z*~!@&%$^\\(\\)#_\[\]\-\+={}|?'":,<>.`]+$/.test(resetPassword)) {
                 throw '密码只支持英文数字及符号';
             }
+            // 判断新密码的强度
+            const reg = /^(?![0-9]+$)(?![a-zA-Z]+$).{6,16}$/;
+            if (!reg.test(resetPassword)) {
+                throw '请设置至少包含数字和字母的密码';
+            }
             const btn = $(this);
             $.ajax({
                 url: '/setting/user/reset/password',

+ 2 - 2
app/view/setting/category.ejs

@@ -28,8 +28,8 @@
     </div>
 </div>
 <script>
-    let cData = JSON.parse('<%- JSON.stringify(categoryData) %>');
-    const cType = JSON.parse('<%- JSON.stringify(categoryType) %>');
+    let cData = JSON.parse(unescape('<%- escape(JSON.stringify(categoryData)) %>'));
+    const cType = JSON.parse(unescape('<%- escape(JSON.stringify(categoryType)) %>'));
     let tenders = JSON.parse(unescape('<%- escape(JSON.stringify(tenderData)) %>'));
 </script>
 <script src="/public/js/category.js"></script>