diff --git a/electron/config/config.default.js b/electron/config/config.default.js
index 6334e25..f0e2e3c 100644
--- a/electron/config/config.default.js
+++ b/electron/config/config.default.js
@@ -84,7 +84,7 @@ module.exports = (appInfo) => {
/* 内置http服务 */
config.httpServer = {
- enable: true, // 是否启用
+ enable: false, // 是否启用
port: 7071, // 默认端口(如果端口被使用,则随机获取一个)
cors: {
origin: "*" // 更多参数: https://www.npmjs.com/package/koa2-cors
diff --git a/electron/controller/example.js b/electron/controller/example.js
index 1ae44f4..bd5fe5b 100644
--- a/electron/controller/example.js
+++ b/electron/controller/example.js
@@ -526,6 +526,48 @@ class ExampleController extends Controller {
// return uploadRes;
}
+
+ /**
+ * 检测http服务是否开启
+ */
+ async checkHttpServer () {
+ const httpServerConfig = this.app.config.httpServer;
+ const url = httpServerConfig.protocol + httpServerConfig.host + ':' + httpServerConfig.port;
+
+ const data = {
+ enable: httpServerConfig.enable,
+ server: url
+ }
+ return data;
+ }
+
+ /**
+ * 一个http请求访问此方法
+ */
+ async doHttpRequest () {
+ // http方法
+ const method = this.app.request.method;
+ // http get 参数
+ let params = this.app.request.query;
+ params = (params instanceof Object) ? JSON.parse(JSON.stringify(params)) : {};
+ // http post 参数
+ const body = this.app.request.body;
+
+ const httpInfo = {
+ method,
+ params,
+ body
+ }
+ console.log('httpInfo:', httpInfo);
+
+ if (!body.id) {
+ return false;
+ }
+ const dir = electronApp.getPath(body.id);
+ shell.openPath(dir);
+
+ return true;
+ }
}
module.exports = ExampleController;
diff --git a/frontend/src/api/main.js b/frontend/src/api/main.js
index 4551932..e1248bf 100644
--- a/frontend/src/api/main.js
+++ b/frontend/src/api/main.js
@@ -24,6 +24,8 @@ const ipcApiRoute = {
downloadApp: 'controller.example.downloadApp',
dbOperation: 'controller.example.dbOperation',
uploadFile: 'controller.example.uploadFile',
+ checkHttpServer: 'controller.example.checkHttpServer',
+ doHttpRequest: 'controller.example.doHttpRequest'
}
const specialIpcRoute = {
diff --git a/frontend/src/config/router.config.js b/frontend/src/config/router.config.js
index e0a4902..9ae3d55 100644
--- a/frontend/src/config/router.config.js
+++ b/frontend/src/config/router.config.js
@@ -62,10 +62,15 @@ export const constantRouterMap = [
component: () => import('@/views/base/theme/Index')
},
{
- path: '/base/software/open',
+ path: '/base/software/index',
name: 'BaseSoftwareIndex',
component: () => import('@/views/base/software/Index')
},
+ {
+ path: '/base/httpserver/index',
+ name: 'BaseHttpServerIndex',
+ component: () => import('@/views/base/httpserver/Index')
+ },
{
path: '/base/system/index',
name: 'BaseSystemIndex',
diff --git a/frontend/src/config/subMenu.js b/frontend/src/config/subMenu.js
index 6badb77..2b0449a 100644
--- a/frontend/src/config/subMenu.js
+++ b/frontend/src/config/subMenu.js
@@ -69,6 +69,12 @@ export default {
pageName: 'BaseSoftwareIndex',
params: {}
},
+ 'menu_510' : {
+ icon: 'profile',
+ title: 'http服务',
+ pageName: 'BaseHttpServerIndex',
+ params: {}
+ },
'menu_900' : {
icon: 'profile',
title: '测试',
diff --git a/frontend/src/layouts/AppSider.vue b/frontend/src/layouts/AppSider.vue
index 9dd34f7..8866d67 100644
--- a/frontend/src/layouts/AppSider.vue
+++ b/frontend/src/layouts/AppSider.vue
@@ -47,17 +47,13 @@ export default {
};
},
created () {
- //console.log('[sider] [created] 1');
},
mounted () {
- //console.log('[sider] [mounted] 2');
this.menuHandle()
},
methods: {
menuHandle (e) {
this.current = e ? e.key : this.default_key;
- //console.log('[sider] [methods] 3');
- //console.log('[sider] [methods] current', this.current);
const linkInfo = this.menu[this.current]
console.log('[home] load page:', linkInfo.pageName);
this.$router.push({ name: linkInfo.pageName, params: linkInfo.params})
diff --git a/frontend/src/views/base/httpserver/Index.vue b/frontend/src/views/base/httpserver/Index.vue
new file mode 100644
index 0000000..7d53866
--- /dev/null
+++ b/frontend/src/views/base/httpserver/Index.vue
@@ -0,0 +1,73 @@
+
+ * 状态:{{ currentStatus }} * 地址:{{ servicAddress }}
当前状态:{{ currentStatus }}
+* 当前状态:{{ currentStatus }}
* 拔掉电源,使用电池供电
* 接入电源
diff --git a/frontend/src/views/base/testapi/Index.vue b/frontend/src/views/base/testapi/Index.vue index 6df01c5..9a2e5b2 100644 --- a/frontend/src/views/base/testapi/Index.vue +++ b/frontend/src/views/base/testapi/Index.vue @@ -6,8 +6,10 @@