Add generation lock and floating-first auto
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
saveSettings,
|
||||
findLastAIMessageId,
|
||||
classifyError,
|
||||
isGenerating,
|
||||
} from './novel-draw.js';
|
||||
import { registerToToolbar, removeFromToolbar } from '../../widgets/message-toolbar.js';
|
||||
|
||||
@@ -754,6 +755,11 @@ async function handleFloorDrawClick(messageId) {
|
||||
const panelData = panelMap.get(messageId);
|
||||
if (!panelData || panelData.state !== FloatState.IDLE) return;
|
||||
|
||||
if (isGenerating()) {
|
||||
toastr?.info?.('已有任务进行中,请等待完成');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await generateAndInsertImages({
|
||||
messageId,
|
||||
@@ -777,8 +783,9 @@ async function handleFloorDrawClick(messageId) {
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('[NovelDraw]', e);
|
||||
if (e.message === '已取消') {
|
||||
if (e.message === '已取消' || e.message?.includes('已有任务进行中')) {
|
||||
setFloorState(messageId, FloatState.IDLE);
|
||||
if (e.message?.includes('已有任务进行中')) toastr?.info?.(e.message);
|
||||
} else {
|
||||
setFloorState(messageId, FloatState.ERROR, { error: classifyError(e) });
|
||||
}
|
||||
@@ -1230,6 +1237,11 @@ async function handleFloatingDrawClick() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isGenerating()) {
|
||||
toastr?.info?.('已有任务进行中,请等待完成');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await generateAndInsertImages({
|
||||
messageId,
|
||||
@@ -1253,8 +1265,9 @@ async function handleFloatingDrawClick() {
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('[NovelDraw]', e);
|
||||
if (e.message === '已取消') {
|
||||
if (e.message === '已取消' || e.message?.includes('已有任务进行中')) {
|
||||
setFloatingState(FloatState.IDLE);
|
||||
if (e.message?.includes('已有任务进行中')) toastr?.info?.(e.message);
|
||||
} else {
|
||||
setFloatingState(FloatState.ERROR, { error: classifyError(e) });
|
||||
}
|
||||
@@ -1547,4 +1560,5 @@ export {
|
||||
SIZE_OPTIONS,
|
||||
createFloatingButton,
|
||||
destroyFloatingButton,
|
||||
setFloatingState,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user