Commit 5e39c7b1 by 肖康

同步测试

parent 794a6e44
......@@ -84,7 +84,7 @@ const NavBig = (props: ResponseTypeCateList) => {
items.map((item, index) => {
return (
<li className={router.pathname === item.url ? styles.act : ''} key={item.name + index}>
<Link href={item.url}>{item.name}</Link>
<Link href={item.url} >{item.name}</Link>
</li>
)
})
......
import { QQURL } from "@/configReact";
import { useContext } from "react";
......
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
prefetch: false,
},
reactStrictMode: false, // 关闭 React 严格模式
// 配置代理
async rewrites() {
......@@ -8,6 +11,19 @@ const nextConfig = {
destination: 'http://erpweb.liexindev.net/api/:path*',
}, ];
},
async headers() {
return [
{
source: '/_next/data/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=3600, immutable'
},
],
},
];
},
};
export default nextConfig;
\ No newline at end of file
{
"name": "reactdemo",
"name": "europaWeb",
"version": "0.1.0",
"private": true,
"scripts": {
......@@ -10,7 +10,7 @@
},
"dependencies": {
"axios": "^1.7.2",
"next": "14.2.5",
"next": "13",
"react": "^18",
"react-dom": "^18",
"react-paginate": "^8.2.0",
......@@ -22,7 +22,7 @@
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "14.2.5",
"eslint-config-next": "12",
"typescript": "^5"
}
}
......@@ -8,12 +8,13 @@ import { GetServerSideProps } from 'next';
import { getCateList } from "@/server/getCateList";
import type { ResponseTypeCateList } from '@/components/Header/components/NavBig/types'
export const getStaticProps: GetServerSideProps = async () => {
return getCateList()
}
const Page = (props: { cateList: ResponseTypeCateList }) => {
return (
<>
<main>
......
export type ResponseType = {
success: boolean,
data: Array<{
shopId: string,
shopName: string,
cartList: Array<{
productId: string,
imgUrl: string,
weight: string,
title: string,
price: number,
count: number
}>
}>
}
\ No newline at end of file
......@@ -4,7 +4,9 @@ import '../public/styles/base.scss'
import type { AppProps } from 'next/app';
const MyApp= ({ Component, pageProps }:AppProps) => {
return <Component {...pageProps} />
};
......
......@@ -6,7 +6,7 @@ import { GetServerSideProps } from 'next';
import { getCateList } from "@/server/getCateList";
import type { ResponseTypeCateList } from '@/components/Header/components/NavBig/types'
export const getStaticProps: GetServerSideProps = async () => {
export const getServerSideProps: GetServerSideProps = async (context) => {
return getCateList()
}
......
export type ResponseType = {
success: boolean,
data: Array<{
shopId: string,
shopName: string,
cartList: Array<{
productId: string,
imgUrl: string,
weight: string,
title: string,
price: number,
count: number
}>
}>
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ import { useEffect, useRef, useState } from 'react';
import type { ListSortType } from '@/components/ListSort/types'
import type { dataListItemType } from '@/components/ListOneItem/types'
import type { brandResponseType, requestDataType, brandInfoResponseType, brandInfoType } from './types'
import type { brandResponseType, requestDataType, brandInfoResponseType } from '@/types/brandTypes'
import ListOneItem from '@/components/ListOneItem';
import useRequest from '@/hooks/useRequest';
......@@ -97,10 +97,10 @@ const Page = (props: { cateList: ResponseTypeCateList,brandInfoData:brandInfoRes
<>
<main>
<Header {...props.cateList} />
<BreadNav><strong>"{brandInfo?.brand_name}"的型号搜索结果</strong></BreadNav>
<BreadNav><strong>&quot;{brandInfo?.brand_name}&quot;的型号搜索结果</strong></BreadNav>
<div className={`${styles.mvBrandlistPage} w1226`} >
<div className={`${styles.brandheadsl} row boxsiz`}>
<img src={brandInfo?.brand_logo || 'http://static.ichunt.com//dist/res/home/images/goods_default.png'} alt="" className={styles.brandimg} />
<img src={brandInfo?.brand_logo || 'http://static.ichunt.com//dist/res/home/images/goods_default.png'} alt='' className={styles.brandimg} />
<div className={styles.brandInfo} >
<h2>{brandInfo?.brand_name}</h2>
<div className={styles.textBf}>
......
......@@ -7,10 +7,10 @@ import { getBrandMapData } from "@/server/getBrandMapData";
import type { ResponseTypeCateList } from '@/components/Header/components/NavBig/types'
import type { brandMapResponseType } from './types';
import type { brandMapResponseType } from '@/types/brandMapTypes';
import Link from 'next/link';
export const getStaticProps: GetServerSideProps = async () => {
export const getServerSideProps: GetServerSideProps = async () => {
return getBrandMapData()
}
const BrandMap = (props: { cateList: ResponseTypeCateList, brandMapData: brandMapResponseType }) => {
......
......@@ -6,7 +6,7 @@ import { useEffect, useRef, useState } from 'react';
import type { ListSortType } from '@/components/ListSort/types'
import type { dataListItemType } from '@/components/ListOneItem/types'
import type { classResponseType, requestDataType } from './types'
import type { classResponseType, requestDataType } from '@/types/categoryTypes'
import ListOneItem from '../../components/ListOneItem';
import useRequest from '../../hooks/useRequest';
......
......@@ -7,10 +7,10 @@ import { getClassMapData } from "@/server/getClassMapData";
import Footer from "@/components/Footer";
import Header from "@/components/Header";
import type { classMapResponseType } from './types';
import type { classMapResponseType } from '@/types/classMapTypes';
import type { ResponseTypeCateList } from '@/components/Header/components/NavBig/types'
export const getStaticProps: GetServerSideProps = async () => {
export const getServerSideProps: GetServerSideProps = async () => {
return getClassMapData()
}
......
......@@ -7,7 +7,7 @@ import { GetServerSideProps } from 'next';
import { getCateList } from "@/server/getCateList";
import type { ResponseTypeCateList } from '@/components/Header/components/NavBig/types'
export const getStaticProps: GetServerSideProps = async () => {
export const getServerSideProps: GetServerSideProps = async (context) => {
return getCateList()
}
......
export type ResponseType = {
success: boolean,
data: Array<{
shopId: string,
shopName: string,
cartList: Array<{
productId: string,
imgUrl: string,
weight: string,
title: string,
price: number,
count: number
}>
}>
}
\ No newline at end of file
......@@ -5,7 +5,7 @@ import DetailHead from './components/DetailHead';
import DetailSection from './components/DetailSection';
import BreadNav from '../../components/BreadNav';
import type { DetailResponseType } from './types'
import type { DetailResponseType,skuInfoResponseType } from '@/types/detailTypes'
import Footer from "@/components/Footer";
import Header from "@/components/Header";
......@@ -19,11 +19,11 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
return getDetailData(query.sku_id)
}
const Page = (props: { cateList: ResponseTypeCateList, brandInfoData: DetailResponseType }) => {
const Page = (props: { cateList: ResponseTypeCateList, detailInfoData: DetailResponseType }) => {
const detailData = props.brandInfoData
const detailData = props.detailInfoData
const sku_info:skuInfoResponseType=detailData.data?.sku_info
return (
<>
......@@ -32,10 +32,10 @@ const Page = (props: { cateList: ResponseTypeCateList, brandInfoData: DetailResp
<Header {...props.cateList} />
<div className={styles.mvDetailPage}>
{
detailData && detailData.data?.sku_info ?
sku_info ?
<>
<BreadNav > <strong>{detailData.data?.sku_info?.sku_name}</strong></BreadNav>
<DetailHead {...detailData} />
<DetailHead {...sku_info} />
<DetailSection {...detailData} />
</>
:
......
import QqIcon from "@/components/QqIcon"
import type { DetailResponseType } from '../types'
import type { skuInfoResponseType } from '@/types/detailTypes'
import styles from '../index.module.scss'
import { QQURL } from "@/configReact";
const DetailHead = (props: DetailResponseType) => {
const DetailHead = (props: skuInfoResponseType) => {
const sku_info = props!.data?.sku_info!
const sku_info =props!
return (
<>
......@@ -29,7 +29,7 @@ const DetailHead = (props: DetailResponseType) => {
</div>
</div>
</div>
<div className={`${styles.R} boxsiz`}>
<div className={`${styles.r} boxsiz`}>
<p className='row'>
<span className={styles.items}>库存:{sku_info.stock} </span>
<span className={styles.items}>交期:HK {sku_info.hk_delivery_time}</span>
......@@ -43,7 +43,7 @@ const DetailHead = (props: DetailResponseType) => {
<span className={styles.items}>递增: {sku_info.multiple}</span>
</p>
{
sku_info.ladder_price.map((item,index) => {
(sku_info.ladder_price||[]).map((item,index) => {
return (
<p className='row' key={index}>
<span className={styles.items}> {item.purchase}+</span>
......
import Link from 'next/link'
import type { DetailResponseType } from '../types'
import type { DetailResponseType } from '@/types/detailTypes'
import styles from '../index.module.scss'
......
......@@ -14,7 +14,7 @@ import { getHomeData } from "../server/getHomeData";
import type {ResponseTypeCateList} from '@/components/Header/components/NavBig/types'
import type {ResponseTypeHome} from './index/types'
import type {ResponseTypeHome} from '@/types/indexTypes'
const Page=(props:{cateList:ResponseTypeCateList,homepageList:ResponseTypeHome})=>{
......@@ -42,7 +42,7 @@ const Page=(props:{cateList:ResponseTypeCateList,homepageList:ResponseTypeHome})
//getServerSideProps
export const getStaticProps: GetServerSideProps = async () => {
export const getServerSideProps: GetServerSideProps = async () => {
return getHomeData()
}
......
......@@ -4,6 +4,8 @@ import { Swiper, SwiperSlide } from 'swiper/react';
import { Autoplay, Pagination } from 'swiper/modules';
import 'swiper/css';
import 'swiper/css/pagination';
import Image from 'next/image';
const HomeBanner = () => {
const bannerList = [
{
......
import styles from '../index.module.scss'
import Link from 'next/link';
import type { ResponseTypeHome } from '../types';
import type { ResponseTypeHome } from '@/types/indexTypes';
const HomeFloor1 = (props: ResponseTypeHome) => {
const on_sale_list = props!.data?.on_sale_list || []
......@@ -27,9 +27,9 @@ const HomeFloor1 = (props: ResponseTypeHome) => {
</div>
<a href='/' className={styles.floor1ad}>
<Link href='/' className={styles.floor1ad}>
<img src="https://img.ichunt.com/test/images/cms/202405/30/a263b85bf297ae7d85f68a01b5db320d.jpg" alt="" />
</a>
</Link>
</div>
</>
)
......
import Link from 'next/link';
import styles from '../index.module.scss'
import type { ResponseTypeHome } from '../types';
import type { ResponseTypeHome } from '@/types/indexTypes';
const HomeFloor2 = (props: ResponseTypeHome) => {
const recommend_goods_list = props!.data?.recommend_goods_list || []
return (
......
import Link from 'next/link';
import styles from '../index.module.scss'
import type { ResponseTypeHome } from '../types';
import type { ResponseTypeHome } from '@/types/indexTypes';
const HomeFloor3 = (props: ResponseTypeHome) => {
const recommend_brand_list = props!.data?.recommend_brand_list || []
......
......@@ -7,14 +7,14 @@ import { GetServerSideProps } from 'next';
import { getCateList } from "@/server/getCateList";
import type { ResponseTypeCateList } from '@/components/Header/components/NavBig/types'
export const getStaticProps: GetServerSideProps = async () => {
export const getServerSideProps: GetServerSideProps = async () => {
return getCateList()
}
import { useEffect, useState } from 'react';
import FilterDate from './FilterDate';
import useRequest from '../../hooks/useRequest';
import type { NoticeResponseType, listType } from './types'
import type { NoticeResponseType, listType } from '@/types/noticeTypes'
......
......@@ -7,8 +7,8 @@ import BreadNav from '../../components/BreadNav';
import ListSort from '../../components/ListSort';
import ListOneItem from '../../components/ListOneItem';
import { brandsAndClasssReducer, supplierDataReducer } from './reducer';
import type { ResponseTypeSearch, supplierDataType } from './types'
import { brandsAndClasssReducer, supplierDataReducer } from '@/reducers/searchReducers';
import type { ResponseTypeSearch, supplierDataType } from '@/types/searchTypes'
import useRequest from '../../hooks/useRequest';
import ListNoData from '../../components/ListNoData';
import { useRouter } from 'next/router';
......@@ -21,7 +21,7 @@ import { GetServerSideProps } from 'next';
import { getCateList } from "@/server/getCateList";
import type { ResponseTypeCateList } from '@/components/Header/components/NavBig/types'
export const getStaticProps: GetServerSideProps = async () => {
export const getServerSideProps: GetServerSideProps = async () => {
return getCateList()
}
const supplierIdS = ['', '24']
......@@ -106,7 +106,7 @@ const Page = (props: { cateList: ResponseTypeCateList }) => {
<>
<main>
<Header {...props.cateList} />
<BreadNav><strong>"{keyword}"的型号搜索结果</strong></BreadNav>
<BreadNav><strong>&quot;{keyword}&quot;的型号搜索结果</strong></BreadNav>
<div className={`${styles.mvSearchPage} w1226`} >
<div className={styles.shiftBox}>
<div className={`${styles.shiftGroup} row`} >
......
import type { BrandAndClassType, supplierDataType } from './types'
import type { ListSortType } from '../../components/ListSort/types'
import type { BrandAndClassType, supplierDataType } from '@/types/searchTypes'
import type { ListSortType } from '@/components/ListSort/types'
export const brandsAndClasssReducer = (state: BrandAndClassType, action: any) => {
if (action.type === 'brandsInit' || action.type === 'classsInit') {
......@@ -122,3 +122,5 @@ export const supplierDataReducer = (state: Array<supplierDataType>, action: {typ
import {API_URL} from '../configReact'
export async function getCateList() {
const res = await fetch(API_URL+'/api/home/getCateList');
const cateList= await res.json()
// 将数据作为 props 返回
return { props: { cateList} };
}
\ No newline at end of file
const cateList = await res.json();
return { props: { cateList } };
}
......@@ -4,6 +4,8 @@ export async function getHomeData() {
// 在这里进行异步数据获取
const res = await fetch(API_URL+'/api/home/getCateList');
const res2 = await fetch(API_URL+'/api/home/getHomepageList');
const [cateList, homepageList] = await Promise.all([
res.json(),
res2.json()
......
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
......@@ -18,9 +22,20 @@
}
],
"paths": {
"@/*": ["./*"]
}
"@/*": [
"./*"
]
},
"target": "es5",
"forceConsistentCasingInFileNames": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
......@@ -12,3 +12,5 @@ export type brandItenType={
brand_logo:string,
brand_name:string
}
import type { dataListItemType } from '../../components/ListOneItem/types'
import type { dataListItemType } from '@/components/ListOneItem/types'
export type brandResponseType = {
code: number | string,
data: {
......@@ -33,3 +33,4 @@ export type brandInfoType = {
"brand_desc": string
}
import type { dataListItemType } from '../../components/ListOneItem/types'
import type { dataListItemType } from '@/components/ListOneItem/types'
export type classResponseType = {
code: number|string,
data: {
......@@ -21,3 +21,4 @@ export type requestDataType={
......@@ -8,4 +8,6 @@ export type classItemType = {
"goods_type_id": string | number,
"goods_type_name": string,
child?:classItemType[]
}
\ No newline at end of file
}
export type DetailResponseType = {
code: number|string,
data: {
sku_info:skuInfoResponseType|null,
sku_info:skuInfoResponseType,
other_sku_list:Array<{
sku_name:string,
sku_id:string|number,
......@@ -15,7 +15,7 @@ export type DetailResponseType = {
export type skuInfoResponseType = {
sku_name:string,
brand_name?:string,
goods_images:string,
goods_images?:string,
encap:string,
batch_sn:string,
remark:string,
......@@ -32,4 +32,5 @@ export type skuInfoResponseType = {
price_us:number,
purchase:number
}>
}
\ No newline at end of file
}|undefined|null
......@@ -26,4 +26,5 @@ export type recommendGoodsListType = {
sku_id:string|number,
single_price:string|number,
sku_name:string
}
\ No newline at end of file
}
import type { dataListItemType } from '../../components/ListOneItem/types'
import type { dataListItemType } from '@/components/ListOneItem/types'
export type ResponseTypeSearch = {
code: number | string,
data:Array<supplierDataType>,
......@@ -21,3 +21,6 @@ export type BrandAndClassType = Array<{
}>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment