张恒

更新依赖,以及修正之前的遗留问题,还有解决了electron在国内下载不了的问题

......@@ -16,6 +16,7 @@ nrm use taobao
# ELECTRON只要下载了一次您自己没有清除缓存的话,就可以直接使用上次的安装包,这样通过cnpm安装完成之后,一定!要删除一次依赖包!一定哦!
# 再使用npm安装就会使用缓存了,免去那个魔法的过程~~
# 或者可以使用更加优秀的yarn。
# 当然,yarn也需要配置淘宝镜像,需要将配置到系统的环境变量里
npm install or yarn install
# 启动之后,会在9080端口监听
......@@ -41,6 +42,7 @@ npm config edit
这是花裤衩大大原本的[地址](https://github.com/PanJiaChen/electron-vue-admin)
# 更新日志
- 2019年11月22日更新:得益于群里老哥的提醒,通过修改系统环境变量得到了通过yarn下载electron失败的问题,具体操作如下:用户环境变量中新增两个个变量,一个是变量名为`ELECTRON_MIRROR`,变量值为`https://npm.taobao.org/mirrors/electron/`,另一个是变量名为`registry`,变量值为`https://registry.npm.taobao.org/`,然后系统变量中同样也加上这两个值,完成之后,删除node_module文件夹。然后执行yarn install,如果还是提示未安装,那就去electron文件夹内执行一次yarn install,就好了。这样的话,不仅仅只是yarn更快了,electron的rebuild也会加速很多。所以推荐使用yarn。
- 2019年11月19日更新:更新了不使用updater进行全量更新的方法,但是该方法不会校验安装包md5值,也就是说,包如果被拦截了。。可能就会出问题,这一点我正在想办法处理。
- 2019年10月31日更新:升级electron版本至7,但是需要做一些修改,由于淘宝的问题,导致electron新的下载器出现故障,故我们需要对electron的下载器做一些更改,这非常容易,不用担心
首先我们在淘宝代理设置下,安装完成依赖,此时是报错的,现在进入项目的node_modules文件夹内找到electron,点击进入,然后修改其中的package.json文件,修改dependencies对象中的依赖为:
......
......@@ -116,7 +116,7 @@
"cross-env": "^6.0.3",
"css-loader": "^3.2.0",
"del": "^5.1.0",
"electron": "^7.1.1",
"electron": "^7.1.2",
"electron-builder": "^22.1.0",
"electron-devtools-installer": "^2.2.4",
"eslint": "^6.6.0",
......@@ -129,7 +129,7 @@
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"express": "^4.17.1",
"file-loader": "^4.2.0",
"file-loader": "^4.3.0",
"html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "0.8.0",
"multispinner": "^0.2.1",
......@@ -141,7 +141,7 @@
"svg-sprite-loader": "^4.1.6",
"terser-webpack-plugin": "^2.2.1",
"through2-filter": "^3.0.0",
"url-loader": "^2.2.0",
"url-loader": "^2.3.0",
"vue-html-loader": "^1.2.4",
"vue-loader": "^15.7.2",
"vue-style-loader": "^4.1.2",
......
......@@ -10,8 +10,14 @@ var Sysarch = null
var downloadUrL = null
// 识别操作系统位数
os.arch().includes('64') ? Sysarch = 'win64' : Sysarch = 'win32'
// 暂时忽略linux版本,因为我。。= =没有linux不过问题不大,很快就会有
os.platform().includes('win') ? downloadUrL = baseUrl + `electron_${version}_${Sysarch}.exe?${new Date().getTime()}` : downloadUrL = baseUrl + `electron_${version}_mac.dmg?${new Date().getTime()}`
// 识别操作系统
if (os.platform().includes('win')) {
downloadUrL = baseUrl + `electron_${version}_${Sysarch}.exe?${new Date().getTime()}`
} else if (os.platform().includes('linux')) {
downloadUrL = baseUrl + `electron_${version}_${Sysarch}.exe?${new Date().getTime()}`
} else {
downloadUrL = baseUrl + `electron_${version}_mac.dmg?${new Date().getTime()}`
}
export default {
download (mainWindow) {
ipcMain.on('satrt-download', (event, msg) => {
......@@ -29,9 +35,11 @@ export default {
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:
mainWindow.webContents.send('download-error', true)
dialog.showErrorBox('下载出错', '由于网络或其他未知原因导致客户端下载出错,请前往官网进行重新安装')
break
}
})
......
......@@ -23,6 +23,8 @@
<el-button type="primary" round @click="getdata">读取数据</el-button>
<el-button type="primary" round @click="deledata">清除所有数据</el-button>
<el-button type="primary" round @click="CheckUpdate('one')">检查更新</el-button>
</div>
<div class="doc">
<el-button type="primary" round @click="CheckUpdate('two')">检查更新(第二种方法)</el-button>
</div>
</div>
......@@ -186,6 +188,17 @@ export default {
this.colors = "#d81e06";
}
});
ipcApi.on("download-paused", (event, arg) => {
if (arg) {
this.progressStaus = "warning";
this.$alert("下载由于未知原因被中断!", "提示", {
confirmButtonText: "重试",
callback: action => {
ipcApi.send('download-restart')
}
});
}
});
ipcApi.on("download-done", (event, age) => {
this.filePath = age.filePath;
this.progressStaus = "success";
......@@ -262,7 +275,9 @@ main > div {
font-size: 18px;
margin-bottom: 10px;
}
.doc{
margin-bottom: 20px;
}
.doc p {
color: black;
margin-bottom: 10px;
......
此文件的差异太大,无法显示。