├── comUtils ├── request.js ├── axios.js ├── transforms.js └── api-requester.js ├── components ├── Nav_L.js ├── Nav_R.js ├── view │ ├── Nav_L.js │ ├── Nav_R.js │ ├── Footer.js │ ├── Layout.js │ └── Header.js ├── next-seo │ ├── utils │ │ └── markup.js │ ├── index.js │ ├── meta │ │ ├── defaultSEO.jsx │ │ ├── __tests__ │ │ │ ├── __snapshots__ │ │ │ │ └── buildTags.test.jsx.snap │ │ │ └── buildTags.test.jsx │ │ └── buildTags.jsx │ └── jsonld │ │ ├── course.jsx │ │ ├── blog.jsx │ │ └── article.jsx ├── Footer.js ├── Layout.js ├── Header.js └── order-kefu │ ├── index.js │ └── style.css ├── pages ├── active │ ├── _componentsA.js │ └── index.js ├── error.js ├── _app.js ├── _document.js ├── index.js └── _error.js ├── .vscode └── settings.json ├── .next ├── static │ ├── webpack │ │ └── d2f734234e2340b8923b.hot-update.json │ ├── chunks │ │ ├── 0.js.map │ │ ├── 0.js │ │ ├── styles.js.map │ │ └── styles.js │ └── css │ │ └── static │ │ └── development │ │ └── pages │ │ ├── index.js.chunk.css.map │ │ └── index.js.chunk.css ├── server │ ├── ssr-module-cache.js │ ├── pages-manifest.json │ └── static │ │ └── development │ │ └── pages │ │ ├── _document.js.map │ │ ├── _error.js.map │ │ ├── _error.js │ │ ├── _document.js │ │ ├── _app.js.map │ │ └── index.js.map ├── react-loadable-manifest.json └── build-manifest.json ├── .gitignore ├── asserts ├── css │ ├── antd-custom.less │ ├── footer.less │ ├── styles.less │ ├── home.less │ ├── kefu.less │ ├── reset.css │ └── header.less └── images │ ├── header.jpg │ ├── page-1.jpg │ ├── page-2.jpg │ ├── page-3.jpg │ ├── page-4.jpg │ ├── page-5.jpg │ └── page-6.jpg ├── static ├── images │ ├── ssr.jpg │ ├── ssr1.jpg │ ├── header.jpg │ ├── logoh2.png │ ├── page-1.jpg │ ├── page-2.jpg │ ├── page-3.jpg │ ├── page-4.jpg │ ├── page-5.jpg │ └── page-6.jpg ├── js │ ├── kefu.js │ └── jquery.fullPage.min.js └── css │ └── jquery.fullPage.css ├── .babelrc ├── config └── index.js ├── stores ├── index.js ├── home │ └── index.js └── withStore.js ├── env ├── .env.testing ├── .env.development └── .env.production ├── seo ├── base-seo.js └── home-seo.js ├── next.config.js ├── README.md ├── package.json └── server.js /comUtils/request.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /components/Nav_L.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /components/Nav_R.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /components/view/Nav_L.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /components/view/Nav_R.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pages/active/_componentsA.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "git.ignoreLimitWarning": true 3 | } -------------------------------------------------------------------------------- /.next/static/webpack/d2f734234e2340b8923b.hot-update.json: -------------------------------------------------------------------------------- 1 | {"h":"585e2fe9d9d571bad90a","c":{}} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | *.log 4 | package-lock.json 5 | yarn.lock 6 | node_modules/* 7 | .next/ 8 | -------------------------------------------------------------------------------- /asserts/css/antd-custom.less: -------------------------------------------------------------------------------- 1 | @primary-color: #fff; 2 | @layout-header-height: 40px; 3 | @border-radius-base: 0px; 4 | -------------------------------------------------------------------------------- /components/next-seo/utils/markup.js: -------------------------------------------------------------------------------- 1 | const markup = jsonld => ({ __html: jsonld }); 2 | 3 | export default markup; 4 | -------------------------------------------------------------------------------- /static/images/ssr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1degrees/next-react-mobx-antd-boilerplate/HEAD/static/images/ssr.jpg -------------------------------------------------------------------------------- /static/images/ssr1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1degrees/next-react-mobx-antd-boilerplate/HEAD/static/images/ssr1.jpg -------------------------------------------------------------------------------- /.next/static/chunks/0.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"static/chunks/0.js","sources":[],"mappings":";;;;;;;;;;;;;;A","sourceRoot":""} -------------------------------------------------------------------------------- /asserts/images/header.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1degrees/next-react-mobx-antd-boilerplate/HEAD/asserts/images/header.jpg -------------------------------------------------------------------------------- /asserts/images/page-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1degrees/next-react-mobx-antd-boilerplate/HEAD/asserts/images/page-1.jpg -------------------------------------------------------------------------------- /asserts/images/page-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1degrees/next-react-mobx-antd-boilerplate/HEAD/asserts/images/page-2.jpg -------------------------------------------------------------------------------- /asserts/images/page-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1degrees/next-react-mobx-antd-boilerplate/HEAD/asserts/images/page-3.jpg -------------------------------------------------------------------------------- /asserts/images/page-4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1degrees/next-react-mobx-antd-boilerplate/HEAD/asserts/images/page-4.jpg -------------------------------------------------------------------------------- /asserts/images/page-5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1degrees/next-react-mobx-antd-boilerplate/HEAD/asserts/images/page-5.jpg -------------------------------------------------------------------------------- /asserts/images/page-6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1degrees/next-react-mobx-antd-boilerplate/HEAD/asserts/images/page-6.jpg -------------------------------------------------------------------------------- /static/images/header.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1degrees/next-react-mobx-antd-boilerplate/HEAD/static/images/header.jpg -------------------------------------------------------------------------------- /static/images/logoh2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1degrees/next-react-mobx-antd-boilerplate/HEAD/static/images/logoh2.png -------------------------------------------------------------------------------- /static/images/page-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1degrees/next-react-mobx-antd-boilerplate/HEAD/static/images/page-1.jpg -------------------------------------------------------------------------------- /static/images/page-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1degrees/next-react-mobx-antd-boilerplate/HEAD/static/images/page-2.jpg -------------------------------------------------------------------------------- /static/images/page-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1degrees/next-react-mobx-antd-boilerplate/HEAD/static/images/page-3.jpg -------------------------------------------------------------------------------- /static/images/page-4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1degrees/next-react-mobx-antd-boilerplate/HEAD/static/images/page-4.jpg -------------------------------------------------------------------------------- /static/images/page-5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1degrees/next-react-mobx-antd-boilerplate/HEAD/static/images/page-5.jpg -------------------------------------------------------------------------------- /static/images/page-6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1degrees/next-react-mobx-antd-boilerplate/HEAD/static/images/page-6.jpg -------------------------------------------------------------------------------- /.next/server/ssr-module-cache.js: -------------------------------------------------------------------------------- 1 | 2 | /* This cache is used by webpack for instantiated modules */ 3 | module.exports = {} 4 | -------------------------------------------------------------------------------- /asserts/css/footer.less: -------------------------------------------------------------------------------- 1 | @import "~antd/dist/antd.less"; 2 | @import "./antd-custom.less"; 3 | @import "./header.less"; 4 | @import "./footer.less"; -------------------------------------------------------------------------------- /components/Footer.js: -------------------------------------------------------------------------------- 1 | import Head from 'next/head' 2 | 3 | export default () => ( 4 |
5 |
6 | ) 7 | -------------------------------------------------------------------------------- /components/view/Footer.js: -------------------------------------------------------------------------------- 1 | import Head from 'next/head' 2 | 3 | export default () => ( 4 |
5 |
6 | ) 7 | -------------------------------------------------------------------------------- /.next/server/pages-manifest.json: -------------------------------------------------------------------------------- 1 | {"/_app":"static\\development\\pages\\_app.js","/_document":"static\\development\\pages\\_document.js","/_error":"static\\development\\pages\\_error.js","/index":"static\\development\\pages\\index.js","/":"static\\development\\pages\\index.js"} -------------------------------------------------------------------------------- /components/next-seo/index.js: -------------------------------------------------------------------------------- 1 | import DefaultSeo from './meta/defaultSEO'; 2 | import ArticleJsonLd from './jsonld/article'; 3 | import BlogJsonLd from './jsonld/blog'; 4 | import CourseJsonLd from './jsonld/course'; 5 | 6 | export default DefaultSeo; 7 | export { ArticleJsonLd, BlogJsonLd, CourseJsonLd }; 8 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ "next/babel" ], 3 | "plugins": [ 4 | ["@babel/plugin-proposal-decorators", { "legacy": true }], 5 | ["@babel/plugin-proposal-class-properties", { "loose": true }], 6 | [ 7 | "import", 8 | { 9 | "libraryName": "antd", 10 | "style": "less" 11 | } 12 | ] 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | export const WWW_URL = process.env.WWW_URL; 2 | 3 | export const WORKER_URL = process.env.WORKER_URL; 4 | 5 | export const SERVICE_URL = process.env.SERVICE_URL; 6 | 7 | export const EVENT_URL = process.env.EVENT_URL; 8 | 9 | export const FRONTEND_URL = process.env.FRONTEND_URL; 10 | 11 | export const APP_URL = process.env.APP_URL; 12 | -------------------------------------------------------------------------------- /stores/index.js: -------------------------------------------------------------------------------- 1 | import HomeStore from './home'; 2 | 3 | 4 | let store = null; 5 | function initStore (isServer) { 6 | if (isServer) { 7 | return { homeStore : new HomeStore() }; 8 | } else { 9 | if (store === null) { 10 | store = { homeStore : new HomeStore() } 11 | } 12 | return store 13 | } 14 | } 15 | export default initStore; -------------------------------------------------------------------------------- /env/.env.testing: -------------------------------------------------------------------------------- 1 | USER_URL=//www.zhangxiao.club/ 2 | USER_API=//www.zhangxiao.club/ 3 | WWW_URL=//www.zhangxiao.club/ 4 | WORKER_URL=//www.zhangxiao.club/ 5 | MASTER_URL=//www.zhangxiao.club/ 6 | SERVICE_URL=//www.zhangxiao.club/ 7 | EVENT_URL=//www.zhangxiao.club/ 8 | CITY_API=//www.zhangxiao.club/ 9 | FRONTEND_URL=//www.zhangxiao.club/ 10 | APP_URL=//www.zhangxiao.club/ -------------------------------------------------------------------------------- /env/.env.development: -------------------------------------------------------------------------------- 1 | USER_URL=//www.zhangxiao.club/ 2 | USER_API=//www.zhangxiao.club/ 3 | WWW_URL=//www.zhangxiao.club/ 4 | WORKER_URL=//www.zhangxiao.club/ 5 | MASTER_URL=//www.zhangxiao.club/ 6 | SERVICE_URL=//www.zhangxiao.club/ 7 | EVENT_URL=//www.zhangxiao.club/ 8 | CITY_API=//www.zhangxiao.club/ 9 | FRONTEND_URL=//www.zhangxiao.club/ 10 | APP_URL=//www.zhangxiao.club/ -------------------------------------------------------------------------------- /env/.env.production: -------------------------------------------------------------------------------- 1 | USER_URL=//www.zhangxiao.club/ 2 | USER_API=//www.zhangxiao.club/ 3 | WWW_URL=//www.zhangxiao.club/ 4 | WORKER_URL=//www.zhangxiao.club/ 5 | MASTER_URL=//www.zhangxiao.club/ 6 | SERVICE_URL=//www.zhangxiao.club/ 7 | EVENT_URL=//www.zhangxiao.club/ 8 | CITY_API=//www.zhangxiao.club/ 9 | FRONTEND_URL=//www.zhangxiao.club/ 10 | APP_URL=//www.zhangxiao.club/ 11 | -------------------------------------------------------------------------------- /static/js/kefu.js: -------------------------------------------------------------------------------- 1 | (function (w, d, s, i, v, j, b) { 2 | w[i] = w[i] || function () { 3 | (w[i].v = w[i].v || []).push(arguments) 4 | }; 5 | j = d.createElement(s), 6 | b = d.getElementsByTagName(s)[0]; 7 | j.async = true; 8 | j.charset = "UTF-8"; 9 | j.src = "https://www.v5kf.com/151447/v5kf.js"; 10 | b.parentNode.insertBefore(j, b); 11 | })(window, document, "script", "V5CHAT"); -------------------------------------------------------------------------------- /stores/home/index.js: -------------------------------------------------------------------------------- 1 | import { action, observable } from 'mobx' 2 | 3 | export default class HomeStore { 4 | @observable lastUpdate = 0 5 | @observable light = false 6 | 7 | constructor (lastUpdate) { 8 | this.lastUpdate = lastUpdate 9 | } 10 | 11 | @action start = () => { 12 | this.timer = setInterval(() => { 13 | this.lastUpdate = Date.now() 14 | this.light = true 15 | }, 1000) 16 | } 17 | 18 | stop = () => clearInterval(this.timer) 19 | } -------------------------------------------------------------------------------- /.next/static/chunks/0.js: -------------------------------------------------------------------------------- 1 | (window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],{ 2 | 3 | /***/ "./node_modules/next/dist/client/noop.js": 4 | /*!***********************************************!*\ 5 | !*** ./node_modules/next/dist/client/noop.js ***! 6 | \***********************************************/ 7 | /*! no static exports found */ 8 | /***/ (function(module, exports, __webpack_require__) { 9 | 10 | "use strict"; 11 | 12 | 13 | /***/ }) 14 | 15 | }]); 16 | //# sourceMappingURL=0.js.map -------------------------------------------------------------------------------- /pages/error.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default class Error extends React.Component { 4 | static getInitialProps({ res, err }) { 5 | const statusCode = res ? res.statusCode : err ? err.statusCode : null; 6 | return { statusCode } 7 | } 8 | 9 | render() { 10 | return ( 11 |

12 | {this.props.statusCode 13 | ? `An error ${this.props.statusCode} occurred on server` 14 | : 'An error occurred on client'} 15 |

16 | ) 17 | } 18 | } -------------------------------------------------------------------------------- /asserts/css/styles.less: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: xiao·Zhang 3 | * @Date: 2018-08-09 11:03:25 4 | * @Last Modified by: xiao·Zhang 5 | * @Last Modified time: 2018-10-10 11:57:54 6 | * @file: 页面CSS汇总样式文件 7 | */ 8 | 9 | @import "./reset.css"; 10 | @import "~antd/dist/antd.less"; 11 | @import "./antd-custom.less"; 12 | @import "./home.less"; 13 | @import "./header.less"; 14 | @import "./kefu.less"; 15 | 16 | li { 17 | list-style: none; 18 | } 19 | 20 | .link { 21 | display: inline-block; 22 | margin: 2px 6px; 23 | font-size: 14px; 24 | color:blue; 25 | cursor: pointer; 26 | } 27 | 28 | .hide { 29 | display: none !important; 30 | } -------------------------------------------------------------------------------- /components/next-seo/meta/defaultSEO.jsx: -------------------------------------------------------------------------------- 1 | import Head from 'next/head'; 2 | import PropTypes from 'prop-types'; 3 | import React from 'react'; 4 | import buildTags from './buildTags'; 5 | 6 | class DefaultSeo extends React.Component { 7 | constructor(props) { 8 | super(props); 9 | if (!props.config) { 10 | throw new Error('[next-seo] You must supply an SEO configuration'); 11 | } 12 | } 13 | 14 | render() { 15 | const { config } = this.props; 16 | return {buildTags(config)}; 17 | } 18 | } 19 | 20 | DefaultSeo.propTypes = { 21 | config: PropTypes.object.isRequired, 22 | }; 23 | 24 | export default DefaultSeo; 25 | -------------------------------------------------------------------------------- /seo/base-seo.js: -------------------------------------------------------------------------------- 1 | export default { 2 | "title": '万师傅-中国领先的家居服务平台|家具、卫浴、灯具等配送安装维修网', 3 | "Content-Type": 'text/html; charset=utf-8', 4 | "X-UA-Compatible": 'IE=edge,chrome=1', 5 | "force-rendering": 'webkit', 6 | "renderer" : 'webkit', 7 | "viewport": 'width=device-width, initial-scale=1', 8 | "keywords": '家具拆装,家具配送,家具安装,家具维修', 9 | "description": '万师傅是全国专业家居售后服务网站,提供【家具】【晾衣架】【灯具】【卫浴】【 墙纸地毯】的拆装,搬运等服务担保交易;师傅覆盖全国600多个城市,快速,便捷,省钱,有保障!', 10 | "360-site-verification" : '5dda074586814ec11ca818e715f3f8d0', 11 | "google-site-verification" : 'uSG4Wt-p0CWw3m75z9xAKV-LH_QEyVTe-W1el-wrjv8', 12 | "author": "zhangxiao@wshifu.com", 13 | }; -------------------------------------------------------------------------------- /pages/active/index.js: -------------------------------------------------------------------------------- 1 | import React, { Component }from 'react' 2 | import Router, { withRouter } from 'next/router' 3 | import Layout from '@components/view/Layout.js' 4 | 5 | class Index extends Component { 6 | static getInitialProps({ req, res, err }) { 7 | console.log('第二个页面getInitialProps') 8 | const statusCode = res ? res.statusCode : err ? err.statusCode : null; 9 | return { statusCode } 10 | } 11 | 12 | render() { 13 | return ( 14 | 15 |
16 |
活动页面
17 |
18 |
19 | ) 20 | } 21 | } 22 | 23 | export default withRouter(Index) -------------------------------------------------------------------------------- /comUtils/axios.js: -------------------------------------------------------------------------------- 1 | import Axios from 'axios'; 2 | import { isPlainObject } from 'lodash/lang'; 3 | import qs from 'qs' 4 | import { BASE_URL } from '../config' 5 | // import { camelizeKeys, snakeizeKeys } from './transforms'; 6 | 7 | const axios = Axios.create({ 8 | baseURL: BASE_URL, 9 | timeout: 3000, 10 | withCredentials: true, 11 | responseType: 'json', 12 | transformRequest(data) { 13 | if (isPlainObject(data)) data = qs.stringify(data); 14 | return data; 15 | }, 16 | // transformResponse(data) { 17 | // // data comes as string in IE 18 | // if (typeof data === 'string' && data.length) data = JSON.parse(data); 19 | // return data; 20 | // } 21 | }); 22 | 23 | export default axios; 24 | -------------------------------------------------------------------------------- /.next/react-loadable-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "./noop": [ 3 | { 4 | "id": "./node_modules/next/dist/client/noop.js", 5 | "name": "./node_modules/next/dist/client/noop.js", 6 | "file": "static/chunks/0.js", 7 | "publicPath": "static/chunks/0.js" 8 | } 9 | ], 10 | "../../asserts/css/styles.less": [ 11 | { 12 | "id": "./asserts/css/styles.less", 13 | "name": "./asserts/css/styles.less", 14 | "file": "static/chunks/styles.js", 15 | "publicPath": "static/chunks/styles.js" 16 | } 17 | ], 18 | "undefined": [ 19 | { 20 | "id": 5, 21 | "name": null, 22 | "file": "static/chunks/styles.js", 23 | "publicPath": "static/chunks/styles.js" 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /components/view/Layout.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: xiao·Zhang 3 | * @Date: 2018-08-09 11:03:25 4 | * @Last Modified by: xiao·Zhang 5 | * @Last Modified time: 2018-10-10 11:48:59 6 | * @file: 页面布局组件 7 | */ 8 | 9 | import React, { Component }from 'react' 10 | import Head from 'next/head' 11 | import Header from './Header' 12 | import Footer from './Footer' 13 | import OrderAndKefu from '../order-kefu' 14 | 15 | import '../../asserts/css/styles.less' 16 | // @inject('homeStore') @observer 17 | class Layout extends Component { 18 | render () { 19 | let { children } = this.props; 20 | return ( 21 |
22 |
23 | 24 | {children} 25 |
27 | ) 28 | } 29 | } 30 | 31 | export default Layout; -------------------------------------------------------------------------------- /.next/build-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "devFiles": [ 3 | "static/development/dll/dll_4a2ab6ce0cb456fbfead.js" 4 | ], 5 | "pages": { 6 | "/_app": [ 7 | "static/runtime/webpack.js", 8 | "static/runtime/main.js" 9 | ], 10 | "/_error": [ 11 | "static/runtime/webpack.js", 12 | "static/runtime/main.js" 13 | ], 14 | "/index": [ 15 | "static/runtime/webpack.js", 16 | "static/css/styles.chunk.css", 17 | "static/chunks/styles.js", 18 | "static/css/static/development/pages/index.js.chunk.css", 19 | "static/runtime/main.js" 20 | ], 21 | "/": [ 22 | "static/runtime/webpack.js", 23 | "static/css/styles.chunk.css", 24 | "static/chunks/styles.js", 25 | "static/css/static/development/pages/index.js.chunk.css", 26 | "static/runtime/main.js" 27 | ] 28 | } 29 | } -------------------------------------------------------------------------------- /pages/_app.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: houzhitao 3 | * @Date: 2018-08-29 14:20:01 4 | * @Last Modified by: xiao·Zhang 5 | * @Last Modified time: 2018-08-30 09:48:01 6 | * @file: 全局注入store,用作状态保留页面 (经测试react生命周期仅在首次进入调用) 7 | */ 8 | 9 | import App, {Container} from 'next/app' 10 | import React from 'react' 11 | import withStore from '../stores/withStore' 12 | import { Provider } from 'mobx-react' 13 | import NextSeo from 'next-seo'; 14 | import SEO from '../seo/base-seo.js'; 15 | 16 | class MyApp extends App { 17 | render () { 18 | const {Component, pageProps, mobxStore} = this.props; 19 | return ( 20 | 21 | 22 | 23 | 24 | 25 | 26 | ) 27 | } 28 | } 29 | 30 | export default withStore(MyApp) 31 | -------------------------------------------------------------------------------- /components/Layout.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: xiao·Zhang 3 | * @Date: 2018-08-09 11:03:25 4 | * @Last Modified by: xiao·Zhang 5 | * @Last Modified time: 2018-08-13 16:42:10 6 | * @file: 页面布局组件 7 | */ 8 | import '../asserts/css/styles.less' 9 | 10 | import React, { Component }from 'react' 11 | import Head from 'next/head' 12 | import Header from './Header.js' 13 | import Footer from './Footer.js' 14 | import { inject, observer } from 'mobx-react' 15 | 16 | @inject('homeStore') @observer 17 | class Layout extends Component { 18 | render () { 19 | let { children } = this.props; 20 | console.log("------layout-------",this.props.homeStore) 21 | return ( 22 |
23 |
24 | {children} 25 |
30 | ) 31 | } 32 | } 33 | 34 | export default Layout; -------------------------------------------------------------------------------- /comUtils/transforms.js: -------------------------------------------------------------------------------- 1 | import { isArray, isPlainObject, camelCase, snakeCase } from 'lodash'; 2 | 3 | const IGNORED = ['_destroy']; 4 | 5 | export function objectRecursiveTransform(obj, func) { 6 | if (isArray(obj)) { 7 | return obj.map(e => objectRecursiveTransform(e, func)); 8 | } 9 | 10 | if (!isPlainObject(obj)) { 11 | return obj; 12 | } 13 | 14 | const result = {}; 15 | 16 | for (const key in obj) { 17 | const val = obj[key]; 18 | const tKey = IGNORED.includes(key) ? key : func(key); 19 | 20 | if (isArray(val) || isPlainObject(val)) { 21 | result[tKey] = objectRecursiveTransform(val, func); 22 | } else { 23 | result[tKey] = val; 24 | } 25 | } 26 | 27 | return result; 28 | } 29 | 30 | export function camelizeKeys(obj) { 31 | return objectRecursiveTransform(obj, camelCase); 32 | } 33 | 34 | export function snakeizeKeys(obj) { 35 | return objectRecursiveTransform(obj, snakeCase); 36 | } 37 | -------------------------------------------------------------------------------- /asserts/css/home.less: -------------------------------------------------------------------------------- 1 | .container { 2 | width: 100%; 3 | .page-1 { 4 | width: 100%; 5 | background: url(/static/images/page-1.jpg) no-repeat; 6 | background-size: cover 7 | } 8 | .page-2 { 9 | width: 100%; 10 | background: url(/static/images/page-2.jpg) no-repeat; 11 | background-size: cover 12 | } 13 | .page-3 { 14 | width: 100%; 15 | background: url(/static/images/page-3.jpg) no-repeat; 16 | background-size: cover 17 | } 18 | .page-4 { 19 | width: 100%; 20 | background: url(/static/images/page-4.jpg) no-repeat; 21 | background-size: cover 22 | } 23 | .page-5 { 24 | width: 100%; 25 | background: url(/static/images/page-5.jpg) no-repeat; 26 | background-size: cover 27 | } 28 | .page-6 { 29 | width: 100%; 30 | background: url(/static/images/page-6.jpg) no-repeat; 31 | background-size: cover 32 | } 33 | } -------------------------------------------------------------------------------- /components/Header.js: -------------------------------------------------------------------------------- 1 | import Head from 'next/head' 2 | 3 | export default () => ( 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | {/* */} 16 | 17 | 23 |
24 | ) 25 | -------------------------------------------------------------------------------- /pages/_document.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: xiao·Zhang 3 | * @Date: 2018-08-29 14:20:01 4 | * @Last Modified by: xiao·Zhang 5 | * @Last Modified time: 2018-10-10 13:52:42 6 | * @file: 全局引入样式,外部组件库页面 (经测试不存react在生命周期) 7 | */ 8 | 9 | import Document, { Head, Main, NextScript } from 'next/document' 10 | 11 | export default class MyDocument extends Document { 12 | static async getInitialProps(ctx) { 13 | const initialProps = await Document.getInitialProps(ctx) 14 | return { ...initialProps } 15 | } 16 | 17 | render() { 18 | return ( 19 | 20 | 21 | 22 | 23 |