@ablula/egg-yuque-viewer
Advanced tools
Comparing version 0.1.7 to 0.1.8-beta.0
'use strict'; | ||
exports.yuqueViewer = { | ||
npm: '@ablula/document-client', | ||
npm: '@ablula/document-client@0.1.1-beta.2', | ||
namespace: 'ant-design/course', | ||
@@ -13,3 +13,3 @@ search: '/documents/search', | ||
showEditor: true, | ||
view: '/help', | ||
view: '/documents', | ||
token: '', | ||
@@ -19,3 +19,4 @@ darkMode: true, | ||
blackColor: 'black', | ||
logo: 'https://i.ablula.tech/ablula.png', | ||
logo: 'https://img.alicdn.com/tfs/TB1xYGCA1H2gK0jSZJnXXaT1FXa-204-240.png', | ||
user: 'mark.ck' | ||
}; |
@@ -32,38 +32,36 @@ 'use strict'; | ||
if (view) { | ||
if (showSearch && !search) { | ||
console.warn('show search without search api, search won\'t be shown'.yellow); | ||
} | ||
if (lazyLoad && !prefix) { | ||
throw new Error('prefix required in lazyMode.'); | ||
} | ||
if (showSearch && !search) { | ||
console.warn('show search without search api, search won\'t be shown'.yellow); | ||
} | ||
if (lazyLoad && !prefix) { | ||
throw new Error('prefix required in lazyMode.'); | ||
} | ||
router.get('GetDocument', `${prefix}/*`, async (ctx, next) => { | ||
const locator = ctx.request.path.split(`${prefix}/`)[1]; | ||
const result = await yuqueClient.getDocument(locator); | ||
ctx.status = 200; | ||
ctx.body = result; | ||
next(); | ||
}); | ||
router.get('GetDocument', `${prefix}/*`, async (ctx, next) => { | ||
const locator = ctx.request.path.split(`${prefix}/`)[1]; | ||
const result = await yuqueClient.getDocument(locator); | ||
ctx.status = 200; | ||
ctx.body = result; | ||
next(); | ||
}); | ||
router.get(`Static Resources-${view}/js`, `${view}/index.js`, async ctx => { | ||
return ctx.redirect(`https://cdn.jsdelivr.net/npm/${_config.npm}/build/index.js`); | ||
}); | ||
router.get(`Static Resources-${view}/css`, `${view}/index.css`, async ctx => { | ||
return ctx.redirect(`https://cdn.jsdelivr.net/npm/${_config.npm}/build/index.css`); | ||
}); | ||
router.get(`Static Resources-${view}/js`, `${view}/index.js`, async ctx => { | ||
return ctx.redirect(`https://cdn.jsdelivr.net/npm/${_config.npm}/build/index.js`); | ||
}); | ||
router.get(`Static Resources-${view}/css`, `${view}/index.css`, async ctx => { | ||
return ctx.redirect(`https://cdn.jsdelivr.net/npm/${_config.npm}/build/index.css`); | ||
}); | ||
router.get(`GetDocumentView-${view}`, `${view === '/' ? '' : view}/*`, async (ctx, next) => { | ||
ctx.body = await yuqueClient.getDocumentView(); | ||
next(); | ||
}); | ||
router.get(`GetDocumentView-${view}`, `${view}`, async (ctx, next) => { | ||
ctx.body = await yuqueClient.getDocumentView(); | ||
next(); | ||
}); | ||
router.get(`GetDocumentView-${view}`, `${view}/*`, async (ctx, next) => { | ||
ctx.body = await yuqueClient.getDocumentView(); | ||
next(); | ||
}); | ||
} | ||
}; | ||
router.get(`GetDocumentView-${view}`, `${view === '/' ? '' : view}/*`, async (ctx, next) => { | ||
ctx.body = await yuqueClient.getDocumentView(); | ||
next(); | ||
}); | ||
router.get(`GetDocumentView-${view}`, `${view}`, async (ctx, next) => { | ||
ctx.body = await yuqueClient.getDocumentView(); | ||
next(); | ||
}); | ||
router.get(`GetDocumentView-${view}`, `${view}/*`, async (ctx, next) => { | ||
ctx.body = await yuqueClient.getDocumentView(); | ||
next(); | ||
}); | ||
}; |
@@ -69,4 +69,7 @@ 'use strict'; | ||
const { app, config } = this; | ||
if (!config.user) { | ||
return {}; | ||
} | ||
const namespace = config.namespace; | ||
const docs = await this.request(`${this.baseUrl}/users/mark.ck`); | ||
const docs = await this.request(`${this.baseUrl}/users/${config.user}`); | ||
// console.log('docs: ', docs); | ||
@@ -99,8 +102,14 @@ if (!docs || !docs.data) { | ||
const { config } = this; | ||
let [ directories, documents, userInfo ] = await Promise.all([ | ||
this.getDirectories(), | ||
this.getDocuments(), | ||
this.getUserInfo(), | ||
]); | ||
let directories, documents, userInfo; | ||
if (config.user) { | ||
[ directories, userInfo ] = await Promise.all([ | ||
this.getDirectories(), | ||
this.getUserInfo(), | ||
]); | ||
} else { | ||
directories = await this.getDirectories(); | ||
} | ||
if (directories.length <= 20) { | ||
documents = await this.getDocuments(); | ||
directories = await Promise.all(directories.map(async directory => { | ||
@@ -130,3 +139,3 @@ directory.document = await this.getDocument(directory.locator); | ||
directories, | ||
documents, | ||
documents: documents || [], | ||
userInfo, | ||
@@ -219,2 +228,2 @@ }, config))}</script> | ||
module.exports = LarkService; | ||
module.exports = LarkService; |
{ | ||
"name": "@ablula/egg-yuque-viewer", | ||
"author": "mark.ck", | ||
"version": "0.1.7", | ||
"version": "0.1.8-beta.0", | ||
"description": "egg plugin for yuque viewer", | ||
@@ -41,2 +41,2 @@ "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
12231
292