fix(dnfs): 移动请求期间禁用按钮防止重复提交
后端 update_note 走 AI 审核耗时较长,confirmMove 期间禁用移动条 与表单按钮,finally 统一恢复
This commit is contained in:
1 parent
751866d9c1
commit
3bc4f9720f
1 file changed
+14
-1
@@ -363,7 +363,8 @@ function renderMoveBar() {
|
|||||||
movebar.appendChild(cancel_btn);
|
movebar.appendChild(cancel_btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* by qing — 执行移动:把待移动节点挂到当前层(stack 顶,根为 0) */
|
/* by qing — 执行移动:把待移动节点挂到当前层(stack 顶,根为 0)。
|
||||||
|
* 后端 update_note 会走 AI 内容审核,耗时较长,期间禁用移动条与表单按钮防止重复提交 */
|
||||||
async function confirmMove() {
|
async function confirmMove() {
|
||||||
if (moving_node == null) {
|
if (moving_node == null) {
|
||||||
return;
|
return;
|
||||||
@@ -377,11 +378,23 @@ async function confirmMove() {
|
|||||||
alert('该节点已在当前层');
|
alert('该节点已在当前层');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 防重复点击:请求进行中禁用按钮(成功/失败都在 finally 恢复)
|
||||||
|
movebar.querySelectorAll('button').forEach(function(b) { b.disabled = true; });
|
||||||
|
input_note_submit.disabled = true;
|
||||||
|
input_note_clear.disabled = true;
|
||||||
|
delete_note.disabled = true;
|
||||||
|
try {
|
||||||
var result = await moveNode(moving_node.id, target_pid, moving_node.title, moving_node.content);
|
var result = await moveNode(moving_node.id, target_pid, moving_node.title, moving_node.content);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
moving_node = null;
|
moving_node = null;
|
||||||
renderMoveBar();
|
renderMoveBar();
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
movebar.querySelectorAll('button').forEach(function(b) { b.disabled = false; });
|
||||||
|
input_note_submit.disabled = false;
|
||||||
|
input_note_clear.disabled = false;
|
||||||
|
delete_note.disabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* by shufeng2012 */
|
/* by shufeng2012 */
|
||||||
|
|||||||
Reference in new issue
Block a user