parent
2d6a202857
commit
f633d4e96c
|
|
@ -1,4 +1,5 @@
|
|||
const axios = require('../../utils/axios');
|
||||
const { getList } = require('./util');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { category } = ctx.params;
|
||||
|
|
@ -31,10 +32,16 @@ module.exports = async (ctx) => {
|
|||
ctx.state.data = {
|
||||
title: `妹子图-${mapper[category].name}`,
|
||||
link: `http://www.mzitu.com/${category}`,
|
||||
item: data.map((item) => ({
|
||||
title: item.title,
|
||||
description: `<img referrerpolicy="no-referrer" src="${item.thumb_src}">`,
|
||||
link: `http://www.mzitu.com/${item.id}`,
|
||||
})),
|
||||
item: await Promise.all(
|
||||
data.map(async (item) => {
|
||||
const list = await getList(item.id);
|
||||
const listDescription = list.join('');
|
||||
return {
|
||||
title: `${item.title} ${list.length} pages`,
|
||||
description: `<img referrerpolicy="no-referrer" src="${item.thumb_src}"><br />${listDescription}`,
|
||||
link: `http://www.mzitu.com/${item.id}`,
|
||||
};
|
||||
})
|
||||
),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
const axios = require('../../utils/axios');
|
||||
const { getList } = require('./util');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { type = '' } = ctx.params;
|
||||
|
|
@ -15,20 +16,22 @@ module.exports = async (ctx) => {
|
|||
url,
|
||||
});
|
||||
const data = response.data;
|
||||
|
||||
ctx.state.data = {
|
||||
title: '妹子图',
|
||||
link: `http://www.mzitu.com/${type}`,
|
||||
item: data.map((item) => {
|
||||
if (type === 'hot') {
|
||||
item.thumb_src = item.thumb_src_min;
|
||||
}
|
||||
|
||||
return {
|
||||
title: item.title,
|
||||
description: `<img referrerpolicy="no-referrer" src="${item.thumb_src}">`,
|
||||
link: `http://www.mzitu.com/${item.id}`,
|
||||
};
|
||||
}),
|
||||
item: await Promise.all(
|
||||
data.map(async (item) => {
|
||||
if (type === 'hot') {
|
||||
item.thumb_src = item.thumb_src_min;
|
||||
}
|
||||
const list = await getList(item.id);
|
||||
const listDescription = list.join('');
|
||||
return {
|
||||
title: `${item.title} ${list.length} pages`,
|
||||
description: `<img referrerpolicy="no-referrer" src="${item.thumb_src}"><br />${listDescription}`,
|
||||
link: `http://www.mzitu.com/${item.id}`,
|
||||
};
|
||||
})
|
||||
),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
const axios = require('../../utils/axios');
|
||||
const { getList } = require('./util');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let tag = ctx.params.tag;
|
||||
|
|
@ -21,10 +22,16 @@ module.exports = async (ctx) => {
|
|||
ctx.state.data = {
|
||||
title: name,
|
||||
link: `http://www.mzitu.com/tag/${tag}`,
|
||||
item: data.map((item) => ({
|
||||
title: item.title,
|
||||
description: `<img referrerpolicy="no-referrer" src="${item.thumb_src}">`,
|
||||
link: `http://www.mzitu.com/${item.id}`,
|
||||
})),
|
||||
item: await Promise.all(
|
||||
data.map(async (item) => {
|
||||
const list = await getList(item.id);
|
||||
const listDescription = list.join('');
|
||||
return {
|
||||
title: `${item.title} ${list.length} pages`,
|
||||
description: `<img referrerpolicy="no-referrer" src="${item.thumb_src}"><br />${listDescription}`,
|
||||
link: `http://www.mzitu.com/${item.id}`,
|
||||
};
|
||||
})
|
||||
),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
const axios = require('../../utils/axios');
|
||||
|
||||
exports.getList = async (id) => {
|
||||
const contentUrl = `http://adr.meizitu.net/wp-json/wp/v2/i?id=${id}`;
|
||||
const contentResponse = await axios({
|
||||
method: 'get',
|
||||
url: contentUrl,
|
||||
});
|
||||
const content = contentResponse.data.content.split(',');
|
||||
return content.map((url) => {
|
||||
url = url.replace(/"/g, '');
|
||||
return `<img referrerpolicy="no-referrer" src="${url}"><br />`;
|
||||
});
|
||||
};
|
||||
Loading…
Reference in New Issue