{"id":771,"date":"2022-05-31T20:38:54","date_gmt":"2022-05-31T12:38:54","guid":{"rendered":"https:\/\/usei.cn\/?p=771"},"modified":"2022-05-31T20:40:33","modified_gmt":"2022-05-31T12:40:33","slug":"eletron-%e5%bc%80%e5%90%af%e8%87%aa%e5%90%af","status":"publish","type":"post","link":"https:\/\/usei.cn\/index.php\/2022\/05\/31\/eletron-%e5%bc%80%e5%90%af%e8%87%aa%e5%90%af\/","title":{"rendered":"eletron \u5f00\u542f\u81ea\u542f"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u4e00\u3002Main\u4e3b\u7ebf\u7a0b<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u5f00\u673a\u81ea\u542f\u4e0e\u5173\u95ed\u542f\u52a8\nipcMain.on('startFun', (e, arg) => {\n  console.log(arg)\n  console.log(app.getLoginItemSettings().openAtLogin)\n  \n  if(arg==app.getLoginItemSettings().openAtLogin) return;\n  if(arg){\n    app.setLoginItemSettings({\n      openAtLogin: arg,\n      path: process.execPath\n    })\n  }else{\n    app.setLoginItemSettings({\n      openAtLogin: false\n    })\n  }<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3002Render\u6e32\u67d3\u8fdb\u7a0b<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;el-menu-item @click=\"startUp()\">\r\n\t&lt;i class=\"el-icon-sort\">&lt;\/i>\r\n  &lt;span v-if=\"autoStart\">\u5173\u95ed\u5f00\u673a\u542f\u52a8&lt;\/span>\r\n  &lt;span v-else>\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8&lt;\/span>\r\n&lt;\/el-menu-item><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>created() {\r\n    this.updateTime()\r\n    \/\/ \u67e5\u8be2\u5f00\u673a\u542f\u52a8\u8bbe\u7f6e\r\n    this.autoStart = ipc.sendSync('getStartFun')\r\n  },\r\n    methods: {\r\n    \/\/ \u5f00\u673a\u542f\u52a8\r\n    startUp() {\r\n       if (!this.autoStart) {\r\n        \/\/ \u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\r\n        ipc.send('startFun', true)\r\n      } else {\r\n        \/\/ \u5173\u95ed\u5f00\u673a\u542f\u52a8\r\n        ipc.send('startFun', false)\r\n      }\r\n      this.autoStart = ipc.sendSync('getStartFun') \/\/ \u91cd\u65b0\u62c9\u53d6\u72b6\u6001\r\n    }\r\n  }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3002Main\u4e3b\u7ebf\u7a0b \u4e8c\u3002Render\u6e32\u67d3\u8fdb\u7a0b<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69,8],"tags":[],"class_list":["post-771","post","type-post","status-publish","format-standard","hentry","category-eletron","category-frontend"],"_links":{"self":[{"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/posts\/771","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/comments?post=771"}],"version-history":[{"count":2,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/posts\/771\/revisions"}],"predecessor-version":[{"id":774,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/posts\/771\/revisions\/774"}],"wp:attachment":[{"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/media?parent=771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/categories?post=771"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/tags?post=771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}