From 440568b58b59196c932ad9677c75aba55271de42 Mon Sep 17 00:00:00 2001 From: Celeter Date: Sat, 12 Sep 2020 15:12:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B9=A6=E6=BA=90=E8=B0=83?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/web/index.html | 2 +- app/src/main/assets/web/index.js | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/src/main/assets/web/index.html b/app/src/main/assets/web/index.html index 2af52d9a4..7b2f15ee1 100644 --- a/app/src/main/assets/web/index.html +++ b/app/src/main/assets/web/index.html @@ -56,7 +56,7 @@
搜索
搜索地址:
-
diff --git a/app/src/main/assets/web/index.js b/app/src/main/assets/web/index.js index 7b0ec52a3..9d09d50de 100644 --- a/app/src/main/assets/web/index.js +++ b/app/src/main/assets/web/index.js @@ -18,7 +18,7 @@ function hashParam(key, val) { } } // 创建书源规则容器对象 -const RuleJSON = (() => { +function Container() { let ruleJson = {}; let searchJson = {}; let exploreJson = {}; @@ -60,7 +60,7 @@ const RuleJSON = (() => { ruleJson.ruleContent = contentJson; return ruleJson; -})(); +} // 选项卡Tab切换事件处理 function showTab(tabName) { $$('.tabtitle>*').forEach(node => { node.className = node.className.replace(' this', ''); }); @@ -106,6 +106,7 @@ function HttpPost(url, data) { } // 将书源表单转化为书源对象 function rule2json() { + let RuleJSON = Container(); // 转换base Object.keys(RuleJSON).forEach(key => { if (!key.startsWith("rule")) { @@ -117,7 +118,8 @@ function rule2json() { let searchJson = {}; //Object.keys(JSON.parse(RuleJSON.ruleSearch)).forEach(key => { Object.keys(RuleJSON.ruleSearch).forEach(key => { - searchJson[key] = $('#' + 'ruleSearch_' + key).value; + if ($('#' + 'ruleSearch_' + key).value) + searchJson[key] = $('#' + 'ruleSearch_' + key).value; }); //RuleJSON.ruleSearch = JSON.stringify(searchJson); RuleJSON.ruleSearch = searchJson; @@ -126,7 +128,8 @@ function rule2json() { let exploreJson = {}; //Object.keys(JSON.parse(RuleJSON.ruleExplore)).forEach(key => { Object.keys(RuleJSON.ruleExplore).forEach(key => { - exploreJson[key] = $('#' + 'ruleExplore_' + key).value; + if ($('#' + 'ruleExplore_' + key).value) + exploreJson[key] = $('#' + 'ruleExplore_' + key).value; }); //RuleJSON.ruleExplore = JSON.stringify(exploreJson); RuleJSON.ruleExplore = exploreJson; @@ -135,7 +138,8 @@ function rule2json() { let bookInfoJson = {}; //Object.keys(JSON.parse(RuleJSON.ruleBookInfo)).forEach(key => { Object.keys(RuleJSON.ruleBookInfo).forEach(key => { - bookInfoJson[key] = $('#' + 'ruleBookInfo_' + key).value; + if ($('#' + 'ruleBookInfo_' + key).value) + bookInfoJson[key] = $('#' + 'ruleBookInfo_' + key).value; }); //RuleJSON.ruleBookInfo = JSON.stringify(bookInfoJson); RuleJSON.ruleBookInfo = bookInfoJson; @@ -144,7 +148,8 @@ function rule2json() { let tocJson = {}; //Object.keys(JSON.parse(RuleJSON.ruleToc)).forEach(key => { Object.keys(RuleJSON.ruleToc).forEach(key => { - tocJson[key] = $('#' + 'ruleToc_' + key).value; + if ($('#' + 'ruleToc_' + key).value) + tocJson[key] = $('#' + 'ruleToc_' + key).value; }); //RuleJSON.ruleToc = JSON.stringify(tocJson); RuleJSON.ruleToc = tocJson; @@ -153,7 +158,8 @@ function rule2json() { let contentJson = {}; //Object.keys(JSON.parse(RuleJSON.ruleContent)).forEach(key => { Object.keys(RuleJSON.ruleContent).forEach(key => { - contentJson[key] = $('#' + 'ruleContent_' + key).value; + if ($('#' + 'ruleContent_' + key).value) + contentJson[key] = $('#' + 'ruleContent_' + key).value; }); //RuleJSON.ruleContent = JSON.stringify(contentJson); RuleJSON.ruleContent = contentJson; @@ -168,6 +174,7 @@ function rule2json() { } // 将书源对象填充到书源表单 function json2rule(RuleEditor) { + let RuleJSON = Container(); // 转换base Object.keys(RuleJSON).forEach(key => { if (!key.startsWith("rule")) {