正在显示
4 个修改的文件
包含
88 行增加
和
5 行删除
| ... | @@ -41,6 +41,89 @@ npm config edit | ... | @@ -41,6 +41,89 @@ npm config edit |
| 41 | 这是花裤衩大大原本的[地址](https://github.com/PanJiaChen/electron-vue-admin) | 41 | 这是花裤衩大大原本的[地址](https://github.com/PanJiaChen/electron-vue-admin) |
| 42 | 42 | ||
| 43 | # 更新日志 | 43 | # 更新日志 |
| 44 | +- 2019年10月31日更新:升级electron版本至7,但是需要做一些修改,由于淘宝的问题,导致electron新的下载器出现故障,故我们需要对electron的下载器做一些更改,这非常容易,不用担心 | ||
| 45 | +首先我们在淘宝代理设置下,安装完成依赖,此时是报错的,现在进入项目的node_modules文件夹内找到electron,点击进入,然后修改其中的package.json文件,修改dependencies对象中的依赖为: | ||
| 46 | +```json | ||
| 47 | + "dependencies": { | ||
| 48 | + "@types/node": "^12.0.12", | ||
| 49 | + "extract-zip": "^1.0.3", | ||
| 50 | + "electron-download": "^4.1.0" | ||
| 51 | + }, | ||
| 52 | +``` | ||
| 53 | +然后我们需要再修改install.js中的代码(实际就是6中的install代码) | ||
| 54 | +```js | ||
| 55 | +#!/usr/bin/env node | ||
| 56 | + | ||
| 57 | +var version = require('./package').version | ||
| 58 | + | ||
| 59 | +var fs = require('fs') | ||
| 60 | +var os = require('os') | ||
| 61 | +var path = require('path') | ||
| 62 | +var extract = require('extract-zip') | ||
| 63 | +var download = require('electron-download') | ||
| 64 | + | ||
| 65 | +var installedVersion = null | ||
| 66 | +try { | ||
| 67 | + installedVersion = fs.readFileSync(path.join(__dirname, 'dist', 'version'), 'utf-8').replace(/^v/, '') | ||
| 68 | +} catch (ignored) { | ||
| 69 | + // do nothing | ||
| 70 | +} | ||
| 71 | + | ||
| 72 | +if (process.env.ELECTRON_SKIP_BINARY_DOWNLOAD) { | ||
| 73 | + process.exit(0) | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +var platformPath = getPlatformPath() | ||
| 77 | + | ||
| 78 | +var electronPath = process.env.ELECTRON_OVERRIDE_DIST_PATH || path.join(__dirname, 'dist', platformPath) | ||
| 79 | + | ||
| 80 | +if (installedVersion === version && fs.existsSync(electronPath)) { | ||
| 81 | + process.exit(0) | ||
| 82 | +} | ||
| 83 | + | ||
| 84 | +// downloads if not cached | ||
| 85 | +download({ | ||
| 86 | + cache: process.env.electron_config_cache, | ||
| 87 | + version: version, | ||
| 88 | + platform: process.env.npm_config_platform, | ||
| 89 | + arch: process.env.npm_config_arch, | ||
| 90 | + strictSSL: process.env.npm_config_strict_ssl === 'true', | ||
| 91 | + force: process.env.force_no_cache === 'true', | ||
| 92 | + quiet: process.env.npm_config_loglevel === 'silent' || process.env.CI | ||
| 93 | +}, extractFile) | ||
| 94 | + | ||
| 95 | +// unzips and makes path.txt point at the correct executable | ||
| 96 | +function extractFile (err, zipPath) { | ||
| 97 | + if (err) return onerror(err) | ||
| 98 | + extract(zipPath, { dir: path.join(__dirname, 'dist') }, function (err) { | ||
| 99 | + if (err) return onerror(err) | ||
| 100 | + fs.writeFile(path.join(__dirname, 'path.txt'), platformPath, function (err) { | ||
| 101 | + if (err) return onerror(err) | ||
| 102 | + }) | ||
| 103 | + }) | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +function onerror (err) { | ||
| 107 | + throw err | ||
| 108 | +} | ||
| 109 | + | ||
| 110 | +function getPlatformPath () { | ||
| 111 | + var platform = process.env.npm_config_platform || os.platform() | ||
| 112 | + | ||
| 113 | + switch (platform) { | ||
| 114 | + case 'darwin': | ||
| 115 | + return 'Electron.app/Contents/MacOS/Electron' | ||
| 116 | + case 'freebsd': | ||
| 117 | + case 'linux': | ||
| 118 | + return 'electron' | ||
| 119 | + case 'win32': | ||
| 120 | + return 'electron.exe' | ||
| 121 | + default: | ||
| 122 | + throw new Error('Electron builds are not available on platform: ' + platform) | ||
| 123 | + } | ||
| 124 | +} | ||
| 125 | +``` | ||
| 126 | +然后执行npm i 即可完成安装,至于打包的话,您可能需要去淘宝镜像手动下载并且放好位置,才能完成打包操作,不然依旧还是报下载错误的信息。 | ||
| 44 | - 2019年10月18日更新:不知不觉中倒也过去了一个月,啊哈哈这次更新给大家带来的是updater的示例,这依旧是个实验特性,所以在新分支中才可以使用,使用方式则是,安装依赖, | 127 | - 2019年10月18日更新:不知不觉中倒也过去了一个月,啊哈哈这次更新给大家带来的是updater的示例,这依旧是个实验特性,所以在新分支中才可以使用,使用方式则是,安装依赖, |
| 45 | 运行 `npm run update:serve` 来启动这个node服务器,然后您如果想在dev的时候就看到效果需要先运行build拿到 `latest.yml`文件,然后将其更名为 `dev-app-update.yml` 放入`dist/electron`中,和`main.js`同级,然后你需要关闭或者排除webpack的自动清除插件(我已经屏蔽了,所以无需大家自己动手),然后点击软件中的检查更新即可,记住当软件正在运行的时候,是无法应用安装的,所以您需要关闭之后方可安装。这并不是一个错误! | 128 | 运行 `npm run update:serve` 来启动这个node服务器,然后您如果想在dev的时候就看到效果需要先运行build拿到 `latest.yml`文件,然后将其更名为 `dev-app-update.yml` 放入`dist/electron`中,和`main.js`同级,然后你需要关闭或者排除webpack的自动清除插件(我已经屏蔽了,所以无需大家自己动手),然后点击软件中的检查更新即可,记住当软件正在运行的时候,是无法应用安装的,所以您需要关闭之后方可安装。这并不是一个错误! |
| 46 | 129 | ... | ... |
此文件的差异被折叠,
点击展开。
| ... | @@ -71,7 +71,7 @@ | ... | @@ -71,7 +71,7 @@ |
| 71 | "dependencies": { | 71 | "dependencies": { |
| 72 | "axios": "^0.19.0", | 72 | "axios": "^0.19.0", |
| 73 | "date-fns": "^1.30.1", | 73 | "date-fns": "^1.30.1", |
| 74 | - "electron-updater": "^4.1.2", | 74 | + "electron-updater": "^4.2.0", |
| 75 | "element-ui": "^2.12.0", | 75 | "element-ui": "^2.12.0", |
| 76 | "js-cookie": "^2.2.0", | 76 | "js-cookie": "^2.2.0", |
| 77 | "nedb": "^1.8.0", | 77 | "nedb": "^1.8.0", |
| ... | @@ -116,8 +116,8 @@ | ... | @@ -116,8 +116,8 @@ |
| 116 | "cross-env": "^6.0.3", | 116 | "cross-env": "^6.0.3", |
| 117 | "css-loader": "^3.1.0", | 117 | "css-loader": "^3.1.0", |
| 118 | "del": "^5.0.0", | 118 | "del": "^5.0.0", |
| 119 | - "electron": "^6.1.2", | 119 | + "electron": "^7.0.0", |
| 120 | - "electron-builder": "^21.2.0", | 120 | + "electron-builder": "^22.1.0", |
| 121 | "electron-devtools-installer": "^2.2.4", | 121 | "electron-devtools-installer": "^2.2.4", |
| 122 | "eslint": "^6.6.0", | 122 | "eslint": "^6.6.0", |
| 123 | "eslint-config-standard": "^14.1.0", | 123 | "eslint-config-standard": "^14.1.0", |
| ... | @@ -147,7 +147,7 @@ | ... | @@ -147,7 +147,7 @@ |
| 147 | "vue-style-loader": "^4.1.2", | 147 | "vue-style-loader": "^4.1.2", |
| 148 | "vue-template-compiler": "^2.6.10", | 148 | "vue-template-compiler": "^2.6.10", |
| 149 | "webpack": "^4.41.2", | 149 | "webpack": "^4.41.2", |
| 150 | - "webpack-cli": "^3.3.9", | 150 | + "webpack-cli": "^3.3.10", |
| 151 | "webpack-dev-server": "^3.9.0", | 151 | "webpack-dev-server": "^3.9.0", |
| 152 | "webpack-hot-middleware": "^2.25.0", | 152 | "webpack-hot-middleware": "^2.25.0", |
| 153 | "webpack-merge": "^4.2.2" | 153 | "webpack-merge": "^4.2.2" | ... | ... |
| ... | @@ -12,7 +12,7 @@ if (process.env.NODE_ENV !== 'development') { | ... | @@ -12,7 +12,7 @@ if (process.env.NODE_ENV !== 'development') { |
| 12 | global.__static = path.join(__dirname, '/static').replace(/\\/g, '\\\\') | 12 | global.__static = path.join(__dirname, '/static').replace(/\\/g, '\\\\') |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | -const loadingURL = process.env.NODE_ENV === 'development' ? `http://localhost:9080/static/loader.html` : `file://${__static}/loader.html` | 15 | +const loadingURL = process.env.NODE_ENV === 'development' ? 'http://localhost:9080/static/loader.html' : `file://${__static}/loader.html` |
| 16 | 16 | ||
| 17 | function onAppReady () { | 17 | function onAppReady () { |
| 18 | initWindow(loadingURL) | 18 | initWindow(loadingURL) | ... | ... |
-
请 注册 或 登录 后发表评论