example.js 837 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. 'use strict';
  2. const BaseController = require('../base');
  3. class ExampleController extends BaseController {
  4. async openLocalDir() {
  5. const self = this;
  6. const { ctx, service } = this;
  7. const body = ctx.request.body;
  8. const id = body.id;
  9. const data = {};
  10. let dir = '';
  11. switch (id) {
  12. case 'download' :
  13. dir = 'C:/Users/Public/Downloads';
  14. break;
  15. case 'picture' :
  16. dir = 'C:/Users/Public/Pictures';
  17. break;
  18. case 'video' :
  19. dir = 'C:/Users/Public/Videos';
  20. break;
  21. case 'doc' :
  22. dir = 'C:/Users/Public/Documents';
  23. break;
  24. case 'music' :
  25. dir = 'C:/Users/Public/Music';
  26. break;
  27. }
  28. await service.example.openLocalDir(dir);
  29. self.sendSuccess(data);
  30. }
  31. }
  32. module.exports = ExampleController;