home.js 658 B

123456789101112131415161718192021222324
  1. /* eslint-disable array-callback-return */
  2. 'use strict';
  3. // const UUID = require('uuid');
  4. const fs = require('fs');
  5. const path = require('path');
  6. const Controller = require('egg').Controller;
  7. class HomeController extends Controller {
  8. async home() {
  9. const { ctx } = this;
  10. ctx.response.type = 'html';
  11. ctx.body = fs.readFileSync(path.resolve(__dirname, '../public/index.html'));
  12. }
  13. async reboot() {
  14. try {
  15. await this.service.files.reboot();
  16. this.ctx.body = { errcode: 0, errmsg: '' };
  17. } catch (error) {
  18. // this.ctx.body = { errcode: -1, errmsg: error };
  19. throw error;
  20. }
  21. }
  22. }
  23. module.exports = HomeController;