hmjz100/LinkSwift · warning · Error

提示:<br/>请打开文件夹后再勾选文件~

Error message

提示:<br/>请打开文件夹后再勾选文件~

What it means

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.

Source

Thrown at (改)网盘直链下载助手.user.js:6580

					title: "提示",
					html: `<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>`,
					icon: "info",
					showCloseButton: true,
					showDenyButton: true,
					confirmButtonText: `<svg class="pl-icon"><use xlink:href="#pl-icon-fa-check"/></svg> 切换`,
					denyButtonText: `<svg class="pl-icon"><use xlink:href="#pl-icon-fa-x-mark"/></svg> 不要`,
				});
				if (dialog.isConfirmed) {
					document.querySelector(config.$aliyun.mount.switch).click();
					return message.success("提示:<br/>切换为列表视图成功<br/>请再获取一次下载链接吧~");
				}
				return false;
			}

			// 获取选择的文件列表
			let selects = this.getSelectedList();
			if (selects.length === 0) throw new Error("提示:<br/>请勾选要下载的文件哦~");
			if (selects.every(item => item.type !== "file")) throw new Error("提示:<br/>请打开文件夹后再勾选文件~");

			$doc.find(".loading-popup .loading-title").html(`链接获取中`);
			$doc.find(".loading-popup .swal2-html-container").html(`<div>正在获取文件对应的下载链接~</div>`);

			if (temp.page === "home") {
				selects = selects.filter(item => item.type === "file");
				const token = base.getStorage("token");
				if (!token || !token.token_type || !token.access_token) {
					return message.error("提示:<br/>请先登录网盘~");
				}
				selects = await this.getFilesUrl(selects, `${token.token_type} ${token.access_token}`).catch(e => {
					if (e instanceof Error) throw e;
					throw new Error(e?.message || e || "[阿里云盘] 获取文件 URL 失败");
				});
			} else {
				throw new Error("提示:<br/>页面错误~");
			}

View on GitHub (pinned to 417ea5e28a)

Solutions

  1. Open the folder in the Aliyun Drive UI and check the individual files inside instead of the folder row.
  2. Select at least one real file so the check passes, then retry.
  3. For bulk folder downloads, enter each folder and select its files.
Defensive patterns

Strategy: validation

Validate before calling

const selects = this.getSelectedList();
if (selects.length && selects.every(i => i.type !== 'file')) { alert('请打开文件夹并勾选其中的文件'); return; }

Type guard

const hasFileSelected = (items) => Array.isArray(items) && items.some(i => i.type === 'file');

Try / catch

try { await getLinks(); } catch (e) { if (String(e.message).includes('打开文件夹')) { alert('请勾选具体文件而非文件夹'); return; } throw e; }

Prevention

When it happens

Trigger: `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.

Common situations: 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.

Related errors


AI-assisted analysis of hmjz100/LinkSwift@417ea5e28a (2026-09-02). Data as JSON: /api/errors/e087803e04adf7c7. Report an issue: GitHub.