16,874
个编辑
LLWiki正在建设中,欢迎加入我们!
(未知原因,还是不行) 标签:撤销 |
|||
*/
mw.safeEdit = function(api, curRevid, params, flag) {
return mw.timedQuery(api, {prop: 'info', titles: params.title, pageids: params.pageid},
console.debug('API request: 开始提交编辑');▼
mw.msg('gadget-lib-latest')).then(function(data) {
const now = mw.now();▼
// 未创建的页面lastrevid返回undefined,因此下式同样为false
return api.postWithEditToken( $.extend({action: 'edit', baserevid: curRevid || cid}, params) ).then(function() {▼
if (data.query.pages[0].lastrevid > (curRevid || cid)) {
console.debug('End API request: 编辑成功!用时 ' + (mw.now() - now) + ' ms');▼
}, function(reason) {▼
mw.notify( mw.msg('gadget-lib-conflict' + (flag ? 2 : 1)),
{type: 'error', autoHideSeconds: 'long', tag: 'editConflict'} );
throw 'editConflict';
}
mw.notify( mw.msg('gadget-lib-editFail', reason),▼
{type: 'error', autoHideSeconds: 'long', tag: 'apiFailure'} );▼
▲
throw 'editFailure';▼
});▼
▲ mw.notify( mw.msg('gadget-lib-editFail', reason),
▲ {type: 'error', autoHideSeconds: 'long', tag: 'apiFailure'} );
▲ throw 'editFailure';
}, function() { throw 'revisionQueryFailure'; }); // mw.timedQuery已通知错误信息
};
|