Skip to content

Commit 42841af

Browse files
committed
feat(nude-moon): support scrolling left-right
1 parent 07b8ac4 commit 42841af

1 file changed

Lines changed: 23 additions & 26 deletions

File tree

src/site/nude-moon.tsx

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1+
import { hotkeysMap } from 'components/Manga';
12
import {
23
domParse,
3-
onUrlChange,
4-
waitUrlChange,
4+
getKeyboardCode,
5+
linstenKeydown,
6+
querySelectorClick,
57
} from 'helper';
68
import { useInit } from 'main';
79

810
(async () => {
9-
const isMangaPage = () => location.pathname.match(/^\/[0-9]+--/);
10-
await waitUrlChange(isMangaPage);
11-
12-
const { store, setState, showComic, init } = await useInit('nude-moon', {
13-
autoShow: false,
14-
defaultOption: { pageNum: 1 },
15-
});
11+
const isMangaPage = () => location.pathname.match(/^\/[0-9]+--/) !== null;
1612

1713
const original = async () => {
1814
const url = new URL(location.href);
@@ -32,24 +28,25 @@ import { useInit } from 'main';
3228
(e) => `https://nude-moon.org${e[0]}`
3329
);
3430
}
35-
setState('comicMap', '', { getImgList: original })
36-
37-
onUrlChange(async (lastUrl) => {
38-
if (!lastUrl) return;
3931

40-
if (!isMangaPage())
41-
return setState((state) => {
42-
state.fab.show = false;
43-
state.manga.show = false;
44-
});
45-
46-
setState((state) => {
47-
state.fab.show = undefined;
48-
state.manga.show = false;
49-
});
50-
51-
if (store.options.autoShow) await showComic();
32+
const { setState } = await useInit('nude-moon', {
33+
autoShow: false,
34+
defaultOption: { pageNum: 1 },
5235
});
5336

54-
init();
37+
setState((state) => {
38+
if (isMangaPage()) state.comicMap[''].getImgList = original;
39+
})
40+
41+
linstenKeydown((e) => {
42+
console.log(hotkeysMap(), getKeyboardCode(e));
43+
switch (hotkeysMap()[getKeyboardCode(e)]) {
44+
case 'scroll_right':
45+
e.preventDefault();
46+
return querySelectorClick('a.small', 'Следующая')?.();
47+
case 'scroll_left':
48+
e.preventDefault();
49+
return querySelectorClick('a.small', 'Предыдущая')?.();
50+
}
51+
});
5552
})();

0 commit comments

Comments
 (0)