gsx 2 anni fa
parent
commit
1e7e5e4ed9

+ 1 - 1
electron/controller/framework.js

@@ -217,7 +217,7 @@ class FrameworkController extends Controller {
   /**
    * 异步消息类型
    */ 
-   async ipcInvokeMsg(args, event) {
+  async ipcInvokeMsg(args, event) {
     let timeNow = dayjs().format('YYYY-MM-DD HH:mm:ss');
     const data = args + ' - ' + timeNow;
     

+ 13 - 13
electron/controller/os.js

@@ -29,7 +29,7 @@ class OsController extends Controller {
   /**
    * 消息提示对话框
    */
-  messageShow () {
+  messageShow() {
     dialog.showMessageBoxSync({
       type: 'info', // "none", "info", "error", "question" 或者 "warning"
       title: '自定义标题-message',
@@ -43,7 +43,7 @@ class OsController extends Controller {
   /**
    * 消息提示与确认对话框
    */
-  messageShowConfirm () {
+  messageShowConfirm() {
     const res = dialog.showMessageBoxSync({
       type: 'info',
       title: '自定义标题-message',
@@ -61,7 +61,7 @@ class OsController extends Controller {
   /**
    * 选择目录
    */
-  selectFolder () {
+  selectFolder() {
     const filePaths = dialog.showOpenDialogSync({
       properties: ['openDirectory', 'createDirectory']
     });
@@ -76,7 +76,7 @@ class OsController extends Controller {
   /**
    * 打开目录
    */
-  openDirectory (args) {
+  openDirectory(args) {
     if (!args.id) {
       return false;
     }
@@ -94,7 +94,7 @@ class OsController extends Controller {
   /**
    * 加载视图内容
    */
-  loadViewContent (args) {
+  loadViewContent(args) {
     const { type, content } = args;
     let contentUrl = content;
     if (type == 'html') {
@@ -109,7 +109,7 @@ class OsController extends Controller {
   /**
    * 移除视图内容
    */
-  removeViewContent () {
+  removeViewContent() {
    
     this.service.os.removeBrowserView();
 
@@ -119,7 +119,7 @@ class OsController extends Controller {
   /**
    * 打开新窗口
    */
-  createWindow (args) {
+  createWindow(args) {
     const { type, content, windowName, windowTitle } = args;
     let contentUrl = null;
     if (type == 'html') {
@@ -155,7 +155,7 @@ class OsController extends Controller {
   /**
    * 获取窗口contents id
    */
-  getWCid (args) {
+  getWCid(args) {
     const addonWindow = this.app.addon.window;
 
     // 主窗口的name默认是main,其它窗口name开发者自己定义
@@ -189,7 +189,7 @@ class OsController extends Controller {
   /**
    * 创建系统通知
    */
-  sendNotification (args, event) {
+  sendNotification(args, event) {
     const { title, subtitle, body, silent} = args;
 
     if (!Notification.isSupported()) {
@@ -218,7 +218,7 @@ class OsController extends Controller {
   /**
    * 电源监控
    */
-  initPowerMonitor (args, event) {
+  initPowerMonitor(args, event) {
     const channel = 'controller.os.initPowerMonitor';
     powerMonitor.on('on-ac', (e) => {
       let data = {
@@ -258,7 +258,7 @@ class OsController extends Controller {
   /**
    * 获取屏幕信息
    */
-  getScreen (args) {
+  getScreen(args) {
     let data = [];
     let res = {};
     if (args == 0) {
@@ -322,7 +322,7 @@ class OsController extends Controller {
   /**
    * 获取系统主题
    */
-  getTheme () {
+  getTheme() {
     let theme = 'system';
     if (nativeTheme.shouldUseHighContrastColors) {
       theme = 'light';
@@ -336,7 +336,7 @@ class OsController extends Controller {
   /**
    * 设置系统主题
    */
-  setTheme (args) {
+  setTheme(args) {
 
     // TODO 好像没有什么明显效果
     nativeTheme.themeSource = args;

+ 7 - 9
frontend/src/views/framework/socket/Ipc.vue

@@ -79,13 +79,12 @@ export default {
   },
   methods: {
     init () {
-      const self = this;
       // 避免重复监听,或者将 on 功能写到一个统一的地方,只加载一次
       this.$ipc.removeAllListeners(ipcApiRoute.ipcSendMsg);
       this.$ipc.on(ipcApiRoute.ipcSendMsg, (event, result) => {
         console.log('[ipcRenderer] [socketMsgStart] result:', result);
 
-        self.messageString = result;
+        this.messageString = result;
         // 调用后端的另一个接口
         event.sender.send(ipcApiRoute.hello, 'electron-egg');
       })
@@ -110,28 +109,27 @@ export default {
       }
       this.$ipc.send(ipcApiRoute.ipcSendMsg, params)
     },
-    handleInvoke () {
-      const self = this;
+    handleInvoke() {
       this.$ipc.invoke(ipcApiRoute.ipcInvokeMsg, '异步-回调').then(r => {
         console.log('r:', r);
-        self.message1 = r;
+        this.message1 = r;
       });
     },
-    async handleInvoke2 () {
+    async handleInvoke2() {
       const msg = await this.$ipc.invoke(ipcApiRoute.ipcInvokeMsg, '异步');
       console.log('msg:', msg);
       this.message2 = msg;
     },
-    handleSendSync () {
+    handleSendSync() {
       const msg = this.$ipc.sendSync(ipcApiRoute.ipcSendSyncMsg, '同步');
       this.message3 = msg;
     },
-    createWindow (index) {
+    createWindow(index) {
       this.$ipc.invoke(ipcApiRoute.createWindow, this.views[index]).then(id => {
         console.log('[createWindow] id:', id);
       })
     },
-    async sendTosubWindow () {
+    async sendTosubWindow() {
       // 新窗口id
       this.newWcId = await this.$ipc.invoke(ipcApiRoute.getWCid, this.windowName);
       this.$ipc.sendTo(this.newWcId, specialIpcRoute.window1ToWindow2, '窗口1通过 sendTo 给窗口2发送消息');