feat: 新增媒体排序组件,支持图片与视频的拖拽排序与上传,优化媒体查看器功能
This commit is contained in:
+56
-33
@@ -36,15 +36,30 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 图片轮播 -->
|
||||
<!-- 图片 / 视频轮播 -->
|
||||
<div v-if="data.artwork.images?.length" class="carousel">
|
||||
<img
|
||||
v-for="(img, i) in data.artwork.images"
|
||||
<div
|
||||
v-for="(m, i) in data.artwork.images"
|
||||
:key="i"
|
||||
:src="img.url"
|
||||
class="carousel-img"
|
||||
@click="openLightbox(img.url)"
|
||||
/>
|
||||
class="carousel-item"
|
||||
@click="openViewer(data.artwork.images, i)"
|
||||
>
|
||||
<video
|
||||
v-if="isVideo(m)"
|
||||
:src="m.url"
|
||||
class="carousel-media"
|
||||
muted
|
||||
playsinline
|
||||
preload="metadata"
|
||||
/>
|
||||
<img v-else :src="m.url" :alt="m.name" class="carousel-media" loading="lazy" />
|
||||
<div v-if="isVideo(m)" class="play-overlay">
|
||||
<svg viewBox="0 0 64 64" width="56" height="56" aria-hidden="true">
|
||||
<circle cx="32" cy="32" r="30" fill="rgba(0,0,0,0.42)" />
|
||||
<polygon points="26,21 46,32 26,43" fill="#fff" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 基础信息 -->
|
||||
@@ -79,7 +94,7 @@
|
||||
playsinline
|
||||
preload="metadata"
|
||||
/>
|
||||
<img v-else :src="m.url" @click="openLightbox(m.url)" />
|
||||
<img v-else :src="m.url" loading="lazy" @click="openViewer([m], 0)" />
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
@@ -92,7 +107,7 @@
|
||||
<h2 class="section-title">{{ t('section.cert') }}</h2>
|
||||
<div class="cert-grid">
|
||||
<div v-for="(c, i) in data.certificates" :key="i" class="cert">
|
||||
<img v-if="c.url" :src="c.url" @click="openLightbox(c.url)" />
|
||||
<img v-if="c.url" :src="c.url" loading="lazy" @click="openViewer([{ url: c.url, name: c.name, type: 'image' }], 0)" />
|
||||
<div class="cert-name text-ellipsis">{{ c.name }}</div>
|
||||
<div v-if="c.issuer" class="muted cert-issuer text-ellipsis">{{ c.issuer }}</div>
|
||||
</div>
|
||||
@@ -123,10 +138,8 @@
|
||||
<footer class="footer muted">{{ appName }}</footer>
|
||||
</template>
|
||||
|
||||
<!-- 大图预览 -->
|
||||
<div v-if="lightbox" class="lightbox" @click="lightbox = ''">
|
||||
<img :src="lightbox" />
|
||||
</div>
|
||||
<!-- 媒体查看器:图片可双指缩放/拖动,视频弹窗播放 -->
|
||||
<media-viewer v-model:show="viewerShow" :items="viewerItems" :start="viewerStart" />
|
||||
|
||||
<!-- 轻提示 -->
|
||||
<transition name="toast">
|
||||
@@ -142,6 +155,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import dayjs from 'dayjs';
|
||||
import { fetchTrace, fetchAppInfo } from '@/api';
|
||||
import { setLocale } from '@/locales';
|
||||
import MediaViewer from '@/components/MediaViewer.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const { t, locale } = useI18n();
|
||||
@@ -149,9 +163,12 @@ const { t, locale } = useI18n();
|
||||
const loading = ref(true);
|
||||
const data = ref<any>(null);
|
||||
const appName = ref('');
|
||||
const lightbox = ref('');
|
||||
const toast = ref('');
|
||||
|
||||
const viewerShow = ref(false);
|
||||
const viewerItems = ref<any[]>([]);
|
||||
const viewerStart = ref(0);
|
||||
|
||||
const otherLangLabel = computed(() => (locale.value === 'zh-CN' ? 'EN' : '中文'));
|
||||
const stateKey = computed(() => {
|
||||
const s = data.value?.status;
|
||||
@@ -171,10 +188,12 @@ function ellipsis(s?: string) {
|
||||
return s.length > 16 ? `${s.slice(0, 8)}…${s.slice(-6)}` : s;
|
||||
}
|
||||
function isVideo(m: { type?: string; url?: string }) {
|
||||
return m.type === 'video' || /\.(mp4|webm|mov|m4v)$/i.test(m.url || '');
|
||||
return m.type === 'video' || /\.(mp4|webm|mov|m4v|ogg)$/i.test(m.url || '');
|
||||
}
|
||||
function openLightbox(url: string) {
|
||||
lightbox.value = url;
|
||||
function openViewer(items: any[], index: number) {
|
||||
viewerItems.value = items || [];
|
||||
viewerStart.value = index;
|
||||
viewerShow.value = true;
|
||||
}
|
||||
function toggleLang() {
|
||||
setLocale(locale.value === 'zh-CN' ? 'en-US' : 'zh-CN');
|
||||
@@ -198,7 +217,7 @@ async function copy(text?: string) {
|
||||
async function load(code: string) {
|
||||
loading.value = true;
|
||||
data.value = null;
|
||||
lightbox.value = '';
|
||||
viewerShow.value = false;
|
||||
try {
|
||||
data.value = await fetchTrace(code);
|
||||
} catch {
|
||||
@@ -329,14 +348,31 @@ watch(
|
||||
padding: 0 12px;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
.carousel-img {
|
||||
.carousel-item {
|
||||
position: relative;
|
||||
width: 86%;
|
||||
height: 240px;
|
||||
object-fit: cover;
|
||||
border-radius: 14px;
|
||||
scroll-snap-align: center;
|
||||
flex-shrink: 0;
|
||||
background: #e7ecf3;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
}
|
||||
.carousel-media {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
background: #000;
|
||||
}
|
||||
.play-overlay {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
.art-title {
|
||||
font-size: 20px;
|
||||
@@ -484,19 +520,6 @@ watch(
|
||||
font-size: 12px;
|
||||
padding: 24px 0 32px;
|
||||
}
|
||||
.lightbox {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.92);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 50;
|
||||
}
|
||||
.lightbox img {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
.toast {
|
||||
position: fixed;
|
||||
bottom: 60px;
|
||||
|
||||
Reference in New Issue
Block a user