文件预览代码优化

This commit is contained in:
xintaofei
2026-03-17 00:35:14 +08:00
parent b4a6f70389
commit 0d913ebd94
2 changed files with 4 additions and 3 deletions

View File

@@ -1375,8 +1375,7 @@ export function FileWorkspacePanel() {
), ),
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
a: ({ node, href, children, ...aProps }) => { a: ({ node, href, children, ...aProps }) => {
const isRelative = const isRelative = href && !/^[a-z][a-z0-9+.-]*:|^#/i.test(href)
href && !/^https?:\/\/|^mailto:|^#/.test(href)
if (isRelative && href) { if (isRelative && href) {
return ( return (
<a <a

View File

@@ -221,7 +221,9 @@ export function FileWorkspaceTabBar() {
{canOpenInBrowser && activeTab?.path && folder?.path && ( {canOpenInBrowser && activeTab?.path && folder?.path && (
<button <button
type="button" type="button"
onClick={() => openPath(`${folder.path}/${activeTab.path}`)} onClick={() => {
openPath(`${folder.path}/${activeTab.path}`).catch(() => {})
}}
className="shrink-0 flex items-center justify-center w-10 hover:bg-primary/8 transition-colors" className="shrink-0 flex items-center justify-center w-10 hover:bg-primary/8 transition-colors"
aria-label={t("preview")} aria-label={t("preview")}
title={t("preview")} title={t("preview")}