Skip to content

Commit 9b6e482

Browse files
authored
洛天依佑我成功秒掉Medium-Zoom 实例
Signed-off-by: 本新同学 <yuanbenxin@outlook.com>
1 parent 846d5ce commit 9b6e482

1 file changed

Lines changed: 41 additions & 111 deletions

File tree

docs/.vitepress/theme/components/Donate.vue

Lines changed: 41 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
<div class="qrcode-container">
77
<div class="qrcode-wrapper">
8-
<img class="qrcode" src="/wechat.png" alt="微信捐赠">
8+
<img class="qrcode zoomable" src="/wechat.png" alt="微信捐赠">
99
<div class="tip">微信扫码捐赠</div>
1010
</div>
1111
<div class="qrcode-wrapper">
12-
<img class="qrcode" src="/alipay.png" alt="支付宝捐赠">
12+
<img class="qrcode zoomable" src="/alipay.png" alt="支付宝捐赠">
1313
<div class="tip">支付宝扫码捐赠</div>
1414
</div>
1515
</div>
@@ -22,11 +22,11 @@
2222
import { onMounted } from 'vue'
2323
2424
onMounted(() => {
25-
// ===== 1. 在 DOM 加载后把所有图片的点击事件解绑 =====
26-
document.querySelectorAll('img').forEach(img => {
27-
const clone = img.cloneNode(true)
28-
img.replaceWith(clone)
29-
})
25+
// ===== 1. 卸载 Medium-Zoom =====
26+
if (window.mediumZoom) {
27+
window.mediumZoom.detach()
28+
window.mediumZoom = null
29+
}
3030
3131
// ===== 2. 自定义二维码点击放大 =====
3232
const imgs = document.querySelectorAll('.qrcode-wrapper img.zoomable')
@@ -39,12 +39,11 @@ onMounted(() => {
3939
const modal = document.createElement('div')
4040
modal.className = 'modal-card'
4141
42-
// ==== 统一放大尺寸,保证两张图视觉一致 ====
43-
const fixedWidth = 320
44-
const fixedHeight = 320
42+
// 统一放大尺寸
43+
const fixedSize = 320
4544
4645
modal.innerHTML = `
47-
<img src="${img.src}" style="width: ${fixedWidth}px; height: ${fixedHeight}px; object-fit: contain;">
46+
<img src="${img.src}" style="width: ${fixedSize}px; height: ${fixedSize}px; object-fit: contain;">
4847
<div class="modal-title">SecRandom团队再次感谢您的支持</div>
4948
<div class="modal-subtitle">点击周围空白关闭</div>
5049
`
@@ -62,14 +61,6 @@ onMounted(() => {
6261
})
6362
</script>
6463

65-
<template>
66-
<div>
67-
<img src="/img1.png" class="zoomable" style="width: 300px;" />
68-
<img src="/img2.png" class="zoomable" style="width: 200px;" />
69-
</div>
70-
</template>
71-
72-
7364
<style scoped>
7465
.donate-container {
7566
display: flex;
@@ -85,110 +76,49 @@ onMounted(() => {
8576
margin: 40px 0;
8677
}
8778
88-
h1 {
89-
font-size: 2.8rem;
90-
font-weight: 600;
91-
color: var(--vp-c-text-1);
92-
margin: 0 0 20px 0;
93-
text-align: center;
94-
}
95-
96-
p {
97-
font-size: 1.4rem;
98-
color: var(--vp-c-text-1);
99-
text-align: center;
100-
margin: 0 0 30px 0;
101-
}
102-
103-
.thanks {
104-
margin-top: 25px;
105-
font-size: 0.9rem;
106-
color: var(--vp-c-text-1);
107-
}
108-
109-
.qrcode-container {
110-
display: flex;
111-
gap: 30px;
112-
flex-wrap: wrap;
113-
justify-content: center;
114-
}
115-
116-
.qrcode-wrapper {
117-
display: flex;
118-
flex-direction: column;
119-
align-items: center;
120-
background: var(--vp-c-bg-alt);
121-
backdrop-filter: blur(15px);
122-
border-radius: 20px;
123-
padding: 15px;
124-
box-shadow: 0 4px 20px rgba(0,0,0,0.08);
125-
transition: transform 0.3s ease, box-shadow 0.3s ease;
126-
}
127-
128-
.qrcode-wrapper:hover {
129-
transform: scale(1.05);
130-
box-shadow: 0 8px 28px rgba(0,0,0,0.15);
131-
}
79+
h1 { font-size: 2.8rem; font-weight: 600; color: var(--vp-c-text-1); margin:0 0 20px 0; text-align:center; }
80+
p { font-size: 1.4rem; color: var(--vp-c-text-1); text-align:center; margin:0 0 30px 0; }
81+
.thanks { margin-top:25px; font-size:0.9rem; color: var(--vp-c-text-1); }
13282
133-
.qrcode {
134-
width: 140px;
135-
height: 140px;
136-
border-radius: 16px;
137-
margin-bottom: 10px;
138-
object-fit: cover;
139-
}
83+
.qrcode-container { display:flex; gap:30px; flex-wrap:wrap; justify-content:center; }
84+
.qrcode-wrapper { display:flex; flex-direction:column; align-items:center; background: var(--vp-c-bg-alt); backdrop-filter: blur(15px); border-radius:20px; padding:15px; box-shadow:0 4px 20px rgba(0,0,0,0.08); transition: transform 0.3s ease, box-shadow 0.3s ease; }
85+
.qrcode-wrapper:hover { transform: scale(1.05); box-shadow: 0 8px 28px rgba(0,0,0,0.15); }
14086
141-
.tip {
142-
font-size: 0.9rem;
143-
color: var(--vp-c-text-1);
144-
}
87+
.qrcode { width:140px; height:140px; border-radius:16px; margin-bottom:10px; object-fit:cover; }
88+
.tip { font-size:0.9rem; color: var(--vp-c-text-1); }
14589
14690
@media (max-width: 768px) {
147-
.donate-container { padding: 30px 20px; }
148-
.qrcode-container { gap: 20px; }
149-
.qrcode { width: 110px; height: 110px; }
150-
}
91+
.donate-container { padding:30px 20px; }
92+
.qrcode-container { gap:20px; }
93+
.qrcode { width:110px; height:110px; }
94+
}
15195
</style>
15296

153-
<!-- 弹窗全局样式 -->
15497
<style>
98+
/* 弹窗全局样式 */
15599
.modal-overlay {
156100
position: fixed;
157-
inset: 0;
158-
display: flex;
159-
align-items: center;
160-
justify-content: center;
161-
background: rgba(0, 0, 0, 0.45);
162-
z-index: 9999;
101+
inset:0;
102+
display:flex;
103+
align-items:center;
104+
justify-content:center;
105+
background: rgba(0,0,0,0.45);
106+
z-index:9999;
163107
}
164108
165109
.modal-card {
166-
background: var(--vp-c-bg, #fff);
167-
border-radius: 20px;
168-
padding: 16px;
169-
box-shadow: 0 20px 60px rgba(0,0,0,0.25);
170-
max-width: 90vw;
171-
max-height: 90vh;
172-
display: flex;
173-
flex-direction: column;
174-
align-items: center;
175-
}
176-
177-
.modal-card img {
178-
display: block;
179-
border-radius: 12px;
180-
}
181-
182-
.modal-title {
183-
margin-top: 12px;
184-
font-weight: 600;
185-
text-align: center;
110+
background: var(--vp-c-bg,#fff);
111+
border-radius:20px;
112+
padding:16px;
113+
box-shadow:0 20px 60px rgba(0,0,0,0.25);
114+
max-width:90vw;
115+
max-height:90vh;
116+
display:flex;
117+
flex-direction:column;
118+
align-items:center;
186119
}
187120
188-
.modal-subtitle {
189-
margin-top: 6px;
190-
font-size: 12px;
191-
opacity: .7;
192-
text-align: center;
193-
}
121+
.modal-card img { display:block; border-radius:12px; }
122+
.modal-title { margin-top:12px; font-weight:600; text-align:center; }
123+
.modal-subtitle { margin-top:6px; font-size:12px; opacity:.7; text-align:center; }
194124
</style>

0 commit comments

Comments
 (0)