feat(admin): 优化商品审核工作台界面、截图凭证核验与按住速览体验
- 深度优化商品审核工作台:指标概览卡片、风险边条队列、标价管道联动、核心资产高密度展示、底部决策浮动 Dock、全套键盘快捷键 - 重构截图大图查看体验:移除旧版底部溢出的全局画廊,封装全屏居中弹窗 AdminListingReviewPreviewDialog,支持「按住速览(松手即关闭)」与「常驻弹窗(缩放/翻页/打码/原图)」双模交互 - 新增在线截图编辑器 ImageEditorDialog:支持平滑马赛克打码、自由裁剪与旋转保存 - 弹窗组件解耦:抽离审核拒绝、调价、全量核验、快捷键速查等子组件,严格控制单文件行数 - 后端支持:新增商品审核调整价格接口与配套单元测试
This commit is contained in:
@@ -0,0 +1,655 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import {
|
||||
ArrowLeft,
|
||||
ArrowRight,
|
||||
Close,
|
||||
EditPen,
|
||||
FullScreen,
|
||||
Lock,
|
||||
RefreshRight,
|
||||
TopRight,
|
||||
ZoomIn,
|
||||
ZoomOut,
|
||||
} from '@element-plus/icons-vue'
|
||||
|
||||
export interface PreviewScreenshotItem {
|
||||
url: string
|
||||
label: string
|
||||
categoryKey?: string
|
||||
}
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
visible: boolean
|
||||
images: PreviewScreenshotItem[]
|
||||
initialIndex?: number
|
||||
isPeekMode?: boolean
|
||||
previewUrls?: Record<string, string>
|
||||
}>(),
|
||||
{
|
||||
initialIndex: 0,
|
||||
isPeekMode: false,
|
||||
previewUrls: () => ({}),
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', value: boolean): void
|
||||
(e: 'update:isPeekMode', value: boolean): void
|
||||
(e: 'edit', payload: { shot: PreviewScreenshotItem; index: number }): void
|
||||
(e: 'openRaw', url: string): void
|
||||
}>()
|
||||
|
||||
const currentIndex = ref(0)
|
||||
const zoomScale = ref(1)
|
||||
const rotationDeg = ref(0)
|
||||
|
||||
watch(
|
||||
() => props.initialIndex,
|
||||
newIdx => {
|
||||
currentIndex.value = Math.max(0, Math.min(newIdx, props.images.length - 1))
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
visible => {
|
||||
if (visible) {
|
||||
zoomScale.value = 1
|
||||
rotationDeg.value = 0
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const currentItem = computed<PreviewScreenshotItem | null>(() => {
|
||||
if (!props.images.length) return null
|
||||
return props.images[currentIndex.value] || props.images[0] || null
|
||||
})
|
||||
|
||||
const currentDisplayUrl = computed(() => {
|
||||
if (!currentItem.value) return ''
|
||||
return props.previewUrls[currentItem.value.url] || currentItem.value.url
|
||||
})
|
||||
|
||||
const imageTransformStyle = computed(() => ({
|
||||
transform: `scale(${zoomScale.value}) rotate(${rotationDeg.value}deg)`,
|
||||
transition: 'transform 0.2s cubic-bezier(0.4, 0, 0.2, 1)',
|
||||
}))
|
||||
|
||||
function handlePrev() {
|
||||
if (currentIndex.value > 0) {
|
||||
currentIndex.value -= 1
|
||||
resetTransform()
|
||||
} else if (props.images.length > 1) {
|
||||
currentIndex.value = props.images.length - 1
|
||||
resetTransform()
|
||||
}
|
||||
}
|
||||
|
||||
function handleNext() {
|
||||
if (currentIndex.value < props.images.length - 1) {
|
||||
currentIndex.value += 1
|
||||
resetTransform()
|
||||
} else if (props.images.length > 1) {
|
||||
currentIndex.value = 0
|
||||
resetTransform()
|
||||
}
|
||||
}
|
||||
|
||||
function handleZoomIn() {
|
||||
zoomScale.value = Math.min(3, +(zoomScale.value + 0.25).toFixed(2))
|
||||
}
|
||||
|
||||
function handleZoomOut() {
|
||||
zoomScale.value = Math.max(0.5, +(zoomScale.value - 0.25).toFixed(2))
|
||||
}
|
||||
|
||||
function handleResetZoom() {
|
||||
zoomScale.value = 1
|
||||
rotationDeg.value = 0
|
||||
}
|
||||
|
||||
function handleRotate() {
|
||||
rotationDeg.value = (rotationDeg.value + 90) % 360
|
||||
}
|
||||
|
||||
function resetTransform() {
|
||||
zoomScale.value = 1
|
||||
rotationDeg.value = 0
|
||||
}
|
||||
|
||||
function lockToDialog() {
|
||||
emit('update:isPeekMode', false)
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
emit('update:visible', false)
|
||||
emit('update:isPeekMode', false)
|
||||
}
|
||||
|
||||
function handleEdit() {
|
||||
if (currentItem.value) {
|
||||
emit('edit', { shot: currentItem.value, index: currentIndex.value })
|
||||
handleClose()
|
||||
}
|
||||
}
|
||||
|
||||
function handleOpenRaw() {
|
||||
if (currentItem.value) {
|
||||
emit('openRaw', currentItem.value.url)
|
||||
}
|
||||
}
|
||||
|
||||
function handleGlobalMouseUp() {
|
||||
if (props.visible && props.isPeekMode) {
|
||||
handleClose()
|
||||
}
|
||||
}
|
||||
|
||||
function handleKeyDown(e: KeyboardEvent) {
|
||||
if (!props.visible) return
|
||||
|
||||
if (e.key === 'Escape') {
|
||||
e.stopPropagation()
|
||||
handleClose()
|
||||
} else if (e.key === 'ArrowLeft') {
|
||||
e.stopPropagation()
|
||||
handlePrev()
|
||||
} else if (e.key === 'ArrowRight') {
|
||||
e.stopPropagation()
|
||||
handleNext()
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('mouseup', handleGlobalMouseUp)
|
||||
window.addEventListener('touchend', handleGlobalMouseUp)
|
||||
window.addEventListener('keydown', handleKeyDown)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('mouseup', handleGlobalMouseUp)
|
||||
window.removeEventListener('touchend', handleGlobalMouseUp)
|
||||
window.removeEventListener('keydown', handleKeyDown)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition name="preview-fade">
|
||||
<div
|
||||
v-if="visible && currentItem"
|
||||
class="admin-preview-overlay"
|
||||
:class="{ 'is-peek': isPeekMode }"
|
||||
@click.self="handleClose"
|
||||
>
|
||||
<!-- Peek Mode Floating Top Status Bar -->
|
||||
<div v-if="isPeekMode" class="peek-hud-pill">
|
||||
<span class="hud-dot" />
|
||||
<span class="hud-text">按住速览中 · 松开鼠标自动关闭</span>
|
||||
<button class="hud-btn-lock" type="button" @click.stop="lockToDialog">
|
||||
<el-icon><Lock /></el-icon>
|
||||
<span>固定为弹窗</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Dialog Container -->
|
||||
<div class="admin-preview-container" :class="{ 'is-peek': isPeekMode }">
|
||||
<!-- Top Header -->
|
||||
<div class="preview-header">
|
||||
<div class="header-left">
|
||||
<span class="category-pill">{{ currentItem.label }}</span>
|
||||
<span v-if="images.length > 1" class="index-badge">
|
||||
{{ currentIndex + 1 }} / {{ images.length }}
|
||||
</span>
|
||||
<span v-if="!isPeekMode" class="hotkey-tip">快捷键:← / → 翻页 · Esc 退出</span>
|
||||
</div>
|
||||
|
||||
<!-- Toolbar Controls -->
|
||||
<div class="header-toolbar">
|
||||
<button
|
||||
class="tool-btn"
|
||||
title="缩小"
|
||||
type="button"
|
||||
:disabled="zoomScale <= 0.5"
|
||||
@click="handleZoomOut"
|
||||
>
|
||||
<el-icon><ZoomOut /></el-icon>
|
||||
</button>
|
||||
<button
|
||||
class="tool-btn reset-btn"
|
||||
title="还原比例"
|
||||
type="button"
|
||||
@click="handleResetZoom"
|
||||
>
|
||||
{{ Math.round(zoomScale * 100) }}%
|
||||
</button>
|
||||
<button
|
||||
class="tool-btn"
|
||||
title="放大"
|
||||
type="button"
|
||||
:disabled="zoomScale >= 3"
|
||||
@click="handleZoomIn"
|
||||
>
|
||||
<el-icon><ZoomIn /></el-icon>
|
||||
</button>
|
||||
<button class="tool-btn" title="顺时针旋转 90°" type="button" @click="handleRotate">
|
||||
<el-icon><RefreshRight /></el-icon>
|
||||
</button>
|
||||
<button
|
||||
class="tool-btn"
|
||||
title="新标签页打开原图"
|
||||
type="button"
|
||||
@click="handleOpenRaw"
|
||||
>
|
||||
<el-icon><TopRight /></el-icon>
|
||||
</button>
|
||||
<button
|
||||
class="tool-btn close-btn"
|
||||
title="关闭预览 (Esc)"
|
||||
type="button"
|
||||
@click="handleClose"
|
||||
>
|
||||
<el-icon><Close /></el-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Main Image Viewport -->
|
||||
<div class="preview-body" @click.self="handleClose">
|
||||
<!-- Left Arrow -->
|
||||
<button
|
||||
v-if="images.length > 1"
|
||||
class="nav-btn prev-btn"
|
||||
title="上一张 (←)"
|
||||
type="button"
|
||||
@click.stop="handlePrev"
|
||||
>
|
||||
<el-icon><ArrowLeft /></el-icon>
|
||||
</button>
|
||||
|
||||
<!-- Image Stage -->
|
||||
<div class="image-stage" @click.self="handleClose">
|
||||
<img
|
||||
:src="currentDisplayUrl"
|
||||
:alt="currentItem.label"
|
||||
:style="imageTransformStyle"
|
||||
class="preview-image"
|
||||
draggable="false"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Right Arrow -->
|
||||
<button
|
||||
v-if="images.length > 1"
|
||||
class="nav-btn next-btn"
|
||||
title="下一张 (→)"
|
||||
type="button"
|
||||
@click.stop="handleNext"
|
||||
>
|
||||
<el-icon><ArrowRight /></el-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Footer Action Bar -->
|
||||
<div class="preview-footer">
|
||||
<div class="footer-left">
|
||||
<span class="file-info">{{ currentItem.label }}</span>
|
||||
</div>
|
||||
<div class="footer-actions">
|
||||
<button class="action-btn edit-btn" type="button" @click="handleEdit">
|
||||
<el-icon><EditPen /></el-icon>
|
||||
<span>在线编辑 / 马赛克打码</span>
|
||||
</button>
|
||||
<button class="action-btn secondary-btn" type="button" @click="handleOpenRaw">
|
||||
<el-icon><FullScreen /></el-icon>
|
||||
<span>浏览器原图</span>
|
||||
</button>
|
||||
<button class="action-btn close-action-btn" type="button" @click="handleClose">
|
||||
<span>关闭预览 (Esc)</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.preview-fade-enter-active,
|
||||
.preview-fade-leave-active {
|
||||
transition:
|
||||
opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
|
||||
transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
|
||||
.preview-fade-enter-from,
|
||||
.preview-fade-leave-to {
|
||||
opacity: 0;
|
||||
transform: scale(0.97);
|
||||
}
|
||||
|
||||
.admin-preview-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
z-index: 3500;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(10, 15, 29, 0.88);
|
||||
backdrop-filter: blur(8px);
|
||||
padding: 24px;
|
||||
box-sizing: border-box;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.peek-hud-pill {
|
||||
position: absolute;
|
||||
top: 18px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 6px 16px;
|
||||
border-radius: 999px;
|
||||
background: rgba(30, 41, 59, 0.92);
|
||||
border: 1px solid rgba(148, 163, 184, 0.25);
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
|
||||
color: #f8fafc;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
z-index: 3600;
|
||||
animation: hudPulse 2s infinite ease-in-out;
|
||||
}
|
||||
|
||||
@keyframes hudPulse {
|
||||
0%,
|
||||
100% {
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
50% {
|
||||
box-shadow:
|
||||
0 8px 28px rgba(59, 130, 246, 0.35),
|
||||
0 0 0 1px rgba(96, 165, 250, 0.4);
|
||||
}
|
||||
}
|
||||
|
||||
.hud-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: #38bdf8;
|
||||
box-shadow: 0 0 8px #38bdf8;
|
||||
}
|
||||
|
||||
.hud-btn-lock {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
background: #2563eb;
|
||||
color: #ffffff;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
padding: 3px 10px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.hud-btn-lock:hover {
|
||||
background: #1d4ed8;
|
||||
}
|
||||
|
||||
.admin-preview-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
max-width: 1060px;
|
||||
max-height: 88vh;
|
||||
background: #0f172a;
|
||||
border: 1px solid rgba(148, 163, 184, 0.2);
|
||||
border-radius: 14px;
|
||||
box-shadow:
|
||||
0 24px 60px rgba(0, 0, 0, 0.6),
|
||||
0 0 0 1px rgba(255, 255, 255, 0.06);
|
||||
overflow: hidden;
|
||||
animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
|
||||
@keyframes modalPop {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: scale(0.96) translateY(6px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: scale(1) translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.preview-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 18px;
|
||||
background: rgba(15, 23, 42, 0.95);
|
||||
border-bottom: 1px solid rgba(51, 65, 85, 0.6);
|
||||
}
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.category-pill {
|
||||
display: inline-block;
|
||||
padding: 4px 10px;
|
||||
border-radius: 6px;
|
||||
background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
|
||||
color: #ffffff;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
|
||||
}
|
||||
|
||||
.index-badge {
|
||||
color: #94a3b8;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.hotkey-tip {
|
||||
color: #64748b;
|
||||
font-size: 12px;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.header-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.tool-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 6px;
|
||||
background: rgba(51, 65, 85, 0.5);
|
||||
border: 1px solid rgba(148, 163, 184, 0.15);
|
||||
color: #e2e8f0;
|
||||
font-size: 15px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.tool-btn:hover:not(:disabled) {
|
||||
background: rgba(71, 85, 105, 0.8);
|
||||
color: #ffffff;
|
||||
border-color: rgba(148, 163, 184, 0.3);
|
||||
}
|
||||
|
||||
.tool-btn:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.tool-btn.reset-btn {
|
||||
width: auto;
|
||||
padding: 0 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.tool-btn.close-btn:hover {
|
||||
background: #ef4444;
|
||||
border-color: #ef4444;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.preview-body {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: 1;
|
||||
min-height: 420px;
|
||||
max-height: calc(88vh - 120px);
|
||||
background: #020617;
|
||||
overflow: hidden;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.image-stage {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.preview-image {
|
||||
max-width: 100%;
|
||||
max-height: calc(88vh - 160px);
|
||||
object-fit: contain;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
|
||||
transform-origin: center center;
|
||||
}
|
||||
|
||||
.nav-btn {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 50%;
|
||||
background: rgba(30, 41, 59, 0.75);
|
||||
border: 1px solid rgba(148, 163, 184, 0.2);
|
||||
color: #f8fafc;
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
z-index: 10;
|
||||
backdrop-filter: blur(4px);
|
||||
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.nav-btn:hover {
|
||||
background: rgba(37, 99, 235, 0.9);
|
||||
color: #ffffff;
|
||||
transform: translateY(-50%) scale(1.1);
|
||||
box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
|
||||
}
|
||||
|
||||
.prev-btn {
|
||||
left: 20px;
|
||||
}
|
||||
|
||||
.next-btn {
|
||||
right: 20px;
|
||||
}
|
||||
|
||||
.preview-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 18px;
|
||||
background: rgba(15, 23, 42, 0.95);
|
||||
border-top: 1px solid rgba(51, 65, 85, 0.6);
|
||||
}
|
||||
|
||||
.file-info {
|
||||
color: #94a3b8;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.footer-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 7px 14px;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.edit-btn {
|
||||
background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
|
||||
color: #ffffff;
|
||||
box-shadow: 0 2px 8px rgba(217, 119, 6, 0.35);
|
||||
}
|
||||
|
||||
.edit-btn:hover {
|
||||
background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.secondary-btn {
|
||||
background: rgba(51, 65, 85, 0.6);
|
||||
border-color: rgba(148, 163, 184, 0.2);
|
||||
color: #e2e8f0;
|
||||
}
|
||||
|
||||
.secondary-btn:hover {
|
||||
background: rgba(71, 85, 105, 0.8);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.close-action-btn {
|
||||
background: transparent;
|
||||
color: #94a3b8;
|
||||
border-color: rgba(148, 163, 184, 0.15);
|
||||
}
|
||||
|
||||
.close-action-btn:hover {
|
||||
background: rgba(239, 68, 68, 0.15);
|
||||
border-color: rgba(239, 68, 68, 0.3);
|
||||
color: #f87171;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user