From 498d36567b1e7ae71e79a8481d89c66ce83d86f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=80=E4=B9=8B?= Date: Tue, 22 Apr 2025 18:01:20 +0800 Subject: [PATCH] =?UTF-8?q?todo:=20=E4=BC=98=E5=8C=96=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E7=9A=84=E8=84=9A=E6=9C=AC=E8=B5=84=E6=BA=90=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/service/service_worker/runtime.ts | 43 ++++++++++++----------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/app/service/service_worker/runtime.ts b/src/app/service/service_worker/runtime.ts index 1401a13..11fda21 100644 --- a/src/app/service/service_worker/runtime.ts +++ b/src/app/service/service_worker/runtime.ts @@ -196,33 +196,36 @@ export class RuntimeService { // 匹配当前页面的脚本 const matchScriptUuid = await this.getPageScriptUuidByUrl(chromeSender.url!); - const scripts = await Promise.all( - matchScriptUuid.map(async (uuid): Promise => { - const scriptRes = Object.assign({}, this.scriptMatchCache?.get(uuid)); - // 判断脚本是否开启 - if (scriptRes.status === SCRIPT_STATUS_DISABLE) { + const scripts = matchScriptUuid.map((uuid) => { + const scriptRes = Object.assign({}, this.scriptMatchCache?.get(uuid)); + // 判断脚本是否开启 + if (scriptRes.status === SCRIPT_STATUS_DISABLE) { + return undefined; + } + // 如果是iframe,判断是否允许在iframe里运行 + if (chromeSender.frameId !== undefined) { + if (scriptRes.metadata.noframes) { return undefined; } - // 如果是iframe,判断是否允许在iframe里运行 - if (chromeSender.frameId !== undefined) { - if (scriptRes.metadata.noframes) { - return undefined; - } - } - // 获取value - return scriptRes; - }) - ); + } + // 获取value + return scriptRes; + }); const enableScript = scripts.filter((item) => item); - // 加载value - await Promise.all( - enableScript.map(async (script) => { + await Promise.all([ + // 加载value + ...enableScript.map(async (script) => { const value = await this.value.getScriptValue(script!); script!.value = value; - }) - ); + }), + // 加载resource + ...enableScript.map(async (script) => { + // const resource = await this.script.buildScriptRunResource(script!); + // script!.resource = resource; + }), + ]); this.mq.emit("pageLoad", { tabId: chromeSender.tab?.id,