From f1efa111890f0aeb123f8439162d0601eea14d0c Mon Sep 17 00:00:00 2001 From: wangyantong <51265903115@stu.ecnu.edu.cn> Date: Sun, 10 Nov 2024 19:56:59 +0800 Subject: [PATCH] fix: optimize fastpr (#910) --- src/locales/en/translation.json | 1 - src/locales/zh_CN/translation.json | 1 - src/pages/ContentScripts/features/fast-pr/index.tsx | 3 --- src/pages/Sandbox/index.jsx | 8 ++------ 4 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index a7a1dcf8..b14497e3 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -151,7 +151,6 @@ "success_create_pr": "PR created successfully.\nPR URL: {{url}}", "error_get_user_info": "Failed to get user info: {{status}}", "error_get_file": "The path is a directory, not a file.", - "error_match_FastPr_Url": "Error executing URL matching function: {{status}}.", "github_token_not_found": "GitHub token not found.\nPlease enter the token in the Settings page of the extension.", "gitee_token_not_found": "Gitee token not found.\nPlease enter the token in the Settings page of the extension." } diff --git a/src/locales/zh_CN/translation.json b/src/locales/zh_CN/translation.json index 1d2482da..3f912aea 100644 --- a/src/locales/zh_CN/translation.json +++ b/src/locales/zh_CN/translation.json @@ -150,7 +150,6 @@ "success_create_pr": "PR创建成功。\nPR 地址为: {{url}}", "error_get_user_info": "获取用户信息失败:{{status}}", "error_get_file": "该路径是一个目录,而不是文件", - "error_match_FastPr_Url": "执行URL匹配函数出错", "github_token_not_found": "GitHub 的 token 没有找到。\n请记得在扩展程序的设置页面输入 GitHub token。", "gitee_token_not_found": "Gitee 的 token 没有找到。\n请记得在扩展程序的设置页面输入 Gitee token。" } diff --git a/src/pages/ContentScripts/features/fast-pr/index.tsx b/src/pages/ContentScripts/features/fast-pr/index.tsx index c2a10f5b..336f7ddd 100644 --- a/src/pages/ContentScripts/features/fast-pr/index.tsx +++ b/src/pages/ContentScripts/features/fast-pr/index.tsx @@ -58,9 +58,6 @@ const observeUrlChanges = () => { window.addEventListener('message', (event: MessageEvent) => { if (event.data && event.data.matchedUrl) { init(event.data.matchedUrl); - } else if (event.data && event.data.error) { - const key = 'FastPR'; - handleMessage('error', t('error_match_FastPr_Url', { status: event.data.error }), key); } }); diff --git a/src/pages/Sandbox/index.jsx b/src/pages/Sandbox/index.jsx index e3f3883d..ec1526a2 100644 --- a/src/pages/Sandbox/index.jsx +++ b/src/pages/Sandbox/index.jsx @@ -30,12 +30,8 @@ const SandboxApp = () => { const handleMessage = (event) => { const { command, url } = event.data; if (command === 'matchUrl') { - try { - const matchedUrl = window.matchFastPrUrl(url); - event.source.postMessage({ matchedUrl }, event.origin); - } catch (error) { - event.source.postMessage({ error: error.message }, event.origin); - } + const matchedUrl = window.matchFastPrUrl(url); + event.source.postMessage({ matchedUrl }, event.origin); } };