feat(protect): 皮肤选择旁加「查看」按钮,用全屏图片查看器看大图
Docker Build / Build and Push Docker Image (push) Successful in 1m6s
Docker Build / Deploy to Server (push) Successful in 2s

原来只能 hover 预览图点「看大图」,出来的是带标题栏的普通弹窗,图只是等比
缩在弹窗里,看不清细节。

- 新增 components/image-lightbox.vue:Teleport 到 body 的全屏查看器
  · 黑底 92% + backdrop-blur,图片居中 object-contain
  · 滚轮缩放 100%~600%,顶部显示百分比、+/-/还原按钮,快捷键 + - 0
  · 放大后可按住拖动平移(cursor-grab/grabbing),缩回 100% 自动归位
  · 双击切换(1x ↔ 1.25x)、Esc / 点空白 / 右上角 X 关闭
  · 打开时锁 body 滚动,关闭还原
- 皮肤下拉右边加「查看」按钮(Eye 图标),点开就是查看器
- 预览图上的 hover「看大图」也改为打开同一个查看器
- 删掉旧的 UiDialog 预览弹窗与 previewTheme/openThemePreview/previewOpen
This commit is contained in:
2026-11-26 15:51:01 +08:00
parent 9e85d2371d
commit a2e41f659f
5 changed files with 244 additions and 57 deletions
+203
View File
@@ -0,0 +1,203 @@
<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
import { Maximize2, Minus, Plus, RotateCcw, X } from "lucide-vue-next";
const props = defineProps<{
open: boolean;
src: string;
title?: string;
}>();
const emit = defineEmits<{ (e: "update:open", v: boolean): void }>();
const MIN = 1;
const MAX = 6;
const STEP = 1.25;
const scale = ref(1);
const tx = ref(0);
const ty = ref(0);
const dragging = ref(false);
let startX = 0;
let startY = 0;
let baseTx = 0;
let baseTy = 0;
const zoomLabel = computed(() => `${Math.round(scale.value * 100)}%`);
const canPan = computed(() => scale.value > 1);
function close() {
emit("update:open", false);
}
function reset() {
scale.value = 1;
tx.value = 0;
ty.value = 0;
}
function clampScale(v: number) {
return Math.min(MAX, Math.max(MIN, v));
}
function applyScale(next: number) {
scale.value = clampScale(next);
if (scale.value === 1) {
tx.value = 0;
ty.value = 0;
}
}
function zoomIn() {
applyScale(scale.value * STEP);
}
function zoomOut() {
applyScale(scale.value / STEP);
}
function onWheel(e: WheelEvent) {
e.preventDefault();
// 以图片中心为锚点缩放,简单可靠;指针不在中心时也能接受
applyScale(scale.value * (e.deltaY < 0 ? 1.12 : 1 / 1.12));
}
function onPointerDown(e: MouseEvent) {
if (!canPan.value) return;
dragging.value = true;
startX = e.clientX;
startY = e.clientY;
baseTx = tx.value;
baseTy = ty.value;
}
function onPointerMove(e: MouseEvent) {
if (!dragging.value) return;
tx.value = baseTx + (e.clientX - startX);
ty.value = baseTy + (e.clientY - startY);
}
function onPointerUp() {
dragging.value = false;
}
function onKeydown(e: KeyboardEvent) {
if (!props.open) return;
if (e.key === "Escape") close();
else if (e.key === "+" || e.key === "=") zoomIn();
else if (e.key === "-") zoomOut();
else if (e.key === "0") reset();
}
watch(
() => props.open,
(v) => {
if (v) {
reset();
document.body.style.overflow = "hidden";
} else {
document.body.style.overflow = "";
dragging.value = false;
}
},
);
onMounted(() => window.addEventListener("keydown", onKeydown));
onBeforeUnmount(() => {
window.removeEventListener("keydown", onKeydown);
document.body.style.overflow = "";
});
</script>
<template>
<Teleport to="body">
<Transition
enter-active-class="transition duration-150 ease-out"
enter-from-class="opacity-0"
leave-active-class="transition duration-100 ease-in"
leave-to-class="opacity-0"
>
<div
v-if="open"
class="fixed inset-0 z-[200] flex flex-col bg-black/92 backdrop-blur-sm select-none"
@click.self="close"
@mousemove="onPointerMove"
@mouseup="onPointerUp"
@mouseleave="onPointerUp"
>
<!-- 顶部工具栏 -->
<div
class="flex shrink-0 items-center justify-between gap-3 px-4 py-3 text-white/90"
>
<div class="flex min-w-0 items-center gap-3">
<Maximize2 class="size-4 shrink-0 text-white/50" />
<span class="truncate text-sm font-medium">{{
title || "预览"
}}</span>
</div>
<div class="flex items-center gap-1">
<button
type="button"
class="flex size-8 items-center justify-center rounded-md text-white/70 transition-colors hover:bg-white/10 hover:text-white disabled:opacity-35"
:disabled="scale <= MIN"
title="缩小(-)"
@click="zoomOut"
>
<Minus class="size-4" />
</button>
<span class="w-12 text-center text-xs tabular-nums text-white/60">{{
zoomLabel
}}</span>
<button
type="button"
class="flex size-8 items-center justify-center rounded-md text-white/70 transition-colors hover:bg-white/10 hover:text-white disabled:opacity-35"
:disabled="scale >= MAX"
title="放大(+)"
@click="zoomIn"
>
<Plus class="size-4" />
</button>
<button
type="button"
class="flex size-8 items-center justify-center rounded-md text-white/70 transition-colors hover:bg-white/10 hover:text-white"
title="还原(0)"
@click="reset"
>
<RotateCcw class="size-4" />
</button>
<div class="mx-1 h-5 w-px bg-white/15" />
<button
type="button"
class="flex size-8 items-center justify-center rounded-md text-white/70 transition-colors hover:bg-white/10 hover:text-white"
title="关闭(Esc)"
@click="close"
>
<X class="size-4" />
</button>
</div>
</div>
<!-- 图片区 -->
<div
class="relative min-h-0 flex-1 overflow-hidden"
@click.self="close"
>
<img
:src="src"
:alt="title"
class="absolute top-1/2 left-1/2 max-h-full max-w-full origin-center object-contain transition-transform duration-75"
:class="
canPan
? dragging
? 'cursor-grabbing'
: 'cursor-grab'
: 'cursor-zoom-in'
"
:style="{
transform: `translate(-50%, -50%) translate(${tx}px, ${ty}px) scale(${scale})`,
}"
draggable="false"
@wheel.prevent="onWheel"
@mousedown.prevent="onPointerDown"
@dblclick="scale > 1 ? reset() : zoomIn()"
/>
</div>
<!-- 底部提示 -->
<div class="shrink-0 pb-3 text-center text-[11px] text-white/40">
滚轮缩放 · 放大后拖动平移 · 双击切换 · Esc 关闭
</div>
</div>
</Transition>
</Teleport>
</template>
+37 -57
View File
@@ -4,6 +4,7 @@ import type { Component } from "vue";
import {
CheckCircle2,
Eye,
FileUp,
Loader2,
PackageCheck,
@@ -19,6 +20,7 @@ import { toast } from "vue-sonner";
import SingleFilter from "@/components/data-table/single-filter.vue";
import ProtectDataTable from "@/pages/admin/protect/components/data-table.vue";
import ImageLightbox from "@/components/image-lightbox.vue";
import { BasicPage } from "@/components/global-layout";
import api, { BASE_URL } from "@/services/api";
@@ -106,12 +108,8 @@ function themeSub(label: string) {
return parts.length > 1 ? parts.slice(1).join("·").trim() : "";
}
// 点卡片角上的放大镜看大图
const previewTheme = ref<{ value: string; label: string } | null>(null);
const previewOpen = ref(false);
function openThemePreview(theme: { value: string; label: string }) {
previewTheme.value = theme;
previewOpen.value = true;
}
// 皮肤大图:全屏图片查看器(滚轮缩放 / 拖动平移 / Esc 关闭)
const lightboxOpen = ref(false);
// 组合框选一套,下方预览图跟着切换(不再铺一整片网格)
const currentThemeOption = computed(
() =>
@@ -650,21 +648,32 @@ onBeforeUnmount(() => {
{{ t("admin.protect.themeLabel") }}
</UiLabel>
<div class="space-y-3">
<div class="max-w-xs">
<UiSelect v-model="shellTheme">
<UiSelectTrigger class="w-full">
<UiSelectValue />
</UiSelectTrigger>
<UiSelectContent>
<UiSelectItem
v-for="o in themeOptions"
:key="o.value"
:value="o.value"
>
{{ o.label }}
</UiSelectItem>
</UiSelectContent>
</UiSelect>
<div class="flex items-center gap-2">
<div class="w-full max-w-xs">
<UiSelect v-model="shellTheme">
<UiSelectTrigger class="w-full">
<UiSelectValue />
</UiSelectTrigger>
<UiSelectContent>
<UiSelectItem
v-for="o in themeOptions"
:key="o.value"
:value="o.value"
>
{{ o.label }}
</UiSelectItem>
</UiSelectContent>
</UiSelect>
</div>
<UiButton
variant="outline"
class="h-9 shrink-0 px-3"
@click="lightboxOpen = true"
>
<Eye class="mr-1.5 size-3.5" />{{
t("admin.protect.themeView")
}}
</UiButton>
</div>
<div
class="group relative max-w-2xl overflow-hidden rounded-lg border border-border/70 bg-[#101419] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.04)]"
@@ -679,12 +688,7 @@ onBeforeUnmount(() => {
type="button"
class="absolute inset-0 flex items-end justify-end p-2 opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100"
:aria-label="t('admin.protect.themeZoom')"
@click="
openThemePreview({
value: shellTheme,
label: currentThemeLabel,
})
"
@click="lightboxOpen = true"
>
<span
class="flex items-center gap-1 rounded-md bg-black/60 px-2 py-1 text-[11px] text-white backdrop-blur-sm"
@@ -701,36 +705,12 @@ onBeforeUnmount(() => {
</div>
</div>
<!-- 点预览图上的放大镜看 1:1 大图 -->
<UiDialog v-model:open="previewOpen">
<UiDialogContent class="max-w-4xl">
<UiDialogHeader>
<UiDialogTitle>{{ previewTheme?.label }}</UiDialogTitle>
<UiDialogDescription>{{
t("admin.protect.themeZoomHint")
}}</UiDialogDescription>
</UiDialogHeader>
<img
v-if="previewTheme"
:src="`/theme-previews/${previewTheme.value}.png`"
:alt="previewTheme.label"
class="w-full rounded-md border bg-[#101419]"
/>
<UiDialogFooter class="gap-2">
<UiButton variant="outline" @click="previewOpen = false">
{{ t("common.close") }}
</UiButton>
<UiButton
@click="
shellTheme = previewTheme!.value;
previewOpen = false;
"
>
{{ t("admin.protect.themeUseThis") }}
</UiButton>
</UiDialogFooter>
</UiDialogContent>
</UiDialog>
<!-- 全屏图片查看器:滚轮缩放 / 放大后拖动平移 / 双击切换 / Esc 关闭 -->
<ImageLightbox
v-model:open="lightboxOpen"
:src="`/theme-previews/${shellTheme}.png`"
:title="currentThemeLabel"
/>
<!-- 程序版本:壳拿它和平台已发布版本比对,决定是否提示/强制更新 -->
<div class="flex flex-col gap-3 sm:flex-row sm:items-center">
+1
View File
@@ -2676,6 +2676,7 @@
"themeBits64": "64-bit",
"themeBits32": "32/64-bit",
"themeZoom": "Preview",
"themeView": "View",
"themeZoomHint": "Actual rendering of the produced verification dialog (raw screenshot)",
"themeUseThis": "Use this skin"
},
+1
View File
@@ -2695,6 +2695,7 @@
"themeBits64": "64 位",
"themeBits32": "32/64 位",
"themeZoom": "看大图",
"themeView": "查看",
"themeZoomHint": "这是产物验证弹窗的实际渲染效果(截图,未做任何美化)",
"themeUseThis": "用这套皮肤"
},
+2
View File
@@ -46,6 +46,7 @@ declare module 'vue' {
GlobalLayoutBasicPage: typeof import('./../components/global-layout/basic-page.vue')['default']
GlobalLayoutTwoCol: typeof import('./../components/global-layout/two-col.vue')['default']
GlobalLayoutTwoColAside: typeof import('./../components/global-layout/two-col-aside.vue')['default']
ImageLightbox: typeof import('./../components/image-lightbox.vue')['default']
InspiraUiFlickeringGrid: typeof import('./../components/inspira-ui/flickering-grid.vue')['default']
InspiraUiGlowingEffect: typeof import('./../components/inspira-ui/glowing-effect.vue')['default']
InspiraUiMarquee: typeof import('./../components/inspira-ui/marquee/index.vue')['default']
@@ -449,6 +450,7 @@ declare global {
const GlobalLayoutBasicPage: typeof import('./../components/global-layout/basic-page.vue')['default']
const GlobalLayoutTwoCol: typeof import('./../components/global-layout/two-col.vue')['default']
const GlobalLayoutTwoColAside: typeof import('./../components/global-layout/two-col-aside.vue')['default']
const ImageLightbox: typeof import('./../components/image-lightbox.vue')['default']
const InspiraUiFlickeringGrid: typeof import('./../components/inspira-ui/flickering-grid.vue')['default']
const InspiraUiGlowingEffect: typeof import('./../components/inspira-ui/glowing-effect.vue')['default']
const InspiraUiMarquee: typeof import('./../components/inspira-ui/marquee/index.vue')['default']