Skip to content

Commit 10b15ee

Browse files
committed
Fix original article links
1 parent fa9fdbb commit 10b15ee

2 files changed

Lines changed: 47 additions & 6 deletions

File tree

src/App.jsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,8 @@ function ArticleListPane({
953953
}
954954

955955
function ReaderPane({ article, feed, mobilePane, onBack, onToggleStar }) {
956+
const articleLink = normalizeArticleLink(article?.link);
957+
956958
return (
957959
<main className={`pane reader-pane ${mobilePane === "reader" ? "mobile-active" : ""}`}>
958960
{article ? (
@@ -985,17 +987,17 @@ function ReaderPane({ article, feed, mobilePane, onBack, onToggleStar }) {
985987
<Star size={18} fill={article.starred ? "currentColor" : "none"} />
986988
</Button>
987989
</ActionTooltip>
988-
{article.link ? (
989-
<Button
990-
as="a"
991-
href={article.link}
990+
{articleLink ? (
991+
<a
992+
className="reader-link-button"
993+
href={articleLink}
992994
target="_blank"
993995
rel="noreferrer"
994-
variant="flat"
996+
aria-label="打开原文"
995997
title="打开原文"
996998
>
997999
原文
998-
</Button>
1000+
</a>
9991001
) : null}
10001002
</div>
10011003
</div>
@@ -1021,6 +1023,18 @@ function ReaderPane({ article, feed, mobilePane, onBack, onToggleStar }) {
10211023
);
10221024
}
10231025

1026+
function normalizeArticleLink(value) {
1027+
if (!value) {
1028+
return "";
1029+
}
1030+
1031+
try {
1032+
return new URL(value, window.location.href).href;
1033+
} catch {
1034+
return "";
1035+
}
1036+
}
1037+
10241038
function AddFeedDialog({ folders, onClose, onSubmit }) {
10251039
const [form, setForm] = useState({
10261040
url: "",

src/styles.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,33 @@ button {
9494
gap: 8px;
9595
}
9696

97+
.reader-link-button {
98+
min-width: 54px;
99+
height: 40px;
100+
display: inline-flex;
101+
align-items: center;
102+
justify-content: center;
103+
padding: 0 14px;
104+
border: 1px solid transparent;
105+
border-radius: 10px;
106+
background: color-mix(in srgb, var(--text) 8%, transparent);
107+
color: var(--text);
108+
font-size: 14px;
109+
font-weight: 720;
110+
text-decoration: none;
111+
line-height: 1;
112+
}
113+
114+
.reader-link-button:hover {
115+
border-color: var(--border);
116+
background: color-mix(in srgb, var(--text) 12%, transparent);
117+
}
118+
119+
.reader-link-button:focus-visible {
120+
outline: 2px solid color-mix(in srgb, var(--accent) 42%, transparent);
121+
outline-offset: 2px;
122+
}
123+
97124
.app.accent-blue {
98125
--accent: #2563eb;
99126
--accent-soft: rgba(37, 99, 235, 0.12);

0 commit comments

Comments
 (0)