@ablula/egg-yuque-viewer
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -16,3 +16,3 @@ 'use strict'; | ||
if (search) { | ||
router.get(`GetDocumentView-${search}`, `${search}`, async (ctx, next) => { | ||
router.get(`GetDocumentView-${search}`, `${search}`, async ctx => { | ||
const keywords = ctx.query.keywords; | ||
@@ -19,0 +19,0 @@ if (!keywords) { |
@@ -117,7 +117,26 @@ 'use strict'; | ||
const url = `${this.baseUrl}/repos/${config.namespace}/docs/${locator}`; | ||
const result = await this.request(url); | ||
if (!result || !result.data) { | ||
app.logger.error(`Get document from lark failed, groupId: ${config.namespace}, locator: ${locator}`); | ||
try { | ||
const result = await this.request(url); | ||
if (!result || !result.data) { | ||
app.logger.error(`Get document from lark failed, groupId: ${config.namespace}, locator: ${locator}`); | ||
return { | ||
locator, | ||
title: '', | ||
data: '', | ||
creator: '', | ||
}; | ||
} | ||
app.logger.info('getDocument SUCCESSFULLY'); | ||
const data = result && result.data || {}; | ||
const content = (data.body_html || '').replace(/<img/g, '<img referrerpolicy="no-referrer"'); | ||
return { | ||
locator, | ||
title: data.title, | ||
data: content, | ||
creator: data.creator && data.creator.name, | ||
}; | ||
} catch (e) { | ||
app.logger.error('getDocument failed: ' + e.message); | ||
return { | ||
locator, | ||
title: '', | ||
@@ -128,11 +147,2 @@ data: '', | ||
} | ||
app.logger.info('getDocument SUCCESSFULLY'); | ||
const data = result && result.data || {}; | ||
const content = (data.body_html || '').replace(/<img/g, '<img referrerpolicy="no-referrer"'); | ||
return { | ||
locator, | ||
title: data.title, | ||
data: content, | ||
creator: data.creator && data.creator.name, | ||
}; | ||
} | ||
@@ -139,0 +149,0 @@ |
{ | ||
"name": "@ablula/egg-yuque-viewer", | ||
"author": "mark.ck", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "egg plugin for yuque viewer", | ||
@@ -6,0 +6,0 @@ "eggPlugin": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10608
244