12
12
}"
13
13
@click =" (e) => goPostDetail(e, item)"
14
14
@click.middle =" (e) => goPostDetail(e, item, true)"
15
+ @mousedown =" preventDefaultMiddleClick"
15
16
>
16
17
<!-- seo 为了抓取链接 -->
17
18
<NuxtLink
111
112
<template v-if =" item .type === 1 " >
112
113
<NuxtLink
113
114
@click.stop
115
+ @click.middle.stop
114
116
:to =" {
115
117
name: 'postDetail',
116
118
params: { id: item.alias || item._id },
132
134
<NuxtLink
133
135
class =" dflex flexCenter cGray94 hover:text-primary-500"
134
136
@click.stop
137
+ @click.middle.stop
135
138
:to =" {
136
139
name: 'postDetail',
137
140
params: { id: item.alias || item._id },
146
149
<NuxtLink
147
150
class =" dflex flexCenter cGray94 hover:text-primary-500"
148
151
@click.stop
152
+ @click.middle.stop
149
153
:to =" {
150
154
name: 'postDetail',
151
155
params: { id: item.alias || item._id },
166
170
class =" dflex flexCenter cursor-pointer hover:text-primary-500"
167
171
:class =" item.isLike ? 'text-primary-500' : 'cGray94'"
168
172
@click.stop =" likePost(item._id)"
173
+ @click.middle.stop
169
174
v-if =" likeListInited"
170
175
>
171
176
<!-- 加载 -->
@@ -466,16 +471,15 @@ const goPostDetail = (e, item, middle) => {
466
471
// 判断是否按着ctrl键,如果是就在新标签页打开
467
472
// 如果middle为true,就在新标签页打开
468
473
if (middle || e .ctrlKey || e .metaKey ) {
469
- if (middle) {
470
- e .preventDefault ()
471
- }
474
+ console .log (' middle' )
472
475
// resolveUrl
473
476
const url = router .resolve ({
474
477
name: routeName,
475
478
params: { id },
476
479
}).href
477
480
window .open (url, ' _blank' )
478
481
} else {
482
+ console .log (' post push' )
479
483
router .push ({
480
484
name: routeName,
481
485
params: {
@@ -485,6 +489,14 @@ const goPostDetail = (e, item, middle) => {
485
489
}
486
490
}
487
491
492
+ const preventDefaultMiddleClick = (e ) => {
493
+ console .log (e .button , e .target .tagName )
494
+ if (e .button === 1 && e .target .tagName !== ' A' ) {
495
+ console .log (' preventDefault middle click' )
496
+ e .preventDefault ()
497
+ }
498
+ }
499
+
488
500
// console.log(postsData)
489
501
const likeListInited = ref (false )
490
502
const likeListLoading = ref (false )
0 commit comments