Skip to content

Commit c95e99d

Browse files
新增筛选功能.
1 parent 0075197 commit c95e99d

File tree

3 files changed

+100
-10
lines changed

3 files changed

+100
-10
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
## 说明
66

77
- 能用就行.
8-
- 要在`Http标头`里添加参数才能正常使用喔,`Header`填写`Platform`喔,`Value`里填写`1`喔.
8+
- 要在**Http标头**里添加请求参数才能正常使用,请新建一个****`Platform`,****`1`的参数.
9+
- 在使用**搜索**时,筛选功能不生效.
10+
- 当筛选的**主题**的值为`推荐`时,**地区/进度**的值不生效.
911

1012
## 登录
1113

index.js

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
1+
async function setMangaListFilterOptions() {
2+
const url = 'https://api.mangacopy.com/api/v3/h5/filter/comic/tags';
3+
try {
4+
let result = [{
5+
label: '主题',
6+
name: 'theme',
7+
options: [{
8+
label: '推荐',
9+
value: 'recommend'
10+
}, {
11+
label: '全部',
12+
value: 0
13+
}]
14+
},
15+
{
16+
label: '地区/进度',
17+
name: 'top',
18+
options: [{
19+
label: '全部',
20+
value: 0
21+
}]
22+
}
23+
]
24+
const rawResponse = await window.Rulia.httpRequest({
25+
url: url,
26+
method: 'GET',
27+
payload: 'format=json&type=1'
28+
});
29+
const response = JSON.parse(rawResponse);
30+
for (var item of response.results.theme) {
31+
result[0].options.push({
32+
label: item.name,
33+
value: item.path_word
34+
})
35+
}
36+
for (var item of response.results.top) {
37+
result[1].options.push({
38+
label: item.name,
39+
value: item.path_word
40+
})
41+
}
42+
window.Rulia.endWithResult(result);
43+
} catch (error) {
44+
window.Rulia.endWithResult([])
45+
}
46+
}
47+
48+
149
async function getMangaListByRecommend(page, pageSize) {
250
const url =
351
'https://api.mangacopy.com/api/v3/recs';
@@ -25,6 +73,46 @@ async function getMangaListByRecommend(page, pageSize) {
2573
}
2674
}
2775

76+
async function getMangaListByCategory(page, pageSize, filterOptions) {
77+
if (filterOptions.theme == 'recommend') {
78+
return await getMangaListByRecommend(page, pageSize);
79+
} else {
80+
const url = 'https://api.mangacopy.com/api/v3/comics';
81+
try {
82+
var theme = '';
83+
var top = '';
84+
if (filterOptions.theme && filterOptions.theme != 0) {
85+
theme = '&theme=' + filterOptions.theme;
86+
}
87+
if (filterOptions.top && filterOptions.top != 0) {
88+
top = '&top=' + filterOptions.top;
89+
}
90+
var payload = '_update=true&format=json&free_type=1&limit=' + pageSize + '&offset=' + ((page - 1) *
91+
pageSize) + '&ordering=popular' + theme + top;
92+
const rawResponse = await window.Rulia.httpRequest({
93+
url: url,
94+
method: 'GET',
95+
payload: payload
96+
})
97+
const response = JSON.parse(rawResponse);
98+
var result = {
99+
list: []
100+
}
101+
for (var manga of response.results.list) {
102+
var comic = {
103+
title: manga.name,
104+
url: 'https://www.mangacopy.com/comic/' + manga.path_word,
105+
coverUrl: manga.cover
106+
}
107+
result.list.push(comic);
108+
}
109+
window.Rulia.endWithResult(result);
110+
} catch (error) {
111+
window.Rulia.endWithException(error.message);
112+
}
113+
}
114+
}
115+
28116
async function getMangaListBySearching(page, pageSize, keyword) {
29117
const url =
30118
'https://api.mangacopy.com/api/v3/search/comic';
@@ -53,11 +141,11 @@ async function getMangaListBySearching(page, pageSize, keyword) {
53141
}
54142
}
55143

56-
async function getMangaList(page, pageSize, keyword) {
144+
async function getMangaList(page, pageSize, keyword, rawFilterOptions) {
57145
if (keyword) {
58146
return await getMangaListBySearching(page, pageSize, keyword);
59147
} else {
60-
return await getMangaListByRecommend(page, pageSize);
148+
return await getMangaListByCategory(page, pageSize, JSON.parse(rawFilterOptions));
61149
}
62150
}
63151

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "@rulia/CopyManga",
3-
"title": "拷贝漫画",
4-
"description": "拷贝漫画插件.",
5-
"version": "0.0.2",
6-
"author": "LittleStar_OuO",
7-
"tags": ["Copy", "Manga","CopyManga"],
8-
"homepage": "https://github.com/LittleStar-OuO/plugin.CopyManga"
2+
"name": "@rulia/CopyManga",
3+
"title": "拷贝漫画",
4+
"description": "拷贝漫画插件.",
5+
"version": "0.0.3",
6+
"author": "LittleStar_OuO",
7+
"tags": ["Copy", "Manga", "CopyManga"],
8+
"homepage": "https://github.com/LittleStar-OuO/plugin.CopyManga"
99
}

0 commit comments

Comments
 (0)