diff --git a/src/containers/header/component.tsx b/src/containers/header/component.tsx index 442d8b4a..b22c2a57 100644 --- a/src/containers/header/component.tsx +++ b/src/containers/header/component.tsx @@ -115,19 +115,33 @@ class Header extends React.Component { .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,