hmjz100/LinkSwift · error · Error
提示:<br/>请先登录网盘~
Error message
提示:<br/>请先登录网盘~
What it means
Thrown after token retrieval in 天翼云盘 getLink() when the resulting token is falsy — i.e. neither the cached accessToken nor getToken() produced a usable token, but no exception was raised either. The script requires authentication to call the link API, so it tells the user to log into the netdisk first.
Source
Thrown at (改)网盘直链下载助手.user.js:7372
} else if (res.res_code == "ShareNotFoundFlatDir") {
return { index, downloadUrl: "提示:<br/>请[转存]文件,之后再👉前往[我的网盘]中下载哦~" };
} else {
return { index, downloadUrl: "获取下载地址失败,刷新后再试试吧~" + (res.res_code ? res.res_code : "") };
}
},
async getLink() {
let selects = this.getSelectedList();
if (selects.length === 0) throw new Error("提示:<br/>请勾选要下载的文件哦~");
if (selects.every(item => item.isFolder)) throw new Error("提示:<br/>请打开文件夹后再勾选文件~");
selects = selects.filter(item => !item.isFolder)
$doc.find(".loading-popup .loading-title").html(`令牌获取中`);
$doc.find(".loading-popup .swal2-html-container").html(`<div>正在获取状态~</div>`);
const token = base.getStorage("accessToken") || await this.getToken().catch(e => {
if (e instanceof Error) throw e;
throw new Error(e?.message || e || "[天翼云盘] 获取令牌失败");
});
if (!token) {
throw new Error("提示:<br/>请先登录网盘~");
}
$doc.find(".loading-popup .loading-title").html(`令牌获取中`);
$doc.find(".loading-popup .swal2-html-container").html(`<div>获取缓存成功~</div>`);
const batchSize = 15;
let proc = 0;
$doc.find(".loading-popup .loading-title").html(`链接获取中`);
$doc.find(".loading-popup .swal2-html-container").html(`<div>正在获取文件对应的下载链接~</div>`);
for (let i = 0; i < selects.length; i += batchSize) {
const batch = selects.slice(i, i + batchSize);
const queue = [];
batch.forEach((item, localIndex) => {
const globalIndex = i + localIndex;
queue.push(this.getFileUrl(item, globalIndex, token)
.then(val => {
proc++;
$doc.find(".loading-popup .swal2-html-container").html(`<div>已获取 ${proc} / ${selects.length} 个链接~</div>`);
return val;
}));
View on GitHub (pinned to 417ea5e28a)
Solutions
- Log into 天翼云盘 (cloud.189.cn) in the same browser profile, refresh the page, and retry.
- Verify getToken() — if it can resolve with an empty value on unauthenticated sessions, make it throw instead so the real cause is shown.
- Avoid clearing cookies/storage for the cloud site while using the script; don't use the script in private/incognito mode where sessions don't persist.
Example fix
// before: getToken() may silently resolve empty
const token = await getToken();
// after: fail loudly so users see the login problem
const token = await getToken();
if (!token) throw new Error('请先登录天翼云盘再使用下载功能~'); Defensive patterns
Strategy: validation
Validate before calling
const token = base.getStorage('accessToken');
if (!token) {
alert('请先登录天翼云盘~');
return;
} Type guard
function hasToken(t) {
return typeof t === 'string' && t.trim().length > 0;
} Try / catch
try {
await getLink();
} catch (e) {
if (e.message.includes('请先登录网盘')) {
window.open('https://cloud.189.cn/', '_blank');
} else throw e;
} Prevention
- Log in to cloud.189.cn in the same browser profile before using the script.
- Avoid private/incognito mode where sessions and storage don't persist.
- Don't clear cookies for the cloud site mid-session.
- Make getToken() throw on empty results so the root cause isn't masked.
When it happens
Trigger: const token = base.getStorage("accessToken") || await this.getToken(); evaluates to null/undefined/empty string, then the `if (!token)` check at line 7372 fires.
Common situations: User never logged into 天翼云盘 in this browser; the login session expired and getToken() resolved with an empty token instead of failing; the script's storage was cleared (private browsing, cookie cleanup) removing the cached accessToken.
Related errors
- [天翼云盘] 获取令牌失败
- AccessTokenInvalid
- 提示:<br/>请先登录网盘后再刷新页面呢~
- 提示:<br/>请先登录网盘~<br/>代码:${res.code}
- GreaseMonkey 兼容 XMLHttpRequest 不可用。
AI-assisted analysis of hmjz100/LinkSwift@417ea5e28a (2026-09-02).
Data as JSON: /api/errors/345200ebb3e6c132.
Report an issue: GitHub.