Repository navigation
fix: restore document list pagination and scope detail scrolling #8302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ import ButtonExecutionRecord from './components/ButtonExecutionRecord.vue' | |
| import DocumentStatus from './components/DocumentStatus.vue' | ||
| import DocumentTags from './components/DocumentTags.vue' | ||
| import ButtonImportDocument from './import-document/ButtonImportDocument.vue' | ||
| import { saveDocumentPagination, takeDocumentPagination } from './pagination-return' | ||
| import { DOCUMENT_STATUS_FILTER_OPTIONS, DOCUMENT_STATUS_OPTIONS } from './status' | ||
| import ButtonUploadDocument from './upload-document/ButtonUploadDocument.vue' | ||
| import { DOCUMENT_HIT_HANDLING_LABELS } from '@/constants/document' | ||
|
|
@@ -85,10 +86,15 @@ const { knowledge, resourceApi, routeNames, routeParams } = useKnowledgeDetailCo | |
| /* 文档分段入口:选择列与行内操作继续处理自身交互。 */ | ||
| function handleOpenParagraph(document: DocumentItem, column?: TableColumnCtx<DocumentItem> | null) { | ||
| if (loading.value || operationLoading.value || column?.type === 'selection') return | ||
| void router.push({ | ||
| const listLocation = route.fullPath | ||
| const { currentPage, pageSize } = paginationConfig.value | ||
| const detailLocation = { | ||
| name: routeNames.value.paragraph, | ||
| params: { ...routeParams.value, type: knowledgeType.value, documentId: document.id }, | ||
| query: route.query, | ||
| } | ||
| void router.push(detailLocation).then((failure) => { | ||
| if (!failure) saveDocumentPagination(router, listLocation, detailLocation, { currentPage, pageSize }) | ||
| }) | ||
| } | ||
|
|
||
|
|
@@ -146,7 +152,13 @@ function handleCreateDocument(name: string) { | |
| /* 文档筛选与分页查询 */ | ||
| const loading = ref(false) | ||
| const documentData = ref<DocumentItem[]>([]) | ||
| const paginationConfig = ref({ currentPage: 1, pageSize: 20, total: 0 }) | ||
| const savedPagination = takeDocumentPagination(router) | ||
| const paginationConfig = ref({ | ||
| currentPage: savedPagination?.currentPage ?? 1, | ||
| pageSize: savedPagination?.pageSize ?? 20, | ||
| total: 0, | ||
| }) | ||
|
|
||
| const documentQuery = ref<Dict<unknown>>({}) | ||
| const orderBy = ref<string>() | ||
| const creatorOptions = ref<OptionItem<string>[]>([]) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The diff is generally reasonable, but there are several things to check/fix. I’m assuming Potential issues
Minor note
Recommended fix summary
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /** 分段页返回原文档列表时一次性恢复分页。 */ | ||
| import type { RouteLocationNormalized, RouteLocationRaw, Router } from 'vue-router' | ||
|
|
||
| interface DocumentPagination { | ||
| currentPage: number | ||
| pageSize: number | ||
| } | ||
|
|
||
| const documentPagination = new WeakMap<RouteLocationNormalized, { listLocation: string; pagination: DocumentPagination }>() | ||
|
|
||
| /** 进入分段成功后记录分页,只在本次分段导航返回原列表时交给列表。 */ | ||
| export function saveDocumentPagination(router: Router, listLocation: string, detailLocation: RouteLocationRaw, pagination: DocumentPagination) { | ||
| const detail = router.currentRoute.value | ||
| if (detail.fullPath !== router.resolve(detailLocation).fullPath) return | ||
|
|
||
| const snapshot = { listLocation, pagination } | ||
| documentPagination.set(detail, snapshot) | ||
| const stopTracking = router.afterEach((to, from, failure) => { | ||
| if (failure || from !== detail) return | ||
| stopTracking() | ||
| documentPagination.delete(detail) | ||
| if (to.fullPath === listLocation) documentPagination.set(to, snapshot) | ||
| }) | ||
| } | ||
|
|
||
| /** 读取当前分段页对应的原列表地址。 */ | ||
| export function getDocumentListReturnLocation(router: Router) { | ||
| return documentPagination.get(router.currentRoute.value)?.listLocation | ||
| } | ||
|
|
||
| /** 读取本次返回的分页并立即清空。 */ | ||
| export function takeDocumentPagination(router: Router) { | ||
| const list = router.currentRoute.value | ||
| const snapshot = documentPagination.get(list) | ||
| documentPagination.delete(list) | ||
| return snapshot?.pagination | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff is syntactically valid, but there are several fragility/compatibility concerns:
:has()browser support:has()is not supported in older browser versions. If the project still supports older Safari/Firefox/enterprise browsers, this layout rule will silently fail.:has(). Use a fallback or avoid:has()if support is required.Tight coupling to Element Plus /
MkViewLayoutinternal DOMmain > .el-scrollbar > .el-scrollbar__wrap > .el-scrollbar__view.MkViewLayoutor Element Plus can break it silently.MkViewLayoutor applying a dedicated class to the scrollbar view instead of piercing internal implementation details.Assumption that
class="resource-detail-layout"lands on the expected rootMkViewLayouthas a single root element and normal attribute fallthrough.inheritAttrs: false, or redirects attrs, the selector may not match.height: 100%may be ineffectiveheight: 100%only resolves correctly if the parent chain has a definite height.flex: 1; min-height: 0;rather than onlyheight: 100%.:has(> .mk-scrollbar-fill-height)is direct-child-only.mk-scrollbar-fill-height, the rule stops applying.Potentially broad selector
.resource-detail-layout :deep(main > ...)can match nestedmainelements under the layout.Suggested improvement: avoid
:has()and internal DOM coupling by havingMkViewLayoutsupport a “fill height” class/prop, or by placing a semantic class directly on the scrollbar view. If keeping the current approach, add a browser-support fallback and document that the selector depends on Element Plus internals.Minor: the CSS comment is in Chinese; consider matching the project’s comment-language convention.