Browse Source

解决隐私模式下无法使用的问题

tags/v8.0
枫谷剑仙 5 years ago
parent
commit
1da1964b45
12 changed files with 45 additions and 31 deletions
  1. BIN
      images/cards_ko/CARDS_059.PNG
  2. BIN
      images/cards_ko/CARDS_064.PNG
  3. BIN
      images/cards_ko/CARDS_065.PNG
  4. +1
    -1
      monsters-info/ckey.json
  5. +1
    -1
      monsters-info/mon_en.json
  6. +1
    -1
      monsters-info/mon_ja.json
  7. +1
    -1
      monsters-info/mon_ko.json
  8. +1
    -1
      monsters-info/official-API/ja-card.json
  9. +1
    -1
      monsters-info/official-API/ko-card.json
  10. +1
    -1
      monsters-info/official-API/ko-skill.json
  11. +1
    -1
      monsters-info/skill_ko.json
  12. +37
    -23
      script.js

BIN
images/cards_ko/CARDS_059.PNG View File

Before After
Width: 1024  |  Height: 1024  |  Size: 868 kB Width: 1024  |  Height: 1024  |  Size: 882 kB

BIN
images/cards_ko/CARDS_064.PNG View File

Before After
Width: 1024  |  Height: 1024  |  Size: 881 kB Width: 1024  |  Height: 1024  |  Size: 959 kB

BIN
images/cards_ko/CARDS_065.PNG View File

Before After
Width: 1024  |  Height: 1024  |  Size: 258 kB Width: 1024  |  Height: 1024  |  Size: 791 kB

+ 1
- 1
monsters-info/ckey.json View File

@@ -1 +1 @@
[{"code":"ja","ckey":{"card":"d3e9a943f09bbf444291179041ed4de4","skill":"fea03ea5be0d261cb1a6d14b3d7ee1b7"},"updateTime":1601605012077},{"code":"en","ckey":{"card":"002bea450276a099b28f012023d5650f","skill":"3fffcf62e1b5e94153a48c1b3f7ad4ae"},"updateTime":1601605012077},{"code":"ko","ckey":{"card":"df61cc16e271ac12e5f38868bd5f76ab","skill":"bcd806f990925ac1ae719b71f78c7f8e"},"updateTime":1601605012077}]
[{"code":"ja","ckey":{"card":"1436ec8035542260ed47f15468ef8990","skill":"fea03ea5be0d261cb1a6d14b3d7ee1b7"},"updateTime":1602211726941},{"code":"en","ckey":{"card":"f536b899c0dc7ea0292538bc9eb8f63d","skill":"3fffcf62e1b5e94153a48c1b3f7ad4ae"},"updateTime":1602211726941},{"code":"ko","ckey":{"card":"4b28d962efb98d921e4f06e29c8d32db","skill":"4d4d75ebe0016bc9e1198d35890d96ca"},"updateTime":1602211726941}]

+ 1
- 1
monsters-info/mon_en.json
File diff suppressed because it is too large
View File


+ 1
- 1
monsters-info/mon_ja.json
File diff suppressed because it is too large
View File


+ 1
- 1
monsters-info/mon_ko.json
File diff suppressed because it is too large
View File


+ 1
- 1
monsters-info/official-API/ja-card.json
File diff suppressed because it is too large
View File


+ 1
- 1
monsters-info/official-API/ko-card.json
File diff suppressed because it is too large
View File


+ 1
- 1
monsters-info/official-API/ko-skill.json
File diff suppressed because it is too large
View File


+ 1
- 1
monsters-info/skill_ko.json
File diff suppressed because it is too large
View File


+ 37
- 23
script.js View File

@@ -22,7 +22,7 @@ if (location.search.includes('&')) {
}

const dbName = "PADDF";
var db;
var db = null;
const DBOpenRequest = indexedDB.open(dbName,2);

DBOpenRequest.onsuccess = function(event) {
@@ -32,9 +32,11 @@ DBOpenRequest.onsuccess = function(event) {
};
DBOpenRequest.onerror = function(event) {
// 错误处理
console.log("PADDF:数据库无法启用,数据全部重置。",event);
console.log("PADDF:数据库无法启用,删除可能存在的异常数据库。",event);
indexedDB.deleteDatabase(dbName); //直接把整个数据库删掉
alert('Some errors have occurred, please refresh the page.');
console.log("也可能是隐私模式导致无法启用数据库,于是尝试不保存的情况下读取数据。");
loadData();
//alert('Some errors have occurred, please refresh the page.');
//history.go(); //直接强制刷新
};
DBOpenRequest.onupgradeneeded = function(event) {
@@ -490,7 +492,7 @@ function loadData(force = false)

if (statusLine) statusLine.classList.remove("loading-check-version");
if (statusLine) statusLine.classList.add("loading-mon-info");
if (currentCkey.ckey.card == lastCurrentCkey.ckey.card) {
if (db && currentCkey.ckey.card == lastCurrentCkey.ckey.card) {
console.log(`cards_${currentDataSource.code} ckey相等,直接读取已有的数据`, currentCkey.ckey.card);
const transaction = db.transaction([`cards`]);
const objectStore = transaction.objectStore(`cards`);
@@ -528,16 +530,22 @@ function loadData(force = false)
console.log("Cards数据JSON解码出错", e);
return;
}
const transaction = db.transaction([`cards`], "readwrite");
transaction.oncomplete = function(event) {
console.log(`cards_${currentDataSource.code} 写入完毕`);
lastCurrentCkey.ckey.card = currentCkey.ckey.card;
lastCurrentCkey.updateTime = currentCkey.updateTime;
localStorage.setItem("PADDF-ckey", JSON.stringify(lastCkeys)); //储存新的ckey
if (db)
{
const transaction = db.transaction([`cards`], "readwrite");
transaction.oncomplete = function(event) {
console.log(`cards_${currentDataSource.code} 写入完毕`);
lastCurrentCkey.ckey.card = currentCkey.ckey.card;
lastCurrentCkey.updateTime = currentCkey.updateTime;
localStorage.setItem("PADDF-ckey", JSON.stringify(lastCkeys)); //储存新的ckey
dealCardsData(Cards);
};
const objectStore = transaction.objectStore(`cards`);
objectStore.put(Cards,currentDataSource.code);
}else //隐私模式无法启动数据库
{
dealCardsData(Cards);
};
const objectStore = transaction.objectStore(`cards`);
objectStore.put(Cards,currentDataSource.code);
}
},
onerror: function(response) {
console.error("Cards JSON数据获取失败", response);
@@ -570,7 +578,7 @@ function loadData(force = false)
if (statusLine) statusLine.classList.remove("loading-mon-info");

if (statusLine) statusLine.classList.add("loading-skill-info");
if (currentCkey.ckey.skill == lastCurrentCkey.ckey.skill) {
if (db && currentCkey.ckey.skill == lastCurrentCkey.ckey.skill) {
console.log(`skills_${currentDataSource.code} ckey相等,直接读取已有的数据`, currentCkey.ckey.card);
const transaction = db.transaction([`skills`]);
const objectStore = transaction.objectStore(`skills`);
@@ -608,16 +616,22 @@ function loadData(force = false)
console.log("Cards数据JSON解码出错", e);
return;
}
const transaction = db.transaction([`skills`], "readwrite");
transaction.oncomplete = function(event) {
console.log(`skills_${currentDataSource.code} 写入完毕`);
lastCurrentCkey.ckey.skill = currentCkey.ckey.skill;
lastCurrentCkey.updateTime = currentCkey.updateTime;
localStorage.setItem("PADDF-ckey", JSON.stringify(lastCkeys)); //储存新的ckey
if (db)
{
const transaction = db.transaction([`skills`], "readwrite");
transaction.oncomplete = function(event) {
console.log(`skills_${currentDataSource.code} 写入完毕`);
lastCurrentCkey.ckey.skill = currentCkey.ckey.skill;
lastCurrentCkey.updateTime = currentCkey.updateTime;
localStorage.setItem("PADDF-ckey", JSON.stringify(lastCkeys)); //储存新的ckey
dealSkillData(Skills);
};
const objectStore = transaction.objectStore(`skills`);
objectStore.put(Skills,currentDataSource.code);
}else //隐私模式无法启动数据库
{
dealSkillData(Skills);
};
const objectStore = transaction.objectStore(`skills`);
objectStore.put(Skills,currentDataSource.code);
}
},
onerror: function(response) {
console.error("Skills JSON数据获取失败", response);


Loading…
Cancel
Save