Skip to content

Commit 952a016

Browse files
committed
feat: ✨ 增加卷轴模式下的「自适应宽度」设置,替代删除「图片适合宽度」设置
#285
1 parent 3c92768 commit 952a016

19 files changed

Lines changed: 208 additions & 88 deletions

File tree

locales/en.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
},
7373
"other": {
7474
"auto": "Auto",
75+
"custom": "Custom",
7576
"disable": "Disable",
7677
"distance": "distance",
7778
"download": "Download",
@@ -129,10 +130,12 @@
129130
"option": {
130131
"abreast_duplicate": "Column duplicates ratio",
131132
"abreast_mode": "Abreast scroll mode",
133+
"adjust_to_width": "Adaptive Width",
132134
"align_edge": "Align to edge when turning page",
133135
"always_load_all_img": "Always load all images",
134136
"autoFullscreen": "Auto fullscreen",
135137
"autoHiddenMouse": "Auto hide mouse",
138+
"auto_scale": "Auto Scale",
136139
"auto_scroll_trigger_end": "Continue scrolling on the end page",
137140
"auto_switch_page_mode": "Auto switch single/double page mode by aspect ratio",
138141
"background_color": "Background Color",
@@ -145,7 +148,7 @@
145148
"dir_rtl": "RTL (Japanese manga)",
146149
"disable_auto_enlarge": "Disable automatic image enlarge",
147150
"first_page_fill": "Enable first page fill by default",
148-
"fit_to_width": "Fit to width",
151+
"full_width": "Viewport Width",
149152
"img_recognition": "Image Recognition",
150153
"img_recognition_background": "Recognition background color",
151154
"img_recognition_pageFill": "Auto switch page fill",

locales/hu.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
},
7373
"other": {
7474
"auto": "自动",
75+
"custom": "Egyedi",
7576
"disable": "Letiltás",
7677
"distance": "távolság",
7778
"download": "Letöltés",
@@ -129,10 +130,12 @@
129130
"option": {
130131
"abreast_duplicate": "每列重复比例",
131132
"abreast_mode": "并排卷轴模式",
133+
"adjust_to_width": "Adaptív Szélesség",
132134
"align_edge": "Lapozáskor élhez igazítás",
133135
"always_load_all_img": "始终加载所有图片",
134136
"autoFullscreen": "Automatikus teljes képernyő",
135137
"autoHiddenMouse": "自动隐藏鼠标",
138+
"auto_scale": "தானியங்கு அளவு",
136139
"auto_scroll_trigger_end": "Görgetés folytatása a végoldalon",
137140
"auto_switch_page_mode": "按屏幕比例切换单双页",
138141
"background_color": "背景颜色",
@@ -145,7 +148,7 @@
145148
"dir_rtl": "从右到左(日漫)",
146149
"disable_auto_enlarge": "禁止图片自动放大",
147150
"first_page_fill": "默认启用首页填充",
148-
"fit_to_width": "图片适合宽度",
151+
"full_width": "Nézetablak Szélesség",
149152
"img_recognition": "图像识别",
150153
"img_recognition_background": "识别背景色",
151154
"img_recognition_pageFill": "自动调整页面填充",

locales/ru.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
},
7373
"other": {
7474
"auto": "Авто",
75+
"custom": "Custom",
7576
"disable": "Отключить",
7677
"distance": "расстояние",
7778
"download": "Скачать",
@@ -129,10 +130,12 @@
129130
"option": {
130131
"abreast_duplicate": "Коэффициент дублирования столбцов",
131132
"abreast_mode": "Режим прокрутки в ряд",
133+
"adjust_to_width": "Адаптивная ширина",
132134
"align_edge": "Выравнивание по краю при перелистывании страницы",
133135
"always_load_all_img": "Всегда загружать все изображения",
134136
"autoFullscreen": "Авто полный экран",
135137
"autoHiddenMouse": "Автоматически скрывать курсор мыши",
138+
"auto_scale": "Авто масштаб",
136139
"auto_scroll_trigger_end": "Продолжить прокрутку на конечной странице",
137140
"auto_switch_page_mode": "Автоматическое переключение режима одной/двойной страницы в зависимости от соотношения сторон",
138141
"background_color": "Цвет фона",
@@ -145,7 +148,7 @@
145148
"dir_rtl": "Чтение справа налево (Японская манга)",
146149
"disable_auto_enlarge": "Отключить автоматическое масштабирование изображений",
147150
"first_page_fill": "Включить заполнение первой страницы по умолчанию",
148-
"fit_to_width": "По ширине",
151+
"full_width": "Ширина окна просмотра",
149152
"img_recognition": "распознавание изображений",
150153
"img_recognition_background": "Определить цвет фона",
151154
"img_recognition_pageFill": "Автоматическое переключение заполнения страницы",

locales/ta.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
},
7373
"other": {
7474
"auto": "தானியங்கி",
75+
"custom": "தனிப்பயனாக்க",
7576
"disable": "முடக்கவும்",
7677
"distance": "தூரம்",
7778
"download": "பதிவிறக்குங்கள்",
@@ -129,10 +130,12 @@
129130
"option": {
130131
"abreast_duplicate": "ஒவ்வொரு நெடுவரிசை நகல் விகிதம்",
131132
"abreast_mode": "இணை சுருள் பயன்முறை",
133+
"adjust_to_width": "தகவமைப்பு அகலம்",
132134
"align_edge": "பக்கத்தைத் திருப்பும்போது விளிம்பில் சீரமை",
133135
"always_load_all_img": "எப்போதும் எல்லா படங்களையும் ஏற்றவும்",
134136
"autoFullscreen": "தானியங்கி முழுத்திரை",
135137
"autoHiddenMouse": "தானியங்கி மறைக்கும் சுட்டி",
138+
"auto_scale": "தானியங்கு அளவு",
136139
"auto_scroll_trigger_end": "இறுதிப் பக்கத்தில் உருட்டலைத் தொடரவும்",
137140
"auto_switch_page_mode": "விகிதத்தின் அடிப்படையில் ஒற்றை/இரட்டை பக்க பயன்முறையை தானாக மாற்றவும்",
138141
"background_color": "பின்னணி நிறம்",
@@ -145,7 +148,7 @@
145148
"dir_rtl": "வலமிருந்து இடமாக (ரிமான்)",
146149
"disable_auto_enlarge": "தடைசெய்யப்பட்ட படங்கள் தானாக விரிவாக்கப்படுகின்றன",
147150
"first_page_fill": "இயல்பாக, முகப்புப்பக்க நிரப்புதலை இயக்கவும்",
148-
"fit_to_width": "அகலத்திற்கு ஏற்ற படம்",
151+
"full_width": "காட்சிச் சாளர அகலம்",
149152
"img_recognition": "பட ஏற்பு",
150153
"img_recognition_background": "அடையாள பின்னணி நிறம்",
151154
"img_recognition_pageFill": "தானியங்கி சரிசெய்தல் பக்கம் நிரப்புதல்",

locales/zh.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
},
7373
"other": {
7474
"auto": "自动",
75+
"custom": "自定义",
7576
"disable": "禁用",
7677
"distance": "距离",
7778
"download": "下载",
@@ -129,10 +130,12 @@
129130
"option": {
130131
"abreast_duplicate": "每列重复比例",
131132
"abreast_mode": "并排卷轴模式",
133+
"adjust_to_width": "自适应宽度",
132134
"align_edge": "滚动翻页时对齐边缘",
133135
"always_load_all_img": "始终加载所有图片",
134136
"autoFullscreen": "自动全屏",
135137
"autoHiddenMouse": "自动隐藏鼠标",
138+
"auto_scale": "自动缩放",
136139
"auto_scroll_trigger_end": "在结束页上继续滚动",
137140
"auto_switch_page_mode": "按屏幕比例切换单双页",
138141
"background_color": "背景颜色",
@@ -145,7 +148,7 @@
145148
"dir_rtl": "从右到左(日漫)",
146149
"disable_auto_enlarge": "禁止图片自动放大",
147150
"first_page_fill": "默认启用首页填充",
148-
"fit_to_width": "图片适合宽度",
151+
"full_width": "视窗宽度",
149152
"img_recognition": "图像识别",
150153
"img_recognition_background": "识别背景色",
151154
"img_recognition_pageFill": "自动调整页面填充",

src/components/Manga/actions/imageSize.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
imgList,
1010
isAbreastMode,
1111
placeholderSize,
12+
scrollModeScale,
1213
} from './memo';
1314

1415
/** 获取指定图片的显示尺寸 */
@@ -28,10 +29,11 @@ export const getImgDisplaySize = (
2829
};
2930

3031
if (isAbreastMode()) return setWidth(abreastColumnWidth());
31-
if (state.option.scrollMode.fitToWidth) return setWidth(state.rootSize.width);
32+
if (state.option.scrollMode.adjustToWidth === 'full')
33+
return setWidth(state.rootSize.width);
3234

33-
height *= state.option.scrollMode.imgScale;
34-
width *= state.option.scrollMode.imgScale;
35+
height *= scrollModeScale();
36+
width *= scrollModeScale();
3537

3638
if (width > state.rootSize.width) return setWidth(state.rootSize.width);
3739

@@ -54,8 +56,8 @@ createEffectOn(
5456
imgList,
5557
() => store.option.scrollMode.enabled,
5658
() => store.option.scrollMode.abreastMode,
57-
() => store.option.scrollMode.fitToWidth,
58-
() => store.option.scrollMode.imgScale,
59+
() => store.option.scrollMode.adjustToWidth,
60+
scrollModeScale,
5961
() => store.rootSize,
6062
placeholderSize,
6163
],

src/components/Manga/actions/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export * from './readProgress';
1313
export * from './renderPage';
1414
export * from './scroll';
1515
export * from './scrollbar';
16+
export * from './scrollMode';
1617
export * from './scrollModeDrag';
1718
export * from './show';
1819
export * from './switch';

src/components/Manga/actions/memo/img.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { ComicImg } from '../../store/image';
44

55
import { store } from '../../store';
66
import { findFillIndex } from '../helper';
7+
import { isUseAutoScale } from './options';
78

89
export const imgList = createRootMemo(() =>
910
store.imgList.map((url) => store.imgMap[url]),
@@ -50,6 +51,16 @@ export const placeholderSize = createThrottleMemo(
5051
500,
5152
);
5253

54+
/** 卷轴模式下的图片缩放比例 */
55+
export const scrollModeScale = createRootMemo(() => {
56+
if (!isUseAutoScale()) return store.option.scrollMode.imgScale;
57+
58+
// 能让大多数图片的宽度接近指定值的图片缩放比例
59+
return (
60+
(store.option.scrollMode.adjustToWidth as number) / placeholderSize().width
61+
);
62+
});
63+
5364
if (isDevMode)
5465
Object.assign((window as any).unsafeWindow ?? window, {
5566
_imgList: imgList,

src/components/Manga/actions/memo/options.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,31 @@ export const isAbreastMode = createRootMemo(
99

1010
/** 当前是否为双页卷轴模式 */
1111
export const isDoubleMode = createRootMemo(
12-
() => store.option.scrollMode.enabled && store.option.scrollMode.doubleMode,
12+
() =>
13+
store.option.scrollMode.enabled &&
14+
store.option.scrollMode.doubleMode &&
15+
!store.option.scrollMode.abreastMode,
16+
);
17+
18+
/** 当前是否为单页卷轴模式 */
19+
export const isSingleMode = createRootMemo(
20+
() =>
21+
store.option.scrollMode.enabled &&
22+
!store.option.scrollMode.doubleMode &&
23+
!store.option.scrollMode.abreastMode,
1324
);
1425

1526
/** 当前是否为普通卷轴模式(包含了双页卷轴模式) */
1627
export const isScrollMode = createRootMemo(
1728
() => store.option.scrollMode.enabled && !store.option.scrollMode.abreastMode,
1829
);
1930

31+
/** 当前是否正在卷轴模式下使用自动缩放值 */
32+
export const isUseAutoScale = createRootMemo(
33+
() =>
34+
isScrollMode() && typeof store.option.scrollMode.adjustToWidth === 'number',
35+
);
36+
2037
/** 当前是否开启了识别背景色 */
2138
export const isEnableBg = createRootMemo(
2239
() =>

src/components/Manga/actions/memo/scrollMode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const pageHeightList = createRootMemo(() => {
2727
if (!targetImg) throw new Error('找不到图片');
2828
if (
2929
targetImg.size.width < doubleWidth &&
30-
!store.option.scrollMode.fitToWidth
30+
store.option.scrollMode.adjustToWidth === 'disable'
3131
)
3232
return targetImg.size.height;
3333
return targetImg.size.height * (doubleWidth / targetImg.size.width);

0 commit comments

Comments
 (0)