Skip to content

Commit

Permalink
代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
wallace5303 committed Jul 16, 2021
1 parent d4b5fff commit 0d44673
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 123 deletions.
1 change: 0 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* @param app
*/
'use strict';
global.CODE = require('./app/const/statusCode');

class AppBootHook {
constructor(app) {
Expand Down
6 changes: 0 additions & 6 deletions app/config/openAuthConfig.js

This file was deleted.

Empty file removed app/const/common.js
Empty file.
35 changes: 35 additions & 0 deletions app/controller/v1/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,41 @@ class ExampleController extends BaseController {

self.sendSuccess(data);
}

async autoLaunchEnable() {
const { service } = this;

await service.example.autoLaunchEnable();
const data = {
isEnabled: true
};

this.sendSuccess(data);
}

async autoLaunchDisable() {
const { service } = this;

await service.example.autoLaunchDisable();
const data = {
isEnabled: false
};

this.sendSuccess(data);
}

async autoLaunchIsEnabled() {
const { service } = this;

const data = {
isEnabled: null
};

const isEnabled = await service.example.autoLaunchIsEnabled();
data.isEnabled = isEnabled;

this.sendSuccess(data);
}
}

module.exports = ExampleController;
43 changes: 0 additions & 43 deletions app/controller/v1/setting.js

This file was deleted.

6 changes: 6 additions & 0 deletions app/router/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ module.exports = app => {
router.post('/api/v1/example/getTestData', controller.v1.example.getTestData);
// set shortcut
router.post('/api/v1/example/setShortcut', controller.v1.example.setShortcut);
// open launch
router.post('/api/v1/example/autoLaunchEnable', controller.v1.example.autoLaunchEnable);
// close launch
router.post('/api/v1/example/autoLaunchDisable', controller.v1.example.autoLaunchDisable);
// is launch
router.post('/api/v1/example/autoLaunchIsEnabled', controller.v1.example.autoLaunchIsEnabled);
};
4 changes: 0 additions & 4 deletions app/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ module.exports = app => {
// home
router.get('/', controller.v1.home.index);

// hello
//router.get('/', controller.v1.home.hello);

// html
router.get('/home', controller.v1.home.index);

// 引入其他路由
require('./example')(app);
require('./setting')(app);
};
14 changes: 0 additions & 14 deletions app/router/setting.js

This file was deleted.

18 changes: 18 additions & 0 deletions app/service/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ class ExampleService extends BaseService {

return res;
}

async autoLaunchEnable() {
const callResult = await this.ipcCall('example.autoLaunchEnable');

return callResult.data;
}

async autoLaunchDisable() {
const callResult = await this.ipcCall('example.autoLaunchDisable');

return callResult.data;
}

async autoLaunchIsEnabled() {
const callResult = await this.ipcCall('example.autoLaunchIsEnabled');

return callResult.data;
}
}

module.exports = ExampleService;
26 changes: 0 additions & 26 deletions app/service/setting.js

This file was deleted.

21 changes: 0 additions & 21 deletions electron/apis/base.js

This file was deleted.

26 changes: 21 additions & 5 deletions electron/apis/example.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
'use strict';

const path = require('path');
const {
app,
webContents,
shell
} = require('electron');

const {app, webContents, shell} = require('electron');
const AutoLaunchManager = require('../lib/autoLaunch');
const shortcut = require('../lib/shortcut');

exports.getPath = function () {
Expand Down Expand Up @@ -36,6 +34,24 @@ exports.setShortcut = function (shortcutObj) {
return true;
}

exports.autoLaunchEnable = function () {
const autoLaunchManager = new AutoLaunchManager()
const enable = autoLaunchManager.enable()
return enable
}

exports.autoLaunchDisable = function () {
const autoLaunchManager = new AutoLaunchManager()
const disable = autoLaunchManager.disable()
return disable
}

exports.autoLaunchIsEnabled = function () {
const autoLaunchManager = new AutoLaunchManager()
const isEnable = autoLaunchManager.isEnabled()
return isEnable
}

function getElectronPath(filepath) {
//filepath = path.resolve(filepath);
filepath = filepath.replace("resources", "");
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/api/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const mainApi = {
uploadFile: '/api/v1/example/uploadFile',
executeJS: '/api/v1/example/executeJS',
setShortcut: '/api/v1/example/setShortcut',
autoLaunchEnable: '/api/v1/setting/autoLaunchEnable',
autoLaunchDisable: '/api/v1/setting/autoLaunchDisable',
autoLaunchIsEnabled: '/api/v1/setting/autoLaunchIsEnabled'
autoLaunchEnable: '/api/v1/example/autoLaunchEnable',
autoLaunchDisable: '/api/v1/example/autoLaunchDisable',
autoLaunchIsEnabled: '/api/v1/example/autoLaunchIsEnabled'
}

/**
Expand Down

0 comments on commit 0d44673

Please sign in to comment.