Skip to content

Commit

Permalink
fix: 🐛 修复部分情况下会自动切换至单页模式的 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hymbz committed Dec 16, 2023
1 parent 75800e7 commit eeda07f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

这是一个因为目前大部分漫画站都不支持双页显示,所以每次遇到 **漫画中的跨页大图被分割成两页** 就很不爽的人为了有更好的漫画阅读体验而写的油猴脚本,为主流漫画站增加了**双页阅读模式**和各种优化体验的增强功能。

脚本会在网页右下角弹出用于 **进入阅读模式** 的悬浮按钮,其上的快捷按钮用于切换站点增强功能的开启与否默认会开启**自动进入阅读模式**的功能,也可在这里关闭。脚本没有全局设置,所有修改都只会在当前站点生效保存。~~反正平时也就只上那几个站点~~
脚本会在网页右下角弹出用于 **进入阅读模式** 的悬浮按钮,其上的快捷按钮用于切换站点增强功能的开启与否默认会开启**自动进入阅读模式**的功能,也可在这里关闭。脚本没有全局设置,所有修改都只会在当前站点生效保存。~~反正平时也就只上那几个站点~~

对于支持站点以外的网站,脚本也提供了「[简易阅读模式](#简易阅读模式)」,除了得手动跳转上/下一话外,和支持站点的使用体验没有区别。

Expand Down
2 changes: 1 addition & 1 deletion docs/README-out.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

这是一个因为目前大部分漫画站都不支持双页显示,所以每次遇到 **漫画中的跨页大图被分割成两页** 就很不爽的人为了有更好的漫画阅读体验而写的油猴脚本,为主流漫画站增加了**双页阅读模式**和各种优化体验的增强功能。

脚本会在网页右下角弹出用于 **进入阅读模式** 的悬浮按钮,其上的快捷按钮用于切换站点增强功能的开启与否默认会开启**自动进入阅读模式**的功能,也可在这里关闭。脚本没有全局设置,所有修改都只会在当前站点生效保存。~~反正平时也就只上那几个站点~~
脚本会在网页右下角弹出用于 **进入阅读模式** 的悬浮按钮,其上的快捷按钮用于切换站点增强功能的开启与否默认会开启**自动进入阅读模式**的功能,也可在这里关闭。脚本没有全局设置,所有修改都只会在当前站点生效保存。~~反正平时也就只上那几个站点~~

对于支持站点以外的网站,脚本也提供了「[简易阅读模式](#简易阅读模式)」,除了得手动跳转上/下一话外,和支持站点的使用体验没有区别。

Expand Down
14 changes: 8 additions & 6 deletions src/components/Manga/actions/imageSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ export const updateImgSize = (i: number, width: number, height: number) => {
let isEdited = updateImgType(state, img);

switch (img.type) {
// 连续出现多张跨页图后,自动开启单页模式
// 连续出现多张跨页图后,将剩余未加载图片类型设为跨页图
case 'long':
case 'wide': {
if (!state.flag.autoOnePageMode || !checkImgTypeCount(state, isWideImg))
break;
state.option.onePageMode = true;
state.flag.autoOnePageMode = false;
if (!state.flag.autoWide || !checkImgTypeCount(state, isWideImg)) break;
state.imgList.forEach((comicImg, index) => {
if (comicImg.loadType === 'wait' && comicImg.type === '')
state.imgList[index].type = 'wide';
});
state.flag.autoWide = true;
isEdited = true;
break;
}
Expand All @@ -66,7 +68,7 @@ export const updateImgSize = (i: number, width: number, height: number) => {
case 'vertical': {
if (
!state.flag.autoScrollMode ||
!checkImgTypeCount(state, (image) => image.type === 'vertical')
!checkImgTypeCount(state, ({ type }) => type === 'vertical')
)
break;
state.option.scrollMode = true;
Expand Down
6 changes: 3 additions & 3 deletions src/components/Manga/hooks/useInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createEffect, onCleanup } from 'solid-js';

import { assign, isEqualArray } from 'helper';
import type { MangaProps } from '..';
import { refs, setState } from '../store';
import { refs, setState, store } from '../store';
import {
defaultHotkeys,
focus,
Expand All @@ -16,7 +16,7 @@ import { autoCloseFill } from '../handleComicData';
import { playAnimation } from '../helper';

const createComicImg = (url: string): ComicImg => ({
type: '',
type: store.flag.autoWide ? 'wide' : '',
src: url || '',
loadType: 'wait',
});
Expand Down Expand Up @@ -120,7 +120,7 @@ export const useInit = (props: MangaProps) => {
// 处理初始化
if (isInit) {
state.flag.autoScrollMode = true;
state.flag.autoOnePageMode = true;
state.flag.autoWide = true;
autoCloseFill.clear();

if (!state.option.firstPageFill || props.imgList.length <= 3)
Expand Down
4 changes: 2 additions & 2 deletions src/components/Manga/store/other.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export const OtherState = {
flag: {
/** 是否需要自动判断开启卷轴模式 */
autoScrollMode: true,
/** 是否需要自动判断开启单页模式 */
autoOnePageMode: true,
/** 是否需要自动将未加载图片类型设为跨页图 */
autoWide: true,

/**
* 用于防止滚轮连续滚动导致过快触发事件的锁
Expand Down

0 comments on commit eeda07f

Please sign in to comment.