feat(前端界面): 优化默认阅读模式,宽屏单页适高,小屏连续适宽
build.yaml / build (push) Successful in 36s

This commit is contained in:
xiaoqidun committed 2026-09-08 22:42:47 +08:00
1 parent 367a9b98e9
commit a3fdf7e57d
1 file changed
+11 -4
+11 -4
View File
@@ -1250,7 +1250,10 @@ async function openDocument(options = {}) {
state.doc = doc; state.doc = doc;
state.pageIndex = pageIndex; state.pageIndex = pageIndex;
state.scale = options.scale || 1; state.scale = options.scale || 1;
state.fitMode = options.fitMode || "width"; if (!options.fitMode) {
setContinuous(window.matchMedia("(max-width: 640px)").matches);
}
state.fitMode = options.fitMode || (!state.continuous && pageCount === 1 ? "height" : "width");
if (!options.skipAutoFonts && await autoLoadDocumentLocalFonts(openSeq)) { if (!options.skipAutoFonts && await autoLoadDocumentLocalFonts(openSeq)) {
if (openSeq !== state.openSeq) { if (openSeq !== state.openSeq) {
return; return;
@@ -2406,11 +2409,15 @@ function fontMeta(font) {
return parts.join(" · "); return parts.join(" · ");
} }
function toggleContinuous() { function setContinuous(continuous) {
const anchor = state.fitMode === "free" ? scaleAnchor() : null; state.continuous = continuous;
state.continuous = !state.continuous;
el.pageFrame.classList.toggle("continuous", state.continuous); el.pageFrame.classList.toggle("continuous", state.continuous);
el.continuousButton.setAttribute("aria-pressed", String(state.continuous)); el.continuousButton.setAttribute("aria-pressed", String(state.continuous));
}
function toggleContinuous() {
const anchor = state.fitMode === "free" ? scaleAnchor() : null;
setContinuous(!state.continuous);
clearStampHighlights(); clearStampHighlights();
if (state.fitMode === "free") { if (state.fitMode === "free") {
restoreScaleAnchor(anchor); restoreScaleAnchor(anchor);