Skip to content

Commit

Permalink
🐛 优化同步报错问题 #222
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Jul 31, 2023
1 parent aa8a119 commit dd05752
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "scriptcat",
"version": "0.15.0",
"version": "0.15.0-beta",
"description": "脚本猫,一个可以执行用户脚本的浏览器扩展,万物皆可脚本化,让你的浏览器可以做更多的事情!",
"author": "CodFrm",
"license": "GPLv3",
Expand All @@ -12,7 +12,8 @@
"build:linter": "webpack --mode production --config ./webpack/webpack.linter.ts",
"build:no-split": "webpack --mode production --config ./webpack/webpack.no.split.ts",
"dev:linter": "webpack --mode development --config ./webpack/webpack.linter.dev.ts",
"pack": "node ./build/pack.js"
"pack": "node ./build/pack.js",
"changlog": "gitmoji-changelog"
},
"dependencies": {
"@arco-design/web-react": "^2.47.0",
Expand Down
24 changes: 15 additions & 9 deletions src/app/service/synchronize/manager.ts
Expand Up @@ -18,6 +18,7 @@ import { prepareScriptByCode } from "@App/pkg/utils/script";
import { errorMsg, InfoNotification } from "@App/pkg/utils/utils";
import FileSystemFactory from "@Pkg/filesystem/factory";
import FileSystem, { File } from "@Pkg/filesystem/filesystem";
import { t } from "i18next";
import Manager from "../manager";
import ResourceManager from "../resource/manager";
import ScriptManager from "../script/manager";
Expand Down Expand Up @@ -122,12 +123,17 @@ export default class SynchronizeManager extends Manager {
logger.error("create filesystem error", Logger.E(e), {
type: config.filesystem,
});
InfoNotification("同步系统连接失败", errorMsg(e));
if (autoDisable) {
InfoNotification(
`${t("sync_system_connect_failed")}, ${t("sync_system_closed")}`,
`${t("sync_system_closed_description")}\n${errorMsg(e)}`
);
this.systemConfig.cloudSync = {
...this.systemConfig.cloudSync,
enable: false,
};
} else {
InfoNotification(t("sync_system_connect_failed"), errorMsg(e));
}
throw e;
}
Expand Down Expand Up @@ -157,7 +163,7 @@ export default class SynchronizeManager extends Manager {
try {
await this.syncOnce(fs);
} catch (e: any) {
InfoNotification("同步失败,请检查同步配置", errorMsg(e));
this.logger.error("sync error", Logger.E(e));
}
}, 60 * 60 * 1000);
freeFn.push(() => {
Expand All @@ -167,7 +173,7 @@ export default class SynchronizeManager extends Manager {
try {
await this.syncOnce(fs);
} catch (e: any) {
InfoNotification("同步失败,请检查同步配置", errorMsg(e));
this.logger.error("sync error", Logger.E(e));
}
return Promise.resolve(() => {
logger.info("stop cloud sync");
Expand Down Expand Up @@ -490,13 +496,13 @@ export default class SynchronizeManager extends Manager {
}

getUrlName(url: string): string {
let t = url.indexOf("?");
if (t !== -1) {
url = url.substring(0, t);
let index = url.indexOf("?");
if (index !== -1) {
url = url.substring(0, index);
}
t = url.lastIndexOf("/");
if (t !== -1) {
url = url.substring(t + 1);
index = url.lastIndexOf("/");
if (index !== -1) {
url = url.substring(index + 1);
}
return url;
}
Expand Down
3 changes: 3 additions & 0 deletions src/locales/en-US/translation.yaml
Expand Up @@ -341,6 +341,9 @@ cookie_domain: "Cookie Domain"
script_operation_title: "Script is attempting to access script synchronization storage"
script_operation_description: "Please confirm whether you allow the script to perform this operation. If allowed, the script will be able to access the storage space you have set up and create a directory app/${dir} within it."
script_permission_content: "Script"
sync_system_connect_failed: "Sync system connection failed"
sync_system_closed: "Sync turned off"
sync_system_closed_description: "Sync is disabled, please configure again"

# FileSystem
auth_type: Authentication Type
Expand Down
3 changes: 3 additions & 0 deletions src/locales/zh-CN/translation.yaml
Expand Up @@ -342,6 +342,9 @@ cookie_domain: "Cookie域"
script_operation_title: "脚本正在试图操作脚本同步储存空间"
script_operation_description: "请您确认是否允许脚本进行此操作,允许后将允许脚本操作你设定的储存空间,脚本会在储存空间下创建一个app/${dir}的目录进行使用"
script_permission_content: "脚本"
sync_system_connect_failed: "同步系统连接失败"
sync_system_closed: "已关闭同步"
sync_system_closed_description: "同步功能已关闭,请重新配置"

# 文件系统
auth_type: 鉴权类型
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "ScriptCat",
"version": "0.15.0",
"version": "0.15.0.1010",
"author": "CodFrm",
"description": "脚本猫,一个用户脚本管理器,支持后台脚本、定时脚本、页面脚本,可编写脚本每天帮你自动处理事务.",
"options_ui": {
Expand Down

0 comments on commit dd05752

Please sign in to comment.