poi-plugin-akashic-records
Advanced tools
Comparing version 7.0.2-beta.0 to 7.0.2-beta.1
@@ -25,2 +25,4 @@ "use strict"; | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
const { APPDATA_PATH, config } = window; | ||
@@ -35,42 +37,64 @@ | ||
setNickNameId(id) { | ||
this.nickNameId = id; | ||
} | ||
_getDataAccordingToNameId(id, type) { | ||
const testNum = /^[1-9]+[0-9]*$/; | ||
let datalogs = _glob2.default.sync(_pathExtra2.default.join(DATA_PATH, 'akashic-records', this.nickNameId.toString(), type, '*')); | ||
datalogs = datalogs.map(filePath => { | ||
try { | ||
const fileContent = _fsExtra2.default.readFileSync(filePath, 'utf8'); | ||
let logs = fileContent.split("\n"); | ||
logs = logs.map(logItem => { | ||
logItem = logItem.split(','); | ||
if (testNum.test(logItem[0])) { | ||
logItem[0] = parseInt(logItem[0]); | ||
var _this = this; | ||
return _asyncToGenerator(function* () { | ||
const testNum = /^[1-9]+[0-9]*$/; | ||
let datalogs = _glob2.default.sync(_pathExtra2.default.join(DATA_PATH, 'akashic-records', _this.nickNameId.toString(), type, '*')); | ||
datalogs = datalogs.map((() => { | ||
var _ref = _asyncToGenerator(function* (filePath) { | ||
try { | ||
const fileContent = yield _fsExtra2.default.readFile(filePath, 'utf8'); | ||
let logs = fileContent.split("\n"); | ||
logs = logs.map(function (logItem) { | ||
logItem = logItem.split(','); | ||
if (testNum.test(logItem[0])) { | ||
logItem[0] = parseInt(logItem[0]); | ||
} | ||
return logItem; | ||
}); | ||
return logs.filter(function (log) { | ||
return log.length > 2; | ||
}); | ||
} catch (e) { | ||
if (process.env.DEBUG) { | ||
console.warn(`Read and decode file:${filePath} error!${e.toString()}`); | ||
} | ||
return []; | ||
} | ||
return logItem; | ||
}); | ||
return logs.filter(log => log.length > 2); | ||
} catch (e) { | ||
if (process.env.DEBUG) { | ||
console.warn(`Read and decode file:${filePath} error!${e.toString()}`); | ||
} | ||
return []; | ||
} | ||
}); | ||
datalogs = datalogs.reduce((ret, cur) => ret.concat(cur), []); | ||
datalogs.reverse(); | ||
datalogs.sort((a, b) => { | ||
if (isNaN(a[0])) a[0] = new Date(a[0]).getTime(); | ||
if (isNaN(b[0])) b[0] = new Date(b[0]).getTime(); | ||
return b[0] - a[0]; | ||
}); | ||
return datalogs; | ||
return function (_x) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
})()); | ||
datalogs = yield Promise.all(datalogs); | ||
datalogs = datalogs.reduce(function (ret, cur) { | ||
return ret.concat(cur); | ||
}, []); | ||
datalogs.reverse(); | ||
datalogs.sort(function (a, b) { | ||
if (isNaN(a[0])) a[0] = new Date(a[0]).getTime(); | ||
if (isNaN(b[0])) b[0] = new Date(b[0]).getTime(); | ||
return b[0] - a[0]; | ||
}); | ||
return datalogs; | ||
})(); | ||
} | ||
initializeData(id) { | ||
this.nickNameId = id; | ||
const data = {}; | ||
for (const k of Object.keys(_constant2.default.typeList)) { | ||
const type = _constant2.default.typeList[k]; | ||
data[type] = this._getDataAccordingToNameId(this.nickNameId, type); | ||
} | ||
return data; | ||
initializeData() { | ||
var _this2 = this; | ||
return _asyncToGenerator(function* () { | ||
const data = {}; | ||
for (const k of Object.keys(_constant2.default.typeList)) { | ||
const type = _constant2.default.typeList[k]; | ||
data[type] = yield _this2._getDataAccordingToNameId(_this2.nickNameId, type); | ||
} | ||
return data; | ||
})(); | ||
} | ||
@@ -77,0 +101,0 @@ |
{ | ||
"name": "poi-plugin-akashic-records", | ||
"version": "7.0.2-beta.0", | ||
"version": "7.0.2-beta.1", | ||
"description": "logbook plugin for poi", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -219,3 +219,3 @@ 'use strict'; | ||
this.deckCombinedFlag = body.api_combined_flag; | ||
if (this.timeString !== timeToBString(nowDate.getTime())) { | ||
if (this.timeString !== 'INIT' && this.timeString !== timeToBString(nowDate.getTime())) { | ||
this.timeString = timeToBString(nowDate.getTime()); | ||
@@ -325,3 +325,3 @@ const dataItem = [new Date().getTime(), ...body.api_material.map(item => item.api_value)]; | ||
this._ships = []; | ||
this.timeString = ""; | ||
this.timeString = 'INIT'; | ||
this.mapLv = []; | ||
@@ -334,9 +334,6 @@ this.battleStart = false; | ||
this.kdockId = 0; | ||
this.updateLogs(); | ||
} | ||
updateLogs() { | ||
if (this.nickNameId && this.nickNameId != 0) { | ||
const data = _dataCoManager2.default.initializeData(this.nickNameId); | ||
initializeLogs() { | ||
_dataCoManager2.default.initializeData(this.nickNameId).then(data => { | ||
for (const type of Object.keys(data)) { | ||
@@ -346,3 +343,3 @@ this.store.dispatch((0, _actions.initializeLogs)(data[type], type)); | ||
this.timeString = data.resource.length > 0 ? timeToBString(data.resource[0][0]) : ''; | ||
} | ||
}); | ||
} | ||
@@ -354,3 +351,4 @@ | ||
config.set('plugin.Akashic.nickNameId', this.nickNameId); | ||
this.updateLogs(); | ||
_dataCoManager2.default.setNickNameId(this.nickNameId); | ||
this.initializeLogs(); | ||
} | ||
@@ -357,0 +355,0 @@ } |
@@ -62,3 +62,3 @@ 'use strict'; | ||
this.lastClick = 1; | ||
this.lastClick = -1; | ||
} | ||
@@ -65,0 +65,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2754792
58737