Skip to content

Commit f19f623

Browse files
authored
fix: handle changelog anchor links (#8750)
Signed-off-by: Yufeng He <40085740+he-yufeng@users.noreply.github.com>
1 parent 32cfcbf commit f19f623

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

dashboard/src/components/shared/ChangelogDialog.vue

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const changelogVersion = ref('');
3232
const selectedVersion = ref('');
3333
const availableVersions = ref([]);
3434
const loadingVersions = ref(false);
35+
const scrollContainer = ref(null);
3536
3637
// 获取当前版本号(从版本信息中提取)
3738
async function getCurrentVersion() {
@@ -104,6 +105,24 @@ function onVersionChange() {
104105
}
105106
}
106107
108+
function handleChangelogClick(event) {
109+
const targetElement = event.target instanceof Element ? event.target : null;
110+
const anchor = targetElement?.closest('a[href^="#"]');
111+
if (!anchor) return;
112+
113+
const rawHref = anchor.getAttribute('href');
114+
const targetId = rawHref ? decodeURIComponent(rawHref.slice(1)) : '';
115+
if (!targetId) return;
116+
117+
const target = scrollContainer.value?.querySelector(
118+
`#${CSS.escape(targetId)}`,
119+
);
120+
if (!target) return;
121+
122+
event.preventDefault();
123+
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
124+
}
125+
107126
// 监听对话框打开,初始化数据
108127
watch(dialog, async (newValue) => {
109128
if (newValue) {
@@ -178,7 +197,11 @@ getCurrentVersion();
178197
</div>
179198
180199
<!-- 更新日志内容 -->
181-
<div style="max-height: 70vh; overflow-y: auto;">
200+
<div
201+
ref="scrollContainer"
202+
style="max-height: 70vh; overflow-y: auto;"
203+
@click="handleChangelogClick"
204+
>
182205
<div v-if="changelogLoading" class="text-center py-8">
183206
<v-progress-circular indeterminate color="primary"></v-progress-circular>
184207
<div class="mt-4">{{ t('core.navigation.changelogDialog.loading') }}</div>

0 commit comments

Comments
 (0)