Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Yakima-Teng committed Sep 30, 2017
1 parent 540bfd1 commit 5ddf53b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
12 changes: 12 additions & 0 deletions pages/upload/importer.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,24 @@
box-sizing: border-box;
background: #fff scroll no-repeat center center;
background-size: cover;
border-radius: 5%;
overflow: hidden;
&:before, &:after {
content: '';
z-index: 1;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #ccc;
}
&:before {
width: 80%;
height: 10%;
}
&:after {
width: 10%;
height: 80%;
}
&.has-image {
&:before, &:after {
Expand Down
2 changes: 1 addition & 1 deletion pages/upload/importer.min.css

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

5 changes: 3 additions & 2 deletions pages/upload/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
}

var file = files[0]
console.log(file)
var reader = new FileReader()
// ~~用于将字符串转化为整数,MB前的逻辑是为了保留一位小数取整,参考:https://github.com/whxaxes/node-test/issues/11
var fileSize = file.size / 1024 > 1024 ? (~~(10 * file.size / 1024 / 1024) / 10) + 'MB' : ~~(file.size / 1024) + 'KB'
Expand Down Expand Up @@ -132,7 +131,9 @@

// 图片上传,将base64的图片转成二进制对象,塞进formdata上传
function upload (basestr, type) {
document.querySelector('.file-wrapper').style.backgroundImage = 'url(' + basestr + ')'
var fileWrapper = document.querySelector('.file-wrapper')
fileWrapper.style.backgroundImage = 'url(' + basestr + ')'
fileWrapper.classList.add('has-image')
// 去除mime type,atob() 函数用来解码一个已经被base-64编码过的数据
var text = window.atob(basestr.split(',')[1])
var buffer = new Uint8Array(text.length)
Expand Down

0 comments on commit 5ddf53b

Please sign in to comment.