From 95e2380eeb97393c525b359129b793a86f2da8ab Mon Sep 17 00:00:00 2001 From: gaoshuaixing Date: Thu, 31 Dec 2020 16:44:06 +0800 Subject: [PATCH] autolaunch front --- app/controller/v1/setting.js | 8 ++- electron/lib/AutoLaunch.js | 20 ------- frontend/.env | 2 +- frontend/.env.development | 2 +- frontend/.env.preview | 2 +- frontend/src/api/main.js | 42 +++++++++++++- frontend/src/config/router.config.js | 13 ++--- frontend/src/views/Contenta.vue | 32 ----------- frontend/src/views/Contentb.vue | 32 ----------- frontend/src/views/Layout.vue | 10 +--- frontend/src/views/Setting.vue | 77 ++++++++++++++++++++++++++ frontend/src/views/file/UploadFile.vue | 2 +- 12 files changed, 133 insertions(+), 109 deletions(-) delete mode 100644 frontend/src/views/Contenta.vue delete mode 100644 frontend/src/views/Contentb.vue create mode 100644 frontend/src/views/Setting.vue diff --git a/app/controller/v1/setting.js b/app/controller/v1/setting.js index aaa6a7a..ab64fa9 100644 --- a/app/controller/v1/setting.js +++ b/app/controller/v1/setting.js @@ -6,18 +6,22 @@ class SettingController extends BaseController { async autoLaunchEnable() { const { service } = this; - const data = {}; await service.setting.autoLaunchEnable(); + const data = { + isEnabled: true + }; this.sendSuccess(data); } async autoLaunchDisable() { const { service } = this; - const data = {}; await service.setting.autoLaunchDisable(); + const data = { + isEnabled: false + }; this.sendSuccess(data); } diff --git a/electron/lib/AutoLaunch.js b/electron/lib/AutoLaunch.js index 4ae2727..464e252 100644 --- a/electron/lib/AutoLaunch.js +++ b/electron/lib/AutoLaunch.js @@ -12,37 +12,17 @@ class AutoLaunch { openAtLogin: true }) return true; - // return new Promise((resolve, reject) => { - // const enabled = app.getLoginItemSettings(LOGIN_SETTING_OPTIONS).openAtLogin - // if (enabled) { - // resolve() - // } - - // app.setLoginItemSettings({ - // ...LOGIN_SETTING_OPTIONS, - // openAtLogin: true - // }) - // resolve() - // }) } disable () { app.setLoginItemSettings({ openAtLogin: false }) return true; - // return new Promise((resolve, reject) => { - // app.setLoginItemSettings({ openAtLogin: false }) - // resolve() - // }) } isEnabled () { const enabled = app.getLoginItemSettings(LOGIN_SETTING_OPTIONS).openAtLogin; console.log('AutoLaunch isEnabled:', enabled); return enabled; - // return new Promise((resolve, reject) => { - // const enabled = app.getLoginItemSettings(LOGIN_SETTING_OPTIONS).openAtLogin - // resolve(enabled) - // }) } } diff --git a/frontend/.env b/frontend/.env index 32070c6..b73cd6c 100644 --- a/frontend/.env +++ b/frontend/.env @@ -1,3 +1,3 @@ NODE_ENV=production VUE_APP_PREVIEW=false -VUE_APP_API_BASE_URL=api \ No newline at end of file +VUE_APP_API_BASE_URL= \ No newline at end of file diff --git a/frontend/.env.development b/frontend/.env.development index 3173e2f..4226ea9 100644 --- a/frontend/.env.development +++ b/frontend/.env.development @@ -1,3 +1,3 @@ NODE_ENV=development VUE_APP_PREVIEW=true -VUE_APP_API_BASE_URL=http://localhost:7068/api \ No newline at end of file +VUE_APP_API_BASE_URL=http://localhost:7068 \ No newline at end of file diff --git a/frontend/.env.preview b/frontend/.env.preview index 9dda1da..a50b479 100644 --- a/frontend/.env.preview +++ b/frontend/.env.preview @@ -1,3 +1,3 @@ NODE_ENV=production VUE_APP_PREVIEW=true -VUE_APP_API_BASE_URL=http://localhost:7068/api \ No newline at end of file +VUE_APP_API_BASE_URL=http://localhost:7068 \ No newline at end of file diff --git a/frontend/src/api/main.js b/frontend/src/api/main.js index a7e01df..7136fcb 100644 --- a/frontend/src/api/main.js +++ b/frontend/src/api/main.js @@ -2,9 +2,12 @@ import request from '@/utils/request' // import storage from 'store' const mainApi = { - outApi: '/v1/outApi', - openDir: '/v1/example/openLocalDir', - uploadFile: '/v1/example/uploadFile', + outApi: '/api/v1/outApi', + openDir: '/api/v1/example/openLocalDir', + uploadFile: '/api/v1/example/uploadFile', + autoLaunchEnable: '/api/v1/setting/autoLaunchEnable', + autoLaunchDisable: '/api/v1/setting/autoLaunchDisable', + autoLaunchIsEnabled: '/api/v1/setting/autoLaunchIsEnabled' } /** @@ -40,4 +43,37 @@ export function uploadFile (parameter) { method: 'post', data: parameter }) +} + +/** + * autoLaunchEnable + */ +export function autoLaunchEnable (parameter) { + return request({ + url: mainApi.autoLaunchEnable, + method: 'post', + data: parameter + }) +} + +/** + * autoLaunchDisable + */ +export function autoLaunchDisable (parameter) { + return request({ + url: mainApi.autoLaunchDisable, + method: 'post', + data: parameter + }) +} + +/** + * autoLaunchIsEnabled + */ +export function autoLaunchIsEnabled (parameter) { + return request({ + url: mainApi.autoLaunchIsEnabled, + method: 'post', + data: parameter + }) } \ No newline at end of file diff --git a/frontend/src/config/router.config.js b/frontend/src/config/router.config.js index 9b419dd..fc212e5 100644 --- a/frontend/src/config/router.config.js +++ b/frontend/src/config/router.config.js @@ -18,15 +18,10 @@ export const constantRouterMap = [ component: () => import('@/views/file/UploadFile') }, { - path: 'setting1', - name: 'setting1', - component: { template: '

这是设置内一

' } - }, - { - path: 'setting2', - name: 'setting2', - component: { template: '

这是设置内二

' } - }, + path: 'setting', + name: 'setting', + component: () => import('@/views/Setting') + } ] } ] \ No newline at end of file diff --git a/frontend/src/views/Contenta.vue b/frontend/src/views/Contenta.vue deleted file mode 100644 index d070239..0000000 --- a/frontend/src/views/Contenta.vue +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - diff --git a/frontend/src/views/Contentb.vue b/frontend/src/views/Contentb.vue deleted file mode 100644 index 4cc4946..0000000 --- a/frontend/src/views/Contentb.vue +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - diff --git a/frontend/src/views/Layout.vue b/frontend/src/views/Layout.vue index 478675c..379096c 100644 --- a/frontend/src/views/Layout.vue +++ b/frontend/src/views/Layout.vue @@ -65,13 +65,9 @@ export default { }, 'menu_2' : { 'subMenu_1' : { - title: '设置菜单1', - page: '/setting1' - }, - 'subMenu_2' : { - title: '设置菜单2', - page: '/setting2' - }, + title: '基础设置', + page: '/setting' + } }, }, contentPage: '' diff --git a/frontend/src/views/Setting.vue b/frontend/src/views/Setting.vue new file mode 100644 index 0000000..807dc19 --- /dev/null +++ b/frontend/src/views/Setting.vue @@ -0,0 +1,77 @@ + + + \ No newline at end of file diff --git a/frontend/src/views/file/UploadFile.vue b/frontend/src/views/file/UploadFile.vue index 735cd0c..7ac27f1 100644 --- a/frontend/src/views/file/UploadFile.vue +++ b/frontend/src/views/file/UploadFile.vue @@ -44,7 +44,7 @@ export default { data() { return { - action_url: process.env.VUE_APP_API_BASE_URL + '/v1/example/uploadFile', + action_url: process.env.VUE_APP_API_BASE_URL + '/api/v1/example/uploadFile', image_info: [], num: 0 };