From 22ab1e11b848c20eb33b5522a624a5772c1abe55 Mon Sep 17 00:00:00 2001
From: npmrun <1549469775@qq.com>
Date: Fri, 24 Apr 2026 20:42:33 +0800
Subject: [PATCH] feat(markdown): enhance dark mode styling and add post
preview functionality
- Updated SCSS for dark mode to use `:where()` for better specificity in styling `.markdown-body`.
- Added transparent background to highlighted code blocks in dark mode.
- Removed unnecessary navigation buttons from various pages to streamline the user interface.
- Introduced a new post preview page to allow users to view posts before publishing, with visibility handling for different post states.
These changes improve the visual consistency in dark mode and enhance the user experience when managing posts.
---
app/assets/scss/markdown/green.scss | 4 +-
app/assets/scss/markdown/highlight.scss | 4 +-
app/pages/@[publicSlug]/about/index.vue | 5 --
app/pages/@[publicSlug]/posts/[postSlug].vue | 3 -
app/pages/login/index.vue | 7 --
app/pages/me/admin/media-storage.vue | 3 -
app/pages/me/media/orphans.vue | 3 -
app/pages/me/posts/[id].vue | 12 +---
app/pages/me/posts/index.vue | 26 ++++---
app/pages/me/posts/new.vue | 11 ---
app/pages/me/posts/preview/[id].vue | 101 +++++++++++++++++++++++++++
app/pages/register/index.vue | 7 --
packages/drizzle-pkg/db.sqlite | Bin 163840 -> 163840 bytes
13 files changed, 125 insertions(+), 61 deletions(-)
create mode 100644 app/pages/me/posts/preview/[id].vue
diff --git a/app/assets/scss/markdown/green.scss b/app/assets/scss/markdown/green.scss
index 871f046..3e14c73 100644
--- a/app/assets/scss/markdown/green.scss
+++ b/app/assets/scss/markdown/green.scss
@@ -32,7 +32,7 @@
--markdown-padding: 1.6em;
}
-.dark .markdown-body {
+:where(.dark, [data-theme='dark'], [data-color-mode='dark']) .markdown-body {
--color-fg-default: #e5e7eb;
--color-fg-muted: #c0c7d1;
--color-fg-subtle: #9ca3af;
@@ -293,7 +293,7 @@
@include chinese;
}
-.dark .markdown-body.green {
+:where(.dark, [data-theme='dark'], [data-color-mode='dark']) .markdown-body.green {
.code-block-wrapper {
border-color: var(--code-border);
background: var(--code-bg);
diff --git a/app/assets/scss/markdown/highlight.scss b/app/assets/scss/markdown/highlight.scss
index 8b4081b..3cfa842 100644
--- a/app/assets/scss/markdown/highlight.scss
+++ b/app/assets/scss/markdown/highlight.scss
@@ -3,6 +3,7 @@
pre {
code.hljs {
color: #1f2937;
+ background: transparent;
}
.hljs-comment,
@@ -52,11 +53,12 @@
}
}
-.dark .markdown-body {
+:where(.dark, [data-theme='dark'], [data-color-mode='dark']) .markdown-body {
.code-block-wrapper {
pre {
code.hljs {
color: #e5e7eb;
+ background: transparent;
}
.hljs-comment,
diff --git a/app/pages/@[publicSlug]/about/index.vue b/app/pages/@[publicSlug]/about/index.vue
index 37cb7d4..140f8fc 100644
--- a/app/pages/@[publicSlug]/about/index.vue
+++ b/app/pages/@[publicSlug]/about/index.vue
@@ -64,10 +64,5 @@ usePageTitle(() =>
class="prose prose-neutral dark:prose-invert max-w-none prose-img:rounded-lg"
v-html="renderedBio"
/>
-
-
- 返回主页
-
-
diff --git a/app/pages/@[publicSlug]/posts/[postSlug].vue b/app/pages/@[publicSlug]/posts/[postSlug].vue
index e2e6d01..4b13c24 100644
--- a/app/pages/@[publicSlug]/posts/[postSlug].vue
+++ b/app/pages/@[publicSlug]/posts/[postSlug].vue
@@ -116,9 +116,6 @@ function exportMarkdown(): void {
-
- ← 返回主页
-
) => {
-
-
-
- 返回首页
-
-
-
diff --git a/app/pages/me/admin/media-storage.vue b/app/pages/me/admin/media-storage.vue
index ece5c46..80f26e3 100644
--- a/app/pages/me/admin/media-storage.vue
+++ b/app/pages/me/admin/media-storage.vue
@@ -201,9 +201,6 @@ onMounted(async () => {
对有引用但缺文件的记录可使用重新上传按原 storage_key 写回 WebP,不破坏文章/资料中的链接。
-
- 返回控制台
-
diff --git a/app/pages/me/media/orphans.vue b/app/pages/me/media/orphans.vue
index d2ff9f7..f318aa7 100644
--- a/app/pages/me/media/orphans.vue
+++ b/app/pages/me/media/orphans.vue
@@ -165,9 +165,6 @@ async function executeDelete() {
未被任何文章引用的上传图片;宽限期结束后可删除。
-
- 返回控制台
-
diff --git a/app/pages/me/posts/[id].vue b/app/pages/me/posts/[id].vue
index 0e00bc2..9ef0640 100644
--- a/app/pages/me/posts/[id].vue
+++ b/app/pages/me/posts/[id].vue
@@ -26,6 +26,9 @@ const visibilityItems = [
const bodyLength = computed(() => state.bodyMarkdown.trim().length)
const publicPostHref = computed(() => {
+ if (state.visibility !== 'public') {
+ return `/me/posts/preview/${id.value}`
+ }
const ps = user.value?.publicSlug
if (!ps || !state.slug) {
return ''
@@ -158,12 +161,6 @@ async function copyShareUrl() {
>
详情
-
- 返回列表
-
-
@@ -271,9 +268,6 @@ async function copyShareUrl() {
保存文章
-
- 取消并返回
-
删除文章
diff --git a/app/pages/me/posts/index.vue b/app/pages/me/posts/index.vue
index be065c4..6b403cd 100644
--- a/app/pages/me/posts/index.vue
+++ b/app/pages/me/posts/index.vue
@@ -3,7 +3,8 @@ import { useAuthSession } from '../../../composables/useAuthSession'
usePageTitle('我的文章')
-type Row = { id: number; title: string; slug: string; visibility: string }
+type Visibility = 'private' | 'unlisted' | 'public'
+type Row = { id: number; title: string; slug: string; visibility: Visibility }
type ViewMode = 'list' | 'card'
const posts = ref([])
@@ -26,12 +27,15 @@ onMounted(() => {
void load()
})
-function postDetailHref(slug: string) {
+function postDetailHref(post: Row) {
+ if (post.visibility !== 'public') {
+ return `/me/posts/preview/${post.id}`
+ }
const ps = user.value?.publicSlug
- if (!ps || !slug) {
+ if (!ps || !post.slug) {
return ''
}
- return `/@${ps}/posts/${encodeURIComponent(slug)}`
+ return `/@${ps}/posts/${encodeURIComponent(post.slug)}`
}
function visibilityLabel(visibility: string) {
@@ -52,8 +56,9 @@ function visibilityLabel(visibility: string) {
文章
-
+
卡片
-
+
新建
@@ -98,8 +104,8 @@ function visibilityLabel(visibility: string) {
创建文章
-
- 取消并返回
-
diff --git a/app/pages/me/posts/preview/[id].vue b/app/pages/me/posts/preview/[id].vue
new file mode 100644
index 0000000..32dd3ab
--- /dev/null
+++ b/app/pages/me/posts/preview/[id].vue
@@ -0,0 +1,101 @@
+
+
+
+
+
+ 加载中…
+
+
+
+
+
+ {{ visibilityLabel }}
+
+
+ 编辑
+
+
+
+
![]()
+
+
+ 发布于
+
+
+
+ {{ data.title }}
+
+
+ {{ data.excerpt }}
+
+
+
+
+
diff --git a/app/pages/register/index.vue b/app/pages/register/index.vue
index 9f55492..8123958 100644
--- a/app/pages/register/index.vue
+++ b/app/pages/register/index.vue
@@ -119,13 +119,6 @@ const onSubmit = async (_event: FormSubmitEvent) => {