Dependency optimization (#1294)

* -qs

* -urlencode

* +urlencode

* aaa
This commit is contained in:
Rider21
2024-11-06 17:06:34 +03:00
committed by GitHub
parent e5d852a64f
commit 778a5beaed
11 changed files with 2293 additions and 102 deletions
+2267 -62
View File
File diff suppressed because it is too large Load Diff
+3 -4
View File
@@ -32,7 +32,6 @@
"dayjs": "^1.11.10", "dayjs": "^1.11.10",
"htmlparser2": "^9.1.0", "htmlparser2": "^9.1.0",
"protobufjs": "^7.2.6", "protobufjs": "^7.2.6",
"qs": "^6.11.2",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-redux": "^9.1.2", "react-redux": "^9.1.2",
@@ -46,7 +45,6 @@
"@eslint/js": "^9.5.0", "@eslint/js": "^9.5.0",
"@types/eslint__js": "^8.42.3", "@types/eslint__js": "^8.42.3",
"@types/eslint-config-prettier": "^6.11.3", "@types/eslint-config-prettier": "^6.11.3",
"@types/qs": "^6.9.15",
"@types/react": "^18.2.66", "@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22", "@types/react-dom": "^18.2.22",
"@types/react-window": "^1.8.8", "@types/react-window": "^1.8.8",
@@ -60,11 +58,12 @@
"image-size": "^1.1.1", "image-size": "^1.1.1",
"lint-staged": "^15.2.2", "lint-staged": "^15.2.2",
"prettier": "^3.2.5", "prettier": "^3.2.5",
"terser": "^5.34.1", "terser": "^5.36.0",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.5.2", "typescript": "^5.5.2",
"typescript-eslint": "^7.14.1", "typescript-eslint": "^7.14.1",
"vite": "^5.2.0" "vite": "^5.2.0",
"vite-plugin-node-polyfills": "^0.22.0"
}, },
"lint-staged": { "lint-staged": {
"**/*.{js,ts,jsx,tsx}": "prettier --write" "**/*.{js,ts,jsx,tsx}": "prettier --write"
+2 -3
View File
@@ -4,7 +4,6 @@ import { Plugin } from '@typings/plugin';
import { NovelStatus } from '@libs/novelStatus'; import { NovelStatus } from '@libs/novelStatus';
import { load as parseHTML } from 'cheerio'; import { load as parseHTML } from 'cheerio';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import qs from 'qs';
type ReadwnOptions = { type ReadwnOptions = {
versionIncrements?: number; versionIncrements?: number;
@@ -204,12 +203,12 @@ class ReadwnPlugin implements Plugin.PluginBase {
Origin: this.site, Origin: this.site,
}, },
method: 'POST', method: 'POST',
body: qs.stringify({ body: new URLSearchParams({
show: 'title', show: 'title',
tempid: 1, tempid: 1,
tbname: 'news', tbname: 'news',
keyboard: searchTerm, keyboard: searchTerm,
}), }).toString(),
}).then(res => res.text()); }).then(res => res.text());
const loadedCheerio = parseHTML(result); const loadedCheerio = parseHTML(result);
-1
View File
@@ -9,7 +9,6 @@ import '@fontsource/roboto/700.css';
import 'cheerio'; import 'cheerio';
import 'htmlparser2'; import 'htmlparser2';
import 'dayjs'; import 'dayjs';
import 'qs';
import 'protobufjs'; import 'protobufjs';
const { fetch: originalFetch } = window; const { fetch: originalFetch } = window;
+10 -17
View File
@@ -2,15 +2,15 @@ import { load as parseHTML } from 'cheerio';
import { fetchText } from '@libs/fetch'; import { fetchText } from '@libs/fetch';
import { FilterTypes, Filters } from '@libs/filterInputs'; import { FilterTypes, Filters } from '@libs/filterInputs';
import { Plugin } from '@typings/plugin'; import { Plugin } from '@typings/plugin';
// import { encode } from 'urlencode'; import { encode } from 'urlencode';
import { NovelStatus } from '@libs/novelStatus'; import { NovelStatus } from '@libs/novelStatus';
class XinShu69 implements Plugin.PluginBase { class XinShu69 implements Plugin.PluginBase {
id = '69xinshu'; id = '69xinshu';
name = '69书吧'; name = '69书吧';
icon = 'src/cn/69xinshu/icon.png'; icon = 'src/cn/69xinshu/icon.png';
site = 'https://www.69shu.pro'; site = 'https://69shu.biz';
version = '0.1.1'; version = '0.1.2';
async popularNovels( async popularNovels(
pageNo: number, pageNo: number,
@@ -32,20 +32,14 @@ class XinShu69 implements Plugin.PluginBase {
const novelsList = const novelsList =
pageNo === 1 pageNo === 1
? loadedCheerio('div.newbox > ul > li') ? loadedCheerio('.newlistbox > ul > li')
: loadedCheerio('li'); : loadedCheerio('li');
novelsList.each((i, e) => {
const novelUrl = loadedCheerio(e)
.find('li > div > h3 > a:nth-child(2)')
.attr('href');
novelsList.each((i, e) => {
const novelUrl = loadedCheerio(e).find('div > h3 > a').attr('href');
if (novelUrl) { if (novelUrl) {
const novelName = loadedCheerio(e) const novelName = loadedCheerio(e).find('div > h3 > a').text();
.find('li > div > h3 > a:nth-child(2)') const novelCover = loadedCheerio(e).find('a > img').attr('data-src');
.text();
const novelCover = loadedCheerio(e)
.find('li > a > img')
.attr('data-src');
const novel = { const novel = {
name: novelName, name: novelName,
@@ -150,7 +144,7 @@ class XinShu69 implements Plugin.PluginBase {
const searchUrl = `${this.site}/modules/article/search.php`; const searchUrl = `${this.site}/modules/article/search.php`;
const formData = new FormData(); const formData = new FormData();
// formData.append('searchkey', encode(searchTerm, 'gbk')); formData.append('searchkey', encode(searchTerm, 'gbk'));
formData.append('searchtype', 'all'); formData.append('searchtype', 'all');
const body = await fetchText( const body = await fetchText(
@@ -159,12 +153,11 @@ class XinShu69 implements Plugin.PluginBase {
'gbk', 'gbk',
); );
if (body === '') throw Error('无法获取搜索结果,请检查网络'); if (body === '') throw Error('无法获取搜索结果,请检查网络');
const loadedCheerio = parseHTML(body); const loadedCheerio = parseHTML(body);
const novels: Plugin.NovelItem[] = []; const novels: Plugin.NovelItem[] = [];
loadedCheerio('div.newbox > ul > li').each((i, e) => { loadedCheerio('.newbox > ul > li').each((i, e) => {
const novelUrl = loadedCheerio(e).find('a').attr('href')!; const novelUrl = loadedCheerio(e).find('a').attr('href')!;
const novelName = loadedCheerio(e).find('div.newnav > h3').text(); const novelName = loadedCheerio(e).find('div.newnav > h3').text();
const novelCover = loadedCheerio(e).find('img').attr('data-src'); const novelCover = loadedCheerio(e).find('img').attr('data-src');
+1 -2
View File
@@ -1,7 +1,6 @@
import { Plugin } from '@typings/plugin'; import { Plugin } from '@typings/plugin';
import { fetchApi } from '@libs/fetch'; import { fetchApi } from '@libs/fetch';
import { CheerioAPI, load as parseHTML } from 'cheerio'; import { CheerioAPI, load as parseHTML } from 'cheerio';
import qs from 'qs';
import { Filters, FilterTypes } from '@libs/filterInputs'; import { Filters, FilterTypes } from '@libs/filterInputs';
class LibReadPlugin implements Plugin.PluginBase { class LibReadPlugin implements Plugin.PluginBase {
@@ -131,7 +130,7 @@ class LibReadPlugin implements Plugin.PluginBase {
Origin: this.site, Origin: this.site,
}, },
method: 'POST', method: 'POST',
body: qs.stringify({ searchkey: searchTerm }), body: new URLSearchParams({ searchkey: searchTerm }).toString(),
}); });
if (!r.ok) if (!r.ok)
throw new Error( throw new Error(
+1 -2
View File
@@ -2,7 +2,6 @@ import { load as parseHTML } from 'cheerio';
import { fetchApi } from '@libs/fetch'; import { fetchApi } from '@libs/fetch';
import { Plugin } from '@typings/plugin'; import { Plugin } from '@typings/plugin';
import { Filters, FilterTypes } from '@libs/filterInputs'; import { Filters, FilterTypes } from '@libs/filterInputs';
import qs from 'qs';
class NovelsOnline implements Plugin.PluginBase { class NovelsOnline implements Plugin.PluginBase {
id = 'NO.net'; id = 'NO.net';
@@ -119,7 +118,7 @@ class NovelsOnline implements Plugin.PluginBase {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
}, },
method: 'POST', method: 'POST',
body: qs.stringify({ q: searchTerm }), body: new URLSearchParams({ q: searchTerm }).toString(),
}).then(res => res.text()); }).then(res => res.text());
const $ = parseHTML(result); const $ = parseHTML(result);
+1 -2
View File
@@ -1,7 +1,6 @@
import { Plugin } from '@typings/plugin'; import { Plugin } from '@typings/plugin';
import { fetchApi } from '@libs/fetch'; import { fetchApi } from '@libs/fetch';
import { CheerioAPI, load as parseHTML } from 'cheerio'; import { CheerioAPI, load as parseHTML } from 'cheerio';
import qs from 'qs';
import { Filters, FilterTypes } from '@libs/filterInputs'; import { Filters, FilterTypes } from '@libs/filterInputs';
class FreeWebNovel implements Plugin.PluginBase { class FreeWebNovel implements Plugin.PluginBase {
@@ -134,7 +133,7 @@ class FreeWebNovel implements Plugin.PluginBase {
Origin: this.site, Origin: this.site,
}, },
method: 'POST', method: 'POST',
body: qs.stringify({ searchkey: searchTerm }), body: new URLSearchParams({ searchkey: searchTerm }).toString(),
}); });
if (!r.ok) if (!r.ok)
throw new Error( throw new Error(
+6 -7
View File
@@ -1,7 +1,6 @@
import { fetchApi } from '@libs/fetch'; import { fetchApi } from '@libs/fetch';
import { Plugin } from '@typings/plugin'; import { Plugin } from '@typings/plugin';
import { load as parseHTML } from 'cheerio'; import { load as parseHTML } from 'cheerio';
import qs from 'qs';
class Agitoon implements Plugin.PluginBase { class Agitoon implements Plugin.PluginBase {
id = 'agit.xyz'; id = 'agit.xyz';
@@ -29,7 +28,7 @@ class Agitoon implements Plugin.PluginBase {
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8', 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
}, },
method: 'POST', method: 'POST',
body: qs.stringify({ body: new URLSearchParams({
mode: 'get_data_novel_list_p', mode: 'get_data_novel_list_p',
novel_menu: showLatestNovels ? '1' : '3', novel_menu: showLatestNovels ? '1' : '3',
np_day: new Date().getDay(), np_day: new Date().getDay(),
@@ -41,7 +40,7 @@ class Agitoon implements Plugin.PluginBase {
np_genre_ex_2: '00', np_genre_ex_2: '00',
list_limit: 20 * (pageNo - 1), list_limit: 20 * (pageNo - 1),
is_query_first: pageNo == 1, is_query_first: pageNo == 1,
}), }).toString(),
}); });
if (!res.ok) { if (!res.ok) {
throw new Error( throw new Error(
@@ -95,13 +94,13 @@ class Agitoon implements Plugin.PluginBase {
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8', 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
}, },
method: 'POST', method: 'POST',
body: qs.stringify({ body: new URLSearchParams({
mode: 'get_data_novel_list_c', mode: 'get_data_novel_list_c',
wr_id_p: novelPath, wr_id_p: novelPath,
page_no: '1', page_no: '1',
cnt_list: '10000', cnt_list: '10000',
order_type: 'Asc', order_type: 'Asc',
}), }).toString(),
}); });
const resJson = (await res.json()) as responseBook; const resJson = (await res.json()) as responseBook;
@@ -145,11 +144,11 @@ class Agitoon implements Plugin.PluginBase {
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8', 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
}, },
method: 'POST', method: 'POST',
body: qs.stringify({ body: new URLSearchParams({
mode: 'get_data_novel_list_p_sch', mode: 'get_data_novel_list_p_sch',
search_novel: searchTerm, search_novel: searchTerm,
list_limit: 0, list_limit: 0,
}), }).toString(),
}); });
const resJson = (await rawResults.json()) as response; const resJson = (await rawResults.json()) as response;
const novels: Plugin.NovelItem[] = []; const novels: Plugin.NovelItem[] = [];
-1
View File
@@ -25,7 +25,6 @@ class TopLiba implements Plugin.PluginBase {
}); });
if (searchTerm) data.append('q', searchTerm); if (searchTerm) data.append('q', searchTerm);
const body = await fetchApi(this.site + '/?' + data.toString()).then(res => const body = await fetchApi(this.site + '/?' + data.toString()).then(res =>
res.text(), res.text(),
); );
+2 -1
View File
@@ -1,5 +1,6 @@
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc'; import react from '@vitejs/plugin-react-swc';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import path from 'path'; import path from 'path';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
@@ -7,7 +8,7 @@ const dirname = path.dirname(fileURLToPath(import.meta.url));
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [react({ devTarget: 'es5' })], plugins: [nodePolyfills(), react({ devTarget: 'es5' })],
resolve: { resolve: {
alias: { alias: {
'@libs': path.resolve(dirname, './src/libs'), '@libs': path.resolve(dirname, './src/libs'),