|
|
@@ -18,7 +18,7 @@ const CACHE_PREFIX = "art_v1";
|
|
|
// const CACHE_EXPIRES = 60; // 60s刷新一次
|
|
|
const CACHE_EXPIRES = 3600; // 1小时刷新一次即可
|
|
|
|
|
|
-const artSelect = 'name title desc copy width height date publishTime tags lastMod mystery hasSpecial useSpecialThumb publishVersion lock pageId';
|
|
|
+const artSelect = 'name title desc seoTitle seoDescription width height date publishTime tags lastMod mystery hasSpecial useSpecialThumb publishVersion lock pageId';
|
|
|
|
|
|
|
|
|
// 路由:设置语言
|
|
|
@@ -1171,9 +1171,11 @@ router.get('/:lang/coloring-page/:str', function (req, res, next) {
|
|
|
organizeDetail(doc, lang, imageType);
|
|
|
|
|
|
// find relate
|
|
|
- let tags = [...doc.tags];
|
|
|
+ let mytags = [...doc.tags];
|
|
|
let cates = categories.map(e => e.id);
|
|
|
- tags = tags.filter(e => !cates.includes(e));
|
|
|
+ let alltags = tags.map(e => e.tag);
|
|
|
+ mytags = mytags.filter(e => !cates.includes(e) && alltags.includes(e));
|
|
|
+ if (mytags.length == 0) mytags = [...doc.tags];
|
|
|
|
|
|
let query = {
|
|
|
page: req.query.page,
|
|
|
@@ -1182,7 +1184,7 @@ router.get('/:lang/coloring-page/:str', function (req, res, next) {
|
|
|
orderBy: 'publishTime',
|
|
|
order: 'desc',
|
|
|
base: { open: true, status: 9000 },
|
|
|
- filters: { tags },
|
|
|
+ filters: { tags: mytags },
|
|
|
}
|
|
|
|
|
|
let result = await getListBuilder(query, models.Art);
|
|
|
@@ -1190,8 +1192,8 @@ router.get('/:lang/coloring-page/:str', function (req, res, next) {
|
|
|
|
|
|
|
|
|
let data = {
|
|
|
- title: `${doc.title}`,
|
|
|
- description: `${doc.desc}`,
|
|
|
+ title: `${doc.seoTitle}`,
|
|
|
+ description: `${doc.seoDescription}`,
|
|
|
detail: doc,
|
|
|
data: result.data,
|
|
|
page: result.page,
|
|
|
@@ -1261,9 +1263,11 @@ router.get('/:lang/detail/:id', function (req, res, next) {
|
|
|
organizeDetail(doc, lang, imageType);
|
|
|
|
|
|
// find relate
|
|
|
- let tags = [...doc.tags];
|
|
|
+ let mytags = [...doc.tags];
|
|
|
let cates = categories.map(e => e.id);
|
|
|
- tags = tags.filter(e => !cates.includes(e));
|
|
|
+ let alltags = tags.map(e => e.tag);
|
|
|
+ mytags = mytags.filter(e => !cates.includes(e) && alltags.includes(e));
|
|
|
+ if (mytags.length == 0) mytags = [...doc.tags];
|
|
|
|
|
|
let query = {
|
|
|
page: req.query.page,
|
|
|
@@ -1272,15 +1276,15 @@ router.get('/:lang/detail/:id', function (req, res, next) {
|
|
|
orderBy: 'publishTime',
|
|
|
order: 'desc',
|
|
|
base: { open: true, status: 9000 },
|
|
|
- filters: { tags },
|
|
|
+ filters: { tags: mytags },
|
|
|
}
|
|
|
|
|
|
let result = await getListBuilder(query, models.Art);
|
|
|
organizeData(result.data, lang, imageType);
|
|
|
|
|
|
let data = {
|
|
|
- title: `${doc.title}`,
|
|
|
- description: `${doc.desc}`,
|
|
|
+ title: `${doc.seoTitle}`,
|
|
|
+ description: `${doc.seoDescription}`,
|
|
|
data: doc,
|
|
|
translate,
|
|
|
lang,
|
|
|
@@ -1477,14 +1481,23 @@ const organizeDetail = (doc, lang, imageType) => {
|
|
|
console.error(e.message);
|
|
|
}
|
|
|
}
|
|
|
- if (doc.copy) {
|
|
|
+ if (doc.seoTitle) {
|
|
|
try {
|
|
|
- let copyJson = JSON.parse(doc.copy);
|
|
|
- doc.copy = copyJson && copyJson[lang] ? copyJson[lang] : '';
|
|
|
+ let seoTitleJson = JSON.parse(doc.seoTitle);
|
|
|
+ doc.seoTitle = seoTitleJson && seoTitleJson[lang] ? seoTitleJson[lang] : '';
|
|
|
} catch (e) {
|
|
|
console.error(e.message);
|
|
|
}
|
|
|
}
|
|
|
+ if (doc.seoDescription) {
|
|
|
+ try {
|
|
|
+ let seoDescriptionJson = JSON.parse(doc.seoDescription);
|
|
|
+ doc.seoDescription = seoDescriptionJson && seoDescriptionJson[lang] ? seoDescriptionJson[lang] : '';
|
|
|
+ } catch (e) {
|
|
|
+ console.error(e.message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
doc.publishTime = format(new Date(doc.publishTime), 'yyyy-MM-dd');
|
|
|
|
|
|
doc.tags = doc.tags.filter(str => !/[\u4e00-\u9fa5]/.test(str)); // 过滤掉tags中的中文
|