GithubHelp home page GithubHelp logo

sdgdsffdsfff / itellyou-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from big-camel/itellyou-server

0.0 0.0 0.0 126 KB

electron 离屏渲染 react/vue 等spa单页,不修改原代码满足ssr/seo需求

License: Apache License 2.0

JavaScript 100.00%

itellyou-server's Introduction

使用 Electron 离屏渲染 React/Vue 等SPA单页或异步数据请求,以满足 SEO 需求

配置 config.js

// 需要渲染的本地站点
module.exports.HOST = "http://localhost:8011"
// 拦截数据请求 ,在数据请求执行完毕返回html代码,没有数据请求的情况下默认为600ms返回,
module.exports.FILTER = {
    urls:["http://localhost:8011/api/*"],// 在拦截后,全部数据请求返回后等待10ms读取渲染后的html
    // 在拦截数据url的基础上,可以排除一些同步数据请求
    exclude:({ url }) => {
        return url.indexOf('/user/me') > -1
    }
}

使用

node src/index.js

elector 经常安装失败,建议设置

npm config set electron_mirror https://npm.taobao.org/mirrors/electron/

配置 nginx,搜索引擎反向代理

location / {
    if ($http_user_agent ~* "BaiduSpider|360Spider|Sogou web spider|Bingbot|Sosospider|YisouSpider"){
        proxy_pass   http://localhost:8010;
    }
    root web_root;
    index index.html;
    try_files $uri $uri/ /index.html =404;
}

itellyou-server's People

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.