feat(v0.2.1): 添加认证参数支持和客户端下载命令生成

主要更新:
- 新增 auth 参数加密传递支持 (QK/UC Cookie认证)
- 实现下载命令自动生成 (curl/aria2c/迅雷)
- aria2c 命令支持 8 线程 8 片段下载
- 修复 cookie 字段映射问题
- 优化前端 clientLinks 页面
- 添加认证参数文档和测试用例
- 更新 .gitignore 忽略编译目录
This commit is contained in:
q committed 2026-02-05 20:35:47 +08:00
1 parent 7fc6367b9e
commit 3a25e5f2ae
53 files changed
+6881 -1470

No files matched your search

+12
View File
@@ -345,6 +345,18 @@
host: /www\.kdocs\.cn/,
name: 'WPS云文档'
},
quark: {
reg: /https:\/\/pan\.quark\.cn\/s\/[a-zA-Z\d]+/,
host: /pan\.quark\.cn/,
name: '夸克网盘'
},
uc: {
reg: /https:\/\/(fast|drive)\.uc\.cn\/s\/[a-zA-Z\d]+(?:\?public=\d+)?(?:[#&].*)?/,
host: /(fast|drive)\.uc\.cn/,
name: 'UC网盘'
},
other: {
reg: /https:\/\/([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*\.)+[a-zA-Z]{2,}\/s\/.+/,
host: /.*/,
+184 -449
View File
@@ -3,8 +3,8 @@
<el-card>
<template #header>
<div style="display: flex; align-items: center; gap: 12px;">
<el-button @click="goBack" :icon="ArrowLeft" circle size="small" />
<span>客户端下载链接生成器 (实验功能)</span>
<el-icon @click="goBack" style="cursor: pointer; font-size: 20px;"><Close /></el-icon>
<span>客户端下载链接生成器</span>
</div>
</template>
@@ -22,6 +22,42 @@
</el-descriptions>
</div>
<!-- 认证提示 -->
<div v-if="result && result.authRequirement && result.authRequirement !== 'none'" style="margin-bottom: 20px;">
<el-alert
:title="result.authRequirement === 'required' ? '需要认证信息' : '可选认证信息'"
:type="result.authRequirement === 'required' ? 'warning' : 'info'"
show-icon
:closable="false"
>
<template #default>
<div style="font-size: 13px;">
{{ result.authHint }}
<el-link type="primary" @click="goToAuthConfig" style="margin-left: 8px;">
<el-icon><Key /></el-icon>
去配置认证信息
</el-link>
</div>
</template>
</el-alert>
</div>
<!-- 需要客户端提示 -->
<div v-if="result && result.requiresClient" style="margin-bottom: 20px;">
<el-alert
title="此网盘需要使用下载工具"
type="warning"
show-icon
:closable="false"
>
<template #default>
<div style="font-size: 13px;">
该网盘的直链需要特殊请求头,浏览器无法直接下载。请使用以下客户端工具复制命令或链接进行下载。
</div>
</template>
</el-alert>
</div>
<!-- 结果展示区域 -->
<div v-if="result">
<!-- 文件基本信息 -->
@@ -36,11 +72,14 @@
<el-descriptions-item label="解析器" v-if="result.parserInfo">
<el-tag type="warning">{{ result.parserInfo }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="直链" v-if="result.directLink">
<el-descriptions-item label="直链" v-if="result.directLink && !result.requiresClient">
<el-link :href="result.directLink" target="_blank" type="primary">
点击下载
</el-link>
</el-descriptions-item>
<el-descriptions-item label="直链" v-else-if="result.directLink && result.requiresClient">
<el-tag type="danger">需要客户端工具下载</el-tag>
</el-descriptions-item>
</el-descriptions>
</div>
@@ -53,128 +92,72 @@
>
<template #label>
<div style="display: flex; align-items: center; gap: 8px;">
<el-icon
v-if="isElementIcon(getClientLogo(type))"
:size="20"
:color="getClientIconColor(type)"
>
<component :is="getClientLogo(type)" />
</el-icon>
<img
v-else
v-if="getClientLogo(type)"
:src="getClientLogo(type)"
:alt="getClientDisplayName(type)"
style="width: 20px; height: 20px;"
@error="handleImageError"
/>
<el-icon v-else :size="20"><Download /></el-icon>
<span>{{ getClientDisplayName(type) }}</span>
<el-icon
v-if="isClientInstalled(type)"
color="#67C23A"
size="16"
title="已安装"
>
<Check />
</el-icon>
<el-icon
v-else
color="#E6A23C"
size="16"
title="未安装或无法检测"
>
<QuestionFilled />
</el-icon>
<el-tag v-if="!getClientSupportsCookie(type)" type="danger" size="small">不支持Cookie</el-tag>
</div>
</template>
<el-card>
<template #header>
<div style="display: flex; justify-content: space-between; align-items: center;">
<template #header>
<div style="display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;">
<div>
<el-tag :type="getClientTagType(type)" size="large">
{{ getClientDisplayName(type) }}
</el-tag>
<el-tag :type="getClientTagType(type)" size="large">
{{ getClientDisplayName(type) }}
</el-tag>
<span style="margin-left: 12px; color: #666;">
{{ getClientDescription(type) }}
</span>
</div>
</div>
<div style="display: flex; gap: 8px;">
<el-button
size="small"
type="primary"
@click="copyToClipboard(link)"
:icon="CopyDocument"
>
复制
</el-button>
<el-button
size="small"
type="success"
@click="downloadWithClient(type, link)"
:icon="Download"
>
下载
</el-button>
<el-button
v-if="!isClientInstalled(type) && shouldShowDownloadButton(type)"
size="small"
type="warning"
@click="downloadClient(type)"
:icon="Download"
type="primary"
@click="copyToClipboard(link)"
:icon="CopyDocument"
>
下载客户端
复制
</el-button>
</div>
</div>
</template>
<el-input
:model-value="link"
type="textarea"
:rows="getTextareaRows(link)"
readonly
placeholder="客户端下载命令将显示在这里"
</div>
</template>
<el-input
:model-value="link"
type="textarea"
:rows="getTextareaRows(link)"
readonly
placeholder="客户端下载命令将显示在这里"
style="font-family: 'Courier New', 'Consolas', monospace; font-size: 13px;"
/>
</el-card>
/>
</el-card>
</el-tab-pane>
</el-tabs>
<!-- 支持的客户端类型 -->
<div v-if="result.supportedClients" style="margin-top: 20px;">
<!-- 客户端说明 -->
<div style="margin-top: 20px;">
<el-divider content-position="left">
<el-icon><Star /></el-icon>
支持的客户端类型
<el-icon><InfoFilled /></el-icon>
使用说明
</el-divider>
<div style="display: flex; flex-wrap: wrap; gap: 8px;">
<el-tag
v-for="(name, code) in result.supportedClients"
:key="code"
size="small"
:type="getClientTagType(code.toUpperCase())"
>
{{ name }}
</el-tag>
</div>
<!-- 添加说明信息 -->
<el-alert
title="客户端检测说明"
type="info"
:closable="false"
style="margin-top: 12px;"
>
<template #default>
<div style="font-size: 13px;">
<p style="margin: 0 0 8px 0;">
• 为了避免自动打开外部应用,系统不会自动检测大部分下载器是否已安装
</p>
<p style="margin: 0;">
• 您可以点击"下载"按钮尝试使用相应的下载器,或点击"下载客户端"按钮安装
</p>
</div>
</template>
</el-alert>
<el-descriptions :column="1" border>
<el-descriptions-item label="cURL 命令">
支持Cookie,复制命令到终端运行即可下载
</el-descriptions-item>
<el-descriptions-item label="Aria2">
支持Cookie,多线程下载器,复制命令后在终端运行或配置到Aria2客户端
</el-descriptions-item>
<el-descriptions-item label="迅雷">
<el-text type="danger">不支持Cookie</el-text>,仅适用于无需Cookie的直链,点击下载按钮可唤起迅雷
</el-descriptions-item>
</el-descriptions>
</div>
</div>
@@ -190,7 +173,7 @@
<!-- 空状态 -->
<div v-if="!result && !error && !form.shareUrl" style="margin-top: 40px;">
<el-empty description="请从主页点击'客户端链接(实验)'按钮开始使用" />
<el-empty description="请从主页点击'客户端下载'按钮开始使用" />
</div>
</el-card>
</div>
@@ -199,19 +182,17 @@
<script>
import { ref, reactive, onMounted } from 'vue'
import { ElMessage } from 'element-plus'
import { Download, ArrowLeft, CopyDocument, Star, Check, QuestionFilled, Setting } from '@element-plus/icons-vue'
import { Download, Close, CopyDocument, Key, InfoFilled } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'
export default {
name: 'ClientLinks',
components: {
Download,
ArrowLeft,
Close,
CopyDocument,
Star,
Check,
QuestionFilled,
Setting
Key,
InfoFilled
},
setup() {
const form = reactive({
@@ -223,7 +204,6 @@ export default {
const error = ref('')
const router = useRouter()
const activeTab = ref('')
const installedClients = ref(new Set())
// 从 sessionStorage 获取从 Home 页面传递的数据
const loadDataFromHome = () => {
@@ -249,53 +229,86 @@ export default {
}
}
// 客户端 Logo 映射
// 客户端配置(只保留3种)
const clientConfig = {
'CURL': {
displayName: 'cURL 命令',
description: '命令行下载工具,支持Cookie',
logo: 'https://gcore.jsdelivr.net/gh/simple-icons/simple-icons@develop/icons/curl.svg',
tagType: 'success',
supportsCookie: true,
downloadUrl: 'https://curl.se/download.html'
},
'ARIA2': {
displayName: 'Aria2',
description: '多线程下载器,支持Cookie',
logo: 'https://gcore.jsdelivr.net/gh/simple-icons/simple-icons@develop/icons/gnometerminal.svg',
tagType: 'warning',
supportsCookie: true,
downloadUrl: 'https://aria2.github.io/'
},
'THUNDER': {
displayName: '迅雷',
description: '迅雷下载器,不支持Cookie',
logo: null, // 使用base64
tagType: 'primary',
supportsCookie: false,
downloadUrl: 'https://www.xunlei.com/'
}
}
// 迅雷logo(base64)
const thunderLogo = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSIjMUJBMERCIiBkPSJNMTMgMkw0IDEzaDZsLTEgOWw5LTExaC02eiIvPjwvc3ZnPg=='
// 获取客户端 Logo
const getClientLogo = (type) => {
const logoMap = {
'ARIA2': 'https://gcore.jsdelivr.net/gh/simple-icons/simple-icons@develop/icons/gnometerminal.svg',
'MOTRIX': 'Download',
'BITCOMET': 'Download',
'THUNDER': 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNTYiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCA1NiAyMCI+PGRlZnM+PHJlY3QgaWQ9ImEiIHdpZHRoPSI1NiIgaGVpZ2h0PSIyMCIgeD0iMCIgeT0iMCIgcng9IjMiLz48L2RlZnM+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48bWFzayBpZD0iYiIgZmlsbD0iI2ZmZiI+PHVzZSB4bGluazpocmVmPSIjYSIvPjwvbWFzaz48dXNlIHhsaW5rOmhyZWY9IiNhIiBmaWxsPSIjMUJBMERCIi8+PHJlY3Qgd2lkdGg9IjIyIiBoZWlnaHQ9IjIwIiBmaWxsPSIjMEU2QUIyIiBtYXNrPSJ1cmwoI2IpIi8+PHRleHQgZml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MzYsNy4wNzUxNjY2NyAxNC42NzQzMjYyLDcuMDYzMjY2NjcgMTQuNjc0MzI2Miw3LjA1NzMxNjY3IEMxNC42NzQzMjYyLDcuMDUxNDI1IDE0Ljk2MTMwNSw2LjYyMzcyNSAxNS4zMTE4Mjk4LDYuMTA4ODc1IEMxNS42NjIzNTQ2LDUuNTk0MDI1IDE1Ljk1MTI2MjQsNS4xNjYzMjUgMTUuOTUzMTkxNSw1LjE1NjQ2NjY3IEMxNS45NTMxOTE1LDUuMTQ4NLine truncated
'WGET': 'https://gcore.jsdelivr.net/gh/simple-icons/simple-icons@develop/icons/gnu.svg',
'CURL': 'https://gcore.jsdelivr.net/gh/simple-icons/simple-icons@develop/icons/curl.svg',
'IDM': 'https://gcore.jsdelivr.net/gh/simple-icons/simple-icons@develop/icons/internetexplorer.svg',
'FDM': 'Download',
'POWERSHELL': 'Setting'
if (type === 'THUNDER') {
return thunderLogo
}
return logoMap[type] || 'Download'
return clientConfig[type]?.logo || null
}
// 判断是否为 Element Plus 图标
const isElementIcon = (logo) => {
const elementIcons = ['Download', 'Setting']
return elementIcons.includes(logo)
// 获取客户端显示名称
const getClientDisplayName = (type) => {
return clientConfig[type]?.displayName || type
}
// 获取客户端图标颜色
const getClientIconColor = (type) => {
const colorMap = {
'MOTRIX': '#409EFF',
'BITCOMET': '#67C23A',
'FDM': '#E6A23C',
'POWERSHELL': '#F56C6C'
}
return colorMap[type] || '#666'
// 获取客户端描述
const getClientDescription = (type) => {
return clientConfig[type]?.description || '下载工具'
}
// 客户端下载链接映射
// 获取客户端标签类型
const getClientTagType = (type) => {
return clientConfig[type]?.tagType || 'info'
}
// 获取客户端是否支持Cookie
const getClientSupportsCookie = (type) => {
return clientConfig[type]?.supportsCookie !== false
}
// 获取客户端下载链接
const getClientDownloadUrl = (type) => {
const downloadUrls = {
'ARIA2': 'https://aria2.github.io/',
'MOTRIX': 'https://motrix.app/',
'BITCOMET': 'https://www.bitcomet.com/',
'THUNDER': 'https://www.xunlei.com/',
'WGET': 'https://www.gnu.org/software/wget/',
'CURL': 'https://curl.se/download.html',
'IDM': 'https://www.internetdownloadmanager.com/download.html',
'FDM': 'https://www.freedownloadmanager.org/',
'POWERSHELL': 'https://docs.microsoft.com/en-us/powershell/'
return clientConfig[type]?.downloadUrl || '#'
}
// 判断是否应该显示下载客户端按钮
const shouldShowDownloadButton = (type) => {
const os = getOSInfo()
switch (type) {
case 'CURL':
// cURL 在 Windows 上可能需要安装
return os === 'windows'
case 'ARIA2':
// Aria2 需要手动安装
return true
case 'THUNDER':
// 迅雷主要在 Windows 上使用
return os === 'windows'
default:
return false
}
return downloadUrls[type] || '#'
}
// 获取操作系统信息
@@ -304,200 +317,17 @@ export default {
if (userAgent.includes('windows')) return 'windows'
if (userAgent.includes('mac')) return 'mac'
if (userAgent.includes('linux')) return 'linux'
if (userAgent.includes('android')) return 'android'
if (userAgent.includes('ios')) return 'ios'
return 'unknown'
}
// 获取设备类型
const getDeviceType = () => {
const userAgent = navigator.userAgent.toLowerCase()
if (/mobile|android|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent)) {
return 'mobile'
}
return 'desktop'
}
// 检查是否为移动端
const isMobile = () => {
return getDeviceType() === 'mobile'
}
// 检测客户端是否已安装(改进版本,避免自动打开应用)
const detectClient = async (type) => {
try {
const os = getOSInfo()
const deviceType = getDeviceType()
// 移动端不支持大部分下载器
if (deviceType === 'mobile') {
switch (type) {
case 'CURL':
// 移动端可能支持 curl(通过终端应用)
return os === 'android' || os === 'ios'
default:
return false
}
}
switch (type) {
case 'IDM':
// IDM 只在 Windows 桌面端可用
if (os !== 'windows' || deviceType !== 'desktop') return false
return await testProtocol('idm://')
case 'THUNDER':
// 迅雷主要在 Windows 桌面端使用
if (os !== 'windows' || deviceType !== 'desktop') return false
return await testProtocol('thunder://')
case 'BITCOMET':
// 比特彗星主要在 Windows 桌面端使用
if (os !== 'windows' || deviceType !== 'desktop') return false
return await testProtocol('bc://')
case 'MOTRIX':
// Motrix 跨平台桌面端 - 使用保守检测,避免自动打开
if (deviceType !== 'desktop') return false
// 对于 Motrix,我们假设用户可能已安装,但不进行实际检测
// 这样可以避免自动打开应用的问题
return false // 改为 false,让用户手动选择
case 'FDM':
// FDM 主要在 Windows 桌面端使用
if (os !== 'windows' || deviceType !== 'desktop') return false
return await testProtocol('fdm://')
case 'WGET':
// wget 在 Linux/Mac 桌面端通常已安装
return (os === 'linux' || os === 'mac') && deviceType === 'desktop'
case 'CURL':
// curl 在现代桌面系统上通常已安装
return deviceType === 'desktop'
case 'ARIA2':
// aria2 需要手动安装,无法检测
return false
case 'POWERSHELL':
// PowerShell 在 Windows 10+ 桌面端通常可用
return os === 'windows' && deviceType === 'desktop'
default:
return false
}
} catch (error) {
console.warn(`检测客户端 ${type} 失败:`, error)
return false
}
}
// 测试协议是否可用(改进版本,避免自动打开应用)
const testProtocol = (protocol) => {
return new Promise((resolve) => {
// 对于某些协议,我们使用更安全的方式检测
// 而不是直接尝试打开应用
try {
// 创建一个临时的 a 标签来测试协议
const link = document.createElement('a')
link.href = protocol + 'test'
link.style.display = 'none'
// 检查协议是否被识别
const isProtocolSupported = link.protocol === protocol.slice(0, -1) // 移除末尾的 ':'
if (isProtocolSupported) {
// 如果协议被识别,我们假设应用可能已安装
// 但不实际尝试打开它
resolve(true)
} else {
resolve(false)
}
} catch (error) {
// 如果检测失败,返回 false
resolve(false)
}
})
}
// 检测所有客户端(改进版本,避免自动打开应用)
const detectAllClients = async () => {
const clientTypes = ['ARIA2', 'MOTRIX', 'BITCOMET', 'THUNDER', 'WGET', 'CURL', 'IDM', 'FDM', 'POWERSHELL']
// 为了避免自动打开应用,我们使用更保守的检测方式
// 只检测那些不会触发外部应用启动的客户端
const safeDetectionTypes = ['WGET', 'CURL', 'POWERSHELL']
const detectionPromises = safeDetectionTypes.map(async (type) => {
const isInstalled = await detectClient(type)
if (isInstalled) {
installedClients.value.add(type)
}
})
await Promise.all(detectionPromises)
// 对于其他客户端,我们假设它们未安装,让用户手动选择
// 这样可以避免自动打开外部应用的问题
}
// 检查客户端是否已安装
const isClientInstalled = (type) => {
return installedClients.value.has(type)
}
// 判断是否应该显示下载按钮
const shouldShowDownloadButton = (type) => {
const os = getOSInfo()
const deviceType = getDeviceType()
// 移动端不显示下载按钮
if (deviceType === 'mobile') {
return false
}
switch (type) {
case 'CURL':
case 'WGET':
// 命令行工具,在 Linux/Mac 上通常已安装
return os === 'windows'
case 'POWERSHELL':
// PowerShell 在 Windows 10+ 上通常可用
return os !== 'windows'
case 'ARIA2':
// Aria2 需要手动安装
return true
case 'IDM':
case 'THUNDER':
case 'BITCOMET':
case 'FDM':
// Windows 专用工具
return os === 'windows'
case 'MOTRIX':
// 跨平台工具
return true
default:
return false
}
}
// 下载客户端
const downloadClient = (type) => {
const url = getClientDownloadUrl(type)
window.open(url, '_blank')
ElMessage.success(`正在跳转到 ${getClientDisplayName(type)} 下载页面`)
}
// 处理图片加载错误
const handleImageError = (event) => {
event.target.src = 'el-icon-download'
event.target.style.display = 'none'
}
// 组件挂载时加载数据和检测客户端
onMounted(async () => {
loadDataFromHome()
await detectAllClients()
// 组件挂载时加载数据
onMounted(() => {
loadDataFromHome()
// 设置默认激活的 tab
if (result.value && result.value.clientLinks) {
@@ -523,27 +353,10 @@ export default {
const downloadWithClient = (type, link) => {
try {
const os = getOSInfo()
const deviceType = getDeviceType()
// 移动端特殊处理
if (deviceType === 'mobile') {
ElMessage.warning('移动端不支持直接启动下载器,请复制命令到终端使用')
return
}
let downloadUrl = link
let successMessage = `正在使用 ${getClientDisplayName(type)} 下载`
switch (type) {
case 'ARIA2':
// Aria2 需要特殊处理,尝试复制到剪贴板
copyToClipboard(link)
ElMessage.success('Aria2 命令已复制到剪贴板,请在终端中运行')
return
case 'CURL':
case 'WGET':
case 'POWERSHELL':
case 'ARIA2':
// 命令行工具,复制到剪贴板
copyToClipboard(link)
ElMessage.success(`${getClientDisplayName(type)} 命令已复制到剪贴板,请在终端中运行`)
@@ -552,115 +365,29 @@ export default {
case 'THUNDER':
// 迅雷协议
if (os !== 'windows') {
ElMessage.warning('迅雷仅在 Windows 系统上可用')
return
}
window.open(link, '_blank')
break
case 'IDM':
// IDM 协议
if (os !== 'windows') {
ElMessage.warning('IDM 仅在 Windows 系统上可用')
return
}
window.open(link, '_blank')
break
case 'BITCOMET':
// 比特彗星协议
if (os !== 'windows') {
ElMessage.warning('比特彗星仅在 Windows 系统上可用')
return
}
window.open(link, '_blank')
break
case 'MOTRIX':
// Motrix JSON 格式处理
try {
const jsonData = JSON.parse(link)
if (jsonData.url) {
downloadUrl = jsonData.url
window.open(downloadUrl, '_blank')
} else {
ElMessage.warning('Motrix 链接格式错误')
return
}
} catch {
// 如果不是 JSON 格式,尝试直接打开
window.open(link, '_blank')
}
break
case 'FDM':
// FDM 协议
if (os !== 'windows') {
ElMessage.warning('FDM 仅在 Windows 系统上可用')
ElMessage.warning('迅雷主要在 Windows 系统上使用,已复制链接到剪贴板')
copyToClipboard(link)
return
}
window.open(link, '_blank')
ElMessage.success('正在唤起迅雷下载')
break
default:
// 其他情况,直接下载文件
window.open(downloadUrl, '_blank')
successMessage = '正在下载文件'
copyToClipboard(link)
ElMessage.success('链接已复制到剪贴板')
}
ElMessage.success(successMessage)
} catch (err) {
console.error('下载失败:', err)
ElMessage.error('下载失败: ' + err.message)
}
}
// 获取客户端标签类型
const getClientTagType = (type) => {
const tagTypes = {
'ARIA2': 'warning',
'MOTRIX': 'info',
'BITCOMET': 'success',
'THUNDER': 'primary',
'WGET': 'info',
'CURL': 'success',
'IDM': 'danger',
'FDM': 'warning',
'POWERSHELL': 'primary'
}
return tagTypes[type] || 'info'
}
// 获取客户端显示名称
const getClientDisplayName = (type) => {
const displayNames = {
'ARIA2': 'Aria2',
'MOTRIX': 'Motrix',
'BITCOMET': '比特彗星',
'THUNDER': '迅雷',
'WGET': 'wget 命令',
'CURL': 'cURL 命令',
'IDM': 'IDM',
'FDM': 'Free Download Manager',
'POWERSHELL': 'PowerShell'
}
return displayNames[type] || type
}
// 获取客户端描述
const getClientDescription = (type) => {
const descriptions = {
'ARIA2': '多线程下载器',
'MOTRIX': '跨平台下载器',
'BITCOMET': '比特彗星下载器',
'THUNDER': '迅雷下载器',
'WGET': 'Linux 下载工具',
'CURL': '命令行下载工具',
'IDM': 'Windows 下载管理器',
'FDM': '免费下载管理器',
'POWERSHELL': 'Windows PowerShell'
}
return descriptions[type] || '下载工具'
// 下载客户端
const downloadClient = (type) => {
const url = getClientDownloadUrl(type)
window.open(url, '_blank')
ElMessage.success(`正在跳转到 ${getClientDisplayName(type)} 下载页面`)
}
// 格式化文件大小
@@ -690,6 +417,15 @@ export default {
router.push('/')
}
// 跳转到认证配置
const goToAuthConfig = () => {
router.push('/')
// 延迟提示用户点击认证按钮
setTimeout(() => {
ElMessage.info('请点击页面右上角的钥匙图标配置认证信息')
}, 500)
}
return {
form,
result,
@@ -704,17 +440,16 @@ export default {
getTextareaRows,
goBack,
getClientLogo,
isClientInstalled,
downloadClient,
handleImageError,
shouldShowDownloadButton,
isElementIcon,
getClientIconColor
getClientSupportsCookie,
goToAuthConfig
}
}
}
</script>
<style scoped>
/* 移除所有自定义样式,使用 Element Plus 默认主题 */
</style>
/* 使用 Element Plus 默认主题 */
</style>
+496 -7
View File
@@ -38,7 +38,19 @@
</div>
<el-row :gutter="20" style="margin-left: 0; margin-right: 0;">
<el-card class="box-card">
<div style="text-align: right">
<div style="text-align: right; display: flex; justify-content: space-between; align-items: center;">
<!-- 左侧认证配置按钮 -->
<el-tooltip content="配置临时认证信息" placement="bottom">
<el-button
:type="hasAuthConfig ? 'primary' : 'default'"
:class="{ 'auth-config-btn-active': hasAuthConfig }"
circle
size="small"
@click="showAuthConfigDialog = true">
<el-icon><Key /></el-icon>
</el-button>
</el-tooltip>
<!-- 右侧暗色模式切换 -->
<DarkMode @theme-change="handleThemeChange" />
</div>
<div class="demo-basic--circle">
@@ -48,7 +60,7 @@
</div>
<!-- 项目简介移到卡片内 -->
<div class="project-intro">
<div class="intro-title">NFD网盘直链解析0.1.9_b15</div>
<div class="intro-title">NFD网盘直链解析0.2.1</div>
<div class="intro-desc">
<div>支持网盘:蓝奏云、蓝奏云优享、小飞机盘、123云盘、奶牛快传、移动云空间、QQ邮箱云盘、QQ闪传等 <el-link style="color:#606cf5" href="https://github.com/qaiu/netdisk-fast-download?tab=readme-ov-file#%E7%BD%91%E7%9B%98%E6%94%AF%E6%8C%81%E6%83%85%E5%86%B5" target="_blank"> &gt;&gt; </el-link></div>
<div>文件夹解析支持:蓝奏云、蓝奏云优享、小飞机盘、123云盘</div>
@@ -91,7 +103,7 @@
<el-button style="margin-left: 20px" @click="generateMarkdown">生成Markdown</el-button>
<el-button style="margin-left: 20px" @click="generateQRCode">扫码下载</el-button>
<el-button style="margin-left: 20px" @click="getStatistics">分享统计</el-button>
<el-button v-if="false" style="margin-left: 20px" @click="goToClientLinks" type="primary">客户端链接(实验)</el-button>
<el-button style="margin-left: 20px" @click="goToClientLinks" type="primary">生成命令行链接</el-button>
</p>
</div>
@@ -195,6 +207,110 @@
<el-button @click="errorDialogVisible = false">关闭</el-button>
</template>
</el-dialog>
<!-- 临时认证配置弹窗 -->
<el-dialog
v-model="showAuthConfigDialog"
title="临时认证配置"
width="550px"
:close-on-click-modal="false">
<el-form :model="authConfig" label-width="100px" size="default">
<el-form-item label="网盘类型" required>
<el-select v-model="authConfig.panType" placeholder="请选择网盘类型" style="width: 100%" @change="onPanTypeChange">
<el-option-group label="必须认证">
<el-option label="夸克网盘 (QK)" value="QK">
<span>夸克网盘 (QK)</span>
<el-tag size="small" type="danger" style="margin-left: 8px">必须</el-tag>
</el-option>
<el-option label="UC网盘 (UC)" value="UC">
<span>UC网盘 (UC)</span>
<el-tag size="small" type="danger" style="margin-left: 8px">必须</el-tag>
</el-option>
</el-option-group>
<el-option-group label="大文件需认证">
<el-option label="小飞机网盘 (FJ)" value="FJ">
<span>小飞机网盘 (FJ)</span>
<el-tag size="small" type="warning" style="margin-left: 8px">大文件</el-tag>
</el-option>
<el-option label="蓝奏优享 (IZ)" value="IZ">
<span>蓝奏优享 (IZ)</span>
<el-tag size="small" type="warning" style="margin-left: 8px">大文件</el-tag>
</el-option>
</el-option-group>
</el-select>
</el-form-item>
<el-form-item label="认证类型">
<el-select v-model="authConfig.authType" placeholder="请选择认证类型" style="width: 100%">
<el-option
v-for="opt in getSupportedAuthTypes()"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
</el-form-item>
<el-form-item v-if="authConfig.authType === 'password'" label="用户名">
<el-input v-model="authConfig.username" placeholder="请输入用户名" />
</el-form-item>
<el-form-item v-if="authConfig.authType === 'password'" label="密码">
<el-input v-model="authConfig.password" type="password" show-password placeholder="请输入密码" />
</el-form-item>
<el-form-item v-if="authConfig.authType && authConfig.authType !== 'password'" label="Token/Cookie">
<el-input
v-model="authConfig.token"
type="textarea"
:rows="3"
:placeholder="getTokenPlaceholder()" />
</el-form-item>
<el-form-item v-if="authConfig.authType === 'custom'" label="扩展字段1">
<el-input v-model="authConfig.ext1" placeholder="格式: key:value" />
</el-form-item>
<el-form-item v-if="authConfig.authType === 'custom'" label="扩展字段2">
<el-input v-model="authConfig.ext2" placeholder="格式: key:value" />
</el-form-item>
<el-alert
:type="getPanAuthAlertType()"
:closable="false"
show-icon
style="margin-bottom: 15px;">
<template #title>
<span>{{ getPanAuthHint() }}</span>
</template>
</el-alert>
<!-- 已配置的网盘列表 -->
<div v-if="Object.keys(allAuthConfigs).length > 0" style="margin-top: 10px;">
<el-divider content-position="left">已配置的网盘</el-divider>
<el-tag
v-for="(config, panType) in allAuthConfigs"
:key="panType"
closable
:type="panType === authConfig.panType ? 'primary' : 'info'"
style="margin-right: 8px; margin-bottom: 8px; cursor: pointer;"
@click="loadPanConfig(panType)"
@close="removePanConfig(panType)">
{{ getPanDisplayName(panType) }}
</el-tag>
</div>
</el-form>
<template #footer>
<el-button @click="clearAuthConfig">
<el-icon><Delete /></el-icon> 清除配置
</el-button>
<el-button @click="showAuthConfigDialog = false">取消</el-button>
<el-button type="primary" @click="saveAuthConfig">
<el-icon><Check /></el-icon> 保存
</el-button>
</template>
</el-dialog>
<!-- 目录树组件 -->
<div v-if="showDirectoryTree" class="directory-tree-container">
<div style="margin-bottom: 10px; text-align: right;">
@@ -301,10 +417,307 @@ export default {
buildVersion: '',
// 演练场启用状态
playgroundEnabled: false
playgroundEnabled: false,
// 临时认证配置
showAuthConfigDialog: false,
authConfig: {
panType: '', // 网盘类型: QK, UC, FJ, IZ
authType: 'cookie',
username: '',
password: '',
token: '',
cookie: '',
auth: '',
ext1: '',
ext2: '',
ext3: '',
ext4: '',
ext5: ''
},
// 所有网盘的认证配置 { panType: config }
allAuthConfigs: {}
}
},
computed: {
// 检查是否配置了认证信息(针对当前链接的网盘类型)
hasAuthConfig() {
const panType = this.getCurrentPanType()
if (!panType) return false
return !!this.allAuthConfigs[panType]
},
// 获取已配置认证的网盘数量
authConfigCount() {
return Object.keys(this.allAuthConfigs).length
}
},
methods: {
// 从分享链接中提取网盘类型
getCurrentPanType() {
if (!this.link) return ''
const url = this.link.toLowerCase()
if (url.includes('quark.cn') || url.includes('pan.quark.cn')) return 'QK'
if (url.includes('drive.uc.cn') || url.includes('fast.uc.cn')) return 'UC'
if (url.includes('feijipan.com') || url.includes('feijihe.com') || url.includes('xiaofeiyang.com')) return 'FJ'
if (url.includes('ilanzou.com') || url.includes('lanzouv.com')) return 'IZ'
return ''
},
// 获取网盘显示名称
getPanDisplayName(panType) {
const names = {
'QK': '夸克网盘',
'UC': 'UC网盘',
'FJ': '小飞机网盘',
'IZ': '蓝奏优享'
}
return names[panType] || panType
},
// 获取认证提示信息
getPanAuthHint() {
const hints = {
'QK': '夸克网盘必须配置 Cookie 才能解析和下载(登录后从浏览器开发者工具获取)',
'UC': 'UC网盘必须配置 Cookie 才能解析和下载(登录后从浏览器开发者工具获取)',
'FJ': '小飞机网盘大文件(>100MB)需要配置认证信息',
'IZ': '蓝奏优享大文件需要配置认证信息'
}
return hints[this.authConfig.panType] || '请选择网盘类型后配置认证信息'
},
// 获取提示类型
getPanAuthAlertType() {
if (!this.authConfig.panType) return 'info'
if (this.authConfig.panType === 'QK' || this.authConfig.panType === 'UC') return 'warning'
return 'info'
},
// 根据网盘类型获取支持的认证方式列表
getSupportedAuthTypes() {
const panType = this.authConfig.panType?.toLowerCase() || ''
// 定义所有认证类型
const allAuthTypes = {
cookie: { label: 'Cookie', value: 'cookie' },
accesstoken: { label: 'AccessToken', value: 'accesstoken' },
authorization: { label: 'Authorization', value: 'authorization' },
password: { label: '用户名密码', value: 'password' },
custom: { label: '自定义', value: 'custom' }
}
// 根据网盘类型返回支持的认证方式
switch (panType) {
case 'qk': // 夸克网盘:只支持Cookie
case 'uc': // UC网盘:只支持Cookie
case 'qqwy': // QQ微云:只支持Cookie
case 'pali': // 阿里云盘:只支持Cookie
return [allAuthTypes.cookie]
case 'fj': // 小飞机网盘:只支持用户名密码
case 'iz': // 蓝奏优享:只支持用户名密码
return [allAuthTypes.password]
case 'ye': // 123网盘:支持用户名密码和Authorization
return [allAuthTypes.password, allAuthTypes.authorization]
case 'p189': // 天翼云盘:支持用户名密码、AccessToken、Cookie
return [allAuthTypes.password, allAuthTypes.accesstoken, allAuthTypes.cookie]
case 'p139': // 移动云盘:支持Authorization
return [allAuthTypes.authorization]
case 'pwo': // 联通云盘:支持AccessToken
return [allAuthTypes.accesstoken]
default:
// 默认显示所有选项
return Object.values(allAuthTypes)
}
},
// 网盘类型变更时加载对应配置
onPanTypeChange(panType) {
// 先临时设置panType以便获取支持的认证类型
const tempAuthConfig = { ...this.authConfig, panType }
this.authConfig = tempAuthConfig
// 获取该网盘支持的认证类型
const supportedTypes = this.getSupportedAuthTypes()
const defaultAuthType = supportedTypes.length > 0 ? supportedTypes[0].value : 'cookie'
if (this.allAuthConfigs[panType]) {
// 加载已有配置
const config = this.allAuthConfigs[panType]
this.authConfig = { ...this.authConfig, ...config, panType }
// 确保认证类型在支持列表中
if (!supportedTypes.find(t => t.value === this.authConfig.authType)) {
this.authConfig.authType = defaultAuthType
}
} else {
// 重置为默认值,使用该网盘默认的认证类型
this.authConfig = {
panType,
authType: defaultAuthType,
username: '',
password: '',
token: '',
cookie: '',
auth: '',
ext1: '',
ext2: '',
ext3: '',
ext4: '',
ext5: ''
}
}
},
// 加载指定网盘的配置
loadPanConfig(panType) {
this.authConfig.panType = panType
this.onPanTypeChange(panType)
},
// 删除指定网盘的配置
removePanConfig(panType) {
delete this.allAuthConfigs[panType]
localStorage.setItem('nfd_auth_configs', JSON.stringify(this.allAuthConfigs))
if (this.authConfig.panType === panType) {
this.authConfig.panType = ''
}
this.$message.success(`已删除 ${this.getPanDisplayName(panType)} 的认证配置`)
this.updateDirectLink()
},
// 获取 Token 输入框的提示文本
getTokenPlaceholder() {
const placeholders = {
'accesstoken': '请输入 AccessToken',
'cookie': '请输入 Cookie,例如: __puus=xxx; __pus=xxx(从浏览器开发者工具获取)',
'authorization': '请输入 Authorization 头内容,例如: Bearer xxx',
'custom': '请输入主 Token'
}
return placeholders[this.authConfig.authType] || '请输入认证信息'
},
// 保存认证配置
saveAuthConfig() {
if (!this.authConfig.panType) {
this.$message.warning('请先选择网盘类型')
return
}
if (!this.authConfig.authType) {
this.$message.warning('请选择认证类型')
return
}
if (!this.authConfig.token && !this.authConfig.username) {
this.$message.warning('请填写认证信息')
return
}
// 保存到配置集合
const configToSave = { ...this.authConfig }
this.allAuthConfigs[this.authConfig.panType] = configToSave
// 持久化到 localStorage
localStorage.setItem('nfd_auth_configs', JSON.stringify(this.allAuthConfigs))
this.showAuthConfigDialog = false
this.$message.success(`${this.getPanDisplayName(this.authConfig.panType)} 认证配置已保存`)
// 更新智能直链
this.updateDirectLink()
},
// 清除所有认证配置
clearAuthConfig() {
this.authConfig = {
panType: '',
authType: 'cookie',
username: '',
password: '',
token: '',
cookie: '',
auth: '',
ext1: '',
ext2: '',
ext3: '',
ext4: '',
ext5: ''
}
this.allAuthConfigs = {}
localStorage.removeItem('nfd_auth_configs')
this.$message.success('所有认证配置已清除')
this.showAuthConfigDialog = false
// 更新智能直链
this.updateDirectLink()
},
// 加载认证配置
loadAuthConfig() {
const saved = localStorage.getItem('nfd_auth_configs')
if (saved) {
try {
this.allAuthConfigs = JSON.parse(saved)
} catch (e) {
console.error('加载认证配置失败:', e)
}
}
},
// 生成加密的 auth 参数(根据当前链接的网盘类型)
generateAuthParam() {
const panType = this.getCurrentPanType()
if (!panType || !this.allAuthConfigs[panType]) {
return ''
}
const config = this.allAuthConfigs[panType]
// 构建 JSON 对象
const authObj = {}
if (config.authType) authObj.authType = config.authType
if (config.username) authObj.username = config.username
if (config.password) authObj.password = config.password
if (config.token) authObj.token = config.token
if (config.cookie) authObj.cookie = config.cookie
if (config.auth) authObj.auth = config.auth
if (config.ext1) authObj.ext1 = config.ext1
if (config.ext2) authObj.ext2 = config.ext2
if (config.ext3) authObj.ext3 = config.ext3
if (config.ext4) authObj.ext4 = config.ext4
if (config.ext5) authObj.ext5 = config.ext5
// AES 加密 + Base64 + URL 编码
try {
const jsonStr = JSON.stringify(authObj)
const encrypted = this.aesEncrypt(jsonStr, 'nfd_auth_key2026')
return encodeURIComponent(encrypted)
} catch (e) {
console.error('生成认证参数失败:', e)
return ''
}
},
// AES 加密 (ECB 模式, PKCS5Padding)
aesEncrypt(text, key) {
// 使用 CryptoJS 进行 AES 加密
const CryptoJS = require('crypto-js')
const keyBytes = CryptoJS.enc.Utf8.parse(key)
const encrypted = CryptoJS.AES.encrypt(text, keyBytes, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
})
return encrypted.toString() // Base64 编码
},
// 更新智能直链
updateDirectLink() {
if (this.link) {
const authParam = this.generateAuthParam()
const authSuffix = authParam ? `&auth=${authParam}` : ''
this.directLink = `${this.baseAPI}/parser?url=${this.link}${this.password ? `&pwd=${this.password}` : ''}${authSuffix}`
}
},
// 生成预览链接(WPS 云文档特殊处理)
getPreviewLink() {
// 判断 shareKey 是否以 pwps: 开头(WPS 云文档)
@@ -348,11 +761,16 @@ export default {
this.directoryData = []
},
// 统一API调用
// 统一API调用(自动添加认证参数)
async callAPI(endpoint, params = {}) {
this.errorButtonVisible = false
try {
this.isLoading = true
// 添加认证参数
const authParam = this.generateAuthParam()
if (authParam) {
params.auth = authParam
}
const response = await axios.get(`${this.baseAPI}${endpoint}`, { params })
if (response.data.code === 200) {
@@ -376,13 +794,46 @@ export default {
async parseFile() {
try {
this.validateInput()
// 先调用 linkInfo 获取网盘类型
const linkInfoResult = await this.callAPI('/v2/linkInfo', {
url: this.link,
...(this.password && { pwd: this.password })
})
const panType = linkInfoResult.data?.shareLinkInfo?.type
const panName = linkInfoResult.data?.shareLinkInfo?.panName || '未知网盘'
// 根据网盘类型给出提示
if (panType === 'qk' || panType === 'uc') {
// UC和夸克:提示使用命令行下载
this.$message.warning({
message: `${panName}无法在网页端直接下载,请点击"生成下载命令"按钮,使用命令行工具下载`,
duration: 5000,
showClose: true
})
} else if (panType === 'fj' || panType === 'lz' || panType === 'iz' || panType === 'le') {
// 小飞机、蓝奏、优享、联想乐云:提示大文件需要认证
const hasAuth = this.allAuthConfigs[panType]?.cookie ||
this.allAuthConfigs[panType]?.username
if (!hasAuth) {
this.$message.info({
message: `${panName}的大文件解析需要配置认证信息,请在"配置认证"中添加`,
duration: 4000,
showClose: true
})
}
}
// 继续解析文件
const params = { url: this.link }
if (this.password) params.pwd = this.password
const result = await this.callAPI('/json/parser', params)
this.parseResult = result
this.downloadUrl = result.data?.directLink
this.directLink = `${this.baseAPI}/parser?url=${this.link}${this.password ? `&pwd=${this.password}` : ''}`
// 更新智能直链(包含认证参数)
this.updateDirectLink()
this.$message.success('文件解析成功!')
} catch (error) {
console.error('文件解析失败:', error)
@@ -513,7 +964,8 @@ export default {
if (linkInfo.link !== this.link || pwd !== this.password) {
this.password = pwd
this.link = linkInfo.link
this.directLink = `${this.baseAPI}/parser?url=${this.link}${this.password ? `&pwd=${this.password}` : ''}`
// 更新智能直链(包含认证参数)
this.updateDirectLink()
// 聚焦期间只提示一次
if (!this.hasClipboardSuccessTip) {
this.$message.success(`自动识别分享成功, 网盘类型: ${linkInfo.name}; 分享URL ${this.link}; 分享密码: ${this.password || '空'}`)
@@ -633,6 +1085,10 @@ export default {
const params = { url: this.link }
if (this.password) params.pwd = this.password
// 添加认证参数
const authParam = this.generateAuthParam()
if (authParam) params.auth = authParam
const response = await axios.get(`${this.baseAPI}/v2/clientLinks`, { params })
const result = response.data
@@ -669,6 +1125,9 @@ export default {
this.autoReadClipboard = savedAutoRead === 'true'
}
// 加载认证配置
this.loadAuthConfig()
// 获取初始统计信息
this.getInfo()
@@ -1027,4 +1486,34 @@ hr {
#app.dark-theme .playground-link:hover {
color: #66b1ff;
}
/* 认证配置按钮样式 */
.auth-config-btn-active {
animation: auth-pulse 2s infinite;
}
@keyframes auth-pulse {
0% {
box-shadow: 0 0 0 0 rgba(64, 158, 255, 0.4);
}
70% {
box-shadow: 0 0 0 6px rgba(64, 158, 255, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(64, 158, 255, 0);
}
}
/* 认证配置弹窗暗色模式适配 */
#app.dark-theme .el-dialog {
background: #2d2d2d;
}
#app.dark-theme .el-dialog__title {
color: #eee;
}
#app.dark-theme .el-form-item__label {
color: #ccc;
}
</style>