Skip to content

Commit dd05752

Browse files
committed
🐛 优化同步报错问题 #222
1 parent aa8a119 commit dd05752

File tree

6 files changed

+27
-14
lines changed

6 files changed

+27
-14
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scriptcat",
3-
"version": "0.15.0",
3+
"version": "0.15.0-beta",
44
"description": "脚本猫,一个可以执行用户脚本的浏览器扩展,万物皆可脚本化,让你的浏览器可以做更多的事情!",
55
"author": "CodFrm",
66
"license": "GPLv3",
@@ -12,7 +12,8 @@
1212
"build:linter": "webpack --mode production --config ./webpack/webpack.linter.ts",
1313
"build:no-split": "webpack --mode production --config ./webpack/webpack.no.split.ts",
1414
"dev:linter": "webpack --mode development --config ./webpack/webpack.linter.dev.ts",
15-
"pack": "node ./build/pack.js"
15+
"pack": "node ./build/pack.js",
16+
"changlog": "gitmoji-changelog"
1617
},
1718
"dependencies": {
1819
"@arco-design/web-react": "^2.47.0",

src/app/service/synchronize/manager.ts

+15-9
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { prepareScriptByCode } from "@App/pkg/utils/script";
1818
import { errorMsg, InfoNotification } from "@App/pkg/utils/utils";
1919
import FileSystemFactory from "@Pkg/filesystem/factory";
2020
import FileSystem, { File } from "@Pkg/filesystem/filesystem";
21+
import { t } from "i18next";
2122
import Manager from "../manager";
2223
import ResourceManager from "../resource/manager";
2324
import ScriptManager from "../script/manager";
@@ -122,12 +123,17 @@ export default class SynchronizeManager extends Manager {
122123
logger.error("create filesystem error", Logger.E(e), {
123124
type: config.filesystem,
124125
});
125-
InfoNotification("同步系统连接失败", errorMsg(e));
126126
if (autoDisable) {
127+
InfoNotification(
128+
`${t("sync_system_connect_failed")}, ${t("sync_system_closed")}`,
129+
`${t("sync_system_closed_description")}\n${errorMsg(e)}`
130+
);
127131
this.systemConfig.cloudSync = {
128132
...this.systemConfig.cloudSync,
129133
enable: false,
130134
};
135+
} else {
136+
InfoNotification(t("sync_system_connect_failed"), errorMsg(e));
131137
}
132138
throw e;
133139
}
@@ -157,7 +163,7 @@ export default class SynchronizeManager extends Manager {
157163
try {
158164
await this.syncOnce(fs);
159165
} catch (e: any) {
160-
InfoNotification("同步失败,请检查同步配置", errorMsg(e));
166+
this.logger.error("sync error", Logger.E(e));
161167
}
162168
}, 60 * 60 * 1000);
163169
freeFn.push(() => {
@@ -167,7 +173,7 @@ export default class SynchronizeManager extends Manager {
167173
try {
168174
await this.syncOnce(fs);
169175
} catch (e: any) {
170-
InfoNotification("同步失败,请检查同步配置", errorMsg(e));
176+
this.logger.error("sync error", Logger.E(e));
171177
}
172178
return Promise.resolve(() => {
173179
logger.info("stop cloud sync");
@@ -490,13 +496,13 @@ export default class SynchronizeManager extends Manager {
490496
}
491497

492498
getUrlName(url: string): string {
493-
let t = url.indexOf("?");
494-
if (t !== -1) {
495-
url = url.substring(0, t);
499+
let index = url.indexOf("?");
500+
if (index !== -1) {
501+
url = url.substring(0, index);
496502
}
497-
t = url.lastIndexOf("/");
498-
if (t !== -1) {
499-
url = url.substring(t + 1);
503+
index = url.lastIndexOf("/");
504+
if (index !== -1) {
505+
url = url.substring(index + 1);
500506
}
501507
return url;
502508
}

src/locales/en-US/translation.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ cookie_domain: "Cookie Domain"
341341
script_operation_title: "Script is attempting to access script synchronization storage"
342342
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."
343343
script_permission_content: "Script"
344+
sync_system_connect_failed: "Sync system connection failed"
345+
sync_system_closed: "Sync turned off"
346+
sync_system_closed_description: "Sync is disabled, please configure again"
344347

345348
# FileSystem
346349
auth_type: Authentication Type

src/locales/zh-CN/translation.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ cookie_domain: "Cookie域"
342342
script_operation_title: "脚本正在试图操作脚本同步储存空间"
343343
script_operation_description: "请您确认是否允许脚本进行此操作,允许后将允许脚本操作你设定的储存空间,脚本会在储存空间下创建一个app/${dir}的目录进行使用"
344344
script_permission_content: "脚本"
345+
sync_system_connect_failed: "同步系统连接失败"
346+
sync_system_closed: "已关闭同步"
347+
sync_system_closed_description: "同步功能已关闭,请重新配置"
345348

346349
# 文件系统
347350
auth_type: 鉴权类型

src/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 2,
33
"name": "ScriptCat",
4-
"version": "0.15.0",
4+
"version": "0.15.0.1010",
55
"author": "CodFrm",
66
"description": "脚本猫,一个用户脚本管理器,支持后台脚本、定时脚本、页面脚本,可编写脚本每天帮你自动处理事务.",
77
"options_ui": {

0 commit comments

Comments
 (0)