Widget:Uploader:修订间差异
外观
无编辑摘要 |
无编辑摘要 标签:已被回退 |
||
| 第135行: | 第135行: | ||
return Object.fromEntries(Object.values(data.query.pages).map((item) => [item.title.replace("File:", ""), !("missing" in item)])); | return Object.fromEntries(Object.values(data.query.pages).map((item) => [item.title.replace("File:", ""), !("missing" in item)])); | ||
} | } | ||
/** | |||
* @param {string} fileName | |||
* @return {number} | |||
*/ | |||
async function ModerationStatus(fileName) { | |||
const data = await commonsApi.post({ | |||
action: "query", | |||
format: "json", | |||
prop: "revisions", | |||
titles: fileName, | |||
formatversion: "2", | |||
}); | |||
return data.query.pages[0].revisions.moderation.status_code; | |||
} | |||
await loadScript(cdnUrl.requireJs); | await loadScript(cdnUrl.requireJs); | ||
const [ | const [ | ||
| 第985行: | 第999行: | ||
uploadResults = await Promise.all( | uploadResults = await Promise.all( | ||
postData.map(item => new Promise(resolve => { | postData.map(item => new Promise(resolve => { | ||
upload(item) | upload(item).catch(async (e) => { | ||
if (e.code === "moderation-image-queued") { | |||
printLog(`【${item.fileName}】上传成功`); | const Status = await ModerationStatus(`File:${item.fileName}`); | ||
if (Status === 1) { | |||
printLog(`【${item.fileName}】上传成功,并通过审核`); | |||
} else { | |||
printLog(`【${item.fileName}】上传成功,请耐心等待审核`); | |||
} | |||
} else { | |||
printLog.error(`【${item.fileName}】上传失败:${errorInfo(e)}`); | printLog.error(`【${item.fileName}】上传失败:${errorInfo(e)}`); | ||
resolve({ fileName: item.fileName, result: false }); | resolve({ fileName: item.fileName, result: false }); | ||
}); | } | ||
}); | |||
})), | })), | ||
); | ); | ||
| 第1,018行: | 第1,035行: | ||
const segmentedUploadResult = await Promise.all( | const segmentedUploadResult = await Promise.all( | ||
segment.map(item => new Promise(resolve => { | segment.map(item => new Promise(resolve => { | ||
upload(item) | upload(item).catch(async (e) => { | ||
if (e.code === "moderation-image-queued") { | |||
printLog(`【${item.fileName}】上传成功`); | const Status = await ModerationStatus(`File:${item.fileName}`); | ||
if (Status === 1) { | |||
printLog(`【${item.fileName}】上传成功,并通过审核`); | |||
} else { | |||
printLog(`【${item.fileName}】上传成功,请耐心等待审核`); | |||
} | |||
} else { | |||
printLog.error(`【${item.fileName}】上传失败:${errorInfo(e)}`); | printLog.error(`【${item.fileName}】上传失败:${errorInfo(e)}`); | ||
resolve({ fileName: item.fileName, result: false }); | resolve({ fileName: item.fileName, result: false }); | ||
}); | } | ||
}); | |||
})), | })), | ||
); | ); | ||
2025年7月24日 (四) 22:57的版本
Only for MediaWiki:Uploader