-
Notifications
You must be signed in to change notification settings - Fork 120
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
9 changed files
with
109 additions
and
53 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
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
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,49 @@ | ||
const defaultValue = [] | ||
|
||
const searchInfo = (state = defaultValue, action) => { | ||
switch (action.type) { | ||
case 'ADD_SEARCH_INFO': | ||
return [...state, ...action.info] | ||
case 'ADD_SEARCH_COMMENT': | ||
return addComments(state,action.info) | ||
case 'TOPIC_SEARCH_LIKE': | ||
return topicLike(state,action.info) | ||
default: | ||
return state | ||
} | ||
} | ||
|
||
|
||
// 点赞 | ||
function topicLike (state, { | ||
index, topicLikeCounts, topicLike | ||
}) { | ||
let newArray = [...state] | ||
let targetTopic = newArray[index].topic | ||
Object.assign( | ||
targetTopic, | ||
{ | ||
topicLikeCounts, | ||
topicLike | ||
} | ||
) | ||
return newArray | ||
} | ||
|
||
|
||
// 添加评论 | ||
function addComments (state, { | ||
index, replyContent, replyName | ||
}) { | ||
let newArray = [...state] | ||
let sourceComment = { | ||
replyName, | ||
replyContent | ||
} | ||
|
||
newArray[index].discuss.push(sourceComment) | ||
return newArray | ||
} | ||
|
||
|
||
export default searchInfo |
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