upd: 更新electron下载策略和主文件ts编译

master
shuxiaokai 3 years ago
parent e8e8fa863b
commit 1a8e6f4532

@ -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.

@ -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", () => {

@ -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") {

@ -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) {

@ -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配置====================================//

Loading…
Cancel
Save