瀏覽代碼

fast

master
jefry 4 年之前
父節點
當前提交
f81ef9cf57
共有 4 個檔案被更改,包括 116 行新增90 行删除
  1. +6
    -3
      next.config.js
  2. +2
    -22
      pages/_app.js
  3. +42
    -30
      pages/home.js
  4. +66
    -35
      pages/product.js

+ 6
- 3
next.config.js 查看文件

@@ -3,16 +3,19 @@ const withImages = require("next-images");
const withSass = require("@zeit/next-sass"); const withSass = require("@zeit/next-sass");
const webpack = require("webpack"); const webpack = require("webpack");
const path = require("path"); const path = require("path");
const withCSS = require('@zeit/next-css');
// const withCSS = require("@zeit/next-css");


// require("dotenv").config(); // require("dotenv").config();


module.exports = withPlugins([[withSass], [withImages], [withCSS]], {
module.exports = withPlugins([[withSass], [withImages]], {
// env: { // env: {
// API_URL: process.env.API_URL, // API_URL: process.env.API_URL,
// }, // },
trailingSlash: true, trailingSlash: true,
webpack(config, options) {
webpack(config, { dev }) {
if (dev) {
config.devtool = "cheap-module-source-map";
}
config.resolve.modules.push(path.resolve("./")); config.resolve.modules.push(path.resolve("./"));
return config; return config;
}, },


+ 2
- 22
pages/_app.js 查看文件

@@ -24,8 +24,8 @@ import Router from "next/router";
import PageChange from "components/PageChange/PageChange.js"; import PageChange from "components/PageChange/PageChange.js";


import "assets/scss/nextjs-material-kit.scss?v=1.1.0"; import "assets/scss/nextjs-material-kit.scss?v=1.1.0";
Router.events.on("routeChangeStart", url => {
// import styles from "assets/jss/nextjs-material-kit/pages/components.js";
Router.events.on("routeChangeStart", (url) => {
console.log(`Loading: ${url}`); console.log(`Loading: ${url}`);
document.body.classList.add("body-page-transition"); document.body.classList.add("body-page-transition");
ReactDOM.render( ReactDOM.render(
@@ -43,26 +43,6 @@ Router.events.on("routeChangeError", () => {
}); });


export default class MyApp extends App { export default class MyApp extends App {
componentDidMount() {
let comment = document.createComment(`

=========================================================
* NextJS Material Kit v1.1.0 based on Material Kit Free - v2.0.2 (Bootstrap 4.0.0 Final Edition) and Material Kit React v1.8.0
=========================================================

* Product Page: https://www.creative-tim.com/product/nextjs-material-kit
* Copyright 2020 Creative Tim (https://www.creative-tim.com)
* Licensed under MIT (https://github.com/creativetimofficial/nextjs-material-kit/blob/master/LICENSE.md)

* Coded by Creative Tim

=========================================================

* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

`);
document.insertBefore(comment, document.documentElement);
}
static async getInitialProps({ Component, router, ctx }) { static async getInitialProps({ Component, router, ctx }) {
let pageProps = {}; let pageProps = {};




+ 42
- 30
pages/home.js 查看文件

@@ -16,35 +16,44 @@ import Parallax from "components/Parallax/Parallax.js";
import styles from "assets/jss/nextjs-material-kit/pages/components.js"; import styles from "assets/jss/nextjs-material-kit/pages/components.js";
import Button from "components/CustomButtons/Button.js"; import Button from "components/CustomButtons/Button.js";


import GetbusinessPartners from "../api/home/businessPartner.js"
import Getservices from "../api/home/service.js"
import Getcarousels from "../api/home/carousel.js"
import GetbusinessPartners from "../api/home/businessPartner.js";
import Getservices from "../api/home/service.js";
import Getcarousels from "../api/home/carousel.js";


import DataSnackbarContent from "../pages-sections/snackbar.js"; import DataSnackbarContent from "../pages-sections/snackbar.js";
import DataCarousel from "../pages-sections/home/carousel.js"; import DataCarousel from "../pages-sections/home/carousel.js";
import DataService from "../pages-sections/home/service.js"; import DataService from "../pages-sections/home/service.js";
import DataBusinessPartner from "../pages-sections/home/business_partner.js"; import DataBusinessPartner from "../pages-sections/home/business_partner.js";
import CoreValue from "../pages-sections/home/core_value.js"
import CoreValue from "../pages-sections/home/core_value.js";


const useStyles = makeStyles(styles); const useStyles = makeStyles(styles);
const Home = function ({ backend, businessPartners, service, carousel, ...props }) {
const Home = function ({
backend,
businessPartners,
service,
carousel,
...props
}) {
const classes = useStyles(); const classes = useStyles();
const { ...rest } = props; const { ...rest } = props;
<DataService service={props.service}/>
<DataService service={props.service} />;


return ( return (
<div> <div>
<Header <Header
rightLinks={<HeaderLinks/>}
rightLinks={<HeaderLinks />}
fixed fixed
color="info" color="info"
changeColorOnScroll={{ changeColorOnScroll={{
height: 400, height: 400,
color: "white"
color: "white",
}} }}
{...rest} {...rest}
/> />
<Parallax image={require("assets/img/welcome.png")} styles={{marginTop: "50px"}}>
<Parallax
image={require("assets/img/welcome.png")}
styles={{ marginTop: "50px" }}
>
<div className={classes.container}> <div className={classes.container}>
<GridContainer> <GridContainer>
{/* <GridItem> {/* <GridItem>
@@ -69,39 +78,42 @@ const Home = function ({ backend, businessPartners, service, carousel, ...props
<div className={classNames(classes.main, classes.mainRaised)}> <div className={classNames(classes.main, classes.mainRaised)}>
<DataSnackbarContent /> <DataSnackbarContent />
<CoreValue /> <CoreValue />
<DataCarousel carousel={carousel} backend={backend}/>
<DataService service={service} backend={backend}/>
<DataBusinessPartner businessPartners={businessPartners} backend={backend}/>
<DataCarousel carousel={carousel} backend={backend} />
<DataService service={service} backend={backend} />
<DataBusinessPartner
businessPartners={businessPartners}
backend={backend}
/>
</div> </div>
<Footer /> <Footer />
</div> </div>
); );
}
};


export async function getServerSideProps(context) { export async function getServerSideProps(context) {
var businessPartners = [];
var service = [];
var businessPartners = [];
var service = [];
var carousel = []; var carousel = [];
const backend = process.env.BACKEND_SERVER_URI; const backend = process.env.BACKEND_SERVER_URI;


var res = await GetbusinessPartners.GetbusinessPartners();
if (res["STATUS"] === 1) {
businessPartners = res["DATA"]["businessPartners"];
}
var res = await GetbusinessPartners.GetbusinessPartners();
if (res["STATUS"] === 1) {
businessPartners = res["DATA"]["businessPartners"];
}


var res = await Getservices.Getservices();
if (res["STATUS"] === 1) {
service = res["DATA"]["services"];
}
var res = await Getservices.Getservices();
if (res["STATUS"] === 1) {
service = res["DATA"]["services"];
}


var res = await Getcarousels.GetCarousels(); var res = await Getcarousels.GetCarousels();
if (res["STATUS"] === 1) {
carousel = res["DATA"]["carousels"];
}
if (res["STATUS"] === 1) {
carousel = res["DATA"]["carousels"];
}


return {
props: { businessPartners, service, carousel, backend }, // will be passed to the page component as props
};
return {
props: { businessPartners, service, carousel, backend }, // will be passed to the page component as props
};
} }


export default Home;
export default Home;

+ 66
- 35
pages/product.js 查看文件

@@ -16,22 +16,33 @@ import DataProduct from "pages-sections/product/product.js";
import Parallax from "components/Parallax/Parallax.js"; import Parallax from "components/Parallax/Parallax.js";
import styles from "assets/jss/nextjs-material-kit/pages/components.js"; import styles from "assets/jss/nextjs-material-kit/pages/components.js";


import Getproduct from "../api/product/product.js"
import Getproduct from "../api/product/product.js";


const useStyles = makeStyles(styles); const useStyles = makeStyles(styles);


const Product = function ({ backend, yamaha, suzuki, honda, hino, mercedes, bpr, emilia, homes, ...props }) {
const Product = function ({
backend,
yamaha,
suzuki,
honda,
hino,
mercedes,
bpr,
emilia,
homes,
...props
}) {
const classes = useStyles(); const classes = useStyles();
const { ...rest } = props; const { ...rest } = props;
return ( return (
<div> <div>
<Header <Header
rightLinks={<HeaderLinks/>}
rightLinks={<HeaderLinks />}
fixed fixed
color="info" color="info"
changeColorOnScroll={{ changeColorOnScroll={{
height: 400, height: 400,
color: "white"
color: "white",
}} }}
{...rest} {...rest}
/> />
@@ -50,12 +61,22 @@ const Product = function ({ backend, yamaha, suzuki, honda, hino, mercedes, bpr,
</div> </div>
</Parallax> </Parallax>
<div className={classNames(classes.main, classes.mainRaised)}> <div className={classNames(classes.main, classes.mainRaised)}>
<DataProduct yamaha={yamaha} suzuki={suzuki} honda={honda} hino={hino} mercedes={mercedes} bpr={bpr} emilia={emilia} homes={homes} backend={backend}/>
<DataProduct
yamaha={yamaha}
suzuki={suzuki}
honda={honda}
hino={hino}
mercedes={mercedes}
bpr={bpr}
emilia={emilia}
homes={homes}
backend={backend}
/>
</div> </div>
<Footer /> <Footer />
</div> </div>
); );
}
};


export default Product; export default Product;


@@ -70,47 +91,57 @@ export async function getServerSideProps(context) {
var homes = []; var homes = [];
const backend = process.env.BACKEND_SERVER_URI; const backend = process.env.BACKEND_SERVER_URI;


var res = await Getproduct.GetProductYamaha();
if (res["STATUS"] === 1) {
yamaha = res["DATA"]["products"];
}
var res = await Getproduct.GetProductYamaha();
if (res["STATUS"] === 1) {
yamaha = res["DATA"]["products"];
}


var res = await Getproduct.GetProductSuzuki(); var res = await Getproduct.GetProductSuzuki();
if (res["STATUS"] === 1) {
suzuki = res["DATA"]["products"];
}
if (res["STATUS"] === 1) {
suzuki = res["DATA"]["products"];
}


var res = await Getproduct.GetProductHonda(); var res = await Getproduct.GetProductHonda();
if (res["STATUS"] === 1) {
honda = res["DATA"]["products"];
}
if (res["STATUS"] === 1) {
honda = res["DATA"]["products"];
}


var res = await Getproduct.GetProductHino(); var res = await Getproduct.GetProductHino();
if (res["STATUS"] === 1) {
hino = res["DATA"]["products"];
}
if (res["STATUS"] === 1) {
hino = res["DATA"]["products"];
}


var res = await Getproduct.GetProductMercedes(); var res = await Getproduct.GetProductMercedes();
if (res["STATUS"] === 1) {
mercedes = res["DATA"]["products"];
}
if (res["STATUS"] === 1) {
mercedes = res["DATA"]["products"];
}


var res = await Getproduct.GetProductBPR(); var res = await Getproduct.GetProductBPR();
if (res["STATUS"] === 1) {
bpr = res["DATA"]["products"];
}
if (res["STATUS"] === 1) {
bpr = res["DATA"]["products"];
}


var res = await Getproduct.GetProductEmilia(); var res = await Getproduct.GetProductEmilia();
if (res["STATUS"] === 1) {
emilia = res["DATA"]["products"];
}
if (res["STATUS"] === 1) {
emilia = res["DATA"]["products"];
}


var res = await Getproduct.GetProductHomes(); var res = await Getproduct.GetProductHomes();
if (res["STATUS"] === 1) {
homes = res["DATA"]["products"];
}
if (res["STATUS"] === 1) {
homes = res["DATA"]["products"];
}


return {
props: { yamaha, suzuki, honda, hino, mercedes, bpr, emilia, homes, backend }, // will be passed to the page component as props
};
}
return {
props: {
yamaha,
suzuki,
honda,
hino,
mercedes,
bpr,
emilia,
homes,
backend,
}, // will be passed to the page component as props
};
}

Loading…
取消
儲存