Browse Source

open software

gsx 4 years ago
parent
commit
28f50b354c

+ 8 - 0
app/controller/v1/example.js

@@ -181,6 +181,14 @@ class ExampleController extends BaseController {
 
     this.sendSuccess(data);
   }
+
+  async openSoftware() {
+    const { service } = this;
+    const data = {};
+    await service.example.openSoftware('powershell.exe');
+
+    this.sendSuccess(data);
+  }
 }
 
 module.exports = ExampleController;

+ 2 - 0
app/router/example.js

@@ -29,4 +29,6 @@ module.exports = app => {
   router.post('/api/v1/example/autoLaunchDisable', controller.v1.example.autoLaunchDisable);
   // is launch 
   router.post('/api/v1/example/autoLaunchIsEnabled', controller.v1.example.autoLaunchIsEnabled);
+  // open software
+  router.post('/api/v1/example/openSoftware', controller.v1.example.openSoftware);
 };

+ 5 - 0
app/service/example.js

@@ -77,6 +77,11 @@ class ExampleService extends BaseService {
 
     return callResult.data;
   }
+
+  async openSoftware(softName) {
+    let result = await this.ipcCall('example.openSoftware', softName);
+    return result;
+  }
 }
 
 module.exports = ExampleService;

+ 11 - 1
electron/apis/example.js

@@ -1,7 +1,6 @@
 'use strict';
 
 const path = require('path');
-
 const {app, webContents, shell} = require('electron');
 const AutoLaunchManager = require('../lib/autoLaunch');
 const shortcut = require('../lib/shortcut');
@@ -52,6 +51,17 @@ exports.autoLaunchIsEnabled = function () {
   return isEnable
 }
 
+exports.openSoftware = function (softName = '') {
+  if (!softName) {
+    return false;
+  }
+
+  let powershellPath = path.join(app.getAppPath(), "..", "tmp", softName);
+  console.log(powershellPath);
+
+  return true;
+}
+
 function getElectronPath(filepath) {
   //filepath = path.resolve(filepath);
   filepath = filepath.replace("resources", "");

+ 0 - 15
electron/lib/openSoftware.js

@@ -1,15 +0,0 @@
-const { app } = require('electron');
-
-class OpenSoftware {
-	constructor () {
-		if (typeof this.instance === 'object') {
-			return this.instance;
-		}
-	}
-  test () {
-    
-    return true;
-  }
-}
-
-module.exports = OpenSoftware;

+ 0 - 4
electron/preferences.js

@@ -13,8 +13,4 @@ module.exports = () => {
 
   // awaken 
   awaken.setup();
-
-  // Open third party software
-  
-  
 }

+ 2 - 1
frontend/src/api/main.js

@@ -9,7 +9,8 @@ const mainApi = {
   setShortcut: '/api/v1/example/setShortcut',
   autoLaunchEnable: '/api/v1/example/autoLaunchEnable',
   autoLaunchDisable: '/api/v1/example/autoLaunchDisable',
-  autoLaunchIsEnabled: '/api/v1/example/autoLaunchIsEnabled'
+  autoLaunchIsEnabled: '/api/v1/example/autoLaunchIsEnabled',
+  openSoftware: '/api/v1/example/openSoftware',
 }
 
 /**

+ 5 - 0
frontend/src/config/router.config.js

@@ -28,6 +28,11 @@ export const constantRouterMap = [
         component: () => import('@/views/example/Shortcut')
       },
       {
+        path: 'openSoftware',
+        name: 'OpenSoftware',
+        component: () => import('@/views/example/OpenSoftware')
+      },
+      {
         path: 'setting',
         name: 'Setting',
         component: () => import('@/views/Setting')

+ 5 - 0
frontend/src/views/Layout.vue

@@ -73,6 +73,11 @@ export default {
             title: '快捷键',
             pageName: 'Shortcut',
             params: {},
+          },
+          'subMenu_5' : {
+            title: '打开其它软件',
+            pageName: 'OpenSoftware',
+            params: {},
           }
         },
         'menu_2' : {

+ 51 - 0
frontend/src/views/example/OpenSoftware.vue

@@ -0,0 +1,51 @@
+<template>
+  <div>
+    <h3 :style="{ marginBottom: '16px' }">
+      demo5 打开其它软件
+    </h3>
+    <a-list bordered :data-source="data">
+      <a-list-item @click="openSoft(item.id)" slot="renderItem" slot-scope="item">
+        {{ item.content }}
+        <a-button type="link">
+          打开
+        </a-button>
+      </a-list-item>
+    </a-list>
+  </div>
+</template>
+<script>
+import { localApi } from '@/api/main'
+
+const data = [
+  {
+    content: 'powershell.exe',
+    id: 'powershell'
+  }
+];
+
+export default {
+  data() {
+    return {
+      data,
+    };
+  },
+  methods: {
+    openSoft (id) {
+      console.log('id:', id)
+      const params = {
+        'id': id
+      }
+			localApi('openSoftware', params).then(res => {
+				if (res.code !== 0) {
+					// this.$message.info('error')
+					return false
+				}
+				this.$message.info('成功')
+			}).catch(err => {
+				console.log('err:', err)
+			})
+    },
+  }
+};
+</script>
+<style></style>