From 5a4e22dc56f35658830485263eb0fb8a90dad0fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=AB=E8=B0=B7=E5=89=91=E4=BB=99?= Date: Sat, 14 Mar 2020 16:51:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E4=B8=80=E5=B1=82=E5=82=A8?= =?UTF-8?q?=E5=AD=98=E7=9A=84=E6=95=B0=E6=8D=AEJSON=E5=92=8C=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E7=9A=84=E4=B8=AD=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/script.js b/script.js index f1ceebf3..38d3e3e9 100644 --- a/script.js +++ b/script.js @@ -436,7 +436,7 @@ window.onload = function() url:`${sourceDataFolder}/mon_${currentDataSource.code}.json`, //Cards数据文件 onload: function(response) { console.log("Cards ckey变化,储存新数据",currentCkey.ckey.card); - localforage.setItem(`PADDF-${currentDataSource.code}-cards`, response.response).then(function(){ + localforage.setItem(`PADDF-${currentDataSource.code}-cards`, JSON.parse(response.response)).then(function(){ lastCurrentCkeys.ckey.card = currentCkey.ckey.card; lastCurrentCkeys.updateTime = currentCkey.updateTime; GM_setValue("PADDF-ckey", JSON.stringify(lastCkeys)); @@ -460,11 +460,14 @@ window.onload = function() }); } } - function dealCardsData(responseText) + function dealCardsData(response) { try { - Cards = JSON.parse(responseText); + if (typeof(response) == "string") + Cards = JSON.parse(response); + else + Cards = response; }catch(e) { console.log("Cards数据JSON解码出错",e); @@ -495,7 +498,7 @@ window.onload = function() url:`${sourceDataFolder}/skill_${currentDataSource.code}.json`, //Skills数据文件 onload: function(response) { console.log("Skills ckey变化,储存新数据",currentCkey.ckey.skill); - localforage.setItem(`PADDF-${currentDataSource.code}-skills`, response.response).then(function(){ + localforage.setItem(`PADDF-${currentDataSource.code}-skills`, JSON.parse(response.response)).then(function(){ lastCurrentCkeys.ckey.skill = currentCkey.ckey.skill; lastCurrentCkeys.updateTime = currentCkey.updateTime; GM_setValue("PADDF-ckey", JSON.stringify(lastCkeys)); @@ -519,11 +522,14 @@ window.onload = function() }); } } - function dealSkillData(responseText) + function dealSkillData(response) { try { - Skills = JSON.parse(responseText); + if (typeof(response) == "string") + Skills = JSON.parse(response); + else + Skills = response; }catch(e) { console.log("Skills数据JSON解码出错",e);