1 Star 0 Fork 0

会PS的小码农 / vue-ssr_server-rendering

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Vue.js SSR Template

Vue选择性(针对爬虫)服务端渲染

特性

通过nginx拦截,如果不是爬虫访问则直接走前台渲染,如果是爬虫则走服务端渲染。github上很多都是全走服务器渲染的demo 故做了这个小demo,以作为博客前端脚手架

Build Setup

# npm
npm install

# yarn
yarn

# develop
npm run dev

# deploy
npm run deploy

# build 
npm run build

Project Structure


project /
  build /
    dev-server.js
    vue-loader.conf.js
    webpack.base.conf.js
    webpack.client.conf.js
    webpack.server.conf.js
  dist /
  node_modules /
  public /
  src /
    css /
      main.css
    components /
    router /
      index.js
    store /
      index.js
    stylus /
      main.styl
    views /
    app.js
    App.vue
    client-entry.js
    index.html
    server-entry.js
  .gitignore
  app.js
  package.json

nginx 伪静态

location / {
  try_files $uri $uri/ /index.html;
}

nginx 爬虫访问分离配置(很重要)

server {
  listen 80;
  server_name mrxn.net mrxn.net;
  set $flag 0;
  if ($host != 'mrxn.net') {
    set $flag 1;
  }
  if ($server_port = 80) {
    set $flag 1;
  }
  if ($scheme = http) {
    set $flag 1;
  }
  if ($http_user_agent ~* (baiduspider|soso|sogou|yahoo|sohu-search|yodao|YoudaoBot|robozilla|msnbot|MJ12bot|NHN|Twiceler)){
    set $flag 2;
  }
  if ($flag = 1){
    rewrite ^/(.*)$ https://mrxn.net/$1 redirect;
  }

  error_page 200 https://mrxn.net:8088;

}

鸣谢

本项目使用vue-ssr而开,感谢github上一位老铁的贡献 vue-ssr

About Vue.js SSR

vue-server-renderer

特殊说明

如果出现正在DEV编译过程中浏览器进行访问可能会报错,关闭浏览器重新编译即可解决

MIT License Copyright (c) 2016 cc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

vue ssr 服务端渲染【nginx拦截前后端渲染分离】 本项目fork自github上 ccforward/vue-ssr 项目 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/liushuai05/vue-ssr_server-rendering.git
git@gitee.com:liushuai05/vue-ssr_server-rendering.git
liushuai05
vue-ssr_server-rendering
vue-ssr_server-rendering
master

搜索帮助

14c37bed 8189591 565d56ea 8189591