From d64a7fd489787167568bb2ead6f693fa8ba9eef2 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Fri, 27 Feb 2026 14:34:42 +0800 Subject: [PATCH 1/3] feat: code preview page add scroll to top button --- .../[packageName]/v/[version]/[...filePath].vue | 17 +++++++++++++++++ i18n/locales/en.json | 3 ++- i18n/locales/zh-CN.json | 3 ++- i18n/schema.json | 3 +++ lunaria/files/en-GB.json | 3 ++- lunaria/files/en-US.json | 3 ++- lunaria/files/zh-CN.json | 3 ++- 7 files changed, 30 insertions(+), 5 deletions(-) diff --git a/app/pages/package-code/[[org]]/[packageName]/v/[version]/[...filePath].vue b/app/pages/package-code/[[org]]/[packageName]/v/[version]/[...filePath].vue index 2202494d7..29208b231 100644 --- a/app/pages/package-code/[[org]]/[packageName]/v/[version]/[...filePath].vue +++ b/app/pages/package-code/[[org]]/[packageName]/v/[version]/[...filePath].vue @@ -249,6 +249,14 @@ function copyPermalinkUrl() { copyPermalink(url.toString()) } +// Scroll to top of file content +const contentContainer = useTemplateRef('contentContainer') +function scrollToTop() { + if (contentContainer.value) { + contentContainer.value.scrollTo({ top: 0, behavior: 'smooth' }) + } +} + // Canonical URL for this code page const canonicalUrl = computed(() => `https://npmx.dev${getCodeUrl(route.params)}`) @@ -410,6 +418,7 @@ defineOgImageComponent('Default', {