{"record":{"id":"e087803e04adf7c7","repo":"hmjz100/LinkSwift","slug":"br-e08780","errorCode":null,"errorMessage":"提示：<br/>请打开文件夹后再勾选文件~","messagePattern":"提示：<br/>请打开文件夹后再勾选文件~","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"（改）网盘直链下载助手.user.js","lineNumber":6580,"sourceCode":"\t\t\t\t\ttitle: \"提示\",\r\n\t\t\t\t\thtml: `<div style=\"display:flex;align-items:center;justify-content:center;\">请先切换到&nbsp;&nbsp;<svg class=\"icon\" class=\"icon--D3kMk \" viewBox=\"0 0 1024 1024\" width=\"20\" height=\"20\" fill=\"currentColor\"><use xlink:href=\"#PDSDrag\"></use></svg>&nbsp;<b>列表视图</b>&nbsp;&nbsp;后再获取下载链接哦</div>`,\r\n\t\t\t\t\ticon: \"info\",\r\n\t\t\t\t\tshowCloseButton: true,\r\n\t\t\t\t\tshowDenyButton: true,\r\n\t\t\t\t\tconfirmButtonText: `<svg class=\"pl-icon\"><use xlink:href=\"#pl-icon-fa-check\"/></svg> 切换`,\r\n\t\t\t\t\tdenyButtonText: `<svg class=\"pl-icon\"><use xlink:href=\"#pl-icon-fa-x-mark\"/></svg> 不要`,\r\n\t\t\t\t});\r\n\t\t\t\tif (dialog.isConfirmed) {\r\n\t\t\t\t\tdocument.querySelector(config.$aliyun.mount.switch).click();\r\n\t\t\t\t\treturn message.success(\"提示：<br/>切换为列表视图成功<br/>请再获取一次下载链接吧~\");\r\n\t\t\t\t}\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n\t\t\t// 获取选择的文件列表\r\n\t\t\tlet selects = this.getSelectedList();\r\n\t\t\tif (selects.length === 0) throw new Error(\"提示：<br/>请勾选要下载的文件哦~\");\r\n\t\t\tif (selects.every(item => item.type !== \"file\")) throw new Error(\"提示：<br/>请打开文件夹后再勾选文件~\");\r\n\r\n\t\t\t$doc.find(\".loading-popup .loading-title\").html(`链接获取中`);\r\n\t\t\t$doc.find(\".loading-popup .swal2-html-container\").html(`<div>正在获取文件对应的下载链接~</div>`);\r\n\r\n\t\t\tif (temp.page === \"home\") {\r\n\t\t\t\tselects = selects.filter(item => item.type === \"file\");\r\n\t\t\t\tconst token = base.getStorage(\"token\");\r\n\t\t\t\tif (!token || !token.token_type || !token.access_token) {\r\n\t\t\t\t\treturn message.error(\"提示：<br/>请先登录网盘~\");\r\n\t\t\t\t}\r\n\t\t\t\tselects = await this.getFilesUrl(selects, `${token.token_type} ${token.access_token}`).catch(e => {\r\n\t\t\t\t\tif (e instanceof Error) throw e;\r\n\t\t\t\t\tthrow new Error(e?.message || e || \"[阿里云盘] 获取文件 URL 失败\");\r\n\t\t\t\t});\r\n\t\t\t} else {\r\n\t\t\t\tthrow new Error(\"提示：<br/>页面错误~\");\r\n\t\t\t}\r\n\r","sourceCodeStart":6562,"sourceCodeEnd":6598,"githubUrl":"https://github.com/hmjz100/LinkSwift/blob/417ea5e28a3e1a90339710e17356e9fd22b8a34b/（改）网盘直链下载助手.user.js#L6562-L6598","documentation":"Aliyun Drive flow: thrown when every selected item has `type !== 'file'` — i.e. the user only checked folders. Aliyun Drive's direct-link API only serves file download URLs, so the script demands the user open a folder and check files inside it rather than the folder itself.","triggerScenarios":"`selects.every(item => item.type !== \"file\")` is true — all checked rows are folders ('folder' type); fires before any API call, right after the empty-selection check.","commonSituations":"User selects whole folders expecting recursive download; Aliyun Drive's folder items use a type value ('folder') that the script refuses to resolve; user on the drive root where only folders exist.","solutions":["Open the folder in the Aliyun Drive UI and check the individual files inside instead of the folder row.","Select at least one real file so the check passes, then retry.","For bulk folder downloads, enter each folder and select its files."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const selects = this.getSelectedList();\nif (selects.length && selects.every(i => i.type !== 'file')) { alert('请打开文件夹并勾选其中的文件'); return; }","typeGuard":"const hasFileSelected = (items) => Array.isArray(items) && items.some(i => i.type === 'file');","tryCatchPattern":"try { await getLinks(); } catch (e) { if (String(e.message).includes('打开文件夹')) { alert('请勾选具体文件而非文件夹'); return; } throw e; }","preventionTips":["Open folders and select files inside rather than the folder row","Ensure at least one item of type 'file' is checked","For bulk downloads, enter each folder and select its files individually"],"tags":["userscript","aliyun-drive","folder-selection","user-input"],"backgroundTag":"folders-not-directly-downloadable","analyzedSha":"417ea5e28a3e1a90339710e17356e9fd22b8a34b","analyzedAt":"2026-09-02T18:13:32.837Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}