Former-commit-id: c683b18c102388b880ace99f792d1d2f6d2fc595
This commit is contained in:
troyeguo
2021-04-11 14:28:39 +08:00
parent 577d978da4
commit cd7a77d190

View File

@@ -115,19 +115,33 @@ class Header extends React.Component<HeaderProps, HeaderState> {
.require("electron")
.ipcRenderer.sendSync("storage-location", "ping");
let sourcePath = path.join(storageLocation, "config", "readerConfig.json");
const readerConfig = JSON.parse(
fs.readFileSync(sourcePath, { encoding: "utf8", flag: "r" })
);
//如果同步文件夹的记录较新就从同步文件夹同步数据到Koodo
if (
localStorage.getItem("lastSyncTime") &&
parseInt(readerConfig.lastSyncTime) >
parseInt(localStorage.getItem("lastSyncTime")!)
) {
console.log(1);
this.syncFromLocation();
} else {
//否则就把Koodo中数据同步到同步文件夹
try {
const readerConfig = JSON.parse(
fs.readFileSync(sourcePath, { encoding: "utf8", flag: "r" })
);
//如果同步文件夹的记录较新就从同步文件夹同步数据到Koodo
if (
localStorage.getItem("lastSyncTime") &&
parseInt(readerConfig.lastSyncTime) >
parseInt(localStorage.getItem("lastSyncTime")!)
) {
console.log(1);
this.syncFromLocation();
} else {
//否则就把Koodo中数据同步到同步文件夹
BackupUtil.backup(
this.props.books,
this.props.notes,
this.props.bookmarks,
() => {
this.props.handleMessage("Sync Successfully");
this.props.handleMessageBox(true);
},
5,
() => {}
);
}
} catch (error) {
BackupUtil.backup(
this.props.books,
this.props.notes,