Skip to content

Commit 12c9089

Browse files
committed
add clear cache
1 parent c0c796a commit 12c9089

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

app/components/SettingPage.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {connect} from 'react-redux'
1616
import {bindActionCreators} from 'redux'
1717
import CommonRowItem from './common/CommonRowItem'
1818
import {getRefreshHandler} from '../utils/actionUtils'
19+
import {clearCache} from "../dao/db";
1920

2021
/**
2122
* 设置
@@ -138,6 +139,24 @@ class SettingPage extends Component {
138139
})
139140
});
140141
}}/>
142+
<CommonRowItem
143+
showIconNext={true}
144+
topLine={false}
145+
bottomLine={false}
146+
itemIcon={"broadcast"}
147+
textStyle={[styles.centered, styles.normalText, {
148+
textAlignVertical: 'center',
149+
marginHorizontal: Constant.normalMarginEdge
150+
}]}
151+
iconSize={20}
152+
viewStyle={[{
153+
borderRadius: 4, marginTop: Constant.normalMarginEdge,
154+
paddingLeft: Constant.normalMarginEdge
155+
}, styles.shadowCard]}
156+
itemText={I18n('clearCache')}
157+
onClickFun={() => {
158+
clearCache()
159+
}}/>
141160
<CommonRowItem
142161
showIconNext={false}
143162
topLine={false}
@@ -153,6 +172,8 @@ class SettingPage extends Component {
153172
Actions.reset("LoginPage");
154173
loginActions.loginOut();
155174
}}/>
175+
176+
156177
</View>
157178
)
158179
}

app/dao/db/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,4 +286,10 @@ let realm = new Realm({
286286
]
287287
});
288288

289+
export const clearCache = () => {
290+
realm.write(() => {
291+
realm.deleteAll()
292+
})
293+
};
294+
289295
export default realm;

app/style/i18n.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ I18n.translations = {
173173
zhLanguage: 'Chinese',
174174
enLanguage: 'English',
175175
gone410: '410 Gone',
176+
clearCache: 'clearCache',
176177
},
177178
'zh-CN': {
178179
appName: 'GSYGitHubApp',
@@ -335,6 +336,7 @@ I18n.translations = {
335336
zhLanguage: '中文',
336337
enLanguage: '英文',
337338
gone410: '410 Gone,不存在吧?',
339+
clearCache: '清除缓存',
338340
}
339341
};
340342

0 commit comments

Comments
 (0)