gaoshuaixing 5 年之前
父节点
当前提交
bc6aa4fcd1
共有 3 个文件被更改,包括 19 次插入2 次删除
  1. 4 2
      app/controller/v1/setting.js
  2. 3 0
      app/router/index.js
  3. 12 0
      app/router/setting.js

+ 4 - 2
app/controller/v1/setting.js

@@ -5,23 +5,25 @@ const BaseController = require('../base');
 class SettingController extends BaseController {
 class SettingController extends BaseController {
 
 
   async autoLaunchEnable() {
   async autoLaunchEnable() {
+    const self = this;
     const { ctx } = this;
     const { ctx } = this;
 
 
     const data = {
     const data = {
       title: 'hello electron-egg'
       title: 'hello electron-egg'
     };
     };
 
 
-    await ctx.render('index.ejs', data);
+    self.sendSuccess(data);
   }
   }
   
   
   async autoLaunchDisable() {
   async autoLaunchDisable() {
+    const self = this;
     const { ctx } = this;
     const { ctx } = this;
 
 
     const data = {
     const data = {
       title: 'hello'
       title: 'hello'
     };
     };
 
 
-    await ctx.render('hello.ejs', data);
+    self.sendSuccess(data);
   }
   }
 }
 }
 
 

+ 3 - 0
app/router/index.js

@@ -13,4 +13,7 @@ module.exports = app => {
 
 
   // html
   // html
   router.get('/home', controller.v1.home.index);
   router.get('/home', controller.v1.home.index);
+
+  // 引入其他路由
+  require('./setting')(app);
 };
 };

+ 12 - 0
app/router/setting.js

@@ -0,0 +1,12 @@
+'use strict';
+
+/**
+ * @param {Egg.Application} app - egg application
+ */
+module.exports = app => {
+  const { router, controller } = app;
+  // open launch
+  router.get('/api/v1/setting/autoLaunchEnable', controller.v1.setting.autoLaunchEnable);
+  // close launch 
+  router.get('/api/v1/setting/autoLaunchDisable', controller.v1.setting.autoLaunchDisable);
+};