Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit 7a435a9

Browse files
author
soliury
committed
add remove cash
1 parent fd8e343 commit 7a435a9

File tree

6 files changed

+31
-2
lines changed

6 files changed

+31
-2
lines changed

app/actions/UserActions.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
var types = require('../constants/ActionTypes')
22
var UserService = require('../services/UserService')
3+
var TopicService = require('../services/TopicService')
4+
var MessageService = require('../services/MessageService')
5+
var Storage = require('../services/Storage')
36

47

58
function getUser(user) {
@@ -125,3 +128,12 @@ exports.logout = function () {
125128
type: types.LOGOUT
126129
}
127130
}
131+
132+
133+
exports.clear = function () {
134+
TopicService.storage.remove()
135+
MessageService.storage.remove()
136+
return {
137+
type: types.CLEAR
138+
}
139+
}

app/components/Setting.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ class Setting extends Component {
3636
}
3737

3838

39-
onClearPress(){
40-
39+
onClearPress() {
40+
this.props.actions.clear()
41+
window.alert('缓存清除成功!')
4142
}
4243

4344

app/constants/ActionTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ exports.CHECK_TOKEN_FAILED = 'CHECK_TOKEN_FAILED'
1414
exports.LIKE_TOPIC = 'LIKE_TOPIC'
1515
exports.UN_LIKE_TOPIC = 'UN_LIKE_TOPIC'
1616
exports.LOGOUT='LOGOUT'
17+
exports.CLEAR='CLEAR'
1718

1819

1920
exports.GET_UNREAD_MESSAGE_COUNT_SUCCESS = 'GET_UNREAD_MESSAGE_COUNT_SUCCESS'

app/services/MessageService.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ storage.save = function (value) {
1212
return Storage.setItem('messages', value)
1313
}
1414

15+
storage.remove = function () {
16+
return Storage.removeItem('messages')
17+
}
18+
1519

1620
var req = {}
1721

app/services/Storage.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ Storage.multiGet = function (keys) {
3232
})
3333
}
3434

35+
Storage.multiRemove = function (keys) {
36+
return AsyncStorage.multiRemove(keys)
37+
}
38+
3539
module.exports = Storage

app/services/TopicService.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ storage.getAll = function () {
2424
}
2525

2626

27+
storage.remove = function () {
28+
return Storage.multiRemove(tabs.map(tab=> {
29+
return 'tab_' + tab
30+
}))
31+
}
32+
33+
2734
var req = {}
2835

2936

0 commit comments

Comments
 (0)