-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
298 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { dailyRecommendedPlaylist } from './host' | ||
export const RECEIVE_DAILY_RECOMMENDED_PLAYLIST = 'RECEIVE_DAILY_RECOMMENDED_PLAYLIST' | ||
export const REQUIRE_DAILY_RECOMMENDED_PLAYLIST = 'REQUIRE_DAILY_RECOMMENDED_PLAYLIST' | ||
|
||
const requireDailyRecommendedPlaylist = (id) => ({ | ||
type: REQUIRE_DAILY_RECOMMENDED_PLAYLIST, | ||
id | ||
}) | ||
|
||
const receiveDailyRecommendedPlaylist = (id, json) => ({ | ||
type: RECEIVE_DAILY_RECOMMENDED_PLAYLIST, | ||
id, | ||
date: json | ||
}) | ||
|
||
const fetchDailyRecommendedPlaylist = () => (dispatch) => { | ||
return fetch(`${dailyRecommendedPlaylist}`, { | ||
credentials: 'include', | ||
mode: 'cors' | ||
}) | ||
.then((response) => response.json()) | ||
.then((json) => { | ||
if(json && json.code.toString() === '200') { | ||
dispatch(receiveDailyRecommendedPlaylist(json)) | ||
} | ||
}) | ||
} | ||
|
||
const shouldFetchDailyRecommendedPlaylist = (state) => { | ||
|
||
} | ||
|
||
export const fetchDailyRecommendedPlaylistIfNeeded = () => (dispatch, getState) => { | ||
if(shouldFetchDailyRecommendedPlaylist(getState())) { | ||
return dispatch(fetchDailyRecommendedPlaylist()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
const baseURL = 'https://www.shianqi.com' | ||
|
||
//登录 | ||
export const loginURL = `${baseURL}/login/cellphone` | ||
//刷新登录状态登录 | ||
export const refreshURL = `${baseURL}/login/refresh` | ||
export const playlistURL = `${baseURL}/user/playlist` | ||
export const playlistDetailURL = `${baseURL}/playlist/detail` | ||
//每日推荐歌单 | ||
export const dailyRecommendedPlaylist = `${baseURL}/personalized` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { playlistDetailURL } from './host' | ||
|
||
export const RECEIVE_LIST_DETAIL = 'RECEIVE_LIST_DETAIL' | ||
export const REQUEST_LIST_DETAIL = 'REQUEST_LIST_DETAIL' | ||
|
||
const receiveSonglistDetail = (json, id) => ({ | ||
type: RECEIVE_LIST_DETAIL, | ||
data: json, | ||
id | ||
}) | ||
|
||
const requestSonglistDetail = (id) => ({ | ||
type: REQUEST_LIST_DETAIL, | ||
id | ||
}) | ||
|
||
const fetchListDetail = (id) => (dispatch) => { | ||
dispatch(requestSonglistDetail(id)) | ||
return fetch(`${playlistDetailURL}?id=${id}`, { | ||
credentials: 'include', | ||
mode: 'cors' | ||
}) | ||
.then((response) => response.json()) | ||
.then((json) => { | ||
dispatch(receiveSonglistDetail(json, id)) | ||
}) | ||
} | ||
|
||
const shouldFetchListDetail = (state, id) => { | ||
const listDetail = state[id] | ||
if(!listDetail) { | ||
return true | ||
} | ||
if(listDetail.isFetching) { | ||
return false | ||
} | ||
return true | ||
} | ||
|
||
export const fetchListDetailIfNeeded = (id) => (dispatch, getState) => { | ||
if (shouldFetchListDetail(getState(), id)) { | ||
return dispatch(fetchListDetail(id)) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.