mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-10 23:47:29 +00:00
fix: 修复前端错误信息丢失 & QQscTool filesetId 提取失败
- 前端 axios 对 HTTP 非2xx直接reject,catch块丢失后端错误信息,从 error.response.data.msg 提取实际错误展示给用户 - QQscTool extractFilesetId 正则未适配 Nuxt 转义JSON格式
This commit is contained in:
@@ -281,9 +281,11 @@ public class QQscTool extends PanBase {
|
|||||||
* 从 HTML 的 __NUXT_DATA__ 中提取 fileset_id
|
* 从 HTML 的 __NUXT_DATA__ 中提取 fileset_id
|
||||||
*/
|
*/
|
||||||
String extractFilesetId(String html) {
|
String extractFilesetId(String html) {
|
||||||
// 匹配 UUID 格式的 fileset_id(出现在 Nuxt 数据的 fileset_id 字段值位置)
|
// Nuxt __NUXT_DATA__ 中 fileset_id 出现在缓存 key 的嵌套转义 JSON 中:
|
||||||
|
// {\"fileset_id\":\"0500417e-5431-433f-a9f3-d5ccf9412da3\"}
|
||||||
|
// 匹配 \"fileset_id\" 后面最近的 UUID
|
||||||
Pattern pattern = Pattern.compile(
|
Pattern pattern = Pattern.compile(
|
||||||
"\"fileset_id\"[:\\s]*\"([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})\"");
|
"\\\\\"fileset_id\\\\\"[^a-f0-9]*([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})");
|
||||||
Matcher matcher = pattern.matcher(html);
|
Matcher matcher = pattern.matcher(html);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
return matcher.group(1);
|
return matcher.group(1);
|
||||||
|
|||||||
@@ -500,9 +500,14 @@ export default {
|
|||||||
}))
|
}))
|
||||||
resolve(children)
|
resolve(children)
|
||||||
} else {
|
} else {
|
||||||
|
this.$message.error(res.data.msg || '获取子节点失败')
|
||||||
resolve([])
|
resolve([])
|
||||||
}
|
}
|
||||||
}).catch(() => resolve([]))
|
}).catch(err => {
|
||||||
|
const msg = err.response?.data?.msg || err.message
|
||||||
|
if (msg) this.$message.error(msg)
|
||||||
|
resolve([])
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
resolve([])
|
resolve([])
|
||||||
}
|
}
|
||||||
@@ -540,7 +545,8 @@ export default {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('进入文件夹失败:', error)
|
console.error('进入文件夹失败:', error)
|
||||||
this.$message.error('进入文件夹失败')
|
const msg = error.response?.data?.msg || error.message || '进入文件夹失败'
|
||||||
|
this.$message.error(msg)
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
@@ -571,7 +577,8 @@ export default {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('加载目录失败:', error)
|
console.error('加载目录失败:', error)
|
||||||
this.$message.error('加载目录失败')
|
const msg = error.response?.data?.msg || error.message || '加载目录失败'
|
||||||
|
this.$message.error(msg)
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
@@ -669,7 +676,8 @@ export default {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取下载信息失败:', error)
|
console.error('获取下载信息失败:', error)
|
||||||
this.$message.error('获取下载信息失败,尝试直接下载')
|
const msg = error.response?.data?.msg || '获取下载信息失败,尝试直接下载'
|
||||||
|
this.$message.error(msg)
|
||||||
this.downloadFile(file)
|
this.downloadFile(file)
|
||||||
} finally {
|
} finally {
|
||||||
this.downloadLoading = false
|
this.downloadLoading = false
|
||||||
@@ -755,7 +763,8 @@ export default {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('发送到下载器失败:', error)
|
console.error('发送到下载器失败:', error)
|
||||||
this.$message.error('发送到下载器失败: ' + error.message)
|
const msg = error.response?.data?.msg || error.message || '发送到下载器失败'
|
||||||
|
this.$message.error(msg)
|
||||||
} finally {
|
} finally {
|
||||||
this.singleSendLoading = false
|
this.singleSendLoading = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1157,17 +1157,24 @@ export default {
|
|||||||
params.auth = authParam
|
params.auth = authParam
|
||||||
}
|
}
|
||||||
const response = await axios.get(`${this.baseAPI}${endpoint}`, { params })
|
const response = await axios.get(`${this.baseAPI}${endpoint}`, { params })
|
||||||
|
|
||||||
if (response.data.code === 200) {
|
if (response.data.code === 200) {
|
||||||
// this.$message.success(response.data.msg || '操作成功')
|
// this.$message.success(response.data.msg || '操作成功')
|
||||||
return response.data
|
return response.data
|
||||||
} else {
|
} else {
|
||||||
// 在页面右下角显示一个“查看详情”按钮 可以查看原json
|
// 在页面右下角显示一个”查看详情”按钮 可以查看原json
|
||||||
this.errorDetail = response?.data
|
this.errorDetail = response?.data
|
||||||
this.errorButtonVisible = true
|
this.errorButtonVisible = true
|
||||||
throw new Error(response.data.msg || '操作失败')
|
throw new Error(response.data.msg || '操作失败')
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// HTTP 非2xx时,从响应体中提取后端返回的错误信息
|
||||||
|
if (error.response?.data?.msg) {
|
||||||
|
this.errorDetail = error.response.data
|
||||||
|
this.errorButtonVisible = true
|
||||||
|
this.$message.error(error.response.data.msg)
|
||||||
|
throw new Error(error.response.data.msg)
|
||||||
|
}
|
||||||
this.$message.error(error.message || '网络错误')
|
this.$message.error(error.message || '网络错误')
|
||||||
throw error
|
throw error
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export default {
|
|||||||
this.parseResult = res.data
|
this.parseResult = res.data
|
||||||
this.downloadUrl = res.data.data?.directLink
|
this.downloadUrl = res.data.data?.directLink
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.error = '解析失败'
|
this.error = e.response?.data?.msg || e.response?.data?.error || '解析失败'
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export default {
|
|||||||
const res = await axios.get('/v2/getFileList', { params: { url: this.url } })
|
const res = await axios.get('/v2/getFileList', { params: { url: this.url } })
|
||||||
this.directoryData = res.data.data || []
|
this.directoryData = res.data.data || []
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.error = '目录解析失败'
|
this.error = e.response?.data?.msg || e.response?.data?.error || '目录解析失败'
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user