mirror of
https://github.com/koodo-reader/koodo-reader.git
synced 2026-06-18 21:00:35 -04:00
feat: enhance error handling and logging in sync processes, update app version and platform storage
This commit is contained in:
14
main.js
14
main.js
@@ -12,6 +12,7 @@ const {
|
||||
const path = require("path");
|
||||
const isDev = require("electron-is-dev");
|
||||
const Store = require("electron-store");
|
||||
const os = require("os");
|
||||
const store = new Store();
|
||||
const fs = require("fs");
|
||||
const configDir = app.getPath("userData");
|
||||
@@ -31,6 +32,12 @@ var filePath = null;
|
||||
if (process.platform != "darwin" && process.argv.length >= 2) {
|
||||
filePath = process.argv[1];
|
||||
}
|
||||
store.set(
|
||||
"appVersion", packageJson.version,
|
||||
);
|
||||
store.set(
|
||||
"appPlatform", os.platform() + " " + os.release(),
|
||||
);
|
||||
let options = {
|
||||
width: 1050,
|
||||
height: 660,
|
||||
@@ -46,7 +53,6 @@ let options = {
|
||||
sandbox: false,
|
||||
},
|
||||
};
|
||||
const os = require('os');
|
||||
const Database = require("better-sqlite3");
|
||||
if (os.platform() === 'linux') {
|
||||
options = Object.assign({}, options, {
|
||||
@@ -88,8 +94,8 @@ const getDBConnection = (dbName, storagePath, sqlStatement) => {
|
||||
}
|
||||
const getSyncUtil = async (config, isUseCache = true) => {
|
||||
if (!isUseCache || !syncUtilCache[config.service]) {
|
||||
const { SyncUtil, TokenService, ThirdpartyRequest } = await import('./src/assets/lib/kookit-extra.min.mjs');
|
||||
let thirdpartyRequest = new ThirdpartyRequest(TokenService);
|
||||
const { SyncUtil, TokenService, ConfigService, ThirdpartyRequest } = await import('./src/assets/lib/kookit-extra.min.mjs');
|
||||
let thirdpartyRequest = new ThirdpartyRequest(TokenService, ConfigService);
|
||||
|
||||
syncUtilCache[config.service] = new SyncUtil(config.service, config, config.storagePath, thirdpartyRequest);
|
||||
}
|
||||
@@ -103,7 +109,7 @@ const removeSyncUtil = (config) => {
|
||||
const getPickerUtil = async (config, isUseCache = true) => {
|
||||
if (!isUseCache || !pickerUtilCache[config.service]) {
|
||||
const { SyncUtil, TokenService, ThirdpartyRequest } = await import('./src/assets/lib/kookit-extra.min.mjs');
|
||||
let thirdpartyRequest = new ThirdpartyRequest(TokenService);
|
||||
let thirdpartyRequest = new ThirdpartyRequest(TokenService, ConfigService);
|
||||
|
||||
pickerUtilCache[config.service] = new SyncUtil(config.service, config, config.storagePath, thirdpartyRequest);
|
||||
}
|
||||
|
||||
2
src/assets/lib/kookit-extra-browser.min.js
vendored
2
src/assets/lib/kookit-extra-browser.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -181,6 +181,7 @@
|
||||
"Loading": "加载中",
|
||||
"Note": "笔记",
|
||||
"Page width": "页面宽度",
|
||||
"Tasks failed after multiple retries, please check the network connection": "多次重试后任务失败,请检查网络连接",
|
||||
"Digest": "书摘",
|
||||
"Auto expand content": "默认展开所有目录",
|
||||
"Hide footer": "不显示页脚",
|
||||
@@ -283,7 +284,7 @@
|
||||
"Authorization failed, please login again": "授权失败,请重新登录",
|
||||
"Authorization failed": "授权失败",
|
||||
"Testing connection...": "测试连接中...",
|
||||
"We have bypassed the synchronization of book cover for Aliyun Drive": "我们为阿里云盘跳过了图书封面的同步",
|
||||
"We have bypassed the synchronization of book cover for Aliyun Drive, covers will be downloaded automatically when you open the book next time.": "我们为阿里云盘跳过了图书封面的同步,封面将在您下次打开图书时自动下载。",
|
||||
"Connection failed": "连接失败",
|
||||
"Offline failed": "离线失败",
|
||||
"Email": "邮箱",
|
||||
|
||||
@@ -290,22 +290,49 @@ class Header extends React.Component<HeaderProps, HeaderState> {
|
||||
.require("electron")
|
||||
.ipcRenderer.invoke("cloud-stats", config);
|
||||
if (stats.total > 0) {
|
||||
toast.loading(
|
||||
this.props.t("Start Transfering Data") +
|
||||
" (" +
|
||||
stats.completed +
|
||||
"/" +
|
||||
stats.total +
|
||||
")",
|
||||
{
|
||||
id: "syncing",
|
||||
}
|
||||
);
|
||||
if (stats.hasFailedTasks) {
|
||||
toast.error(
|
||||
this.props.t(
|
||||
"Tasks failed after multiple retries, please check the network connection"
|
||||
),
|
||||
{
|
||||
id: "syncing",
|
||||
}
|
||||
);
|
||||
clearInterval(this.timer);
|
||||
this.setState({ isSync: false });
|
||||
return;
|
||||
} else {
|
||||
toast.loading(
|
||||
this.props.t("Start Transfering Data") +
|
||||
" (" +
|
||||
stats.completed +
|
||||
"/" +
|
||||
stats.total +
|
||||
")",
|
||||
{
|
||||
id: "syncing",
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let syncUtil = await SyncService.getSyncUtil();
|
||||
let stats = await syncUtil.getStats();
|
||||
if (stats.total > 0) {
|
||||
if (stats.hasFailedTasks) {
|
||||
toast.error(
|
||||
this.props.t(
|
||||
"Tasks failed after multiple retries, please check the network connection"
|
||||
),
|
||||
{
|
||||
id: "syncing",
|
||||
}
|
||||
);
|
||||
clearInterval(this.timer);
|
||||
this.setState({ isSync: false });
|
||||
return;
|
||||
}
|
||||
toast.loading(
|
||||
this.props.t("Start Transfering Data") +
|
||||
" (" +
|
||||
@@ -339,7 +366,7 @@ class Header extends React.Component<HeaderProps, HeaderState> {
|
||||
if (this.props.defaultSyncOption === "adrive") {
|
||||
toast.success(
|
||||
this.props.t(
|
||||
"We have bypassed the synchronization of book cover for Aliyun Drive"
|
||||
"We have bypassed the synchronization of book cover for Aliyun Drive, covers will be downloaded automatically when you open the book next time."
|
||||
),
|
||||
{
|
||||
duration: 4000,
|
||||
|
||||
@@ -21,8 +21,8 @@ export const initTheme = () => {
|
||||
window.matchMedia("(prefers-color-scheme: dark)").matches;
|
||||
}
|
||||
ConfigService.setReaderConfig("isOSNight", isNight ? "yes" : "no");
|
||||
ConfigService.setReaderConfig("appVersion", packageJson.version);
|
||||
ConfigService.setReaderConfig(
|
||||
ConfigService.setItem("appVersion", packageJson.version);
|
||||
ConfigService.setItem(
|
||||
"appPlatform",
|
||||
isElectron ? osName + " " + osVersion : browserName + " " + browserVersion
|
||||
);
|
||||
|
||||
@@ -12,6 +12,7 @@ export const getThirdpartyRequest = async () => {
|
||||
if (thirdpartyRequest) {
|
||||
return thirdpartyRequest;
|
||||
}
|
||||
console.log("Initializing ThirdpartyRequest", TokenService, ConfigService);
|
||||
thirdpartyRequest = new ThirdpartyRequest(TokenService, ConfigService);
|
||||
return thirdpartyRequest;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user