[关闭]
@jeffjade 2018-04-21T21:45:07.000000Z 字数 1195 阅读 907

常用 Shell 命令

Shell


  1. for n in 1 2 3 4 5 6 7 8 9 10
  2. curl -s "http://localhost:4000/api/getAllLinksCount?active=true" -o /dev/null -w "\n%{time_total}"
  3. for n in 1 2 3 4 5 6 7 8 9 10
  4. curl -s "https://nicelinks.site/api/getAllLinksCount?active=true" -o /dev/null -w "\n%{time_total}"
  5. for n in 1 2 3 4 5 6 7 8 9 10
  6. curl -s "https://nicelinks.site/" -o /dev/null -w "\n%{time_total}"

  1. app.use(async(ctx, next) => {
  2. console.log('ctx.request.url', ctx.request.url)
  3. const request = ctx.request
  4. const isRequestPage = request.url.indexOf('/api/') === -1
  5. const isForceUpdate = request.url.indexOf('cache=update') === -1
  6. if (isRequestPage) {
  7. const pageCacheKey = 'nicelinks-index'
  8. const pageInCache = await PageCache.get(pageCacheKey)
  9. console.log('pageInCache', pageInCache)
  10. if (pageInCache && !isForceUpdate) {
  11. return pageInCache
  12. } else {
  13. let filePath = __dirname + '/../../public/index.html'
  14. let content = fs.readFileSync(filePath, 'utf8')
  15. PageCache.set(pageCacheKey, content)
  16. ctx.body = content
  17. return
  18. }
  19. }
  20. await require('./../routes').routes()(ctx, next)
  21. })
  1. deleteNodeByName (source, name) {
  2. // JSON.parse(JSON.stringify(list))✅; but slice() ❌;
  3. let tempList = this.$_.cloneDeep(source)
  4. tempList.forEach(item => {
  5. item[name] && delete item[name]
  6. if (item.children && item.children.length) {
  7. for (let key in item.children) {
  8. delete item.children[key][name]
  9. }
  10. }
  11. })
  12. return tempList
  13. },
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注