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) {
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;
target.textDefaults = { ...defaults, ...(target.textDefaults.fontChoice ? {fontChoice: target.textDefaults.fontChoice} : {}) };
}
@@ -2735,11 +2735,11 @@ function detachDocumentView() {
}
function attachDocumentTab(tab) {
tab.configurePending ||= tab.state.renderAnnotations !== state.renderAnnotations;
copyApplicationPreferences(tab.state);
workspace.active = tab;
tab.touched = Date.now();
state = tab.state;
el.imageDPI.value = String(state.renderDPI);
for (const face of state.svgFonts.values()) document.fonts.add(face);
state.textFontID = undefined;
resourceManager = tab.resources;
@@ -2768,6 +2768,8 @@ function attachDocumentTab(tab) {
canvasEditor.pendingSelection = tab.view?.selection || null;
documentDialogs?.setOwner(tab);
workspace.resourceView = resourceElements.Panel.open ? resourceManager : null;
setContinuous(state.continuous);
updatePanControl();
trimWorkspaceCaches();
renderDocumentTabs();
}
@@ -6019,6 +6021,7 @@ async function refreshPageDisplay(anchor = scaleAnchor(0)) {
}
async function changeDisplayMode(mode = state.renderMode) {
const tab = documentTab(), state = tab.state;
if (document.body.hasAttribute("data-busy")) {
el.imageDPI.value = String(state.renderDPI);
updateDPIControl();
@@ -6037,13 +6040,15 @@ async function changeDisplayMode(mode = state.renderMode) {
} catch (err) {
state.renderDPI = previous.dpi;
state.renderMode = previous.mode;
state.pageCache.clear();
if (isForegroundDocument(tab)) {
el.imageDPI.value = String(previous.dpi);
resetPageLoading();
state.pageCache.clear();
updateDisplayControls();
showError(err, false);
}
}
}
async function changeFont(font, changes) {
const tab = documentTab(), state = tab.state;
@@ -13331,11 +13336,15 @@ function togglePan() {
setPan(!state.panMode);
}
function updatePanControl() {
el.viewerPanel.classList.toggle("pan-mode", state.panMode);
el.panButton.setAttribute("data-pressed", String(state.panMode));
}
function setPan(enabled) {
endPan();
state.panMode = enabled;
el.viewerPanel.classList.toggle("pan-mode", state.panMode);
el.panButton.setAttribute("data-pressed", String(state.panMode));
updatePanControl();
updateEditorTools();
}
@@ -13624,8 +13633,8 @@ function updateControls() {
el.panButton.disabled = !hasDoc;
el.continuousButton.disabled = !hasDoc;
el.pageLayoutButton.disabled = pageCount < 2 || document.body.hasAttribute("data-busy");
el.pageLayoutButton.textContent = state.pageLayout === 1 ? "单页" : "双页";
el.pageLayoutButton.dataset.short = state.pageLayout === 1 ? "单" : "双";
el.pageLayoutButton.textContent = state.pageLayoutPreference === 1 ? "单页" : "双页";
el.pageLayoutButton.dataset.short = state.pageLayoutPreference === 1 ? "单" : "双";
el.fitButton.toggleAttribute("data-pressed", hasDoc && state.fitMode === "width");
el.fitHeightButton.toggleAttribute("data-pressed", hasDoc && state.fitMode === "height");
updateAnnotationButton();