feat(阅读渲染): 阅读状态按标签独立并同步
build.yaml / build (push) Successful in 47s

This commit is contained in:
xiaoqidun committed 2026-10-25 12:58:50 +08:00
1 parent 3f8240d3c1
commit c4345420d5
1 file changed
+16 -7
+16 -7
View File
@@ -2591,7 +2591,7 @@ function advanceDocumentSequence() {
} }
function copyApplicationPreferences(target) { function copyApplicationPreferences(target) {
for (const key of ["pageLayoutPreference", "renderAnnotations", "renderBackend", "renderMode", "renderDPI", "showPages", "showMeta", "exportFormats"]) target[key] = state[key]; for (const key of ["showPages", "showMeta", "exportFormats"]) target[key] = state[key];
const { fontChoice, ...defaults } = state.textDefaults; const { fontChoice, ...defaults } = state.textDefaults;
target.textDefaults = { ...defaults, ...(target.textDefaults.fontChoice ? {fontChoice: target.textDefaults.fontChoice} : {}) }; target.textDefaults = { ...defaults, ...(target.textDefaults.fontChoice ? {fontChoice: target.textDefaults.fontChoice} : {}) };
} }
@@ -2735,11 +2735,11 @@ function detachDocumentView() {
} }
function attachDocumentTab(tab) { function attachDocumentTab(tab) {
tab.configurePending ||= tab.state.renderAnnotations !== state.renderAnnotations;
copyApplicationPreferences(tab.state); copyApplicationPreferences(tab.state);
workspace.active = tab; workspace.active = tab;
tab.touched = Date.now(); tab.touched = Date.now();
state = tab.state; state = tab.state;
el.imageDPI.value = String(state.renderDPI);
for (const face of state.svgFonts.values()) document.fonts.add(face); for (const face of state.svgFonts.values()) document.fonts.add(face);
state.textFontID = undefined; state.textFontID = undefined;
resourceManager = tab.resources; resourceManager = tab.resources;
@@ -2768,6 +2768,8 @@ function attachDocumentTab(tab) {
canvasEditor.pendingSelection = tab.view?.selection || null; canvasEditor.pendingSelection = tab.view?.selection || null;
documentDialogs?.setOwner(tab); documentDialogs?.setOwner(tab);
workspace.resourceView = resourceElements.Panel.open ? resourceManager : null; workspace.resourceView = resourceElements.Panel.open ? resourceManager : null;
setContinuous(state.continuous);
updatePanControl();
trimWorkspaceCaches(); trimWorkspaceCaches();
renderDocumentTabs(); renderDocumentTabs();
} }
@@ -6019,6 +6021,7 @@ async function refreshPageDisplay(anchor = scaleAnchor(0)) {
} }
async function changeDisplayMode(mode = state.renderMode) { async function changeDisplayMode(mode = state.renderMode) {
const tab = documentTab(), state = tab.state;
if (document.body.hasAttribute("data-busy")) { if (document.body.hasAttribute("data-busy")) {
el.imageDPI.value = String(state.renderDPI); el.imageDPI.value = String(state.renderDPI);
updateDPIControl(); updateDPIControl();
@@ -6037,12 +6040,14 @@ async function changeDisplayMode(mode = state.renderMode) {
} catch (err) { } catch (err) {
state.renderDPI = previous.dpi; state.renderDPI = previous.dpi;
state.renderMode = previous.mode; state.renderMode = previous.mode;
state.pageCache.clear();
if (isForegroundDocument(tab)) {
el.imageDPI.value = String(previous.dpi); el.imageDPI.value = String(previous.dpi);
resetPageLoading(); resetPageLoading();
state.pageCache.clear();
updateDisplayControls(); updateDisplayControls();
showError(err, false); showError(err, false);
} }
}
} }
async function changeFont(font, changes) { async function changeFont(font, changes) {
@@ -13331,11 +13336,15 @@ function togglePan() {
setPan(!state.panMode); setPan(!state.panMode);
} }
function updatePanControl() {
el.viewerPanel.classList.toggle("pan-mode", state.panMode);
el.panButton.setAttribute("data-pressed", String(state.panMode));
}
function setPan(enabled) { function setPan(enabled) {
endPan(); endPan();
state.panMode = enabled; state.panMode = enabled;
el.viewerPanel.classList.toggle("pan-mode", state.panMode); updatePanControl();
el.panButton.setAttribute("data-pressed", String(state.panMode));
updateEditorTools(); updateEditorTools();
} }
@@ -13624,8 +13633,8 @@ function updateControls() {
el.panButton.disabled = !hasDoc; el.panButton.disabled = !hasDoc;
el.continuousButton.disabled = !hasDoc; el.continuousButton.disabled = !hasDoc;
el.pageLayoutButton.disabled = pageCount < 2 || document.body.hasAttribute("data-busy"); el.pageLayoutButton.disabled = pageCount < 2 || document.body.hasAttribute("data-busy");
el.pageLayoutButton.textContent = state.pageLayout === 1 ? "单页" : "双页"; el.pageLayoutButton.textContent = state.pageLayoutPreference === 1 ? "单页" : "双页";
el.pageLayoutButton.dataset.short = state.pageLayout === 1 ? "单" : "双"; el.pageLayoutButton.dataset.short = state.pageLayoutPreference === 1 ? "单" : "双";
el.fitButton.toggleAttribute("data-pressed", hasDoc && state.fitMode === "width"); el.fitButton.toggleAttribute("data-pressed", hasDoc && state.fitMode === "width");
el.fitHeightButton.toggleAttribute("data-pressed", hasDoc && state.fitMode === "height"); el.fitHeightButton.toggleAttribute("data-pressed", hasDoc && state.fitMode === "height");
updateAnnotationButton(); updateAnnotationButton();