Commit ef858e53 authored by mercury233's avatar mercury233

add button: clear cache

parent 2d0aa9d1
...@@ -78,6 +78,8 @@ ...@@ -78,6 +78,8 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button i18n type="button" class="btn btn-danger" style="margin-right: auto" (click)="clear_cache()"
data-toggle="tooltip" i18n-title title="清除MyCard的缓存,并重启MyCard">清除缓存</button>
<button i18n type="button" class="btn btn-secondary" data-dismiss="modal">取消</button> <button i18n type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button i18n type="submit" class="btn btn-primary">确定</button> <button i18n type="submit" class="btn btn-primary">确定</button>
</div> </div>
......
...@@ -66,6 +66,9 @@ export class MyCardComponent implements OnInit { ...@@ -66,6 +66,9 @@ export class MyCardComponent implements OnInit {
this.currentWindow.webContents.openDevTools({ mode: 'undocked' }); this.currentWindow.webContents.openDevTools({ mode: 'undocked' });
} }
}); });
//$('[data-toggle="tooltip"]').tooltip();
// bootstrap有BUG不能用这玩意
// document.addEventListener('drop', (event)=>{ // document.addEventListener('drop', (event)=>{
// console.log('drop', event); // console.log('drop', event);
// event.preventDefault(); // event.preventDefault();
...@@ -133,6 +136,28 @@ export class MyCardComponent implements OnInit { ...@@ -133,6 +136,28 @@ export class MyCardComponent implements OnInit {
shell.openExternal(url); shell.openExternal(url);
} }
clear_cache() {
// 删除下载中的文件可能会出问题 先不搞
// 需要 import * as fs from 'fs-extra';
/*let downloadingDirPath = path.join(this.settingsService.getDefaultLibrary().path, 'downloading');
console.log('removing downloading dir', downloadingDirPath);
fs.remove(downloadingDirPath, (error: any) => {
if (error) { console.error(error); }
remote.getCurrentWebContents().session.clearCache((error: any) => {
if (error) { console.error(error); }
console.log('cache cleared', error);
remote.app.relaunch();
remote.app.quit();
});
});*/
remote.getCurrentWebContents().session.clearCache((error: any) => {
if (error) { console.error(error); }
console.log('cache cleared', error);
remote.app.relaunch();
remote.app.quit();
});
}
submit() { submit() {
if (this.locale !== this.settingsService.getLocale()) { if (this.locale !== this.settingsService.getLocale()) {
localStorage.setItem(SettingsService.SETTING_LOCALE, this.locale); localStorage.setItem(SettingsService.SETTING_LOCALE, this.locale);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment