Skip to content

Commit 6523689

Browse files
committed
style: 🚨 修复 linter 警告
1 parent 96329d3 commit 6523689

12 files changed

Lines changed: 45 additions & 37 deletions

File tree

src/components/Manga/actions/imageUpscale.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ const getModel = async () => {
6868
id: 'upscale',
6969
duration: Number.POSITIVE_INFINITY,
7070
});
71-
// TODO: 修改网址
7271
const bin = await request<ArrayBuffer>(
7372
'https://cdn.jsdelivr.net/npm/@hymbz/comic-read-script@11.12.1/public/realcugan/2x-conservative-128/group1-shard1of1.bin',
7473
{ responseType: 'arraybuffer', noTip: true },

src/components/Manga/actions/translation/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ export const allowBatchTranslation = () =>
1919
store.option.translation.provider !== 'cotrans';
2020

2121
const taskRegistry: Partial<
22-
Record<Option['translation']['provider'], new (url: string) => TranslationTask>
22+
Record<
23+
Option['translation']['provider'],
24+
new (url: string) => TranslationTask
25+
>
2326
> = {
2427
'manga-image-translator': MIT,
2528
cotrans: Cotrans,

src/components/Manga/actions/translation/translator/Cotrans/options.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ export type CotransOptions = {
1313
translator: { translator: string; target_lang: string };
1414
};
1515

16-
export { sizeDict, targetLanguageOptions } from '../MangaImageTranslator/options';
16+
export {
17+
sizeDict,
18+
targetLanguageOptions,
19+
} from '../MangaImageTranslator/options';
1720

1821
/** Cotrans 支持的翻译器列表 */
1922
export const cotransTranslators = [

src/components/Manga/actions/translation/translator/Cotrans/settings.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ import { t } from 'helper';
77

88
import type { Option } from '../../../../store/option';
99

10-
import {
11-
bindOption as _bindOption,
12-
type SetOptionsFunction,
13-
} from '../../..';
10+
import { bindOption as _bindOption, type SetOptionsFunction } from '../../..';
1411
import { SettingsItemSelect } from '../../../../components/SettingsItemSelect';
1512
import { cotransTranslators, targetLanguageOptions } from './options';
1613

src/components/Manga/actions/translation/translator/MangaImageTranslator/index.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type { TaskState } from './helper';
2020
import { setOption } from '../../..';
2121
import { store } from '../../../../store';
2222
import { TranslationTask } from '../../TranslationTask';
23-
import { apiUrl, headers, api } from './helper';
23+
import { api, apiUrl, headers } from './helper';
2424
import { sizeDict } from './options';
2525

2626
/**
@@ -41,10 +41,7 @@ export class MIT extends TranslationTask {
4141
// oxlint-disable-next-line no-unused-vars
4242
const { localUrl: _, ...options } = store.option.translation.mit;
4343

44-
if (!isOldVersion) {
45-
formData.append('image', file);
46-
formData.append('config', JSON.stringify(options));
47-
} else {
44+
if (isOldVersion) {
4845
formData.append('file', file);
4946
formData.append('mime', file.type);
5047
formData.append('size', sizeDict[options.detector.detection_size]);
@@ -53,6 +50,9 @@ export class MIT extends TranslationTask {
5350
formData.append('translator', options.translator.translator);
5451
formData.append('target_lang', options.translator.target_lang);
5552
formData.append('retry', `${store.option.translation.forceRetry}`);
53+
} else {
54+
formData.append('image', file);
55+
formData.append('config', JSON.stringify(options));
5656
}
5757
return formData;
5858
}
@@ -201,8 +201,7 @@ export class MIT extends TranslationTask {
201201
async work(blob: Blob) {
202202
this.setMessage(t('translation.tip.upload'));
203203

204-
if (this.isOldVersion)
205-
return await this.oldWork(blob);
204+
if (this.isOldVersion) return await this.oldWork(blob);
206205

207206
try {
208207
const reader = await this.uploadByStream(blob);
@@ -263,7 +262,11 @@ export const updateMitTranslators = async (noTip = false) => {
263262

264263
// 在切换翻译器或地址时更新可用翻译器列表
265264
createEffectOn(
266-
[() => store.option.translation.provider, () => store.option.translation.mit.localUrl, lang],
265+
[
266+
() => store.option.translation.provider,
267+
() => store.option.translation.mit.localUrl,
268+
lang,
269+
],
267270
([server]) => {
268271
if (server === 'manga-image-translator' && store.imgList.length > 0)
269272
return updateMitTranslators(true);

src/components/Manga/components/SettingTranslation.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import type { Option } from '../store/option';
1010

1111
import { RangeInput } from '../../RangeInput';
1212
import {
13-
allowBatchTranslation,
1413
bindOption as _bindOption,
14+
allowBatchTranslation,
1515
cotransSettings,
1616
imgList,
1717
isTranslatingAll,
@@ -82,10 +82,7 @@ const settingsMap = {
8282

8383
export const SettingTranslation = () => (
8484
<>
85-
<SettingsItemSwitch
86-
name={t('other.enabled')}
87-
{...bindOption('enabled')}
88-
/>
85+
<SettingsItemSwitch name={t('other.enabled')} {...bindOption('enabled')} />
8986

9087
<Show when={store.option.translation.enabled}>
9188
<SettingsItemSelect

src/components/Manga/defaultButtonList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { createEffectOn, t } from 'helper';
1919

2020
import { IconButton } from '../IconButton';
2121
import {
22+
allowBatchTranslation,
2223
doubleClickZoom,
2324
handleScrollModeZoom,
2425
isOnePageMode,
@@ -33,7 +34,6 @@ import {
3334
switchScrollMode,
3435
translateCurrent,
3536
translateToEnd,
36-
allowBatchTranslation,
3737
} from './actions';
3838
import { AutoScrollButton } from './components/autoScroll';
3939
import { DownloadButton } from './components/DownloadButton';

src/components/Manga/defaultSettingList.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,7 @@ export const defaultSettingList: () => SettingList = () => [
413413
</>
414414
),
415415
],
416-
[
417-
t('setting.option.paragraph_translation'),
418-
SettingTranslation,
419-
],
416+
[t('setting.option.paragraph_translation'), SettingTranslation],
420417
[t('other.hotkeys'), SettingHotkeysBlock],
421418
[
422419
t('other.other'),

src/site/ehentai/crossSiteLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const nhentai: SiteFn = async ({ setState, galleryTitle, galleryId }) => {
6060
class: `${galleryId}` === media_id ? 'gt' : 'gtl',
6161
};
6262
})
63-
.sort(
63+
.toSorted(
6464
(a, b) =>
6565
(a.class === 'gt' ? 0 : 1) - (b.class === 'gt' ? 0 : 1) ||
6666
Number(b.showText) - Number(a.showText),

src/site/nhentai.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import { getAdPageByContent } from 'userscript/detectAd';
1414

1515
import { getNhentaiData, toImgList } from '../userscript/nhentaiApi';
1616

17+
/** 等待水合完成,确保之后的 dom 操作不会被水合覆盖 */
18+
const waitHydrated = () => waitDom('#svelte-announcer', 1000 * 5);
19+
1720
universalSPA('nhentai', {
1821
options: {
1922
/** 无限滚动 */
@@ -51,6 +54,7 @@ universalSPA('nhentai', {
5154
},
5255
});
5356

57+
await waitHydrated();
5458
const comicReadModeDom = (
5559
<a
5660
href="javascript:;"
@@ -109,8 +113,7 @@ universalSPA('nhentai', {
109113
if (options.block_totally)
110114
useStyle('.blacklisted.gallery { display: none; }');
111115

112-
/** 等待水合完成,确保之后的 dom 操作不会被水合覆盖 */
113-
await waitDom('#svelte-announcer', 1000 * 5);
116+
await waitHydrated();
114117

115118
if (options.open_link_new_page)
116119
for (const e of querySelectorAll('a:not([href^="javascript:"])'))
@@ -127,9 +130,9 @@ universalSPA('nhentai', {
127130
hr:not(:last-child) { display: none; }
128131
@keyframes load { 0% { width: 100%; } 100% { width: 0; } }
129132
`);
130-
const getContentDom = () => document.getElementById('content')!;
133+
const contentDom = document.getElementById('content')!;
131134
const getObserveDom = () =>
132-
getContentDom().querySelector(
135+
contentDom.querySelector(
133136
':is(.index-container, #favcontainer):last-of-type',
134137
)!;
135138

@@ -150,13 +153,13 @@ universalSPA('nhentai', {
150153
nextUrl =
151154
pagination.querySelector<HTMLAnchorElement>('a.next')?.href;
152155

153-
getContentDom().append(
156+
contentDom.append(
154157
html.querySelector('.index-container, #favcontainer')!,
155158
pagination,
156159
);
157160

158161
const hr = document.createElement('hr');
159-
getContentDom().append(hr);
162+
contentDom.append(hr);
160163
observer.disconnect();
161164
observer.observe(getObserveDom());
162165
if (!nextUrl) hr.style.animationPlayState = 'paused';
@@ -171,7 +174,7 @@ universalSPA('nhentai', {
171174
observer.observe(getObserveDom());
172175

173176
if (querySelector('section.pagination'))
174-
getContentDom().append(document.createElement('hr'));
177+
contentDom.append(document.createElement('hr'));
175178

176179
return () => observer.disconnect();
177180
}

0 commit comments

Comments
 (0)