Skip to content

Commit af1c557

Browse files
lin-snowclaude
andcommitted
fix(editor): return to the same timeline page after editing an echo
Editing an old echo used to jump back to the newest post: on update success the store called resetHomeTimelineState + refreshEchos (page→1) + jumpToHomeTimeline (drops all query), and entering edit mode replaced the whole route query with {tab:'publish'}, dropping ?page. Now entering edit mode preserves the existing query (?page etc.), and on update success we only strip ?tab and navigate back. The timeline remounts and refetches the same page from the server (which already reflects the edit), so the user lands on the page containing the echo they just edited. Search/tag-filter context is preserved too. New-post (add) flow is unchanged — it still jumps to the top. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4681338 commit af1c557

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

web/src/components/advanced/echo/cards/TheEchoCard.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,10 @@ const handleUpdateEcho = async () => {
227227
}
228228
229229
editorStore.isUpdateMode = true
230+
// 保留当前的 ?page 等 query,编辑完返回时间线时才能回到原来那一页(而非跳回第 1 页)
230231
await router.push({
231232
name: 'home',
232-
query: { tab: 'publish' },
233+
query: { ...router.currentRoute.value.query, tab: 'publish' },
233234
})
234235
}
235236

web/src/stores/editor/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ export const useEditorStore = defineStore('editorStore', () => {
8383
void router.push({ name: 'home' }).catch(() => undefined)
8484
}
8585

86+
// 编辑完成后返回时间线:仅去掉 ?tab,保留 ?page 等 query,
87+
// 让时间线重挂载时按原页码重新拉取,停留在被编辑那条所在的页面。
88+
const backToTimelineTab = () => {
89+
const query = { ...router.currentRoute.value.query }
90+
delete query.tab
91+
void router.push({ name: 'home', query }).catch(() => undefined)
92+
}
93+
8694
const setMode = (mode: Mode) => {
8795
currentMode.value = mode
8896
}
@@ -242,14 +250,14 @@ export const useEditorStore = defineStore('editorStore', () => {
242250
loading: justSyncFiles ? t('editor.syncingFiles') : t('editor.updating'),
243251
success: (res) => {
244252
if (res.code === 1 && !justSyncFiles) {
245-
resetHomeTimelineState()
246253
clearEditor()
247-
echoStore.refreshEchos()
248254
isUpdateMode.value = false
249255
echoStore.echoToUpdate = null
250256
setMode(Mode.ECH0)
251257
echoStore.getTags()
252-
jumpToHomeTimeline()
258+
// 不重置分页 / 不跳回顶部:返回当前页,时间线重挂载会按 ?page 重新拉取,
259+
// 服务器返回的数据已含本次编辑结果,用户原地即可看到刚编辑的那条。
260+
backToTimelineTab()
253261
return t('editor.updateSuccess')
254262
} else if (res.code === 1 && justSyncFiles) {
255263
return t('editor.updateSuccessWithSync')

0 commit comments

Comments
 (0)