Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复七牛云格式变化后的添加Bucket报错及复制上传图片的崩溃问题 #83

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ node_modules/
!.gitkeep
.idea
static/styles-dark.css
static/dll/*
# static/dll/*
!static/dll/libs*.*
!static/dll/cos*.*
!static/dll/cos*.*
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# 云存储管理客户端 v0.3.0

# 云存储管理客户端 v0.3.3
![](http://blog-res.mayday5.me/file/icon.png?imageView2/1/w/80/h/80/q/75|imageslim) 女朋友给做的新图标😜
> 云存储管理客户端。支持七牛云、腾讯云、青云、阿里云、又拍云。仿文件夹式管理、图片预览、拖拽上传、文件夹上传、同步、批量导出URL等功能

Expand All @@ -14,6 +13,16 @@
![屏幕快照 2018-12-25 下午4.28.47.png](http://blog-res.mayday5.me/img/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202018-12-25%20%E4%B8%8B%E5%8D%884.28.47.png)

## 更新说明
2019.04.26
***
- 新增上传成功后,自动复制链接到剪切板 感谢[xiaobebe](https://github.com/xiaobebe)
- 新增分页模式开关
- 新增加载提示框添加进度显示(七牛云)
- change:修改操作逻辑.单击为选中,双击为下一级或图片预览
- fix:七牛新建存储空间获取count、space数据异常
- fix:腾讯COS上传失败
- fix: 开启原图保护图片不显示

2018.12.25
***
- 🎄圣诞快乐~
Expand Down Expand Up @@ -59,8 +68,8 @@ old
- 私有空间操作([说明](https://github.com/willnewii/qiniuClient/wiki/%E4%B8%83%E7%89%9B%E7%A7%81%E6%9C%89%E7%A9%BA%E9%97%B4%E5%92%8C%E6%8E%88%E6%9D%83%E7%A9%BA%E9%97%B4%E5%A4%84%E7%90%86))

## 下载
- [云存储管理客户端-0.3.1-mac.dmg](http://blog-res.mayday5.me/file/%E4%BA%91%E5%AD%98%E5%82%A8%E7%AE%A1%E7%90%86%E5%AE%A2%E6%88%B7%E7%AB%AF-0.3.1-mac.dmg)
- [云存储管理客户端-0.3.1-win.exe](http://blog-res.mayday5.me/file/%E4%BA%91%E5%AD%98%E5%82%A8%E7%AE%A1%E7%90%86%E5%AE%A2%E6%88%B7%E7%AB%AF-0.3.1-win.exe)
- [云存储管理客户端-0.3.2-mac.dmg](http://blog-res.mayday5.me/file/%E4%BA%91%E5%AD%98%E5%82%A8%E7%AE%A1%E7%90%86%E5%AE%A2%E6%88%B7%E7%AB%AF-0.3.2-mac.dmg)
- [云存储管理客户端-0.3.2-win.exe](http://blog-res.mayday5.me/file/%E4%BA%91%E5%AD%98%E5%82%A8%E7%AE%A1%E7%90%86%E5%AE%A2%E6%88%B7%E7%AB%AF-0.3.2-win.exe)

## Build Setup
``` bash
Expand All @@ -79,6 +88,9 @@ package,添加了一个cdnPath字段.你可以将资源上传至该路径下.这
- style.css
```

### issue
- 阿里云上传回调异常

## Technologies
- [electron](https://github.com/electron/electron)
- [electron-vue](https://github.com/SimulatedGREG/electron-vue)
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "qiniuclient",
"cnname": "云存储管理客户端",
"cdnPath": "",
"version": "0.3.1",
"version": "0.3.3",
"description": "云存储管理客户端。仿文件夹式管理、图片预览、拖拽上传、文件夹上传、同步、批量导出URL等功能",
"author": "诗人的咸鱼 <[email protected]>",
"license": "MIT",
Expand Down Expand Up @@ -78,7 +78,7 @@
"vue-router": "^2.5.3",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.4.2",
"vue-virtual-scroll-list": "^1.2.8",
"vue-virtual-scroll-list": "^1.3.4",
"vuex": "^2.3.1",
"webpack": "^3.5.2",
"webpack-bundle-analyzer": "^2.13.1",
Expand Down
4 changes: 2 additions & 2 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ const getMenuData = function () {
label: '帮助',
submenu: [
{
label: 'github',
label: 'wiki',
click() {
shell.openExternal('https://github.com/willnewii/qiniuClient');
shell.openExternal('https://github.com/willnewii/qiniuClient/wiki');
}
},
{
Expand Down
53 changes: 25 additions & 28 deletions src/renderer/components/ResourceGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,10 @@
images: [],
//缓存当前路径
cacheName: '',
//是否在多选状态
isMultiple: false,
//点击时间戳,判断是否为双击
itemClickTime: 0,
//多选数组
selection: [],

//virtual-list
remain0: 0,
remain1: 0,
Expand Down Expand Up @@ -175,26 +174,6 @@
},
},
created() {
document.onkeydown = (event) => {
let e = event || window.event || arguments.callee.caller.arguments[0];
switch (e.keyCode) {
case 91://command(mac)
case 93:
case 17://control(win)
this.isMultiple = true;
break;
}
};
document.onkeyup = (event) => {
let e = event || window.event || arguments.callee.caller.arguments[0];
switch (e.keyCode) {
case 91://command
case 93:
case 17://control
this.isMultiple = false;
break;
}
};
EventBus.$on(Constants.Event.updateFiles, (files) => {
this.files = files;
});
Expand All @@ -210,9 +189,12 @@
this.$viewer = viewer;
},
clickItem(file, index) {
if (this.isMultiple) {
this.selectFile(index);
} else {
let time = new Date().getTime();
const CLICKTIME = 300;

if ((time - this.itemClickTime) < CLICKTIME) {
this.itemClickTime = 0;

if (file._directory) {
if (this.bucket.paging) {//切换目录模式,需要重置marker
this.bucket.marker = null;
Expand All @@ -227,8 +209,19 @@
} else {
this.show(file);
}

}
} else {
if (this.itemClickTime === 0) {
setTimeout(() => {
if (this.itemClickTime !== 0) {
this.selectFile(index);
}
this.itemClickTime = 0;
}, CLICKTIME);
} else {
console.log('nothing');
}
this.itemClickTime = time;
}
},
getImgUrlwithStyle(file) {
Expand All @@ -241,7 +234,11 @@
let imageSrc = '';
switch (this.$storage.name) {
case brand.qiniu.key:
imageSrc = url ? `${url}${url.indexOf('?') !== -1 ? '&' : '?'}${imageStyle}` : '';
if (this.bucket.permission == 1) {//如果是私密空间直接显示原图
imageSrc = url;
} else {
imageSrc = url ? `${url}${imageStyle}` : '';
}
break;
case brand.aliyun.key:
if (imageStyle) {
Expand Down
1 change: 1 addition & 0 deletions src/renderer/cos/aliBucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class Bucket extends baseBucket {
}

getResources(option = {}) {
super.getResources();
//delimiter
let params = {
'max-keys': this.limit,
Expand Down
23 changes: 16 additions & 7 deletions src/renderer/cos/baseBucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {Constants, EventBus, util} from '../service/index';
import * as types from "@/vuex/mutation-types";

//由于七牛返回目录的接口不确定,直接通过PageSIze,内容不定.分页模式下,只加载5次
let tempCount = 0;
const MAXCOUNT = 5;
let loadCount = 0;

class baseBucket {

Expand Down Expand Up @@ -45,7 +46,7 @@ class baseBucket {
this.downloads = [];
//上传列表
this.uploads = [];

//在generateUrl 返回https
this.https = false;
//分页加载
this.paging = false;
Expand All @@ -64,8 +65,17 @@ class baseBucket {
this.https = this.vm[types.setup.https];
}

/**
* 此方法目前只有七牛云使用
*/
getResources() {
let txt = '数据加载中,请稍后';

if (this.count !== '') {
txt += `(${parseFloat(this.tempFiles.length / this.count * 100).toFixed(2)}%)`;
}

console.log(this.tempFiles.length, this.count, txt);
if (this.paging) {
txt += ' 分页加载';
}
Expand All @@ -74,7 +84,7 @@ class baseBucket {
message: txt,
flag: 'getResources'
});
tempCount++;
loadCount++;
}

/**
Expand All @@ -88,17 +98,16 @@ class baseBucket {
this.marker = data.marker ? data.marker : '';

//开启分页模式&文件数大于阀值&marker不为空
console.log(this.paging, this.tempFiles.length);
// if (this.paging && this.tempFiles.length >= Constants.PAGESIZE && this.marker) {
if (this.paging && tempCount >= 5 && this.marker) {
console.log(`分页模式:${this.paging} tempFiles:${this.tempFiles.length}`);
if (this.paging && loadCount >= MAXCOUNT && this.marker) {
EventBus.$emit(Constants.Event.loading, {
show: false,
flag: 'getResources'
});

this.files = this.files.concat(Object.freeze(this.tempFiles));
this.tempFiles = [];
tempCount = 0;
loadCount = 0;
} else if (this.marker) {
this.getResources(option);
} else {
Expand Down
1 change: 1 addition & 0 deletions src/renderer/cos/qingBucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Bucket extends baseBucket {
}

getResources(option = {}) {
super.getResources();
let params = {
limit: this.limit,
};
Expand Down
15 changes: 9 additions & 6 deletions src/renderer/cos/qiniuBucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Bucket extends baseBucket {
* 获取域名
* 获取目录
* 获取默认资源列表
* @param vm => page
* @param vm => bucketPage
*/
bindPage(vm) {
this.vm = vm;
Expand All @@ -28,8 +28,7 @@ class Bucket extends baseBucket {
if (info) {
this.space = info.space;
this.count = info.count;

if (info.count > Constants.PAGESIZE) {
if (this.vm.paging && info.count > Constants.PAGESIZE) {
this.paging = true;
}
}
Expand Down Expand Up @@ -90,7 +89,6 @@ class Bucket extends baseBucket {
let day = dayjs();
let param = `?bucket=${this.name}&begin=${day.add(-1, 'day').format(formatStr)}&end=${day.format(formatStr)}&g=day`;


let request1 = new Request();
let url1 = `${qiniu.methods.count}${param}`;

Expand All @@ -104,13 +102,16 @@ class Bucket extends baseBucket {
let url4 = `${qiniu.methods.space_line}${param}`;

Promise.all([request1.get(url1), request2.get(url2), request3.get(url3), request4.get(url4)]).then((result) => {
console.log(result[2].datas[0], result[3].datas[0]);
callback && callback({
count: result[0].datas[0] || result[1].datas[0],
space: result[2].datas[0] || result[3].datas[0]
});
}).catch((error) => {
console.log(error);
callback && callback({
count: 0,
space: 0
});
});
}

Expand Down Expand Up @@ -193,7 +194,9 @@ class Bucket extends baseBucket {
* @returns {*}
*/
generateUrl(key, deadline) {
let url = this.domain ? qiniu.generateUrl(this.domain, key, (this.permission === 1 ? deadline : null)) : '';
let _domain = this.https ? 'https://' : 'http://';

let url = this.domain ? qiniu.generateUrl(_domain + this.domain, key, (this.permission === 1 ? deadline : null)) : '';
return super.generateUrl(url);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/renderer/cos/tencentBucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class Bucket extends baseBucket {
}

getResources(option = {}) {
super.getResources();
let params = {
Bucket: this.name,
Region: this.location,
Expand Down
18 changes: 10 additions & 8 deletions src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ Vue.filter("formatFileSize", function(value) {
//拦截器
axios.interceptors.response.use(
response => {
return JSON.parse(response.data);
try {
return JSON.parse(response.data);
} catch (e) {
return response.data;
}
},
error => {
console.log(error);
Expand All @@ -60,16 +64,14 @@ axios.interceptors.response.use(
);

import App from "./App";
import PasteImageService from "./service/pasteImageService";

new PasteImageService();

new Vue({
el: "#app",
router,
store,
render: h => h(App),
mounted() {
console.table(process.versions);
}
render: h => h(App)
});

import PasteImageService from "./service/pasteImageService";

new PasteImageService();
1 change: 1 addition & 0 deletions src/renderer/mixins/mixin-resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export default {
return this.bucket.generateUrl(file.key, this.setup_deadline);
},
show(file) {
this.$Message.info('不支持预览的文件格式');
},
showImage(file, images) {
this.previewImages = [];
Expand Down
Loading