Skip to content

Commit

Permalink
log--修复一些bug (#7)
Browse files Browse the repository at this point in the history
下载的时候,如果文件已存在,则重命名 && 发布的时候,把对应channel的yml文件转换成json,也上传到oss,用作各客户端获取版本信息
 修复windows下,上边框无法resize的问题
  • Loading branch information
qinyang912 authored Dec 18, 2017
1 parent 7178785 commit 862c320
Show file tree
Hide file tree
Showing 9 changed files with 361 additions and 23 deletions.
79 changes: 79 additions & 0 deletions .rishiqing-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ default:
title: 'rishiqing-electron-deploy' # 推送时候的标题,可自定义,默认是rishiqing-deploy
nodes: # 定义在哪些环节需要通知 , 在发布的时候,node需要有一些默认值
- 'after-build' # 在所有build执行完之后,通知
- 'after-convert' # 在所有convert执行之后,通知
- 'resource' # 在所有resource传输完成
- 'file-replace' # 所有fileReplace任务完成
- 'statistics' # 把发布之后的统计结果通过通知发送出来
Expand All @@ -16,6 +17,9 @@ default:
ia32-beta:
build:
- 'npm run build-ia32-beta'
convert:
target: package-ia32-beta/beta.yml
dest: package-ia32-beta/beta.json
resource:
- dist: 'package-ia32-beta' # 资源所在目录 或者 文件路径
ignore:
Expand All @@ -41,10 +45,23 @@ ia32-beta:
bucket: 'rishiqing-client'
endpoint: 'http://oss-cn-shenzhen.aliyuncs.com'
prefix: 'pc-autoupdate/win/ia32/beta'
- dist: 'package-ia32-beta/beta.json' # 资源所在目录 或者 文件路径
target: 'beta.json'
upload: # 以下指定上传资源文件要用的方式,如果指定多个,会依次使用上传
- type: 'aliyunOss'
param:
accessKeyId: ${ALY_OSS_Access_Id}
secretAccessKey: ${ALY_OSS_Access_Key}
bucket: 'rishiqing-client'
endpoint: 'http://oss-cn-shenzhen.aliyuncs.com'
prefix: 'pc-autoupdate/win/ia32/beta'

ia32-release:
build:
- 'npm run build-ia32-release'
convert:
target: package-ia32-release/release.yml
dest: package-ia32-release/release.json
resource:
- dist: 'package-ia32-release' # 资源所在目录 或者 文件路径
ignore:
Expand All @@ -70,10 +87,23 @@ ia32-release:
bucket: 'rishiqing-client'
endpoint: 'http://oss-cn-shenzhen.aliyuncs.com'
prefix: 'pc-autoupdate/win/ia32/release'
- dist: 'package-ia32-release/release.json' # 资源所在目录 或者 文件路径
target: 'release.json'
upload: # 以下指定上传资源文件要用的方式,如果指定多个,会依次使用上传
- type: 'aliyunOss'
param:
accessKeyId: ${ALY_OSS_Access_Id}
secretAccessKey: ${ALY_OSS_Access_Key}
bucket: 'rishiqing-client'
endpoint: 'http://oss-cn-shenzhen.aliyuncs.com'
prefix: 'pc-autoupdate/win/ia32/release'

x64-beta:
build:
- 'npm run build-x64-beta'
convert:
target: package-x64-beta/beta.yml
dest: package-x64-beta/beta.json
resource:
- dist: 'package-x64-beta' # 资源所在目录 或者 文件路径
ignore:
Expand All @@ -99,10 +129,23 @@ x64-beta:
bucket: 'rishiqing-client'
endpoint: 'http://oss-cn-shenzhen.aliyuncs.com'
prefix: 'pc-autoupdate/win/x64/beta'
- dist: 'package-x64-beta/beta.json' # 资源所在目录 或者 文件路径
target: 'beta.json'
upload: # 以下指定上传资源文件要用的方式,如果指定多个,会依次使用上传
- type: 'aliyunOss'
param:
accessKeyId: ${ALY_OSS_Access_Id}
secretAccessKey: ${ALY_OSS_Access_Key}
bucket: 'rishiqing-client'
endpoint: 'http://oss-cn-shenzhen.aliyuncs.com'
prefix: 'pc-autoupdate/win/x64/beta'

x64-release:
build:
- 'npm run build-x64-release'
convert:
target: package-x64-release/release.yml
dest: package-x64-release/release.json
resource:
- dist: 'package-x64-release' # 资源所在目录 或者 文件路径
ignore:
Expand All @@ -128,10 +171,23 @@ x64-release:
bucket: 'rishiqing-client'
endpoint: 'http://oss-cn-shenzhen.aliyuncs.com'
prefix: 'pc-autoupdate/win/x64/release'
- dist: 'package-x64-release/release.json' # 资源所在目录 或者 文件路径
target: 'release.json'
upload: # 以下指定上传资源文件要用的方式,如果指定多个,会依次使用上传
- type: 'aliyunOss'
param:
accessKeyId: ${ALY_OSS_Access_Id}
secretAccessKey: ${ALY_OSS_Access_Key}
bucket: 'rishiqing-client'
endpoint: 'http://oss-cn-shenzhen.aliyuncs.com'
prefix: 'pc-autoupdate/win/x64/release'

mac-beta:
build:
- 'npm run build-beta'
convert:
target: package-beta/beta-mac.yml
dest: package-beta/beta-mac.json
resource:
- dist: 'package-beta' # 资源所在目录 或者 文件路径
ignore:
Expand All @@ -158,10 +214,23 @@ mac-beta:
bucket: 'rishiqing-client'
endpoint: 'http://oss-cn-shenzhen.aliyuncs.com'
prefix: 'pc-autoupdate/mac/beta'
- dist: 'package-beta/beta-mac.json' # 资源所在目录 或者 文件路径
target: 'beta-mac.json'
upload: # 以下指定上传资源文件要用的方式,如果指定多个,会依次使用上传
- type: 'aliyunOss'
param:
accessKeyId: ${ALY_OSS_Access_Id}
secretAccessKey: ${ALY_OSS_Access_Key}
bucket: 'rishiqing-client'
endpoint: 'http://oss-cn-shenzhen.aliyuncs.com'
prefix: 'pc-autoupdate/mac/beta'

mac-release:
build:
- 'npm run build-release'
convert:
target: package-release/release-mac.yml
dest: package-release/release-mac.json
resource:
- dist: 'package-release' # 资源所在目录 或者 文件路径
ignore:
Expand All @@ -180,6 +249,16 @@ mac-release:
fileReplace:
- dist: 'package-release/release-mac.yml' # 资源所在目录 或者 文件路径
target: 'release-mac.yml'
upload: # 以下指定上传资源文件要用的方式,如果指定多个,会依次使用上传
- type: 'aliyunOss'
param:
accessKeyId: ${ALY_OSS_Access_Id}
secretAccessKey: ${ALY_OSS_Access_Key}
bucket: 'rishiqing-client'
endpoint: 'http://oss-cn-shenzhen.aliyuncs.com'
prefix: 'pc-autoupdate/mac/release'
- dist: 'package-release/release-mac.json'
target: 'release-mac.json'
upload: # 以下指定上传资源文件要用的方式,如果指定多个,会依次使用上传
- type: 'aliyunOss'
param:
Expand Down
17 changes: 11 additions & 6 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: apple
* @Date: 2016-02-17 11:06:44
* @Last Modified by: qinyang
* @Last Modified time: 2017-12-16 18:32:12
* @Last Modified time: 2017-12-18 11:35:52
*/

var path = require('path');
Expand Down Expand Up @@ -36,7 +36,12 @@ module.exports = function (grunt) {
}
},
files: [
{expand: true, src: ['fe/**/*.js'], dest: destPath}
{expand: true, src: ['fe/**/*.js'], dest: destPath},
{expand: true, src: ['utils/**/*.js'], dest: destPath},
{expand: true, src: ['native/**/*.js'], dest: destPath},
{expand: true, src: ['common/**/*.js'], dest: destPath},
{expand: true, src: 'main.js', dest: destPath},
{expand: true, src: 'download.js', dest: destPath}
]
}
},
Expand Down Expand Up @@ -84,10 +89,10 @@ module.exports = function (grunt) {
// },
mainJs: {
files: [
{expand: true, src: 'main.js', dest: destPath},
{expand: true, src: 'download.js', dest: destPath},
{expand: true, src: 'native/*.js', dest: destPath},
{expand: true, src: 'common/*.js', dest: destPath}
// {expand: true, src: 'main.js', dest: destPath},
// {expand: true, src: 'download.js', dest: destPath},
// {expand: true, src: 'native/*.js', dest: destPath},
// {expand: true, src: 'common/*.js', dest: destPath}
]
}
},
Expand Down
30 changes: 28 additions & 2 deletions download.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ const electron = require('electron');
const path = require('path');
const packageJson = require('./package.json');
const EVENTS = require('./common/download_event');
const FileUtil = require('./utils/file');
const BrowserWindow = electron.BrowserWindow;
const ipcMain = electron.ipcMain;
const app = electron.app;

let downloadIdCount = 0;

const DownloadPath = app.getPath('downloads'); // 下载路径
const DownloadItemIdMap = {}; // 缓存下载对象和itemId之间的映射关系
const DownloadFileNameMap = {}; // 缓存正在现在的文件名,防止某些文件还没下载完成,又下载同一文件名的文件

class Download {
constructor () {
Expand Down Expand Up @@ -42,19 +45,41 @@ class Download {
}
}

isFileExist (fileName) {
const p = path.join(DownloadPath, fileName);
return FileUtil.isExist(p) || DownloadFileNameMap[fileName];
}

generateDownloadFileName (fileName) {
let isExist = this.isFileExist(fileName);
if (!isExist) return fileName;
const extname = path.extname(fileName);
const basename = path.basename(fileName, extname);

let count = 0;

while (isExist) {
isExist = this.isFileExist(`${basename}(${++count})${extname}`);
}
return `${basename}(${count})${extname}`;
}

startDownload (item) {
const fileName = this.generateDownloadFileName(item.getFilename());
// 下载项先暂时默认保存到下载路径里,后面需要增加用户修改默认保存路径的功能
item.setSavePath(path.join(app.getPath('downloads'), item.getFilename()));
item.setSavePath(path.join(DownloadPath, fileName));
item.id = ++downloadIdCount;
item.fileName = fileName;
DownloadItemIdMap[item.id] = item;
DownloadFileNameMap[fileName] = true;
this.open();
this.webContents.send(EVENTS.Start, {
savePath: item.getSavePath(),
itemId: item.id,
originUrl: item.getURL(),
mimeType: item.getMimeType(),
hasUserGesture: item.hasUserGesture(),
fileName: item.getFilename(),
fileName: fileName,
totalBytes: item.getTotalBytes(),
receivedBytes: item.getReceivedBytes(),
contentDisposition: item.getContentDisposition(),
Expand Down Expand Up @@ -98,6 +123,7 @@ class Download {
});
}
delete DownloadItemIdMap[item.id];
delete DownloadFileNameMap[item.fileName];
});
}

Expand Down
24 changes: 14 additions & 10 deletions fe/css/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -837,22 +837,22 @@ body.win #main-iframe {
display: inline-block;
}

/* line 185, ../scss/core.scss */
/* line 186, ../scss/core.scss */
.drag-bar-win {
display: none;
position: absolute;
left: 0;
top: 0;
top: 4px;
right: 0;
height: 32px;
height: 28px;
background: #5A98D4;
z-index: 2;
}
/* line 192, ../scss/core.scss */
/* line 193, ../scss/core.scss */
.drag-bar-win .traffic-lights {
position: absolute;
right: 0;
top: 0;
top: -4px;
height: 32px;
display: flex;
z-index: 1;
Expand All @@ -861,31 +861,35 @@ body.win #main-iframe {
align-items: center;
padding: 0 12px;
}
/* line 203, ../scss/core.scss */
/* line 204, ../scss/core.scss */
.drag-bar-win .traffic-lights > span {
display: inline-block;
height: 12px;
width: 12px;
}
/* line 207, ../scss/core.scss */
/* line 208, ../scss/core.scss */
.drag-bar-win .traffic-lights > span img {
vertical-align: top;
}

/* line 215, ../scss/core.scss */
/* line 216, ../scss/core.scss */
body.mac .drag-bar-mac {
display: block;
}

/* line 220, ../scss/core.scss */
body.win {
background: #5A98D4;
}
/* line 222, ../scss/core.scss */
body.win .drag-bar-win {
display: block;
}
/* line 223, ../scss/core.scss */
/* line 225, ../scss/core.scss */
body.win .traffic-lights.mac {
display: none;
}
/* line 226, ../scss/core.scss */
/* line 228, ../scss/core.scss */
body.win #loading, body.win #alert {
top: 32px;
}
8 changes: 5 additions & 3 deletions fe/scss/core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,18 @@ body.win {
}
}
}
$bar-win-offset: 4px;
.drag-bar-win {
display: none;
position: absolute;
left: 0; top: 0; right: 0;
height: 32px;
left: 0; top: $bar-win-offset; right: 0;
height: 32px - $bar-win-offset;
background: #5A98D4;
z-index: 2;
.traffic-lights {
position: absolute;
right: 0;
top: 0;
top: -$bar-win-offset;
height: 32px;
display: flex;
z-index: 1;
Expand All @@ -217,6 +218,7 @@ body.mac {
}
}
body.win {
background: #5A98D4;
.drag-bar-win {
display: block;
}
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rishiqing-electron",
"version": "3.0.3",
"version": "3.0.4",
"author": "北京创仕科锐信息技术有限责任公司",
"electronVersion": "1.7.9",
"main": "main.js",
Expand Down Expand Up @@ -39,8 +39,10 @@
"dependencies": {
"electron-updater": "2.16.3",
"handlebars": "4.0.11",
"is-gzip": "2.0.0",
"jquery": "2.2.0",
"lodash": "4.17.4",
"md5-file": "3.2.3",
"module-alias": "2.0.3",
"nedb": "1.8.0",
"request": "2.72.0",
Expand All @@ -61,7 +63,7 @@
"grunt-contrib-sass": "^0.9.2",
"grunt-contrib-uglify": "git+https://github.com/gruntjs/grunt-contrib-uglify.git#harmony",
"grunt-zip": "^0.17.1",
"rishiqing-deploy": "^1.0.2",
"rishiqing-deploy": "^1.0.3",
"yargs": "^4.1.0"
},
"optionalDependencies": {
Expand Down
Loading

0 comments on commit 862c320

Please sign in to comment.