All checks were successful
Build and Deploy Front / deploy (push) Successful in 10m0s
修复 /track/pull|push 被代理误伤 404;Warning/ProviderService/Dictionary 路径改写;SkuImage 入库归一化。 Co-authored-by: Cursor <cursoragent@cursor.com>
264 lines
6.1 KiB
Vue
264 lines
6.1 KiB
Vue
<template>
|
|
<section class="print-preview-panel">
|
|
<div class="print-preview-toolbar">
|
|
<div class="print-preview-toolbar-left">
|
|
<span class="print-preview-title">面单预览</span>
|
|
<span v-if="subtitle" class="print-preview-subtitle">{{ subtitle }}</span>
|
|
<span v-if="indexLabel" class="print-preview-index">{{ indexLabel }}</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="print-preview-stage">
|
|
<Transition name="print-preview-fade" mode="out-in">
|
|
<div v-if="showBlockingLoader" key="loading" class="print-preview-loading">
|
|
<div class="print-preview-skeleton" aria-hidden="true">
|
|
<div class="print-preview-skeleton-bar short" />
|
|
<div class="print-preview-skeleton-sheet" />
|
|
<div class="print-preview-skeleton-bar" />
|
|
<div class="print-preview-skeleton-bar medium" />
|
|
</div>
|
|
<p class="print-preview-loading-tip">{{ loadingTip }}</p>
|
|
</div>
|
|
|
|
<div v-else-if="error" key="error" class="print-preview-error">
|
|
<a-empty :description="error">
|
|
<a-button size="small" type="primary" @click="emit('retry')">重试</a-button>
|
|
</a-empty>
|
|
</div>
|
|
|
|
<div v-else-if="pdfSource || htmlSrc" key="content" class="print-preview-content">
|
|
<PrintPdfPreview
|
|
v-if="pdfSource"
|
|
:source="pdfSource"
|
|
@loading-failed="emit('loading-failed', $event)"
|
|
@rendered="emit('rendered')"
|
|
/>
|
|
<iframe
|
|
v-else
|
|
class="print-preview-frame"
|
|
title="面单预览"
|
|
:src="htmlSrc"
|
|
@load="emit('rendered')"
|
|
/>
|
|
<div v-if="switching" class="print-preview-switch-mask">
|
|
<a-spin dot />
|
|
<span>切换中…</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div v-else key="empty" class="print-preview-empty">
|
|
<a-empty description="暂无可预览打印内容" />
|
|
</div>
|
|
</Transition>
|
|
</div>
|
|
</section>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed } from 'vue';
|
|
import PrintPdfPreview from '@/components/PrintTemplate/PrintPdfPreview.vue';
|
|
|
|
const props = defineProps<{
|
|
preparing?: boolean;
|
|
loading?: boolean;
|
|
rendering?: boolean;
|
|
switching?: boolean;
|
|
error?: string;
|
|
pdfSource?: string | Uint8Array | null;
|
|
htmlSrc?: string;
|
|
subtitle?: string;
|
|
indexLabel?: string;
|
|
}>();
|
|
|
|
const emit = defineEmits<{
|
|
(e: 'retry'): void;
|
|
(e: 'loading-failed', error: unknown): void;
|
|
(e: 'rendered'): void;
|
|
}>();
|
|
|
|
const showBlockingLoader = computed(() => {
|
|
if (props.preparing) return true;
|
|
if (props.loading) return true;
|
|
if (props.rendering && !props.pdfSource && !props.htmlSrc) return true;
|
|
return false;
|
|
});
|
|
|
|
const loadingTip = computed(() => {
|
|
if (props.preparing) return '正在获取面单…';
|
|
if (props.rendering) return '正在渲染面单…';
|
|
return '正在加载面单…';
|
|
});
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
.print-preview-panel {
|
|
min-height: 0;
|
|
height: 100%;
|
|
border: 1px solid var(--color-border-2);
|
|
border-radius: 10px;
|
|
overflow: hidden;
|
|
background: var(--app-card-bg);
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.print-preview-toolbar {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 10px 12px;
|
|
border-bottom: 1px solid var(--color-border-2);
|
|
background: var(--color-fill-2);
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.print-preview-toolbar-left {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
min-width: 0;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.print-preview-title {
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
color: var(--color-text-2);
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.print-preview-subtitle {
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
color: var(--color-text-1);
|
|
word-break: break-all;
|
|
}
|
|
|
|
.print-preview-index {
|
|
font-size: 12px;
|
|
color: var(--color-text-3);
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.print-preview-stage {
|
|
position: relative;
|
|
flex: 1;
|
|
min-height: 420px;
|
|
overflow: hidden;
|
|
background: var(--color-fill-1);
|
|
}
|
|
|
|
.print-preview-loading,
|
|
.print-preview-error,
|
|
.print-preview-empty {
|
|
height: 100%;
|
|
min-height: 420px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 16px;
|
|
padding: 24px;
|
|
}
|
|
|
|
.print-preview-loading-tip {
|
|
margin: 0;
|
|
font-size: 13px;
|
|
color: var(--color-text-3);
|
|
}
|
|
|
|
.print-preview-skeleton {
|
|
width: min(280px, 72%);
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 12px;
|
|
}
|
|
|
|
.print-preview-skeleton-bar {
|
|
height: 10px;
|
|
border-radius: 6px;
|
|
background: linear-gradient(90deg, var(--color-fill-3) 25%, var(--color-fill-2) 50%, var(--color-fill-3) 75%);
|
|
background-size: 200% 100%;
|
|
animation: print-skeleton-shimmer 1.2s ease-in-out infinite;
|
|
|
|
&.short {
|
|
width: 42%;
|
|
}
|
|
|
|
&.medium {
|
|
width: 68%;
|
|
}
|
|
}
|
|
|
|
.print-preview-skeleton-sheet {
|
|
width: 100%;
|
|
aspect-ratio: 2 / 3;
|
|
border-radius: 10px;
|
|
border: 1px solid var(--color-border-2);
|
|
background: linear-gradient(90deg, var(--color-fill-3) 25%, var(--color-fill-2) 50%, var(--color-fill-3) 75%);
|
|
background-size: 200% 100%;
|
|
animation: print-skeleton-shimmer 1.2s ease-in-out infinite;
|
|
}
|
|
|
|
@keyframes print-skeleton-shimmer {
|
|
0% {
|
|
background-position: 200% 0;
|
|
}
|
|
100% {
|
|
background-position: -200% 0;
|
|
}
|
|
}
|
|
|
|
.print-preview-content {
|
|
position: relative;
|
|
height: 100%;
|
|
min-height: 420px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.print-preview-frame {
|
|
width: 100%;
|
|
flex: 1;
|
|
min-height: 420px;
|
|
border: none;
|
|
background: #fff;
|
|
}
|
|
|
|
.print-preview-switch-mask {
|
|
position: absolute;
|
|
inset: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 10px;
|
|
background: rgba(255, 255, 255, 0.72);
|
|
backdrop-filter: blur(2px);
|
|
color: var(--color-text-2);
|
|
font-size: 13px;
|
|
z-index: 2;
|
|
animation: print-mask-in 0.18s ease;
|
|
}
|
|
|
|
.print-preview-fade-enter-active,
|
|
.print-preview-fade-leave-active {
|
|
transition: opacity 0.22s ease, transform 0.22s ease;
|
|
}
|
|
|
|
.print-preview-fade-enter-from,
|
|
.print-preview-fade-leave-to {
|
|
opacity: 0;
|
|
transform: translateY(6px);
|
|
}
|
|
|
|
@keyframes print-mask-in {
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
}
|
|
</style>
|