h2l-ranking 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,10 +7,16 @@
7
7
  ## 特性
8
8
 
9
9
  - 🖱️ 鼠标滚轮横向滚动
10
- - 📱 响应式设计
10
+ - 📱 响应式设计,自适应窗口大小
11
11
  - 🎨 可自定义样式
12
- - 💡 悬停显示 tooltip(支持描述信息)
13
- - 🖼️ 内置图片预览器(点击图片放大,支持滚轮/手势缩放)
12
+ - 💡 悬停显示 tooltip(PC 端,支持标题和描述)
13
+ - 🖼️ 内置图片预览器
14
+ - 点击图片放大预览
15
+ - PC 端滚轮缩放,移动端双指缩放
16
+ - 缩放后支持拖拽移动
17
+ - 显示标题和描述信息
18
+ - 支持外部链接跳转
19
+ - ⌨️ ESC 键关闭预览
14
20
 
15
21
  ## 安装
16
22
 
@@ -28,32 +34,32 @@ import 'h2l-ranking/style.css'
28
34
 
29
35
  const rankings = ref({
30
36
  hang: [
31
- { title: '《中二病也要谈恋爱》', url: '/images/1.png', description: '本人入宅作,给到一个夯' },
32
- { title: '《玉子爱情故事》', url: '/images/2.png' },
33
- { title: '《葬送的芙莉莲》', url: '/images/3.png' },
34
- { title: '《我心里危险的东西》', url: '/images/4.png' },
35
- { title: '《碧蓝之海 第一季》', url: '/images/5.png' },
36
- { title: '《双城之战》', url: '/images/6.png' },
37
- { title: '《男子高中生的日常》', url: '/images/7.png' },
38
- { title: '《樱花庄的宠物女孩》', url: '/images/8.png' },
39
- { title: '《NO GAME NO LIFE 游戏人生》', url: '/images/9.png' },
40
- { title: '《OVERLORD》', url: '/images/10.png' },
41
- { title: '《言叶之庭》', url: '/images/11.png' },
42
- { title: '《命运石之门》', url: '/images/12.png' }
37
+ { title: '《中二病也要谈恋爱》', cover: '/images/1.png', url: 'https://example.com/1', description: '本人入宅作,给到一个夯' },
38
+ { title: '《玉子爱情故事》', cover: '/images/2.png' },
39
+ { title: '《葬送的芙莉莲》', cover: '/images/3.png' },
40
+ { title: '《我心里危险的东西》', cover: '/images/4.png' },
41
+ { title: '《碧蓝之海 第一季》', cover: '/images/5.png' },
42
+ { title: '《双城之战》', cover: '/images/6.png' },
43
+ { title: '《男子高中生的日常》', cover: '/images/7.png' },
44
+ { title: '《樱花庄的宠物女孩》', cover: '/images/8.png' },
45
+ { title: '《NO GAME NO LIFE 游戏人生》', cover: '/images/9.png' },
46
+ { title: '《OVERLORD》', cover: '/images/10.png' },
47
+ { title: '《言叶之庭》', cover: '/images/11.png' },
48
+ { title: '《命运石之门》', cover: '/images/12.png' }
43
49
  ],
44
50
  upper: [
45
- { title: '《搞笑漫画日和》', url: '/images/13.png' },
46
- { title: '《胆大党》', url: '/images/14.png' },
47
- { title: '《荒川爆笑团》', url: '/images/15.png' },
48
- { title: '《银魂》', url: '/images/16.png' },
49
- { title: '《某科学的超电磁炮》', url: '/images/17.png' },
50
- { title: '《魔法禁书目录》', url: '/images/18.png' },
51
- { title: '《花牌情缘》', url: '/images/19.png' },
52
- { title: '《热带雨林的爆笑生活》', url: '/images/20.png' },
53
- { title: '《零之使魔》', url: '/images/21.png' },
54
- { title: '《魔法少女小圆》', url: '/images/22.png' },
55
- { title: '《齐木楠雄的灾难》', url: '/images/23.png' },
56
- { title: '《Re:从零开始的异世界生活》', url: '/images/24.png' }
51
+ { title: '《搞笑漫画日和》', cover: '/images/13.png' },
52
+ { title: '《胆大党》', cover: '/images/14.png' },
53
+ { title: '《荒川爆笑团》', cover: '/images/15.png' },
54
+ { title: '《银魂》', cover: '/images/16.png' },
55
+ { title: '《某科学的超电磁炮》', cover: '/images/17.png' },
56
+ { title: '《魔法禁书目录》', cover: '/images/18.png' },
57
+ { title: '《花牌情缘》', cover: '/images/19.png' },
58
+ { title: '《热带雨林的爆笑生活》', cover: '/images/20.png' },
59
+ { title: '《零之使魔》', cover: '/images/21.png' },
60
+ { title: '《魔法少女小圆》', cover: '/images/22.png' },
61
+ { title: '《齐木楠雄的灾难》', cover: '/images/23.png' },
62
+ { title: '《Re:从零开始的异世界生活》', cover: '/images/24.png' }
57
63
  ],
58
64
  middle: [],
59
65
  lower: [],
@@ -82,7 +88,8 @@ const rankings = ref({
82
88
  ```ts
83
89
  interface RankingItem {
84
90
  title: string // 标题
85
- url: string // 图片地址
91
+ cover: string // 封面图片地址
92
+ url?: string // 跳转链接(可选),预览时右上角显示外部链接按钮
86
93
  description?: string // 描述(可选)
87
94
  }
88
95
 
package/dist/index.css CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- .h2l-image-viewer[data-v-09434fce] {
2
+ .h2l-image-viewer[data-v-39bb591c] {
3
3
  position: fixed;
4
4
  top: 0;
5
5
  left: 0;
@@ -12,21 +12,23 @@
12
12
  z-index: 9999;
13
13
  padding: 20px;
14
14
  }
15
- .h2l-image-viewer__content[data-v-09434fce] {
15
+ .h2l-image-viewer__content[data-v-39bb591c] {
16
16
  width: 100%;
17
17
  max-width: 600px;
18
18
  display: flex;
19
19
  align-items: center;
20
20
  justify-content: center;
21
+ position: relative;
22
+ z-index: 0;
21
23
  }
22
- .h2l-image-viewer__content img[data-v-09434fce] {
24
+ .h2l-image-viewer__content img[data-v-39bb591c] {
23
25
  max-width: 100%;
24
26
  height: auto;
25
27
  user-select: none;
26
28
  -webkit-user-select: none;
27
29
  touch-action: none;
28
30
  }
29
- .h2l-image-viewer__close[data-v-09434fce] {
31
+ .h2l-image-viewer__close[data-v-39bb591c] {
30
32
  position: absolute;
31
33
  top: 20px;
32
34
  right: 20px;
@@ -36,41 +38,123 @@
36
38
  align-items: center;
37
39
  justify-content: center;
38
40
  background-color: rgba(255, 255, 255, 0.1);
41
+ backdrop-filter: blur(4px);
39
42
  border: none;
40
43
  border-radius: 50%;
41
44
  color: #fff;
42
45
  cursor: pointer;
43
46
  transition: background-color 0.2s;
47
+ z-index: 1;
48
+ }
49
+ .h2l-image-viewer__close[data-v-39bb591c]:hover {
50
+ background-color: rgba(255, 255, 255, 0.2);
44
51
  }
45
- .h2l-image-viewer__close[data-v-09434fce]:hover {
52
+ .h2l-image-viewer__link[data-v-39bb591c] {
53
+ position: absolute;
54
+ top: 20px;
55
+ right: 72px;
56
+ width: 44px;
57
+ height: 44px;
58
+ display: flex;
59
+ align-items: center;
60
+ justify-content: center;
61
+ background-color: rgba(255, 255, 255, 0.1);
62
+ backdrop-filter: blur(4px);
63
+ border: none;
64
+ border-radius: 50%;
65
+ color: #fff;
66
+ cursor: pointer;
67
+ transition: background-color 0.2s;
68
+ text-decoration: none;
69
+ z-index: 1;
70
+ }
71
+ .h2l-image-viewer__link[data-v-39bb591c]:hover {
72
+ background-color: rgba(255, 255, 255, 0.2);
73
+ }
74
+ .h2l-image-viewer__info[data-v-39bb591c] {
75
+ position: absolute;
76
+ bottom: 0;
77
+ left: 0;
78
+ right: 0;
79
+ color: #fff;
80
+ background-color: rgba(0, 0, 0, 0.6);
81
+ backdrop-filter: blur(10px);
82
+ border-top-left-radius: 16px;
83
+ border-top-right-radius: 16px;
84
+ padding: 16px 20px;
85
+ }
86
+ .h2l-image-viewer__info-header[data-v-39bb591c] {
87
+ display: flex;
88
+ align-items: center;
89
+ justify-content: space-between;
90
+ gap: 12px;
91
+ }
92
+ .h2l-image-viewer__title[data-v-39bb591c] {
93
+ font-size: 14px;
94
+ font-weight: 600;
95
+ flex: 1;
96
+ min-width: 0;
97
+ }
98
+ .h2l-image-viewer__description[data-v-39bb591c] {
99
+ margin-top: 12px;
100
+ }
101
+ .h2l-image-viewer__description-text[data-v-39bb591c] {
102
+ line-height: 1.5;
103
+ display: -webkit-box;
104
+ -webkit-box-orient: vertical;
105
+ -webkit-line-clamp: 2;
106
+ overflow: hidden;
107
+ text-overflow: ellipsis;
108
+ word-wrap: break-word;
109
+ transition: -webkit-line-clamp 0.3s ease;
110
+ color: rgba(255, 255, 255, 0.85);
111
+ font-size: 12px;
112
+ }
113
+ .h2l-image-viewer__description-text--expanded[data-v-39bb591c] {
114
+ -webkit-line-clamp: unset;
115
+ max-height: none;
116
+ }
117
+ .h2l-image-viewer__more[data-v-39bb591c] {
118
+ padding: 2px 8px;
119
+ font-size: 11px;
120
+ color: rgba(255, 255, 255, 0.7);
121
+ background-color: rgba(255, 255, 255, 0.1);
122
+ border: none;
123
+ border-radius: 4px;
124
+ cursor: pointer;
125
+ transition: all 0.2s;
126
+ flex-shrink: 0;
127
+ }
128
+ .h2l-image-viewer__more[data-v-39bb591c]:hover {
129
+ color: #fff;
46
130
  background-color: rgba(255, 255, 255, 0.2);
47
131
  }
48
132
 
49
133
  /* 过渡动画 */
50
- .h2l-image-viewer-enter-active[data-v-09434fce],
51
- .h2l-image-viewer-leave-active[data-v-09434fce] {
134
+ .h2l-image-viewer-enter-active[data-v-39bb591c],
135
+ .h2l-image-viewer-leave-active[data-v-39bb591c] {
52
136
  transition: opacity 0.2s ease;
53
137
  }
54
- .h2l-image-viewer-enter-active .h2l-image-viewer__content[data-v-09434fce],
55
- .h2l-image-viewer-leave-active .h2l-image-viewer__content[data-v-09434fce] {
138
+ .h2l-image-viewer-enter-active .h2l-image-viewer__content[data-v-39bb591c],
139
+ .h2l-image-viewer-leave-active .h2l-image-viewer__content[data-v-39bb591c] {
56
140
  transition: opacity 0.2s ease, transform 0.2s ease;
57
141
  }
58
- .h2l-image-viewer-enter-from[data-v-09434fce],
59
- .h2l-image-viewer-leave-to[data-v-09434fce] {
142
+ .h2l-image-viewer-enter-from[data-v-39bb591c],
143
+ .h2l-image-viewer-leave-to[data-v-39bb591c] {
60
144
  opacity: 0;
61
145
  }
62
- .h2l-image-viewer-enter-from .h2l-image-viewer__content[data-v-09434fce],
63
- .h2l-image-viewer-leave-to .h2l-image-viewer__content[data-v-09434fce] {
146
+ .h2l-image-viewer-enter-from .h2l-image-viewer__content[data-v-39bb591c],
147
+ .h2l-image-viewer-leave-to .h2l-image-viewer__content[data-v-39bb591c] {
64
148
  opacity: 0;
65
149
  transform: scale(0.9);
66
150
  }
67
151
 
68
152
 
69
- .h2l-tooltip[data-v-4cbefa86] {
153
+ .h2l-tooltip[data-v-c8ed1c2a] {
70
154
  position: relative;
71
155
  display: inline-flex;
72
156
  }
73
- .h2l-tooltip__content[data-v-4cbefa86] {
157
+ .h2l-tooltip__content[data-v-c8ed1c2a] {
74
158
  position: fixed;
75
159
  transform: translate(-50%, 0);
76
160
  padding: 6px 12px;
@@ -85,7 +169,7 @@
85
169
  flex-direction: column;
86
170
  gap: 4px;
87
171
  }
88
- .h2l-tooltip__content[data-v-4cbefa86]::after {
172
+ .h2l-tooltip__content[data-v-c8ed1c2a]::after {
89
173
  content: '';
90
174
  position: absolute;
91
175
  bottom: 100%;
@@ -94,12 +178,12 @@
94
178
  border: 4px solid transparent;
95
179
  border-bottom-color: rgba(0, 0, 0, 0.85);
96
180
  }
97
- .h2l-tooltip__divider[data-v-4cbefa86] {
181
+ .h2l-tooltip__divider[data-v-c8ed1c2a] {
98
182
  height: 1px;
99
183
  background-color: rgba(255, 255, 255, 0.2);
100
184
  margin: 2px 0;
101
185
  }
102
- .h2l-tooltip__description[data-v-4cbefa86] {
186
+ .h2l-tooltip__description[data-v-c8ed1c2a] {
103
187
  font-size: 11px;
104
188
  color: rgba(255, 255, 255, 0.8);
105
189
  word-wrap: break-word;
@@ -107,31 +191,32 @@
107
191
  }
108
192
 
109
193
  /* 进入和离开动画 */
110
- .h2l-tooltip-enter-active[data-v-4cbefa86],
111
- .h2l-tooltip-leave-active[data-v-4cbefa86] {
194
+ .h2l-tooltip-enter-active[data-v-c8ed1c2a],
195
+ .h2l-tooltip-leave-active[data-v-c8ed1c2a] {
112
196
  transition: all 0.25s ease;
113
197
  }
114
- .h2l-tooltip-enter-from[data-v-4cbefa86],
115
- .h2l-tooltip-leave-to[data-v-4cbefa86] {
198
+ .h2l-tooltip-enter-from[data-v-c8ed1c2a],
199
+ .h2l-tooltip-leave-to[data-v-c8ed1c2a] {
116
200
  opacity: 0;
117
201
  transform: translate(-50%, -10px);
118
202
  }
119
203
 
120
204
 
121
- .h2l-ranking[data-v-bcf2d064] {
205
+ .h2l-ranking[data-v-c1a2322f] {
122
206
  display: flex;
123
207
  border: 1px solid #000;
124
208
  background-color: #1a1a1a;
125
209
  overflow: hidden;
126
210
  }
127
- .h2l-ranking__labels[data-v-bcf2d064] {
211
+ .h2l-ranking__labels[data-v-c1a2322f] {
128
212
  display: flex;
129
213
  flex-direction: column;
214
+ max-width: 120px;
130
215
  min-width: 100px;
131
216
  width: 20%;
132
217
  border-right: 1px solid #000;
133
218
  }
134
- .h2l-ranking__label[data-v-bcf2d064] {
219
+ .h2l-ranking__label[data-v-c1a2322f] {
135
220
  display: flex;
136
221
  align-items: center;
137
222
  justify-content: center;
@@ -141,44 +226,44 @@
141
226
  text-align: center;
142
227
  border-bottom: 1px solid #000;
143
228
  }
144
- .h2l-ranking__label[data-v-bcf2d064]:last-child {
229
+ .h2l-ranking__label[data-v-c1a2322f]:last-child {
145
230
  border-bottom: none;
146
231
  }
147
- .h2l-ranking__label--hang[data-v-bcf2d064] {
232
+ .h2l-ranking__label--hang[data-v-c1a2322f] {
148
233
  background-color: #ff0000;
149
234
  color: #fff;
150
235
  }
151
- .h2l-ranking__label--upper[data-v-bcf2d064] {
236
+ .h2l-ranking__label--upper[data-v-c1a2322f] {
152
237
  background-color: #ff9500;
153
238
  color: #fff;
154
239
  }
155
- .h2l-ranking__label--middle[data-v-bcf2d064] {
240
+ .h2l-ranking__label--middle[data-v-c1a2322f] {
156
241
  background-color: #ffcc00;
157
242
  color: #000;
158
243
  }
159
- .h2l-ranking__label--lower[data-v-bcf2d064] {
244
+ .h2l-ranking__label--lower[data-v-c1a2322f] {
160
245
  background-color: #fef4d1;
161
246
  color: #000;
162
247
  }
163
- .h2l-ranking__label--la[data-v-bcf2d064] {
248
+ .h2l-ranking__label--la[data-v-c1a2322f] {
164
249
  background-color: #ffffff;
165
250
  color: #000;
166
251
  }
167
- .h2l-ranking__content[data-v-bcf2d064] {
252
+ .h2l-ranking__content[data-v-c1a2322f] {
168
253
  flex: 1;
169
254
  display: flex;
170
255
  flex-direction: column;
171
256
  }
172
- .h2l-ranking__row[data-v-bcf2d064] {
257
+ .h2l-ranking__row[data-v-c1a2322f] {
173
258
  display: flex;
174
259
  height: 100px;
175
260
  border-bottom: 1px solid #000;
176
261
  overflow: hidden;
177
262
  }
178
- .h2l-ranking__row[data-v-bcf2d064]:last-child {
263
+ .h2l-ranking__row[data-v-c1a2322f]:last-child {
179
264
  border-bottom: none;
180
265
  }
181
- .h2l-ranking__items[data-v-bcf2d064] {
266
+ .h2l-ranking__items[data-v-c1a2322f] {
182
267
  flex: 1;
183
268
  display: flex;
184
269
  align-items: center;
@@ -191,10 +276,10 @@
191
276
  scrollbar-width: none;
192
277
  -ms-overflow-style: none;
193
278
  }
194
- .h2l-ranking__items[data-v-bcf2d064]::-webkit-scrollbar {
279
+ .h2l-ranking__items[data-v-c1a2322f]::-webkit-scrollbar {
195
280
  display: none;
196
281
  }
197
- .h2l-ranking__item[data-v-bcf2d064] {
282
+ .h2l-ranking__item[data-v-c1a2322f] {
198
283
  position: relative;
199
284
  width: 84px;
200
285
  height: 84px;
@@ -203,7 +288,7 @@
203
288
  background-color: #333;
204
289
  cursor: pointer;
205
290
  }
206
- .h2l-ranking__item img[data-v-bcf2d064] {
291
+ .h2l-ranking__item img[data-v-c1a2322f] {
207
292
  width: 100%;
208
293
  height: 100%;
209
294
  object-fit: cover;
package/dist/index.d.mts CHANGED
@@ -3,7 +3,8 @@ import * as vue from "vue";
3
3
  //#region src/types.d.ts
4
4
  interface RankingItem {
5
5
  title: string;
6
- url: string;
6
+ cover: string;
7
+ url?: string;
7
8
  description?: string;
8
9
  }
9
10
  interface Rankings {
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{Fragment as e,Teleport as t,Transition as n,computed as r,createBlock as i,createCommentVNode as a,createElementBlock as o,createElementVNode as s,createSlots as c,createStaticVNode as l,createTextVNode as u,createVNode as d,defineComponent as f,normalizeStyle as p,onMounted as m,onUnmounted as h,openBlock as g,ref as _,renderList as v,renderSlot as y,toDisplayString as b,watch as x,withCtx as S,withModifiers as C}from"vue";var w=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n};const T={class:`h2l-image-viewer__content`},E=[`src`],D=.5;var O=w(f({__name:`H2lImageViewer`,props:{show:{type:Boolean},src:{}},emits:[`update:show`],setup(e,{emit:c}){let l=e,u=c,f=_(),v=_(1),y=_({active:!1,startDistance:0,startScale:1,centerX:0,centerY:0}),b=r(()=>({transform:`scale(${v.value})`,transformOrigin:`center center`,transition:y.value.active?`none`:`transform 0.2s ease-out`}));function w(){u(`update:show`,!1),setTimeout(()=>{v.value=1},200)}function O(e){e.preventDefault();let t=e.deltaY>0?-.1:.1;v.value=Math.max(D,Math.min(5,v.value+t))}function k(e){if(e.touches.length===2){e.preventDefault();let t=e.touches[0],n=e.touches[1],r=Math.hypot(n.clientX-t.clientX,n.clientY-t.clientY),i=(t.clientX+n.clientX)/2,a=(t.clientY+n.clientY)/2;y.value={active:!0,startDistance:r,startScale:v.value,centerX:i,centerY:a}}}function A(e){if(e.touches.length===2&&y.value.active){e.preventDefault();let t=e.touches[0],n=e.touches[1],r=Math.hypot(n.clientX-t.clientX,n.clientY-t.clientY)/y.value.startDistance;v.value=Math.max(D,Math.min(5,y.value.startScale*r))}}function j(){y.value.active=!1}function M(e){e.key===`Escape`&&w()}return x(()=>l.show,e=>{e||(v.value=1)}),m(()=>{document.addEventListener(`keydown`,M)}),h(()=>{document.removeEventListener(`keydown`,M)}),(r,c)=>(g(),i(t,{to:`body`},[d(n,{name:`h2l-image-viewer`},{default:S(()=>[e.show?(g(),o(`div`,{key:0,ref_key:`containerRef`,ref:f,class:`h2l-image-viewer`,onWheel:O,onTouchstart:k,onTouchmove:A,onTouchend:j,onClick:C(w,[`self`])},[s(`button`,{class:`h2l-image-viewer__close`,onClick:w},[...c[0]||=[s(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},[s(`path`,{d:`M18 6L6 18M6 6l12 12`})],-1)]]),s(`div`,T,[s(`img`,{src:e.src,style:p(b.value),alt:`Preview`},null,12,E)])],544)):a(`v-if`,!0)]),_:1})]))}}),[[`__scopeId`,`data-v-09434fce`]]);const k={class:`h2l-tooltip__title`},A={key:0,class:`h2l-tooltip__divider`},j={key:1,class:`h2l-tooltip__description`};var M=w(f({__name:`H2lTooltip`,setup(e){let r=_(),c=_(!1),l=_({x:0,y:0});function u(){if(!r.value)return;let e=r.value.getBoundingClientRect();l.value={x:e.left+e.width/2,y:e.bottom+8},c.value=!0}function f(){c.value=!1}return m(()=>{r.value?.addEventListener(`mouseenter`,u),r.value?.addEventListener(`mouseleave`,f)}),h(()=>{r.value?.removeEventListener(`mouseenter`,u),r.value?.removeEventListener(`mouseleave`,f)}),(e,u)=>(g(),o(`div`,{ref_key:`triggerRef`,ref:r,class:`h2l-tooltip`},[y(e.$slots,`default`,{},void 0,!0),(g(),i(t,{to:`body`},[d(n,{name:`h2l-tooltip`},{default:S(()=>[c.value?(g(),o(`div`,{key:0,class:`h2l-tooltip__content`,style:p({left:`${l.value.x}px`,top:`${l.value.y}px`})},[s(`div`,k,[y(e.$slots,`content`,{},void 0,!0)]),e.$slots.description?(g(),o(`div`,A)):a(`v-if`,!0),e.$slots.description?(g(),o(`div`,j,[y(e.$slots,`description`,{},void 0,!0)])):a(`v-if`,!0)],4)):a(`v-if`,!0)]),_:3})]))],512))}}),[[`__scopeId`,`data-v-4cbefa86`]]);const N={class:`h2l-ranking__content`},P=[`onClick`],F=[`src`,`alt`],I=[`onClick`],L=[`src`,`alt`],R=[`onClick`],z=[`src`,`alt`],B=[`onClick`],V=[`src`,`alt`],H=[`onClick`],U=[`src`,`alt`];var W=w(f({__name:`H2lRanking`,props:{rankings:{},enableImageViewer:{type:Boolean,default:!0}},setup(t){let n=t,a=_(),f=_(),h=_(0),y=_(!1),x=_(``),C=r(()=>({width:h.value>0?`${h.value}px`:void 0}));m(()=>{a.value&&f.value&&(h.value=a.value.clientWidth-f.value.clientWidth)});function w(e){let t=e.currentTarget;e.deltaY!==0&&(e.preventDefault(),t.scrollLeft+=e.deltaY*.5)}function T(e){n.enableImageViewer&&(x.value=e,y.value=!0)}return(n,r)=>(g(),o(`div`,{ref_key:`rootRef`,ref:a,class:`h2l-ranking`},[d(O,{show:y.value,"onUpdate:show":r[0]||=e=>y.value=e,src:x.value},null,8,[`show`,`src`]),s(`div`,{ref_key:`labelsRef`,ref:f,class:`h2l-ranking__labels`},[...r[1]||=[l(`<div class="h2l-ranking__label h2l-ranking__label--hang" data-v-bcf2d064> 夯 </div><div class="h2l-ranking__label h2l-ranking__label--upper" data-v-bcf2d064> 顶级 </div><div class="h2l-ranking__label h2l-ranking__label--middle" data-v-bcf2d064> 人上人 </div><div class="h2l-ranking__label h2l-ranking__label--lower" data-v-bcf2d064> NPC </div><div class="h2l-ranking__label h2l-ranking__label--la" data-v-bcf2d064> 拉完了 </div>`,5)]],512),s(`div`,N,[s(`div`,{class:`h2l-ranking__row`,style:p(C.value)},[s(`div`,{class:`h2l-ranking__items`,onWheel:w},[(g(!0),o(e,null,v(t.rankings.hang,(e,t)=>(g(),i(M,{key:`hang-${t}`},c({default:S(()=>[s(`div`,{class:`h2l-ranking__item`,onClick:t=>T(e.url)},[s(`img`,{src:e.url,alt:e.title},null,8,F)],8,P)]),content:S(()=>[u(b(e.title),1)]),_:2},[e.description?{name:`description`,fn:S(()=>[u(b(e.description),1)]),key:`0`}:void 0]),1024))),128))],32)],4),s(`div`,{class:`h2l-ranking__row`,style:p(C.value)},[s(`div`,{class:`h2l-ranking__items`,onWheel:w},[(g(!0),o(e,null,v(t.rankings.upper,(e,t)=>(g(),i(M,{key:`upper-${t}`},c({default:S(()=>[s(`div`,{class:`h2l-ranking__item`,onClick:t=>T(e.url)},[s(`img`,{src:e.url,alt:e.title},null,8,L)],8,I)]),content:S(()=>[u(b(e.title),1)]),_:2},[e.description?{name:`description`,fn:S(()=>[u(b(e.description),1)]),key:`0`}:void 0]),1024))),128))],32)],4),s(`div`,{class:`h2l-ranking__row`,style:p(C.value)},[s(`div`,{class:`h2l-ranking__items`,onWheel:w},[(g(!0),o(e,null,v(t.rankings.middle,(e,t)=>(g(),i(M,{key:`middle-${t}`},c({default:S(()=>[s(`div`,{class:`h2l-ranking__item`,onClick:t=>T(e.url)},[s(`img`,{src:e.url,alt:e.title},null,8,z)],8,R)]),content:S(()=>[u(b(e.title),1)]),_:2},[e.description?{name:`description`,fn:S(()=>[u(b(e.description),1)]),key:`0`}:void 0]),1024))),128))],32)],4),s(`div`,{class:`h2l-ranking__row`,style:p(C.value)},[s(`div`,{class:`h2l-ranking__items`,onWheel:w},[(g(!0),o(e,null,v(t.rankings.lower,(e,t)=>(g(),i(M,{key:`lower-${t}`},c({default:S(()=>[s(`div`,{class:`h2l-ranking__item`,onClick:t=>T(e.url)},[s(`img`,{src:e.url,alt:e.title},null,8,V)],8,B)]),content:S(()=>[u(b(e.title),1)]),_:2},[e.description?{name:`description`,fn:S(()=>[u(b(e.description),1)]),key:`0`}:void 0]),1024))),128))],32)],4),s(`div`,{class:`h2l-ranking__row`,style:p(C.value)},[s(`div`,{class:`h2l-ranking__items`,onWheel:w},[(g(!0),o(e,null,v(t.rankings.la,(e,t)=>(g(),i(M,{key:`la-${t}`},c({default:S(()=>[s(`div`,{class:`h2l-ranking__item`,onClick:t=>T(e.url)},[s(`img`,{src:e.url,alt:e.title},null,8,U)],8,H)]),content:S(()=>[u(b(e.title),1)]),_:2},[e.description?{name:`description`,fn:S(()=>[u(b(e.description),1)]),key:`0`}:void 0]),1024))),128))],32)],4)])],512))}}),[[`__scopeId`,`data-v-bcf2d064`]]),G=W;export{W as H2lRanking,G as default};
1
+ import{Fragment as e,Teleport as t,Transition as n,computed as r,createBlock as i,createCommentVNode as a,createElementBlock as o,createElementVNode as s,createSlots as c,createStaticVNode as l,createTextVNode as u,createVNode as d,defineComponent as f,nextTick as p,normalizeClass as m,normalizeStyle as h,onMounted as g,onUnmounted as _,openBlock as v,ref as y,renderList as b,renderSlot as x,toDisplayString as S,unref as C,watch as w,withCtx as T,withModifiers as E}from"vue";function D(e,t=200){let n=null;function r(){n&&clearTimeout(n),n=setTimeout(e,t)}g(()=>{typeof window<`u`&&window.addEventListener(`resize`,r)}),_(()=>{typeof window<`u`&&window.removeEventListener(`resize`,r),n&&clearTimeout(n)})}function O(){if(typeof window>`u`||!navigator.userAgent)return!1;let e=navigator.userAgent.toLowerCase();return[`android`,`iphone`,`ipad`,`ipod`,`windows phone`,`mobi`,`tablet`,`webos`,`blackberry`].some(t=>e.includes(t))}function k(){let e=y(!1);function t(){if(typeof window>`u`)return;let t=window.innerWidth<768,n=`ontouchstart`in window,r=O();e.value=t||n||r}return D(t,200),g(()=>{t()}),{isMobile:e}}function A(){let e=y({active:!1,startX:0,startY:0,translateX:0,translateY:0});function t(t,n){e.value.active=!0,e.value.startX=t,e.value.startY=n}function n(t,n){if(!e.value.active)return;let r=t-e.value.startX,i=n-e.value.startY;e.value.translateX+=r,e.value.translateY+=i,e.value.startX=t,e.value.startY=n}function r(){e.value.active=!1}function i(){e.value.translateX=0,e.value.translateY=0}return{dragState:e,startDrag:t,onDragMove:n,endDrag:r,resetPosition:i}}function j(e){let t=y({active:!1,startDistance:0,startScale:1,centerX:0,centerY:0,isDragging:!1,startX:0,startY:0,startTranslateX:0,startTranslateY:0});function n(n,r){if(n.touches.length===1)r>1&&(t.value.isDragging=!0,t.value.startX=n.touches[0].clientX,t.value.startY=n.touches[0].clientY,t.value.startTranslateX=e.value.translateX,t.value.startTranslateY=e.value.translateY);else if(n.touches.length===2){n.preventDefault();let e=n.touches[0],i=n.touches[1],a=Math.hypot(i.clientX-e.clientX,i.clientY-e.clientY),o=(e.clientX+i.clientX)/2,s=(e.clientY+i.clientY)/2;t.value.active=!0,t.value.startDistance=a,t.value.startScale=r,t.value.centerX=o,t.value.centerY=s,t.value.isDragging=!1}}function r(n,r,i,a){if(n.touches.length===1&&t.value.isDragging){n.preventDefault();let r=n.touches[0].clientX-t.value.startX,i=n.touches[0].clientY-t.value.startY;e.value.translateX=t.value.startTranslateX+r,e.value.translateY=t.value.startTranslateY+i}else if(n.touches.length===2&&t.value.active){n.preventDefault();let e=n.touches[0],o=n.touches[1],s=Math.hypot(o.clientX-e.clientX,o.clientY-e.clientY)/t.value.startDistance;r.value=Math.max(i,Math.min(a,t.value.startScale*s))}}function i(){t.value.active=!1,t.value.isDragging=!1}return{touchState:t,onTouchStart:n,onTouchMove:r,onTouchEnd:i}}const M={xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},ee=f({__name:`CloseIcon`,setup(e){return(e,t)=>(v(),o(`svg`,M,[...t[0]||=[s(`path`,{d:`M18 6L6 18M6 6l12 12`},null,-1)]]))}}),N={xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,viewBox:`0 0 24 24`},te=f({__name:`ExternalLinkIcon`,setup(e){return(e,t)=>(v(),o(`svg`,N,[...t[0]||=[s(`path`,{fill:`currentColor`,d:`M19 19H5V5h7V3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2v-7h-2zM14 3v2h3.59l-9.83 9.83l1.41 1.41L19 6.41V10h2V3z`},null,-1)]]))}});var P=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n};const F=[`href`],ne={class:`h2l-image-viewer__content`},re=[`src`],ie={key:1,class:`h2l-image-viewer__info`},ae={class:`h2l-image-viewer__info-header`},oe={key:0,class:`h2l-image-viewer__title`},se={key:0,class:`h2l-image-viewer__description`},I=.5;var L=P(f({__name:`H2lImageViewer`,props:{show:{type:Boolean},src:{},url:{},title:{},description:{}},emits:[`update:show`],setup(e,{emit:c}){let l=e,u=c,f=y(),b=y(1),x=y(!1),D=y(!1),O=y(),{dragState:k,startDrag:M,onDragMove:N,endDrag:P,resetPosition:L}=A(),{touchState:R,onTouchStart:z,onTouchMove:B,onTouchEnd:V}=j(k),H=r(()=>{let e=k.value.active||R.value.isDragging;return{transform:`translate(${k.value.translateX}px, ${k.value.translateY}px) scale(${b.value})`,transformOrigin:`center center`,transition:e||R.value.active?`none`:`transform 0.2s ease-out`}});async function U(){await p(),O.value&&(D.value=O.value.scrollHeight>O.value.clientHeight)}function W(){x.value=!x.value}function G(){u(`update:show`,!1),setTimeout(()=>{b.value=1,L(),x.value=!1},200)}function K(e){e.preventDefault();let t=e.deltaY>0?-.1:.1;b.value=Math.max(I,Math.min(5,b.value+t))}function q(e){b.value<=1||(e.preventDefault(),M(e.clientX,e.clientY))}function J(e){N(e.clientX,e.clientY)}function Y(){P()}function X(e){z(e,b.value)}function Z(e){B(e,b,I,5)}function Q(){V()}function $(e){e.key===`Escape`&&G()}return w(()=>l.show,e=>{e?U():(b.value=1,L(),x.value=!1)}),w(()=>l.description,()=>{l.show&&U()}),g(()=>{document.addEventListener(`keydown`,$),document.addEventListener(`mousemove`,J),document.addEventListener(`mouseup`,Y)}),_(()=>{document.removeEventListener(`keydown`,$),document.removeEventListener(`mousemove`,J),document.removeEventListener(`mouseup`,Y)}),(r,c)=>(v(),i(t,{to:`body`},[d(n,{name:`h2l-image-viewer`},{default:T(()=>[e.show?(v(),o(`div`,{key:0,ref_key:`containerRef`,ref:f,class:`h2l-image-viewer`,onWheel:K,onTouchstart:X,onTouchmove:Z,onTouchend:Q,onClick:E(G,[`self`])},[s(`button`,{class:`h2l-image-viewer__close`,onClick:G},[d(C(ee))]),e.url?(v(),o(`a`,{key:0,href:e.url,target:`_blank`,rel:`noopener noreferrer`,class:`h2l-image-viewer__link`,title:`打开链接`},[d(C(te))],8,F)):a(`v-if`,!0),s(`div`,ne,[s(`img`,{src:e.src,style:h(H.value),alt:`Preview`,onMousedown:q},null,44,re)]),a(` 标题和描述信息 `),e.title||e.description?(v(),o(`div`,ie,[s(`div`,ae,[e.title?(v(),o(`div`,oe,S(e.title),1)):a(`v-if`,!0),e.description&&D.value?(v(),o(`button`,{key:1,class:`h2l-image-viewer__more`,onClick:W},S(x.value?`收起`:`更多`),1)):a(`v-if`,!0)]),e.description?(v(),o(`div`,se,[s(`div`,{ref_key:`descriptionTextRef`,ref:O,class:m([`h2l-image-viewer__description-text`,{"h2l-image-viewer__description-text--expanded":x.value}])},S(e.description),3)])):a(`v-if`,!0)])):a(`v-if`,!0)],544)):a(`v-if`,!0)]),_:1})]))}}),[[`__scopeId`,`data-v-39bb591c`]]);const R={class:`h2l-tooltip__title`},z={key:0,class:`h2l-tooltip__divider`},B={key:1,class:`h2l-tooltip__description`};var V=P(f({__name:`H2lTooltip`,setup(e){let c=y(),l=y(!1),u=y({x:0,y:0}),{isMobile:f}=k(),p=r(()=>l.value&&!f.value);function m(){if(!c.value||f.value)return;let e=c.value.getBoundingClientRect();u.value={x:e.left+e.width/2,y:e.bottom+8},l.value=!0}function b(){l.value=!1}return g(()=>{c.value?.addEventListener(`mouseenter`,m),c.value?.addEventListener(`mouseleave`,b)}),_(()=>{c.value?.removeEventListener(`mouseenter`,m),c.value?.removeEventListener(`mouseleave`,b)}),(e,r)=>(v(),o(`div`,{ref_key:`triggerRef`,ref:c,class:`h2l-tooltip`},[x(e.$slots,`default`,{},void 0,!0),(v(),i(t,{to:`body`},[d(n,{name:`h2l-tooltip`},{default:T(()=>[p.value?(v(),o(`div`,{key:0,class:`h2l-tooltip__content`,style:h({left:`${u.value.x}px`,top:`${u.value.y}px`})},[s(`div`,R,[x(e.$slots,`content`,{},void 0,!0)]),e.$slots.description?(v(),o(`div`,z)):a(`v-if`,!0),e.$slots.description?(v(),o(`div`,B,[x(e.$slots,`description`,{},void 0,!0)])):a(`v-if`,!0)],4)):a(`v-if`,!0)]),_:3})]))],512))}}),[[`__scopeId`,`data-v-c8ed1c2a`]]);const H={class:`h2l-ranking__content`},U=[`onClick`],W=[`src`,`alt`],G=[`onClick`],K=[`src`,`alt`],q=[`onClick`],J=[`src`,`alt`],Y=[`onClick`],X=[`src`,`alt`],Z=[`onClick`],Q=[`src`,`alt`];var $=P(f({__name:`H2lRanking`,props:{rankings:{},enableImageViewer:{type:Boolean,default:!0}},setup(t){let n=t,a=y(),f=y(),m=y(0),_=y(!1),x=y(``),C=y(``),w=y(``),E=y(``),O=r(()=>({width:m.value>0?`${m.value}px`:void 0}));function k(){a.value&&f.value&&(m.value=a.value.clientWidth-f.value.clientWidth)}D(k,200),g(()=>{p(()=>{k()})});function A(e){let t=e.currentTarget;e.deltaY!==0&&(e.preventDefault(),t.scrollLeft+=e.deltaY*.5)}function j(e,t,r,i){n.enableImageViewer&&(x.value=e,C.value=t||``,w.value=r||``,E.value=i||``,_.value=!0)}return(n,r)=>(v(),o(`div`,{ref_key:`rootRef`,ref:a,class:`h2l-ranking`},[d(L,{show:_.value,"onUpdate:show":r[0]||=e=>_.value=e,src:x.value,url:C.value,title:w.value,description:E.value},null,8,[`show`,`src`,`url`,`title`,`description`]),s(`div`,{ref_key:`labelsRef`,ref:f,class:`h2l-ranking__labels`},[...r[1]||=[l(`<div class="h2l-ranking__label h2l-ranking__label--hang" data-v-c1a2322f> 夯 </div><div class="h2l-ranking__label h2l-ranking__label--upper" data-v-c1a2322f> 顶级 </div><div class="h2l-ranking__label h2l-ranking__label--middle" data-v-c1a2322f> 人上人 </div><div class="h2l-ranking__label h2l-ranking__label--lower" data-v-c1a2322f> NPC </div><div class="h2l-ranking__label h2l-ranking__label--la" data-v-c1a2322f> 拉完了 </div>`,5)]],512),s(`div`,H,[s(`div`,{class:`h2l-ranking__row`,style:h(O.value)},[s(`div`,{class:`h2l-ranking__items`,onWheel:A},[(v(!0),o(e,null,b(t.rankings.hang,(e,t)=>(v(),i(V,{key:`hang-${t}`},c({default:T(()=>[s(`div`,{class:`h2l-ranking__item`,onClick:t=>j(e.cover,e.url,e.title,e.description)},[s(`img`,{src:e.cover,alt:e.title},null,8,W)],8,U)]),content:T(()=>[u(S(e.title),1)]),_:2},[e.description?{name:`description`,fn:T(()=>[u(S(e.description),1)]),key:`0`}:void 0]),1024))),128))],32)],4),s(`div`,{class:`h2l-ranking__row`,style:h(O.value)},[s(`div`,{class:`h2l-ranking__items`,onWheel:A},[(v(!0),o(e,null,b(t.rankings.upper,(e,t)=>(v(),i(V,{key:`upper-${t}`},c({default:T(()=>[s(`div`,{class:`h2l-ranking__item`,onClick:t=>j(e.cover,e.url,e.title,e.description)},[s(`img`,{src:e.cover,alt:e.title},null,8,K)],8,G)]),content:T(()=>[u(S(e.title),1)]),_:2},[e.description?{name:`description`,fn:T(()=>[u(S(e.description),1)]),key:`0`}:void 0]),1024))),128))],32)],4),s(`div`,{class:`h2l-ranking__row`,style:h(O.value)},[s(`div`,{class:`h2l-ranking__items`,onWheel:A},[(v(!0),o(e,null,b(t.rankings.middle,(e,t)=>(v(),i(V,{key:`middle-${t}`},c({default:T(()=>[s(`div`,{class:`h2l-ranking__item`,onClick:t=>j(e.cover,e.url,e.title,e.description)},[s(`img`,{src:e.cover,alt:e.title},null,8,J)],8,q)]),content:T(()=>[u(S(e.title),1)]),_:2},[e.description?{name:`description`,fn:T(()=>[u(S(e.description),1)]),key:`0`}:void 0]),1024))),128))],32)],4),s(`div`,{class:`h2l-ranking__row`,style:h(O.value)},[s(`div`,{class:`h2l-ranking__items`,onWheel:A},[(v(!0),o(e,null,b(t.rankings.lower,(e,t)=>(v(),i(V,{key:`lower-${t}`},c({default:T(()=>[s(`div`,{class:`h2l-ranking__item`,onClick:t=>j(e.cover,e.url,e.title,e.description)},[s(`img`,{src:e.cover,alt:e.title},null,8,X)],8,Y)]),content:T(()=>[u(S(e.title),1)]),_:2},[e.description?{name:`description`,fn:T(()=>[u(S(e.description),1)]),key:`0`}:void 0]),1024))),128))],32)],4),s(`div`,{class:`h2l-ranking__row`,style:h(O.value)},[s(`div`,{class:`h2l-ranking__items`,onWheel:A},[(v(!0),o(e,null,b(t.rankings.la,(e,t)=>(v(),i(V,{key:`la-${t}`},c({default:T(()=>[s(`div`,{class:`h2l-ranking__item`,onClick:t=>j(e.cover,e.url,e.title,e.description)},[s(`img`,{src:e.cover,alt:e.title},null,8,Q)],8,Z)]),content:T(()=>[u(S(e.title),1)]),_:2},[e.description?{name:`description`,fn:T(()=>[u(S(e.description),1)]),key:`0`}:void 0]),1024))),128))],32)],4)])],512))}}),[[`__scopeId`,`data-v-c1a2322f`]]),ce=$;export{$ as H2lRanking,ce as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "h2l-ranking",
3
3
  "type": "module",
4
- "version": "0.0.2",
4
+ "version": "0.1.0",
5
5
  "description": "hang to la ranking",
6
6
  "author": "imba97",
7
7
  "license": "MIT",