|
1 | 1 | import { fetchScriptInfo, prepareScriptByCode } from "@App/pkg/utils/script"; |
2 | | -import { v4 as uuidv4 } from "uuid"; |
| 2 | +import { v4 as uuidv4, v5 as uuidv5 } from "uuid"; |
3 | 3 | import { Group } from "@Packages/message/server"; |
4 | 4 | import Logger from "@App/app/logger/logger"; |
5 | 5 | import LoggerCore from "@App/app/logger/core"; |
@@ -174,6 +174,17 @@ export class ScriptService { |
174 | 174 | return Promise.resolve(prepareScript.script); |
175 | 175 | } |
176 | 176 |
|
| 177 | + // 直接通过code静默安装脚本 |
| 178 | + async installByCode(param: { uuid: string; code: string; upsertBy: InstallSource }) { |
| 179 | + const prepareScript = await prepareScriptByCode(param.code, "", param.uuid, true); |
| 180 | + this.installScript({ |
| 181 | + script: prepareScript.script, |
| 182 | + code: param.code, |
| 183 | + upsertBy: param.upsertBy, |
| 184 | + }); |
| 185 | + return Promise.resolve(prepareScript.script); |
| 186 | + } |
| 187 | + |
177 | 188 | // 获取安装信息 |
178 | 189 | getInstallInfo(uuid: string) { |
179 | 190 | return Cache.getInstance().get(CacheKey.scriptInstallInfo(uuid)); |
@@ -563,6 +574,7 @@ export class ScriptService { |
563 | 574 | this.group.on("isInstalled", this.isInstalled.bind(this)); |
564 | 575 | this.group.on("sortScript", this.sortScript.bind(this)); |
565 | 576 | this.group.on("importByUrl", this.importByUrl.bind(this)); |
| 577 | + this.group.on("installByCode", this.installByCode.bind(this)); |
566 | 578 |
|
567 | 579 | // 定时检查更新, 每10分钟检查一次 |
568 | 580 | chrome.alarms.create("checkScriptUpdate", { |
|
0 commit comments