Giter Club home page Giter Club logo

vnews's Introduction

使用Vue2结合ssr

功能类似vue-hackernews-2.0, 只不过内容源换成掘金网站,因而无法使用service worker的push功能。

替换思路

  1. 手动获取掘金网站的目录,接口路径是https://gold-tag-ms.juejin.im/v1/categories需要在掘金官网的控制台中查看,保存到本地文件src/config/category.js
  2. 观察掘金的获取数据列表接口为https://timeline-merger-ms.juejin.im/v1/get_entry_by_rank?src=web&limit=20&category=5562b415e4b00c57d9b94ac8,这部分配置在src/config/website.js中,如果域名更换了,修改该配置即可
  3. 为了解决跨域问题,在server.js中增加转发代理:
app.get('/v1/get_entry_by_rank', (req, res) => {
  console.log(req.url);
  axios({
      method:'get',
      url: websiteConfig.host + req.url,
      responseType:'stream'
  }).then(response => {
      // console.log(response);
      response.data.pipe(res);
  }).catch(err => {
      console.error(err);
      res.status(500).send('500 | Internal Server Error')
  });
});

vnews's People

Contributors

tiodot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.