即刻空值检查 (#835)
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
const url = require('url');
|
||||
|
||||
module.exports = {
|
||||
emptyResponseCheck: (ctx, data) => {
|
||||
if (data.length === 0) {
|
||||
ctx.state.data = {
|
||||
title: '主题 ID 不存在,或该主题暂无内容',
|
||||
};
|
||||
return true;
|
||||
}
|
||||
},
|
||||
topicDataHanding: (data) =>
|
||||
data.map((item) => {
|
||||
let audioName, videoName, linkName;
|
||||
|
||||
@@ -19,8 +19,12 @@ module.exports = async (ctx) => {
|
||||
});
|
||||
|
||||
const data = response.data.data;
|
||||
const topic = data[0].topic;
|
||||
|
||||
if (common.emptyResponseCheck(ctx, data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const topic = data[0].topic;
|
||||
ctx.state.data = {
|
||||
title: `${topic.content} - 即刻主题精选`,
|
||||
link: `https://web.okjike.com/topic/${id}/official`,
|
||||
|
||||
@@ -19,6 +19,11 @@ module.exports = async (ctx) => {
|
||||
});
|
||||
|
||||
const data = response.data.data;
|
||||
|
||||
if (common.emptyResponseCheck(ctx, data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const topic = data[0].topic;
|
||||
|
||||
ctx.state.data = {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const dayjs = require('dayjs');
|
||||
const common = require('./common');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
@@ -19,6 +20,11 @@ module.exports = async (ctx) => {
|
||||
});
|
||||
|
||||
const data = response.data.data;
|
||||
|
||||
if (common.emptyResponseCheck(ctx, data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const title = data[0].topic.content;
|
||||
|
||||
ctx.state.data = {
|
||||
|
||||
Reference in New Issue
Block a user