From eeccece3735e09253d4661404e72236eaf4f2554 Mon Sep 17 00:00:00 2001 From: jinghui Date: Wed, 18 Nov 2026 20:52:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A1=B6=E6=A0=8F=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E3=80=8C=E6=9B=B4=E5=A4=9A=E7=B4=A0=E6=9D=90=E3=80=8D=E8=8F=9C?= =?UTF-8?q?=E5=8D=95,=E6=96=B0=E7=AA=97=E5=8F=A3=E6=89=93=E5=BC=80=20MinDo?= =?UTF-8?q?c=20=E7=B4=A0=E6=9D=90=E6=A8=A1=E6=9D=BF=E5=A4=A7=E5=85=A8?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/dbg_nav_morelink.py | 44 ++++++++++++++++++++++++++++++++ src/components/header/Header.tsx | 9 +++++++ 2 files changed, 53 insertions(+) create mode 100644 scripts/dbg_nav_morelink.py diff --git a/scripts/dbg_nav_morelink.py b/scripts/dbg_nav_morelink.py new file mode 100644 index 0000000..03594c9 --- /dev/null +++ b/scripts/dbg_nav_morelink.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +"""验证顶栏新增「更多素材」菜单:出现 + 点击新窗口打开目标 URL""" +import sys, asyncio + +BASE = "https://127.0.0.1:3005" +TARGET = "https://doc.88531.cn/docs/mrfx/mrfx-1g99qum57n5qk" + +async def main(): + from playwright.async_api import async_playwright + async with async_playwright() as p: + browser = await p.chromium.launch(args=["--ignore-certificate-errors"]) + ctx = await browser.new_context(ignore_https_errors=True, + viewport={"width": 1600, "height": 900}) + page = await ctx.new_page() + errs = [] + page.on("pageerror", lambda e: errs.append(str(e))) + + await page.goto(BASE + "/", wait_until="domcontentloaded", timeout=120000) + await page.wait_for_timeout(6000) + + link = page.locator("a", has_text="更多素材") + n = await link.count() + print("菜单项存在:", n, "PASS" if n == 1 else "FAIL") + if n: + info = await link.first.evaluate("el => ({href: el.href, target: el.target, text: el.innerText.trim()})") + print("链接:", info) + print("URL正确:", "PASS" if info["href"] == TARGET else "FAIL " + info["href"]) + print("新窗口:", "PASS" if info["target"] == "_blank" else "FAIL") + + # 点击并捕获新标签页 + async with ctx.expect_page() as newp: + await link.first.click() + np = await newp.value + await np.wait_for_load_state("domcontentloaded", timeout=60000) + print("新标签URL:", np.url, "PASS" if np.url.rstrip("/") == TARGET.rstrip("/") else "FAIL") + title = await np.title() + print("目标页title:", title) + await np.close() + + print("JS errors:", errs[:5]) + await page.screenshot(path="/vol1/1000/HD1/APP/hermes/awork/unicut_nav_check.png") + await browser.close() + +asyncio.run(main()) diff --git a/src/components/header/Header.tsx b/src/components/header/Header.tsx index 68653d8..c2a48e5 100644 --- a/src/components/header/Header.tsx +++ b/src/components/header/Header.tsx @@ -116,6 +116,15 @@ const Header = (props: IProps) => { > MCP 使用说明 + {/* 更多素材:外部资源站(MinDoc 文档),新窗口打开 */} + + 更多素材 + {/*