Skip to content

Commit 5deb241

Browse files
committed
调整预览内容中的评论样式
1 parent 064e99d commit 5deb241

File tree

5 files changed

+41
-19
lines changed

5 files changed

+41
-19
lines changed

src/constants.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,8 @@ export const MAX_CONTENT_HEIGHT = 550
100100

101101
export const dataExpiryTime = 60 * 60 * 1000
102102

103-
/** 当 PAT 过期时 V2EX API 返回的错误信息 */
104-
export const TOKEN_EXPIRED_MESSAGE = 'Token expired'
103+
/** 请求 V2EX API 返回的特定信息 */
104+
export const enum RequestMessage {
105+
InvalidToken = 'Invalid token',
106+
TokenExpired = 'Token expired',
107+
}

src/contents/common.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,22 @@ import { colorTheme } from './globals'
2323
2424
<div class="v2p-footer-brand">
2525
<span>
26-
<a href="https://chrome.google.com/webstore/detail/v2ex-polish/onnepejgdiojhiflfoemillegpgpabdm" target="_blank">
26+
<a
27+
href="https://chrome.google.com/webstore/detail/v2ex-polish/onnepejgdiojhiflfoemillegpgpabdm"
28+
target="_blank"
29+
title="Chrome 应用商店"
30+
>
2731
${iconChromeWebStore}
2832
</a>
2933
</span>
3034
<span>
31-
<a href="https://github.com/coolpace/V2EX_Polish" target="_blank">${iconGitHub}</a>
35+
<a
36+
href="https://github.com/coolpace/V2EX_Polish"
37+
target="_blank"
38+
title="GitHub 仓库"
39+
>
40+
${iconGitHub}
41+
</a>
3242
</span>
3343
</div>
3444
</div>

src/contents/home/topic-list.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TOKEN_EXPIRED_MESSAGE } from '../../constants'
1+
import { RequestMessage } from '../../constants'
22
import { iconLoading } from '../../icons'
33
import { fetchTopic, fetchTopicReplies } from '../../services'
44
import { $topicList } from '../globals'
@@ -88,8 +88,8 @@ export function handlingTopicList() {
8888
$template.append(`
8989
<div class="v2p-topic-reply">
9090
<div class="v2p-topic-reply-member">
91-
<img src="${r.member.avatar}">
92-
<span>${r.member.username}:</span>
91+
<img class="v2p-topic-reply-avatar" src="${r.member.avatar}">
92+
<span class="v2p-topic-reply-username">${r.member.username}:</span>
9393
</div>
9494
<div class="v2p-topic-reply-content">${escapeHTML(r.content)}</div>
9595
</div>
@@ -105,7 +105,10 @@ export function handlingTopicList() {
105105
} catch (err) {
106106
if (isV2EX_RequestError(err)) {
107107
const message = err.cause.message
108-
if (message === TOKEN_EXPIRED_MESSAGE) {
108+
if (
109+
message === RequestMessage.TokenExpired ||
110+
message === RequestMessage.InvalidToken
111+
) {
109112
model.$content.empty().append(`<div>${err.cause.message}</div>`)
110113
}
111114
}

src/styles/v2ex-effect.scss

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -469,20 +469,24 @@ body {
469469
}
470470

471471
.v2p-topic-reply-member {
472-
display: inline-flex;
473-
gap: 0 5px;
472+
display: inline;
474473
color: var(--v2p-color-main-700);
475-
vertical-align: bottom;
474+
}
476475

477-
img {
478-
width: 14px;
479-
height: 14px;
480-
object-fit: cover;
476+
.v2p-topic-reply-avatar {
477+
position: relative;
478+
top: 2px;
479+
width: 14px;
480+
height: 14px;
481+
margin-right: 5px;
482+
object-fit: cover;
483+
overflow: hidden;
484+
background-color: var(--v2p-color-main-200);
485+
border-radius: 2px;
486+
}
481487

482-
& + span {
483-
font-weight: bold;
484-
}
485-
}
488+
.v2p-topic-reply-username {
489+
font-weight: bold;
486490
}
487491

488492
.v2p-topic-reply-content {

src/styles/v2ex-theme-default.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ img::selection {
705705

706706
.tab {
707707
background-color: transparent;
708+
user-select: none;
708709

709710
&:not(.v2p-hover-btn):hover {
710711
background-color: var(--v2p-color-main-100);
@@ -714,6 +715,7 @@ img::selection {
714715
.tab_current {
715716
color: var(--box-background-color);
716717
background-color: var(--box-foreground-color);
718+
user-select: none;
717719
}
718720

719721
#reply-box {

0 commit comments

Comments
 (0)