Skip to content

Commit 4807f76

Browse files
committed
✨ 弹出页面增加快速检查脚本更新 #375
1 parent 808f613 commit 4807f76

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

src/app/service/service_worker/script.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Logger from "@App/app/logger/logger";
55
import LoggerCore from "@App/app/logger/core";
66
import Cache from "@App/app/cache";
77
import CacheKey from "@App/app/cache_key";
8-
import { checkSilenceUpdate, ltever, openInCurrentTab, randomString } from "@App/pkg/utils/utils";
8+
import { checkSilenceUpdate, InfoNotification, ltever, openInCurrentTab, randomString } from "@App/pkg/utils/utils";
99
import {
1010
Script,
1111
SCRIPT_RUN_STATUS,
@@ -509,7 +509,22 @@ export class ScriptService {
509509
}
510510

511511
requestCheckUpdate(uuid: string) {
512-
return this.checkUpdate(uuid, "user");
512+
if (uuid) {
513+
return this.checkUpdate(uuid, "user");
514+
} else {
515+
// 批量检查更新
516+
InfoNotification("检查更新", "正在检查所有的脚本更新");
517+
this.scriptDAO
518+
.all()
519+
.then((scripts) => {
520+
return Promise.all(scripts.map((script) => this.checkUpdate(script.uuid, "user")));
521+
})
522+
.then(() => {
523+
InfoNotification("检查更新", "所有脚本检查完成");
524+
return Promise.resolve(true);
525+
});
526+
return Promise.resolve(true);
527+
}
513528
}
514529

515530
isInstalled({ name, namespace }: { name: string; namespace: string }) {

src/pages/popup/App.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ import {
99
IconNotification,
1010
IconPlus,
1111
IconSearch,
12+
IconSync,
1213
} from "@arco-design/web-react/icon";
1314
import React, { useEffect, useState } from "react";
1415
import { RiMessage2Line, RiZzzFill } from "react-icons/ri";
1516
import semver from "semver";
1617
import { useTranslation } from "react-i18next";
1718
import ScriptMenuList from "../components/ScriptMenuList";
18-
import { popupClient } from "../store/features/script";
19+
import { popupClient, scriptClient } from "../store/features/script";
1920
import { ScriptMenu } from "@App/app/service/service_worker/popup";
2021
import { systemConfig } from "../store/global";
2122
import { isUserScriptsAvailable } from "@App/pkg/utils/utils";
@@ -148,6 +149,10 @@ function App() {
148149
});
149150
window.open("/src/options.html#/script/editor?target=initial", "_blank");
150151
break;
152+
case "checkUpdate":
153+
await scriptClient.requestCheckUpdate("");
154+
window.close();
155+
break;
151156
default:
152157
window.open(key, "_blank");
153158
break;
@@ -162,6 +167,10 @@ function App() {
162167
<IconSearch style={iconStyle} />
163168
{t("get_script")}
164169
</Menu.Item>
170+
<Menu.Item key={"checkUpdate"}>
171+
<IconSync style={iconStyle} />
172+
检查更新
173+
</Menu.Item>
165174
<Menu.Item key="https://github.com/scriptscat/scriptcat/issues/new?template=bug_report.md">
166175
<IconBug style={iconStyle} />
167176
{t("report_issue")}

0 commit comments

Comments
 (0)