Skip to content

Commit 1ca9c42

Browse files
committed
优化codeSplitting代码
1 parent af4aad1 commit 1ca9c42

File tree

6 files changed

+23
-90
lines changed

6 files changed

+23
-90
lines changed

scripts/start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
4141
}
4242

4343
// Tools like Cloud9 rely on this.
44-
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
44+
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3002;
4545
const HOST = process.env.HOST || '0.0.0.0';
4646

4747
if (process.env.HOST) {

src/api/lyric-parser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export default class Lyric {
7272
this.lines.sort((a, b) => {
7373
return a.time - b.time
7474
})
75+
7576
}
7677

7778
_findcurLineIndex(time) {

src/application/Player/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ function Player(props) {
8585
setDuration((current.dt / 1000) | 0);
8686
// eslint-disable-next-line
8787
}, [currentIndex, playList]);
88-
89-
9088

9189
useEffect(() => {
9290
playing ? audioRef.current.play() : audioRef.current.pause();

src/application/Search/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const Search = (props) => {
3939

4040
useEffect(() => {
4141
setShow(true);
42-
if(!hotList.length)
42+
if(!hotList.size)
4343
getHotKeyWordsDispatch();
4444
// eslint-disable-next-line
4545
}, []);
@@ -200,9 +200,9 @@ const Search = (props) => {
200200
<ShortcutWrapper show={query}>
201201
<Scroll onScorll={forceCheck}>
202202
<div>
203-
{renderSingers()}
204-
{renderAlbum()}
205-
{renderSongs()}
203+
{ renderSingers() }
204+
{ renderAlbum() }
205+
{ renderSongs() }
206206
</div>
207207
</Scroll>
208208
</ShortcutWrapper>

src/components/slider/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ function Slider(props) {
1111
if(bannerList.length && !sliderSwiper){
1212
let sliderSwiper = new Swiper(".slider-container", {
1313
loop: true,
14-
autoplay: true,
15-
autoplayDisableOnInteraction: false,
14+
autoplay: {
15+
delay: 3000,
16+
disableOnInteraction: false,
17+
},
1618
pagination: {el:'.swiper-pagination'},
1719
});
20+
console.log();
1821
setSliderSwiper(sliderSwiper);
1922
}
2023
}, [bannerList.length, sliderSwiper])

src/routes/index.js

Lines changed: 12 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -3,94 +3,25 @@ import { Redirect } from "react-router-dom";
33
import HomeLayout from "../layouts/HomeLayout";
44
import BlankLayout from "../layouts/BlankLayout";
55

6-
const LoginComponent = lazy(() => import("../application/User/Login"));
7-
const Login = props => {
6+
const SuspenseComponent = Component => props => {
87
return (
98
<Suspense fallback={null}>
10-
<LoginComponent {...props}></LoginComponent>
9+
<Component {...props}></Component>
1110
</Suspense>
12-
);
13-
};
14-
15-
// const HomeComponent = lazy(() => import("../application/Home/"));
16-
// const Home = props => {
17-
// return (
18-
// <Suspense fallback={null}>
19-
// <HomeComponent {...props}></HomeComponent>
20-
// </Suspense>
21-
// );
22-
// };
11+
)
12+
}
2313

2414
const RecommendComponent = lazy(() => import("../application/Recommend/"));
25-
const Recommend = props => {
26-
return (
27-
<Suspense fallback={null}>
28-
<RecommendComponent {...props}></RecommendComponent>
29-
</Suspense>
30-
);
31-
};
32-
3315
const SingersComponent = lazy(() => import("../application/Singers/"));
34-
const Singers = props => {
35-
return (
36-
<Suspense fallback={null}>
37-
<SingersComponent {...props}></SingersComponent>
38-
</Suspense>
39-
);
40-
};
41-
4216
const RankComponent = lazy(() => import("../application/Rank/"));
43-
const Rank = props => {
44-
return (
45-
<Suspense fallback={null}>
46-
<RankComponent {...props}></RankComponent>
47-
</Suspense>
48-
);
49-
};
50-
5117
const AlbumComponent = lazy(() => import("../application/Album/"));
52-
const Album = props => {
53-
return (
54-
<Suspense fallback={null}>
55-
<AlbumComponent {...props}></AlbumComponent>
56-
</Suspense>
57-
);
58-
};
59-
6018
const SingerComponent = lazy(() => import("./../application/Singer/"));
61-
const Singer = props => {
62-
return (
63-
<Suspense fallback={null}>
64-
<SingerComponent {...props}></SingerComponent>
65-
</Suspense>
66-
);
67-
};
68-
6919
const SearchComponent = lazy(() => import("./../application/Search/"));
70-
const Search = props => {
71-
return (
72-
<Suspense fallback={null}>
73-
<SearchComponent {...props}></SearchComponent>
74-
</Suspense>
75-
);
76-
};
7720

7821
export default [
7922
{
8023
component: BlankLayout,
8124
routes: [
82-
{
83-
path: "/user",
84-
component: BlankLayout, //userLayout
85-
routes: [
86-
{
87-
path: "/user/login",
88-
exact: true,
89-
key: "login",
90-
component: Login
91-
}
92-
]
93-
},
9425
{
9526
path: "/",
9627
component: HomeLayout,
@@ -102,47 +33,47 @@ export default [
10233
},
10334
{
10435
path: "/recommend",
105-
component: Recommend,
36+
component: SuspenseComponent(RecommendComponent),
10637
routes: [
10738
{
10839
path: "/recommend/:id",
109-
component: Album
40+
component: SuspenseComponent(AlbumComponent)
11041
}
11142
]
11243
},
11344
{
11445
path: "/singers",
115-
component: Singers,
46+
component: SuspenseComponent(SingersComponent),
11647
key: "singers",
11748
routes: [
11849
{
11950
path: "/singers/:id",
120-
component: Singer
51+
component: SuspenseComponent(SingerComponent)
12152
}
12253
]
12354
},
12455
{
12556
path: "/rank/",
126-
component: Rank,
57+
component: SuspenseComponent(RankComponent),
12758
key: "rank",
12859
routes: [
12960
{
13061
path: "/rank/:id",
131-
component: Album
62+
component: SuspenseComponent(AlbumComponent)
13263
}
13364
]
13465
},
13566
{
13667
path: "/album/:id",
13768
exact: true,
13869
key: "album",
139-
component: Album
70+
component: SuspenseComponent(AlbumComponent)
14071
},
14172
{
14273
path: "/search",
14374
exact: true,
14475
key: "search",
145-
component: Search
76+
component: SuspenseComponent(SearchComponent)
14677
}
14778
]
14879
}

0 commit comments

Comments
 (0)