From 1a8e6f453213dc296faa23a488b6a9ab4541b357 Mon Sep 17 00:00:00 2001 From: shuxiaokai <2581105856@qq.com> Date: Tue, 14 Sep 2021 18:32:49 +0800 Subject: [PATCH] =?UTF-8?q?upd:=20=E6=9B=B4=E6=96=B0electron=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E7=AD=96=E7=95=A5=E5=92=8C=E4=B8=BB=E6=96=87=E4=BB=B6?= =?UTF-8?q?ts=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/background.ts | 2 ++ src/main/update.ts | 4 ++-- src/renderer/helper/index.ts | 2 +- src/renderer/pages/layout/layout.vue | 6 +++++- vue.config.js | 13 +++++++++++++ 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main/background.ts b/src/main/background.ts index 484ef683..7d838edc 100644 --- a/src/main/background.ts +++ b/src/main/background.ts @@ -3,6 +3,7 @@ import { app, protocol, BrowserWindow } from "electron" import { createProtocol } from "vue-cli-plugin-electron-builder/lib" import installExtension, { VUEJS_DEVTOOLS } from "electron-devtools-installer" +import update from "./update"; const isDevelopment = process.env.NODE_ENV !== "production" // Scheme must be registered before the app is ready @@ -64,6 +65,7 @@ app.on("ready", async () => { } } createWindow() + update(); }) // Exit cleanly on request from parent process in development mode. diff --git a/src/main/update.ts b/src/main/update.ts index 86677669..ae0db91a 100644 --- a/src/main/update.ts +++ b/src/main/update.ts @@ -6,7 +6,7 @@ import path from "path"; import { autoUpdater } from "electron-updater"; import { BrowserWindow, ipcMain } from "electron"; -import config from "@/../config/config.js"; +import config from "../config/config"; function update(): void { const { server } = config.updateConfig; @@ -14,7 +14,7 @@ function update(): void { const winId = BrowserWindow.getFocusedWindow()?.id; const win = BrowserWindow.fromId(winId as number); if (process.env.NODE_ENV === "development") { - autoUpdater.updateConfigPath = path.join(__dirname, "../../dev-app-update.yml"); + autoUpdater.updateConfigPath = path.join(__dirname, "../local-update.yml"); } //=====================================render进程事件====================================// ipcMain.on("vue-check-update", () => { diff --git a/src/renderer/helper/index.ts b/src/renderer/helper/index.ts index 9e321176..0799a500 100644 --- a/src/renderer/helper/index.ts +++ b/src/renderer/helper/index.ts @@ -342,7 +342,6 @@ function convertToJson(properties: Properties, options: ConvertToObjectOptions): const isParentArray = (parent && parent.type === "array"); const isComplex = (type === "object" || type === "array" || type === "file"); const keyValIsEmpty = key === "" && value === "" - if (jumpChecked && !property.select) { //过滤掉_select属性为false的值 continue; } @@ -464,6 +463,7 @@ export function apidocConvertParamsToJsonData(properties: Properties, jumpChecke } const rootType = properties[0].type; const rootValue = properties[0].value; + if (rootType === "boolean") { return rootValue === "true" ? true : false; } else if (rootType === "string") { diff --git a/src/renderer/pages/layout/layout.vue b/src/renderer/pages/layout/layout.vue index 069c1e8f..c32e5c02 100644 --- a/src/renderer/pages/layout/layout.vue +++ b/src/renderer/pages/layout/layout.vue @@ -113,6 +113,10 @@ export default defineComponent({ }, created() { this.activeMenuPath = this.$route.path; + this.initUploadEvent(); + if (this.config.updateConfig.autoUpdate) { + this.handleCheckUpdate(); + } }, methods: { //初始化自动更新相关事件 @@ -157,7 +161,7 @@ export default defineComponent({ } }, //检查更新 - handleCheckUpdate(isManual: boolean) { + handleCheckUpdate(isManual = false) { this.downloading = true; this.isManual = isManual; if (config.isElectron) { diff --git a/vue.config.js b/vue.config.js index 93b2193f..1fd1f80f 100644 --- a/vue.config.js +++ b/vue.config.js @@ -42,6 +42,7 @@ module.exports = { }, pluginOptions: { electronBuilder: { + contextIsolation: false, nodeIntegration: true, //参考https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html extends: null, externals: [ @@ -96,6 +97,18 @@ module.exports = { icon: "build/icons", }, }, + //参考 https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/1432 + chainWebpackMainProcess: config => { + config.module + .rule("babel") + .before("ts") + .use("babel") + .loader("babel-loader") + .options({ + presets: [["@babel/preset-env", { modules: false }]], + plugins: ["@babel/plugin-proposal-class-properties"] + }) + } }, }, //=====================================eslint配置====================================//