Skip to content

触发迅雷下载

可以通过触发迅雷的下载协议(thunder://)来实现迅雷下载, 即在链接改为 thuner:// + Base64格式(AA + 原链接 + ZZ)

普通下载

迅雷下载

vue
<script setup>
import { onMounted } from 'vue'

onMounted(() => {
  // 确保在客户端执行
  if (typeof document === 'undefined') return
  
  const links = document.querySelectorAll('a[data-thunder]')
  console.log('Mounted links:', links)

  links.forEach(link => {
    const encoded = btoa(`AA${link.href}ZZ`)
    link.href = `thunder://${encoded}`
    
    // 强制协议触发
    link.onclick = (e) => {
      e.preventDefault()
      window.open(link.href, '_blank')
    }
  })
})
</script>
html
<a href="https://www.hezhiwenda.info/vite/assets/4d2e8423de21abb5f4bd7e7fd708632e19474906.hbULtOSv.jpg">普通下载</a>

<a data-thunder href="https://www.hezhiwenda.info/vite/assets/4d2e8423de21abb5f4bd7e7fd708632e19474906.hbULtOSv.jpg">迅雷下载</a>

TIP

这里使用监听data-thunder属性, 拦截默认点击事件, 并使用window.open打开新窗口

粤ICP备20009776号