umbrella22

将主进程修改为ts,主进程添加__lib文件路径,更新依赖

......@@ -2,13 +2,15 @@
process.env.BABEL_ENV = 'main'
const os = require('os')
const path = require('path')
const { dependencies } = require('../package.json')
const webpack = require('webpack')
const MinifyPlugin = require("babel-minify-webpack-plugin");
const HappyPack = require('happypack')
const HappyThreadPool = HappyPack.ThreadPool({ size: os.cpus().length > 4 ? 4 : os.cpus().length })
const config = require('../config')
// const os = require('os')
// const HappyPack = require('happypack')
// const HappyThreadPool = HappyPack.ThreadPool({ size: os.cpus().length > 4 ? 4 : os.cpus().length })
function resolve(dir) {
return path.join(__dirname, '..', dir)
......@@ -16,7 +18,7 @@ function resolve(dir) {
let mainConfig = {
entry: {
main: path.join(__dirname, '../src/main/index.js')
main: path.join(__dirname, '../src/main/index.ts')
},
externals: [
...Object.keys(dependencies || {})
......@@ -34,10 +36,20 @@ let mainConfig = {
// }
// }
// },
// {
// test: /\.js$/,
// use: 'happypack/loader?id=MainHappyBabel',
// exclude: /node_modules/
// },
{
test: /\.js$/,
use: 'happypack/loader?id=MainHappyBabel',
exclude: /node_modules/
test: /\.ts$/,
use: [{
loader: 'babel-loader',
options: {
cacheDirectory: true
}
}, 'ts-loader'],
},
{
test: /\.node$/,
......@@ -56,16 +68,16 @@ let mainConfig = {
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new HappyPack({
id: "MainHappyBabel",
loaders: [{
loader: 'babel-loader',
options: {
cacheDirectory: true
}
}],
threadPool: HappyThreadPool
})
// new HappyPack({
// id: "MainHappyBabel",
// loaders: [{
// loader: 'babel-loader',
// options: {
// cacheDirectory: true
// }
// }],
// threadPool: HappyThreadPool
// })
],
resolve: {
alias: {
......@@ -82,7 +94,8 @@ let mainConfig = {
if (process.env.NODE_ENV !== 'production') {
mainConfig.plugins.push(
new webpack.DefinePlugin({
'__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`
'__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`,
'__lib': `"${path.join(__dirname, `../${config.DllFolder}`).replace(/\\/g, '\\\\')}"`
})
)
}
......
......@@ -9,7 +9,7 @@ module.exports = {
chineseLog: false,
port: 9080
},
UseStartupChart: false,
UseStartupChart: true,
IsUseSysTitle: true,
DllFolder: '',
BuiltInServerPort: 25565
......
......@@ -81,11 +81,11 @@
"js-cookie": "^2.2.1",
"nprogress": "^0.2.0",
"vue": "^2.6.11",
"vue-router": "^3.3.2",
"vue-router": "^3.4.3",
"vuex": "^3.5.1"
},
"devDependencies": {
"@babel/core": "^7.11.0",
"@babel/core": "^7.11.1",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/plugin-proposal-decorators": "^7.10.5",
"@babel/plugin-proposal-do-expressions": "^7.10.4",
......@@ -106,7 +106,9 @@
"@babel/polyfill": "^7.10.4",
"@babel/preset-env": "^7.11.0",
"@babel/register": "^7.10.5",
"@babel/runtime": "^7.11.0",
"@babel/runtime": "^7.11.2",
"@types/fs-extra": "^9.0.1",
"@types/node": "^14.0.27",
"ajv": "^6.12.3",
"babel-eslint": "^9.0.0",
"babel-loader": "^8.1.0",
......@@ -116,16 +118,16 @@
"chalk": "^4.0.0",
"copy-webpack-plugin": "^6.0.3",
"cross-env": "^7.0.2",
"css-loader": "^4.2.0",
"css-loader": "^4.2.1",
"del": "^5.1.0",
"electron": "^9.1.2",
"electron-builder": "^22.6.1",
"electron": "^9.2.0",
"electron-builder": "^22.8.0",
"electron-devtools-installer": "^3.1.1",
"eslint": "^6.8.0",
"eslint-config-standard": "^14.1.1",
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^3.0.4",
"eslint-plugin-html": "^6.0.2",
"eslint-plugin-html": "^6.0.3",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-node": "^9.2.0",
"eslint-plugin-promise": "^4.2.1",
......@@ -133,17 +135,19 @@
"file-loader": "^6.0.0",
"happypack": "^5.0.1",
"html-webpack-plugin": "^4.3.0",
"mini-css-extract-plugin": "0.9.0",
"mini-css-extract-plugin": "0.10.0",
"multispinner": "^0.2.1",
"node-loader": "^1.0.0",
"node-loader": "^1.0.1",
"portfinder": "^1.0.28",
"sass": "^1.26.10",
"sass-loader": "^9.0.2",
"sass-loader": "^9.0.3",
"split2": "^3.1.1",
"style-loader": "^1.2.1",
"svg-sprite-loader": "^5.0.0",
"terser-webpack-plugin": "^3.0.8",
"terser-webpack-plugin": "^4.1.0",
"through2-filter": "^3.0.0",
"ts-loader": "^8.0.2",
"typescript": "^3.9.7",
"url-loader": "^4.1.0",
"vue-html-loader": "^1.2.4",
"vue-loader": "^15.9.3",
......@@ -153,6 +157,6 @@
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0",
"webpack-hot-middleware": "^2.25.0",
"webpack-merge": "^5.0.9"
"webpack-merge": "^5.1.1"
}
}
......
import { globalShortcut } from 'electron'
import config from '@config'
import config from '@config/index'
export default {
Disablef12 () {
......
// 这里定义了静态文件路径的位置
import path from 'path'
/**
* Set `__static` path to static files in production
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
*/
// 这个瓜皮全局变量只能在单个js中生效,而并不是整个主进程中
if (process.env.NODE_ENV !== 'development') {
global.__static = path.join(__dirname, '/static').replace(/\\/g, '\\\\')
}
export const winURL = process.env.NODE_ENV === 'development' ? `http://localhost:${process.env.PORT}` : `file://${__dirname}/index.html`
export const loadingURL = process.env.NODE_ENV === 'development' ? `http://localhost:${process.env.PORT}/static/loader.html` : `file://${__static}/loader.html`
// 这里定义了静态文件路径的位置
import { join } from 'path'
import { DllFolder } from '@config/index'
var __static: string
var __lib: string
if (process.env.NODE_ENV !== 'development') {
__static = join(__dirname, '/static').replace(/\\/g, '\\\\');
__lib = join(__dirname, '..', '..', '..', '..', `${DllFolder}`).replace(/\\/g, '\\\\')
}
export const winURL = process.env.NODE_ENV === 'development' ? `http://localhost:${process.env.PORT}` : `file://${__dirname}/index.html`
export const loadingURL = process.env.NODE_ENV === 'development' ? `http://localhost:${process.env.PORT}/static/loader.html` : `file://${__static}/loader.html`
export const lib = __lib
\ No newline at end of file
// 这里是定义菜单的地方,详情请查看 https://electronjs.org/docs/api/menu
const { dialog } = require('electron')
const os = require('os')
const version = require('../../../package.json').version
import { dialog } from 'electron'
import { type, arch, release } from 'os'
import { version } from '../../../package.json'
const menu = [
{
label: '设置',
......@@ -24,14 +25,15 @@ const menu = [
}
}]
}]
function info () {
function info() {
dialog.showMessageBox({
title: '关于',
type: 'info',
message: 'electron-Vue框架',
detail: `版本信息:${version}\n引擎版本:${process.versions.v8}\n当前系统:${os.type()} ${os.arch()} ${os.release()}`,
detail: `版本信息:${version}\n引擎版本:${process.versions.v8}\n当前系统:${type()} ${arch()} ${release()}`,
noLink: true,
buttons: ['查看github', '确定']
})
}
export default menu
......
......@@ -5,7 +5,7 @@ import initWindow from './services/windowManager'
import DisableButton from './config/DisableButton'
function onAppReady () {
initWindow()
new initWindow().initWindow()
DisableButton.Disablef12()
}
......
/* eslint-disable prefer-promise-reject-errors */
import app from './server'
import http from 'http'
import config from '@config'
import { createServer } from 'http'
import config from '@config/index'
const port = config.BuiltInServerPort
var server = null
app.set('port', port)
export default {
StatrServer () {
StatrServer() {
return new Promise((resolve, reject) => {
server = http.createServer(app)
server = createServer(app)
server.listen(port)
server.on('error', (error) => {
switch (error.code) {
......@@ -28,9 +28,8 @@ export default {
})
})
},
StopServer () {
StopServer() {
return new Promise((resolve, reject) => {
console.log(server)
if (server) {
server.close()
server.on('close', () => {
......
import { autoUpdater } from 'electron-updater'
import { ipcMain } from 'electron'
import { ipcMain, BrowserWindow } from 'electron'
/**
* -1 检查更新失败 0 正在检查更新 1 检测到新版本,准备下载 2 未检测到新版本 3 下载中 4 下载完成
**/
function Message (mainWindow, type, data) {
const senddata = {
state: type,
msg: data
}
mainWindow.webContents.send('UpdateMsg', senddata)
}
export default {
Update (mainWindow) {
// 设置地址要和package中的一样
class Update {
public mainWindow: BrowserWindow
constructor(mainWindow: BrowserWindow) {
autoUpdater.setFeedURL('http://127.0.0.1:25565/')
this.mainWindow = mainWindow
// 注册事件
this.checkUpdate()
this.start()
this.hasData()
this.noData()
this.listen()
this.done()
this.quitInstall()
this.error()
}
// 负责向渲染进程发送信息
Message(mainWindow: BrowserWindow, type: Number, data?: String) {
const senddata = {
state: type,
msg: data || ''
}
mainWindow.webContents.send('UpdateMsg', senddata)
}
// 当更新发生错误的时候触发。
// 当更新发生错误的时候触发。
error() {
autoUpdater.on('error', (err) => {
console.log('更新出现错误')
console.log(err.message)
console.log('更新出现错误', err.message)
if (err.message.includes('sha512 checksum mismatch')) {
Message(mainWindow, -1, 'sha512校验失败')
this.Message(this.mainWindow, -1, 'sha512校验失败')
}
})
}
// 当开始检查更新的时候触发
// 当开始检查更新的时候触发
start() {
autoUpdater.on('checking-for-update', (event, arg) => {
console.log('开始检查更新')
Message(mainWindow, 0)
this.Message(this.mainWindow, 0)
})
}
// 发现可更新数据时
// 发现可更新数据时
hasData() {
autoUpdater.on('update-available', (event, arg) => {
console.log('有更新')
Message(mainWindow, 1)
this.Message(this.mainWindow, 1)
})
}
// 没有可更新数据时
// 没有可更新数据时
noData() {
autoUpdater.on('update-not-available', (event, arg) => {
console.log('没有更新')
Message(mainWindow, 2)
this.Message(this.mainWindow, 2)
})
}
// 下载监听
// 下载监听
listen() {
autoUpdater.on('download-progress', (progressObj) => {
Message(mainWindow, 3, progressObj)
this.Message(this.mainWindow, 3, progressObj)
})
}
// 下载完成
// 下载完成
done() {
autoUpdater.on('update-downloaded', () => {
console.log('下载完成')
Message(mainWindow, 4)
this.Message(this.mainWindow, 4)
})
// 执行自动更新检查
}
// 执行自动更新检查
checkUpdate() {
ipcMain.handle('check-update', () => {
autoUpdater.checkForUpdates().catch(err => {
console.log('网络连接问题', err)
})
})
// 渲染进程执行更新操作
}
// 退出并安装
quitInstall() {
ipcMain.handle('confirm-update', () => {
autoUpdater.quitAndInstall()
})
}
}
export default Update
......
/* eslint-disable no-case-declarations */
import { app, ipcMain, dialog } from 'electron'
import path from 'path'
import os from 'os'
// 版本以package.json为基准。
const version = require('../../../package.json').version
// 您的下载地址
const baseUrl = 'http://127.0.0.1:25565/'
var Sysarch = null
var defaultDownloadUrL = null
// 识别操作系统位数D
os.arch().includes('64') ? Sysarch = 'win64' : Sysarch = 'win32'
// 识别操作系统
// linux自己修改后缀名哦,我没有linux就没有测试了
if (os.platform().includes('win32')) {
defaultDownloadUrL = baseUrl + `electron_${version}_${Sysarch}.exe?${new Date().getTime()}`
} else if (os.platform().includes('linux')) {
defaultDownloadUrL = baseUrl + `electron_${version}_${Sysarch}?${new Date().getTime()}`
} else {
defaultDownloadUrL = baseUrl + `electron_${version}_mac.dmg?${new Date().getTime()}`
}
export default {
download (mainWindow) {
ipcMain.handle('start-download', (event, msg) => {
mainWindow.webContents.downloadURL(msg.downloadUrL || defaultDownloadUrL)
mainWindow.webContents.session.on('will-download', (event, item, webContents) => {
// 将文件保存在系统的下载目录
const filePath = path.join(app.getPath('downloads'), item.getFilename())
// 自动保存
item.setSavePath(filePath)
// 下载进度
item.on('updated', (event, state) => {
switch (state) {
case 'progressing':
mainWindow.webContents.send('download-progress', (item.getReceivedBytes() / item.getTotalBytes() * 100).toFixed(0))
break
case 'interrupted ':
mainWindow.webContents.send('download-paused', true)
break
default:
break
}
})
// 下载完成或失败
item.once('done', (event, state) => {
switch (state) {
case 'completed':
const data = {
filePath
}
mainWindow.webContents.send('download-done', data)
break
case 'interrupted':
mainWindow.webContents.send('download-error', true)
dialog.showErrorBox('下载出错', '由于网络或其他未知原因导致客户端下载出错,请前往官网进行重新安装')
break
default:
break
}
})
})
})
}
}
import { app, ipcMain, BrowserWindow, dialog } from 'electron'
import { join } from 'path'
import { arch, platform } from 'os'
import { exists, remove } from 'fs-extra'
import { version } from '../../../package.json'
/**
*
* @description
* @returns {void} 下载类
* @param {mainWindow} 主窗口
* @param {downloadUrl} 下载地址,当未传入时则会使用预先设置好的baseUrl拼接名称
* @author Sky
* @date 2020-08-12
*/
class Main {
public mainWindow: BrowserWindow = null
public downloadUrl: string = ""
public version: string = version
public baseUrl: string = ''
public Sysarch: string = arch().includes('64') ? 'win64' : 'win32'
public HistoryFilePath = join(app.getPath('downloads'), platform().includes('win32') ? `electron_${this.version}_${this.Sysarch}.exe` : `electron_${this.version}_mac.dmg`)
constructor(mainWindow: BrowserWindow, downloadUrl?: string) {
this.mainWindow = mainWindow
this.downloadUrl = downloadUrl || platform().includes('win32') ? this.baseUrl + `electron_${this.version}_${this.Sysarch}.exe?${new Date().getTime()}` : this.baseUrl + `electron_${this.version}_mac.dmg?${new Date().getTime()}`
}
start() {
ipcMain.on('satrt-download', (event, msg) => {
// 更新时检查有无同名文件,若有就删除,若无就开始下载
exists(this.HistoryFilePath, async (e) => {
try {
if (e) {
await remove(this.HistoryFilePath)
}
this.mainWindow.webContents.downloadURL(this.downloadUrl)
} catch (error) { console.log(error) }
})
this.mainWindow.webContents.session.on('will-download', (event: any, item: any, webContents: any) => {
const filePath = join(app.getPath('downloads'), item.getFilename())
item.setSavePath(filePath)
item.on('updated', (event: any, state: String) => {
switch (state) {
case 'progressing':
this.mainWindow.webContents.send('download-progress', (item.getReceivedBytes() / item.getTotalBytes() * 100).toFixed(0))
break
default:
this.mainWindow.webContents.send('download-error', true)
dialog.showErrorBox('下载出错', '由于网络或其他未知原因导致客户端下载出错,请前往官网进行重新安装')
break
}
})
item.once('done', (event: any, state: String) => {
switch (state) {
case 'completed':
const data = {
filePath
}
this.mainWindow.webContents.send('download-done', data)
break
case 'interrupted':
this.mainWindow.webContents.send('download-error', true)
dialog.showErrorBox('下载出错', '由于网络或其他未知原因导致客户端下载出错,请前往官网进行重新安装')
break
default:
break
}
})
})
})
}
}
export default Main
import { ipcMain, dialog, BrowserWindow } from 'electron'
import Server from '../server/index'
import Server from '../server'
import { winURL } from '../config/StaticPath'
export default {
Mainfunc (mainWindow, IsUseSysTitle) {
Mainfunc(mainWindow: BrowserWindow, IsUseSysTitle: Boolean) {
ipcMain.handle('IsUseSysTitle', async () => {
return IsUseSysTitle
})
......
import { BrowserWindow, Menu } from 'electron'
import menuconfig from '../config/menu'
import config from '@config'
import setIpc from './ipcMain'
import electronDevtoolsInstaller, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'
import upload from './checkupdate'
import DownloadUpdate from './downloadFile'
import { winURL, loadingURL } from '../config/StaticPath'
var loadWindow = null
var mainWindow = null
function createMainWindow () {
/**
* Initial window options
*/
mainWindow = new BrowserWindow({
height: 800,
useContentSize: true,
width: 1700,
minWidth: 1366,
show: false,
frame: config.IsUseSysTitle,
titleBarStyle: 'hidden',
webPreferences: {
nodeIntegration: true,
webSecurity: false,
// 如果是开发模式可以使用devTools
devTools: process.env.NODE_ENV === 'development',
// devTools: true,
// 在macos中启用橡皮动画
scrollBounce: process.platform === 'darwin'
}
})
// 这里设置只有开发环境才注入显示开发者模式
if (process.env.NODE_ENV === 'development') {
menuconfig.push({
label: '开发者设置',
submenu: [{
label: '切换到开发者模式',
accelerator: 'CmdOrCtrl+I',
role: 'toggledevtools'
}]
})
}
// 载入菜单
const menu = Menu.buildFromTemplate(menuconfig)
Menu.setApplicationMenu(menu)
mainWindow.loadURL(winURL)
setIpc.Mainfunc(mainWindow, config.IsUseSysTitle)
upload.Update(mainWindow)
DownloadUpdate.download(mainWindow)
if (process.env.NODE_ENV === 'development') {
mainWindow.webContents.once('dom-ready', () => {
mainWindow.show()
electronDevtoolsInstaller(VUEJS_DEVTOOLS)
.then((name) => console.log(`installed: ${name}`))
.catch(err => console.log('Unable to install `vue-devtools`: \n', err))
})
if (config.UseStartupChart) loadWindow.destroy()
mainWindow.webContents.openDevTools(true)
} else {
mainWindow.webContents.once('dom-ready', () => {
mainWindow.show()
if (config.UseStartupChart) loadWindow.destroy()
})
}
mainWindow.on('closed', () => {
mainWindow = null
})
}
function loadindWindow () {
loadWindow = new BrowserWindow({
width: 400,
height: 600,
frame: false,
backgroundColor: '#222',
skipTaskbar: true,
transparent: true,
resizable: false,
webPreferences: { experimentalFeatures: true }
})
loadWindow.loadURL(loadingURL)
loadWindow.show()
setTimeout(() => {
createMainWindow()
}, 2000)
loadWindow.on('closed', () => {
loadWindow = null
})
}
function initWindow () {
if (config.UseStartupChart) {
return loadindWindow()
} else {
return createMainWindow()
}
}
export default initWindow
import setIpc from './ipcMain'
import config from '@config/index'
import menuconfig from '../config/menu'
import DownloadUpdate from './downloadFile'
import Update from './checkupdate';
import { app, BrowserWindow, Menu, dialog } from 'electron'
import { winURL, loadingURL } from '../config/StaticPath'
import electronDevtoolsInstaller, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'
class MainInit {
public winURL: string = ''
public shartURL: string = ''
public loadWindow: BrowserWindow = null
public mainWindow: BrowserWindow = null
constructor() {
this.winURL = winURL
this.shartURL = loadingURL
if (process.env.NODE_ENV === 'development') {
menuconfig.push({
label: '开发者设置',
submenu: [{
label: '切换到开发者模式',
accelerator: 'CmdOrCtrl+I',
role: 'toggledevtools'
}]
})
}
}
// 主窗口函数
createMainWindow() {
this.mainWindow = new BrowserWindow({
height: 800,
useContentSize: true,
width: 1700,
minWidth: 1366,
show: false,
frame: config.IsUseSysTitle,
titleBarStyle: 'hidden',
webPreferences: {
nodeIntegration: true,
webSecurity: false,
// 如果是开发模式可以使用devTools
devTools: process.env.NODE_ENV === 'development',
// devTools: true,
// 在macos中启用橡皮动画
scrollBounce: process.platform === 'darwin'
}
})
// 赋予模板
const menu = Menu.buildFromTemplate(menuconfig as any)
// 加载模板
Menu.setApplicationMenu(menu)
// 加载主窗口
this.mainWindow.loadURL(this.winURL)
// 下载文件
new DownloadUpdate(this.mainWindow).start()
// electron-update注册
new Update(this.mainWindow)
// 启用协议,这里暂时只用于自定义头部的时候使用
setIpc.Mainfunc(this.mainWindow, config.IsUseSysTitle)
// 安装devtools
if (process.env.NODE_ENV === 'development') {
this.mainWindow.webContents.once('dom-ready', () => {
this.mainWindow.show()
electronDevtoolsInstaller(VUEJS_DEVTOOLS)
.then((name) => console.log(`已安装: ${name}`))
.catch(err => console.log('无法安装 `vue-devtools`: \n 可能发生得错误:网络连接问题 \n', err))
if (config.UseStartupChart) this.loadWindow.destroy()
this.mainWindow.webContents.openDevTools({ mode: 'undocked', activate: true })
})
} else {
this.mainWindow.webContents.once('dom-ready', () => {
this.mainWindow.show()
if (config.UseStartupChart) this.loadWindow.destroy()
})
}
// 当确定渲染进程卡死时
this.mainWindow.webContents.on('crashed', () => {
dialog.showMessageBox(this.mainWindow, {
type: 'warning',
title: '警告',
buttons: ['重载', '退出'],
message: '图形化进程失去响应,是否等待其恢复?',
noLink: true
}).then(res => {
if (res.response === 0) this.mainWindow.reload()
else this.mainWindow.close()
})
})
// 不知道什么原因,反正就是这个窗口里的页面触发了假死时执行
this.mainWindow.on('unresponsive', () => {
dialog.showMessageBox(this.mainWindow, {
type: 'warning',
title: '警告',
buttons: ['重载', '退出'],
message: '图形化进程失去响应,是否等待其恢复?',
noLink: true
}).then(res => {
if (res.response === 0) this.mainWindow.reload()
else this.mainWindow.close()
})
})
app.on('gpu-process-crashed', () => {
dialog.showMessageBox(this.mainWindow, {
type: 'warning',
title: '',
buttons: ['切换', '退出'],
message: '侦测到图形处理设备丢失,若继续则会导致软件出现意外故障,是否切换到通用模式,若切换后仍然黑屏请联系我们。',
noLink: true
}).then(res => {
// 当显卡出现崩溃现象时使用该设置禁用显卡加速模式。
if (res.response === 0) {
app.disableHardwareAcceleration()
this.mainWindow.reload()
} else {
this.mainWindow.close()
}
})
})
this.mainWindow.on('closed', () => {
this.mainWindow = null
})
}
// 加载窗口函数
loadindWindow(loadingURL: string) {
this.loadWindow = new BrowserWindow({
width: 400,
height: 600,
frame: false,
skipTaskbar: true,
transparent: true,
resizable: false,
webPreferences: { experimentalFeatures: true }
})
this.loadWindow.loadURL(loadingURL)
this.loadWindow.show()
this.loadWindow.setAlwaysOnTop(true)
// 延迟两秒可以根据情况后续调快,= =,就相当于个,sleep吧,就那种。 = =。。。
setTimeout(() => {
this.createMainWindow()
}, 1500)
}
// 初始化窗口函数
initWindow() {
if (config.UseStartupChart) {
return this.loadindWindow(this.shartURL)
} else {
return this.createMainWindow()
}
}
}
export default MainInit
import { ipcRenderer } from 'electron'
export default {
send (name, data = {}) {
send (name, data) {
return new Promise((resolve, reject) => {
ipcRenderer.invoke(name, data).then(res => {
resolve(res)
......
{
"compileOnSave": false,
"compilerOptions": {
"resolveJsonModule": true,
"baseUrl": ".",
"outDir": "./dist/electron",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es5",
"paths": {
"@config/*": [
"config/*"
]
},
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
}
\ No newline at end of file