From 10ec91f3b0cbab62db2424469fd39522c1b638aa Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Sat, 3 Apr 2021 23:43:03 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=A2=9E=E9=87=8F=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=EF=BC=8C=E6=9D=80=E6=8E=89=E7=AB=AF=E5=8F=A3=E5=8D=A0?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E8=BF=9B=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ---- .../core/src/modules/plugin/node/config.js | 5 ++-- .../core/src/shell/scripts/kill-by-port.js | 3 ++- packages/gui/package.json | 2 +- packages/gui/pkg/after-all-artifact-build.js | 2 +- packages/gui/pkg/after-pack.js | 2 +- packages/gui/src/bridge/update/backend.js | 17 +++++++------ packages/gui/src/bridge/update/front.js | 25 +++++++++---------- packages/gui/src/utils/util.apppath.js | 16 ++++++------ packages/gui/vue.config.js | 2 +- 10 files changed, 37 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index a922020..09d54aa 100644 --- a/README.md +++ b/README.md @@ -58,11 +58,6 @@ Windows: 请选择DevSidecar-x.x.x.exe Mac: 请选择DevSidecar-x.x.x.dmg - - -* 阿里云直接下载(http链接,某些浏览器可能打不开,请前往release下载) -[windows版](http://dev-sidecar.docmirror.cn/update/DevSidecar-1.5.0.exe) -[Mac版](http://dev-sidecar.docmirror.cn/update/DevSidecar-1.5.0.dmg) #### 2 安装后打开 diff --git a/packages/core/src/modules/plugin/node/config.js b/packages/core/src/modules/plugin/node/config.js index 6df3f9a..f00e687 100644 --- a/packages/core/src/modules/plugin/node/config.js +++ b/packages/core/src/modules/plugin/node/config.js @@ -16,8 +16,9 @@ module.exports = { // 'cdn.cypress.io': [{ regexp: '/desktop/.*', proxy: 'http://npm.taobao.org/mirrors/cypress/' }] // }, variables: { - SASS_BINARY_SITE: 'https://npm.taobao.org/mirrors/node-sass/', - PHANTOMJS_CDNURL: 'https://npm.taobao.org/mirrors/phantomjs/', + phantomjs_cdnurl: 'https://npm.taobao.org/dist/phantomjs', + chromedriver_cdnurl: 'https://npm.taobao.org/mirrors/chromedriver', + sass_binary_site: 'https://npm.taobao.org/mirrors/node-sass', ELECTRON_MIRROR: 'https://npm.taobao.org/mirrors/electron/', // CYPRESS_DOWNLOAD_MIRROR: 'https://cdn.cypress.io', NVM_NODEJS_ORG_MIRROR: 'https://npm.taobao.org/mirrors/node', diff --git a/packages/core/src/shell/scripts/kill-by-port.js b/packages/core/src/shell/scripts/kill-by-port.js index 13709f0..2738e79 100644 --- a/packages/core/src/shell/scripts/kill-by-port.js +++ b/packages/core/src/shell/scripts/kill-by-port.js @@ -12,7 +12,8 @@ const executor = { throw Error('暂未实现此功能') }, async mac (exec, { port }) { - throw Error('暂未实现此功能') + await exec('kill `lsof -i:' + port + " |grep 'DevSide\\|Elect' |awk '{print $2}'`") + return true } } diff --git a/packages/gui/package.json b/packages/gui/package.json index 795cebf..0c1d3d4 100644 --- a/packages/gui/package.json +++ b/packages/gui/package.json @@ -1,6 +1,6 @@ { "name": "@docmirror/dev-sidecar-gui", - "version": "1.5.1", + "version": "1.5.0", "private": false, "license": "MPL-2.0", "scripts": { diff --git a/packages/gui/pkg/after-all-artifact-build.js b/packages/gui/pkg/after-all-artifact-build.js index cb35328..61c911b 100644 --- a/packages/gui/pkg/after-all-artifact-build.js +++ b/packages/gui/pkg/after-all-artifact-build.js @@ -15,7 +15,7 @@ function appendIntro (context, systemType, latest) { }) } exports.default = async function (context) { - console.log('context222', context) + // console.log('context222', context) appendIntro(context, 'mac', 'latest-mac.yml') appendIntro(context, 'win', 'latest.yml') } diff --git a/packages/gui/pkg/after-pack.js b/packages/gui/pkg/after-pack.js index cf7b012..b320558 100644 --- a/packages/gui/pkg/after-pack.js +++ b/packages/gui/pkg/after-pack.js @@ -2,7 +2,7 @@ const path = require('path') const AdmZip = require('adm-zip') const pkg = require('../package.json') exports.default = async function (context) { - console.log('context', context) + // console.log('context', context) let targetPath let systemType = '' if (context.packager.platform.nodeName === 'darwin') { diff --git a/packages/gui/src/bridge/update/backend.js b/packages/gui/src/bridge/update/backend.js index 312b5b2..ecf284d 100644 --- a/packages/gui/src/bridge/update/backend.js +++ b/packages/gui/src/bridge/update/backend.js @@ -8,7 +8,6 @@ import fs from 'fs' import AdmZip from 'adm-zip' import logger from '../../utils/util.log' import appPathUtil from '../../utils/util.apppath' -import DevSidecar from '@docmirror/dev-sidecar' // eslint-disable-next-line no-unused-vars const isMac = process.platform === 'darwin' @@ -49,18 +48,22 @@ function updateHandle (app, api, win, beforeQuit, quit, log) { } // 本地开发环境,改变app-update.yml地址 if (process.env.NODE_ENV === 'development' && !isMac) { - autoUpdater.updateConfigPath = path.join(__dirname, 'win-unpacked/resources/app-update.yml') autoUpdater.setFeedURL({ provider: 'generic', url: 'http://localhost/dev-sidecar/' }) + if (isMac) { + autoUpdater.updateConfigPath = path.join(__dirname, 'mac/DevSidecar.app/Contents/Resources/app-update.yml') + } else { + autoUpdater.updateConfigPath = path.join(__dirname, 'win-unpacked/resources/app-update.yml') + } } autoUpdater.autoDownload = false let partPackagePath = null function downloadPart (app, value) { - const appPath = appPathUtil.getAppRootPath() + const appPath = appPathUtil.getAppRootPath(app) const fileDir = path.join(appPath, 'update') logger.info('download dir', fileDir) try { @@ -87,11 +90,11 @@ function updateHandle (app, api, win, beforeQuit, quit, log) { } function updatePart (app, api, value, partPackagePath, quit) { - const appPath = appPathUtil.getAppRootPath() + const appPath = appPathUtil.getAppRootPath(app) const platform = api.shell.getSystemPlatform() let target = path.join(appPath, 'resources') if (platform === 'mac') { - target = path.join(appPath, 'Contents/Resources') + target = path.join(appPath, 'Resources') } log.info('开始解压缩,安装升级包', partPackagePath, target) @@ -176,15 +179,13 @@ function updateHandle (app, api, win, beforeQuit, quit, log) { export default { install (context) { - const { app, win, beforeQuit, quit, log } = context + const { app, api, win, beforeQuit, quit, log } = context if (process.env.NODE_ENV === 'development') { Object.defineProperty(app, 'isPackaged', { get () { return true } }) - // updateUrl = 'http://dev-sidecar.docmirror.cn/update/' - // updateUrl = 'http://localhost/dev-sidecar/' } updateHandle(app, api, win, beforeQuit, quit, log) } diff --git a/packages/gui/src/bridge/update/front.js b/packages/gui/src/bridge/update/front.js index c620f1c..228543d 100644 --- a/packages/gui/src/bridge/update/front.js +++ b/packages/gui/src/bridge/update/front.js @@ -60,30 +60,29 @@ function install (app, api) { // 有增量更新 api.update.downloadPart(value) } else { - api.update.downloadUpdate() - } - } - function foundNewVersion (value) { - updateParams.newVersion = true - - if (updateParams.autoDownload !== false) { - app.$message.info('发现新版本,正在下载中...') - updateParams.downloading = true - api.shell.getSystemPlatform().then((platform) => { if (platform === 'mac') { app.$notification.open({ - duration: 10, - message: 'Mac暂不支持自动升级', + duration: 15, + message: 'Mac暂不支持全量自动升级', description: - '请前往github或gitee项目主页下载新版本手动安装,听说苹果对于Electron开发的应用审核不好过。。。。好吧我承认是因为没有钱买苹果开发者账号,┓( ´∀` )┏', + '请前往github或gitee项目release页面下载新版本手动安装', onClick: () => { } }) + return } + api.update.downloadUpdate() }) + } + } + function foundNewVersion (value) { + updateParams.newVersion = true + if (updateParams.autoDownload !== false) { + app.$message.info('发现新版本,正在下载中...') + updateParams.downloading = true downloadNewVersion(value) return } diff --git a/packages/gui/src/utils/util.apppath.js b/packages/gui/src/utils/util.apppath.js index b3c86ca..8a400f1 100644 --- a/packages/gui/src/utils/util.apppath.js +++ b/packages/gui/src/utils/util.apppath.js @@ -1,13 +1,11 @@ import path from 'path' -// const isDevelopment = process.env.NODE_ENV !== 'production' +const isDevelopment = process.env.NODE_ENV !== 'production' export default { - getAppRootPath () { - // if (isDevelopment) { - // return app.getAppPath() - // } else { - // return path.join(app.getAppPath(), '../../') - // } - - return path.resolve('.') + getAppRootPath (app) { + if (isDevelopment) { + return app.getAppPath() + } else { + return path.join(app.getAppPath(), '../../') + } } } diff --git a/packages/gui/vue.config.js b/packages/gui/vue.config.js index 055c3f1..b95b92d 100644 --- a/packages/gui/vue.config.js +++ b/packages/gui/vue.config.js @@ -63,7 +63,7 @@ module.exports = { publish: { provider: 'generic', // url: 'http://dev-sidecar.docmirror.cn/update/' - url: 'http://localhost/dev-sidecar/' + url: 'http://dev-sidecar.docmirror.cn/update/preview/' } }, chainWebpackMainProcess (config) {