mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-30 01:27:26 +08:00
1 parent
dacdf0b3c9
commit
a73d08d328
2 files changed
+31
-12
No files matched your search
@@ -84,6 +84,10 @@
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.document-tab[data-error="true"] .document-tab-name {
|
||||||
|
color: #b42318;
|
||||||
|
}
|
||||||
|
|
||||||
.document-titlebar[data-active="false"] {
|
.document-titlebar[data-active="false"] {
|
||||||
background: var(--titlebar-inactive-background);
|
background: var(--titlebar-inactive-background);
|
||||||
color: var(--titlebar-inactive-foreground);
|
color: var(--titlebar-inactive-foreground);
|
||||||
@@ -881,6 +885,10 @@ button:not(:disabled):hover {
|
|||||||
justify-content: end;
|
justify-content: end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.confirm-dialog .form-actions button[hidden] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.convert-dialog {
|
.convert-dialog {
|
||||||
--convert-control-width: 64px;
|
--convert-control-width: 64px;
|
||||||
width: 720px;
|
width: 720px;
|
||||||
|
|||||||
+23
-12
@@ -2477,8 +2477,9 @@ async function closeWorkspace() {
|
|||||||
if (workspace.tabs.some(tab => tab.state.saving)) { setStatus("文档正在保存,请稍后关闭"); return; }
|
if (workspace.tabs.some(tab => tab.state.saving)) { setStatus("文档正在保存,请稍后关闭"); return; }
|
||||||
if (batch.running && !window.confirm("批量转换尚未完成,是否退出?")) return;
|
if (batch.running && !window.confirm("批量转换尚未完成,是否退出?")) return;
|
||||||
if (workspace.tabs.some(tab => tab.opening || tab.state.exporting) && !window.confirm("文档正在处理,是否取消并退出?")) return;
|
if (workspace.tabs.some(tab => tab.opening || tab.state.exporting) && !window.confirm("文档正在处理,是否取消并退出?")) return;
|
||||||
const dirty = workspace.tabs.some(tab => tab.state.dirty) || canvasEditor.textChanged() || canvasEditor.cropChanged() || canvasEditor.nudgeChanged();
|
const activeDirty = state.dirty || canvasEditor.textChanged() || canvasEditor.cropChanged() || canvasEditor.nudgeChanged();
|
||||||
if (dirty && (workspace.switching || workspace.tabs.some(tab => tab.closing) || document.body.hasAttribute("data-busy") || formDialogOpen())) {
|
const dirty = activeDirty || workspace.tabs.some(tab => tab.state.dirty);
|
||||||
|
if (dirty && (workspace.switching || workspace.tabs.some(tab => tab.closing) || formDialogOpen() || (activeDirty && document.body.hasAttribute("data-busy")))) {
|
||||||
setStatus("操作正在进行,请完成或取消后关闭");
|
setStatus("操作正在进行,请完成或取消后关闭");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2545,6 +2546,8 @@ function renderDocumentTabs() {
|
|||||||
name.textContent = `${tab.state.dirty ? "● " : ""}${title}`;
|
name.textContent = `${tab.state.dirty ? "● " : ""}${title}`;
|
||||||
item.title = `${title}${tab.opening ? ` · ${STATUS.opening}` : tab.state.saving ? " · 正在保存" : tab.error ? ` · ${tab.error}` : ""}`;
|
item.title = `${title}${tab.opening ? ` · ${STATUS.opening}` : tab.state.saving ? " · 正在保存" : tab.error ? ` · ${tab.error}` : ""}`;
|
||||||
item.dataset.loading = String(Boolean(tab.opening));
|
item.dataset.loading = String(Boolean(tab.opening));
|
||||||
|
item.dataset.error = String(Boolean(tab.error));
|
||||||
|
if (tab.error) name.textContent = `! ${name.textContent}`;
|
||||||
const close = document.createElement("button");
|
const close = document.createElement("button");
|
||||||
close.type = "button";
|
close.type = "button";
|
||||||
close.className = "document-tab-close";
|
close.className = "document-tab-close";
|
||||||
@@ -2846,17 +2849,19 @@ function setDirty(dirty) {
|
|||||||
updateWorkspaceDirty();
|
updateWorkspaceDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function requestCloseAction(title, message, save) {
|
async function requestCloseAction(title, message, save, tab = documentTab()) {
|
||||||
if (documentDialogs && !workspace.closing) return documentDialogs.request(el.closePanel, documentTab(), () => {
|
const setup = () => {
|
||||||
el.closeTitle.textContent = title;
|
el.closeTitle.textContent = title;
|
||||||
el.closeMessage.textContent = message;
|
el.closeMessage.textContent = message;
|
||||||
el.closePanel.querySelector('[value="save"]').textContent = save;
|
const saveButton = el.closePanel.querySelector('[value="save"]');
|
||||||
el.closePanel.returnValue = "cancel";
|
saveButton.hidden = !save;
|
||||||
});
|
if (save) saveButton.textContent = save;
|
||||||
el.closeTitle.textContent = title;
|
el.closePanel.querySelector('[value="discard"]').textContent = save ? "放弃" : "停止并关闭";
|
||||||
el.closeMessage.textContent = message;
|
|
||||||
el.closePanel.querySelector('[value="save"]').textContent = save;
|
|
||||||
el.closePanel.returnValue = "cancel";
|
el.closePanel.returnValue = "cancel";
|
||||||
|
el.closePanel.inert = false;
|
||||||
|
};
|
||||||
|
if (documentDialogs && !workspace.closing) return documentDialogs.request(el.closePanel, tab, setup);
|
||||||
|
setup();
|
||||||
const choice = new Promise(resolve => el.closePanel.addEventListener("close", () => resolve(el.closePanel.returnValue), { once: true }));
|
const choice = new Promise(resolve => el.closePanel.addEventListener("close", () => resolve(el.closePanel.returnValue), { once: true }));
|
||||||
if (documentDialogs) documentDialogs.showApplication(el.closePanel);
|
if (documentDialogs) documentDialogs.showApplication(el.closePanel);
|
||||||
else el.closePanel.showModal();
|
else el.closePanel.showModal();
|
||||||
@@ -2865,6 +2870,9 @@ async function requestCloseAction(title, message, save) {
|
|||||||
} finally {
|
} finally {
|
||||||
el.closeTitle.textContent = "关闭文档";
|
el.closeTitle.textContent = "关闭文档";
|
||||||
el.closeMessage.textContent = "文档尚未保存";
|
el.closeMessage.textContent = "文档尚未保存";
|
||||||
|
el.closePanel.querySelector('[value="save"]').hidden = false;
|
||||||
|
el.closePanel.querySelector('[value="discard"]').textContent = "放弃";
|
||||||
|
el.closePanel.inert = document.body.hasAttribute("data-busy");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2899,7 +2907,10 @@ async function closeFile(tab = null) {
|
|||||||
try {
|
try {
|
||||||
if (tab.state.saving && tab.saveCompletion) await tab.saveCompletion;
|
if (tab.state.saving && tab.saveCompletion) await tab.saveCompletion;
|
||||||
if (tab.closed) return;
|
if (tab.closed) return;
|
||||||
if ((tab.opening || tab.state.exporting) && !window.confirm("文档正在处理,是否取消并关闭?")) return;
|
if (tab.opening || tab.state.exporting) {
|
||||||
|
const action = await requestCloseAction("关闭文档", "文档正在处理,是否取消并关闭?", null, tab);
|
||||||
|
if (action !== "discard" || tab.closed) return;
|
||||||
|
}
|
||||||
if (tab.state.dirty || tab === workspace.active && (canvasEditor.input || canvasEditor.crop || canvasEditor.nudge)) {
|
if (tab.state.dirty || tab === workspace.active && (canvasEditor.input || canvasEditor.crop || canvasEditor.nudge)) {
|
||||||
if (tab !== workspace.active && !await activateDocumentTab(tab)) return;
|
if (tab !== workspace.active && !await activateDocumentTab(tab)) return;
|
||||||
if (!await confirmDocumentClose(tab) || tab.closed || workspace.closing) return;
|
if (!await confirmDocumentClose(tab) || tab.closed || workspace.closing) return;
|
||||||
@@ -13756,7 +13767,7 @@ function setBusy(busy, text = "", percent = 0, status = "", tab = documentTab())
|
|||||||
renderSecurity();
|
renderSecurity();
|
||||||
updateDisplayControls();
|
updateDisplayControls();
|
||||||
el.editButton.disabled = busy || Boolean(sealPreview || resourceManager.pick) || !state.doc || !state.ready || state.exporting;
|
el.editButton.disabled = busy || Boolean(sealPreview || resourceManager.pick) || !state.doc || !state.ready || state.exporting;
|
||||||
el.closePanel.inert = busy;
|
el.closePanel.inert = busy && !el.closePanel.open;
|
||||||
el.createForm.inert = busy && !state.imageImporting;
|
el.createForm.inert = busy && !state.imageImporting;
|
||||||
updateCreateOptions();
|
updateCreateOptions();
|
||||||
el.insertForm.inert = busy;
|
el.insertForm.inert = busy;
|
||||||
|
|||||||
Reference in new issue
Block a user