Trash.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. const template=`
  2. <el-dropdown class="toolBar-dropdown hide-800" placement="bottom">
  3. <div class="icon-only font-size-icon">
  4. <i class="fa fa-trash"></i>
  5. </div>
  6. <template #dropdown>
  7. <el-dropdown-menu>
  8. <el-dropdown-item @click="wipeAllCache">
  9. <i class="fa fa-trash"></i>&nbsp;&nbsp;${__('一键清除缓存')}
  10. </el-dropdown-item>
  11. <el-dropdown-item divided @click="wipeContentCache">
  12. <i class="fa fa-file-text"></i>&nbsp;&nbsp;${__('清除内容缓存')}
  13. </el-dropdown-item>
  14. <el-dropdown-item @click="wipeTemplateCache">
  15. <i class="fa fa-file-image-o"></i>&nbsp;&nbsp;${__('清除模板缓存')}
  16. </el-dropdown-item>
  17. <el-dropdown-item @click="wipeBrowserCache">
  18. <i class="fa fa-chrome"></i>&nbsp;&nbsp;${__('清除浏览器缓存')}
  19. <el-tooltip
  20. effect="dark"
  21. content="${__('清除浏览器端静态JS、CSS、图片等资源')}"
  22. placement="top">
  23. <i class="fa fa-info-circle"></i>
  24. </el-tooltip>
  25. </el-dropdown-item>
  26. </el-dropdown-menu>
  27. </template>
  28. </el-dropdown>
  29. `;
  30. export default {
  31. name: "Trash",
  32. data: function () {
  33. return {
  34. }
  35. },
  36. props:{
  37. },
  38. template:template,
  39. methods:{
  40. wipeAllCache:function (){
  41. this.postData('all');
  42. },
  43. wipeContentCache:function (){
  44. this.postData('content');
  45. },
  46. wipeTemplateCache:function (){
  47. this.postData('template');
  48. },
  49. wipeBrowserCache:function (){
  50. this.postData('browser');
  51. },
  52. postData:function (type){
  53. Yunqi.ajax.get('ajax/wipecache',{type:type},true,false).then(res=>{
  54. Yunqi.message.success(__('清理完成'));
  55. setTimeout(function (){
  56. location.reload();
  57. },1500);
  58. }).catch(err=>{
  59. if(!err.msg){
  60. Yunqi.message.error(__('清理失败'));
  61. }
  62. });
  63. }
  64. }
  65. };