feat(admin): 商品管理列表持久化筛选/页码/滚动位置,详情页返回智能回退

This commit is contained in:
yml2213
2026-08-15 13:20:35 +08:00
parent ac47006711
commit 429ce74eff
2 changed files with 120 additions and 7 deletions
@@ -3,12 +3,12 @@ import { readError } from '@/shared/utils/error'
import { CopyDocument, EditPen, Search } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import { computed, onMounted, reactive, ref } from 'vue'
import { useRoute } from 'vue-router'
import { useRoute, useRouter } from 'vue-router'
import { fetchAdminUsers, type AdminUserItem } from '@/features/admin/api/adminUsers'
import { fetchAdminFileBlob } from '@/shared/api/files'
import AuthImage from '@/shared/components/business/AuthImage.vue'
import { adminPath } from '@/shared/utils/adminPath'
import { adminPath, isAdminPath } from '@/shared/utils/adminPath'
import {
centToYuan,
formatCentWithSymbol,
@@ -59,6 +59,17 @@ import { calculatePlatformPricing, roundRatio as roundPricingRatio } from '@/sha
const adminSession = useAdminSessionStore()
const route = useRoute()
const router = useRouter()
// 返回列表:有站内后台历史则回退(保留列表页筛选与滚动恢复),否则直接回列表页。
function goBackToList() {
const back = (window.history.state as { back?: string | null } | null)?.back
if (back && isAdminPath(back)) {
router.back()
return
}
void router.push(adminPath('listings'))
}
const loading = ref(false)
const submitting = ref(false)
const userSearching = ref(false)
@@ -596,9 +607,7 @@ async function openScreenshot(url: string) {
</div>
<div class="toolbar-actions">
<el-button :icon="CopyDocument" @click="copyListingCode">复制编号</el-button>
<RouterLink :to="adminPath('listings')">
<el-button>返回列表</el-button>
</RouterLink>
<el-button @click="goBackToList">返回列表</el-button>
<el-button
v-if="canAdjustExternal"
type="primary"