feat: remove notOperational routes - design

This commit is contained in:
DIYgod
2023-12-20 00:35:56 +08:00
parent f1a9223aac
commit a63c86a049
9 changed files with 8 additions and 317 deletions
-7
View File
@@ -1448,9 +1448,6 @@ router.get('/uniqlo/stylingbook/:category?', lazyloadRouteHandler('./routes/uniq
// unit-image
router.get('/unit-image/films/:type?', lazyloadRouteHandler('./routes/unit-image/films'));
// digic-picture
router.get('/digic-pictures/:menu/:tags?', lazyloadRouteHandler('./routes/digic-pictures/index'));
// Xposed Module Repository
router.get('/xposed/module/:mod', lazyloadRouteHandler('./routes/xposed/module'));
@@ -1858,11 +1855,7 @@ router.get('/nwpu/:column', lazyloadRouteHandler('./routes/nwpu/index'));
router.get('/us/supremecourt/argument_audio/:year?', lazyloadRouteHandler('./routes/us/supremecourt/argument_audio'));
// 优设网
router.get('/uisdc/talk/:sort?', lazyloadRouteHandler('./routes/uisdc/talk'));
router.get('/uisdc/hangye/:caty?', lazyloadRouteHandler('./routes/uisdc/hangye'));
router.get('/uisdc/news', lazyloadRouteHandler('./routes/uisdc/news'));
router.get('/uisdc/zt/:title?', lazyloadRouteHandler('./routes/uisdc/zt'));
router.get('/uisdc/topic/:title?/:sort?', lazyloadRouteHandler('./routes/uisdc/topic'));
// 美国中央情报局
router.get('/cia/foia-annual-report', lazyloadRouteHandler('./routes/us/cia/foia-annual-report'));
-72
View File
@@ -1,72 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const { menu, tags } = ctx.params;
const url = `https://digicpictures.com/${menu}/${tags}`;
const response = await got({
method: 'get',
url,
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('ul#articles-slider li').get().slice(0, 5);
const articledata = await Promise.all(
list.map(async (item) => {
item = $(item);
const link = item.find('a').attr('href');
const cache = await ctx.cache.get(link);
if (cache) {
return Promise.resolve(JSON.parse(cache));
}
const response2 = await got({
method: 'get',
url: link,
});
const articledata = response2.data;
const $2 = cheerio.load(articledata);
const title = $2('div#main-content>div>div>div').find('h1').text();
const time = $2('div#main-content>div>div>div:nth-child(1) p').text();
const images = $2('#main-slider img')
.get()
.map((item) => $2(item).attr('src'));
const content = $2('div#main-content>div>div>div:nth-child(2)')
.html()
.replace(/<span style="(.*?)">/g, '')
.replace('<span>', '<br>')
.replace(/<.?p>/g, '');
const single = {
title,
link,
time,
content,
images,
};
ctx.cache.set(link, JSON.stringify(single));
return Promise.resolve(single);
})
);
ctx.state.data = {
title: 'Digic Picture',
link: 'https://www.digicpictures.com/',
item: list.map((item, index) => {
let content = '';
const imgstyle = `style="max-width: 650px; height: auto; object-fit: contain; flex: 0 0 auto;"`;
content += `${articledata[index].time}<br>${articledata[index].content}<br>`;
if (articledata[index].images) {
for (let p = 0; p < articledata[index].images.length; p++) {
content += `<img ${imgstyle} src="${articledata[index].images[p]}"><br>`;
}
}
return {
title: articledata[index].title,
description: content,
link: articledata[index].link,
pubDate: new Date(articledata[index].time),
};
}),
};
};
-34
View File
@@ -1,34 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const rootUrl = 'https://www.uisdc.com/news';
const response = await got({
method: 'get',
url: rootUrl,
});
const $ = cheerio.load(response.data);
$('.num').remove();
const items = $('.oneimg')
.map((_, item) => {
item = $(item);
const description = item.find('.item-content').html();
const date = description.match(/[db|DB]-(\d{8})-\d{1}./)[1];
return {
description,
link: rootUrl,
title: item.find('h3').text(),
pubDate: new Date(`${date.substr(0, 4)}-${date.substr(4, 2)}-${date.substr(6, 2)}`).toUTCString(),
};
})
.get();
ctx.state.data = {
title: $('title').text(),
link: rootUrl,
item: items,
};
};
-58
View File
@@ -1,58 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const sort = ctx.params.sort || '';
const rootUrl = 'https://www.uisdc.com';
const currentUrl = `${rootUrl}/talk${sort === '' ? '' : '?od=' + sort}`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const list = $('.content-title a')
.slice(0, 10)
.map((_, item) => {
item = $(item);
const time = item.parent().parent().prev().find('.time').text();
return {
title: item.text(),
link: item.attr('href'),
author: item.find('.author-title h3 a').text(),
pubDate: new Date(time.indexOf('-') === 2 ? `${new Date().getFullYear()}-${time}` : time + ' GMT+8').toUTCString(),
};
})
.get();
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'post',
url: `${rootUrl}/ajax.php`,
form: {
action: 'get_comments',
pid: item.link.substr(item.link.length - 11, 6),
pd: '1',
},
});
item.description = '';
for (const p of detailResponse.data.data) {
item.description = `<div><a href="${p.author_url}">${p.author}</a>${p.city === '' ? '' : `(${p.city})`} 回复于 ${p.time}: <p>${p.content}</p></div>`;
}
return item;
})
)
);
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};
-55
View File
@@ -1,55 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const date = require('@/utils/date');
module.exports = async (ctx) => {
const title = ctx.params.title || 'all';
const sort = ctx.params.sort || '';
const rootUrl = 'https://www.uisdc.com';
const currentUrl = `${rootUrl}/${title === 'all' ? 'hunter' : 'topic/' + title}${sort === '' ? '' : '?od=' + sort}`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const list = $('.item-left h2 a, .topic-item h2 a')
.slice(0, 10)
.map((_, item) => {
item = $(item);
return {
title: item.text(),
link: item.attr('href'),
};
})
.get();
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);
item.author = content('h3.author').text().replace('', '');
content('.info .author').remove();
item.description = content('span.img-zoom').html() + content('.main .info').html();
item.pubDate = date(detailResponse.data.match(/<span class="item">时间:(.*)<\/span>/)[1]);
return item;
})
)
);
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};
-65
View File
@@ -1,65 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const title = ctx.params.title || '';
const rootUrl = 'https://www.uisdc.com';
let query, currentUrl;
if (title === '' || title === 'hot') {
query = '.zt-item a h2';
currentUrl = `${rootUrl}/zt?od=${title}`;
} else {
query = '.list-item-zt .item-content a h2';
currentUrl = `${rootUrl}/zt/${title}`;
}
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const list = $(query)
.slice(0, 10)
.map((_, item) => {
item = $(item);
return {
link: item.parent().attr('href'),
};
})
.get();
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);
if (title === '' || title === 'hot') {
item.title = content('.block-main h2').text();
item.description = content('.block-main p').text();
item.pubDate = new Date(content('.time').eq(0).text()).toUTCString();
} else {
item.title = content('#post_title').text();
item.description = content('.article').html();
item.pubDate = new Date(content('.time').attr('title')).toUTCString();
item.author = content('span.original_author, span.editor').text();
}
return item;
})
)
);
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};
+5
View File
@@ -86,6 +86,11 @@ const requestWrapper = (
options.headers['user-agent'] = config.ua;
}
// Accept
if (!headersLowerCaseKeys.includes('Accept')) {
options.headers.Accept = '*/*';
}
let urlHandler;
try {
urlHandler = new URL(options.url || url);
+3
View File
@@ -98,6 +98,9 @@ module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: currentUrl,
headers: {
Referer: rootUrl,
},
});
const list = response.data.datas.map((item) => ({
-26
View File
@@ -40,12 +40,6 @@
| note | computer-skills | design-resources | design-software | design-tutorial | design\_information |
</Route>
## Digic Picture {#digic-picture}
### Works & News {#digic-picture-works-news}
<Route author="MisteryMonster" example="/digic-pictures/works/real-time-engine" path="/digic-pictures/:menu/:tag?" paramsDesc={['`news`, `works`', 'Under WORK types: `/game-cinematics`, `/feature`, `/making-of`, `/commercials-vfx`, `/real-time-engine`']} notOperational="1" />
## Dribbble {#dribbble}
### Popular {#dribbble-popular}
@@ -188,22 +182,6 @@
## 优设网 {#you-she-wang}
### 设计专题 {#you-she-wang-she-ji-zhuan-ti}
<Route author="nczitzk" example="/uisdc/zt/design-history" path="/uisdc/zt/:title?" paramsDesc={['专题名称,可在标签页的 URL 中找到,如 `design-history`;也可填入 `hot` 展示最热门专题,默认展示最新鲜专题']} notOperational="1">
更多设计专题请参见 [优设专题](https://www.uisdc.com/zt)
</Route>
### 细节猎人 {#you-she-wang-xi-jie-lie-ren}
<Route author="nczitzk" example="/uisdc/topic/all" path="/uisdc/topic/:title?/:sort?" paramsDesc={['标签名称,可在标签页的 URL 中找到', '排序方式,`hot` 指最热门,默认为最新鲜']} notOperational="1">
更多细节标签请参见 [全部标签](https://www.uisdc.com/alltopics)
</Route>
### 设计话题 {#you-she-wang-she-ji-hua-ti}
<Route author="nczitzk" example="/uisdc/talk" path="/uisdc/talk/:sort?" paramsDesc={['排序方式,`hot` 指最热门,默认为最新鲜']} notOperational="1" />
### 行业新闻 {#you-she-wang-hang-ye-xin-wen}
<Route author="nczitzk" example="/uisdc/hangye" path="/uisdc/hangye/:caty?" paramsDesc={['分类,见下表,默认为全部新闻']} anticrawler="1">
@@ -212,10 +190,6 @@
| | events-activity | brand-news | new-products |
</Route>
### 优设读报 {#you-she-wang-you-she-du-bao}
<Route author="nczitzk" example="/uisdc/news" path="/uisdc/news" notOperational="1" />
## 站酷 {#zhan-ku}
### 发现(+ 推荐预设) {#zhan-ku-fa-xian-tui-jian-yu-she}