fix:尝试禁用自动导出本地存档功能,效果待测试

This commit is contained in:
ShakeFlower 2025-08-13 21:49:58 +08:00
parent 3db2604d95
commit 8b6664c2f0

View File

@ -69,41 +69,44 @@
}
var _export = function () {
var toExport = [];
// var _export = function () {
// var toExport = [];
localforage.iterate(function (value, key, n) {
if (value == null || !key.startsWith(core.firstData.name)) return;
value = core.decompress(value);
if (value == null) return;
var str = JSON.stringify(value).replace(/[\u007F-\uFFFF]/g, function (chr) {
return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4)
});
str = LZString.compressToBase64(str);
toExport.push(key);
core.saves.cache[key] = str;
fs.writeFile('_saves/' + key, str, 'utf-8', function () {});
}, function () {
if (toExport.length > 0) {
alert('提示!本塔已开启存档本地化!原始存档已全部导出至 _saves/ 目录下。');
}
fs.writeFile('_saves/.exported', '1', 'utf-8', function () {});
rewrite();
core.control.getSaveIndexes(function (indexes) { core.saves.ids = indexes; });
});
}
// localforage.iterate(function (value, key, n) {
// if (value == null || !key.startsWith(core.firstData.name)) return;
// value = core.decompress(value);
// if (value == null) return;
// var str = JSON.stringify(value).replace(/[\u007F-\uFFFF]/g, function (chr) {
// return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4)
// });
// str = LZString.compressToBase64(str);
// toExport.push(key);
// core.saves.cache[key] = str;
// fs.writeFile('_saves/' + key, str, 'utf-8', function () {});
// }, function () {
// if (toExport.length > 0) {
// alert('提示!本塔已开启存档本地化!原始存档已全部导出至 _saves/ 目录下。');
// }
// fs.writeFile('_saves/.exported', '1', 'utf-8', function () {});
// rewrite();
// core.control.getSaveIndexes(function (indexes) { core.saves.ids = indexes; });
// });
// }
fs.mkdir('_saves', function (err) {
if (err) return;
fs.readFile('_saves/.exported', 'utf-8', function(err, data) {
if (!err && data) {
rewrite();
core.control.getSaveIndexes(function (indexes) { core.saves.ids = indexes; });
return;
}
_export();
});
// === 禁用自动导出功能,避免影响造塔 === //
rewrite();
core.control.getSaveIndexes(function (indexes) { core.saves.ids = indexes; });
// fs.readFile('_saves/.exported', 'utf-8', function(err, data) {
// if (!err && data) {
// rewrite();
// core.control.getSaveIndexes(function (indexes) { core.saves.ids = indexes; });
// return;
// }
// _export();
// });
});
})();