Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
playmyswift committed Mar 7, 2018
1 parent 217383a commit 518784c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/SMEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,11 @@ function addEvents (self) {
}
}
editorElement().addEventListener('paste', function (event) {
event.preventDefault()
let items = (event.clipboardData || event.originalEvent.clipboardData).items
for (let index in items) {
let item = items[index]
if (item.kind === 'file') {
event.preventDefault()
let blob = item.getAsFile()
self.upload(blob, (url) => {
self.insertImageHtml(url)
Expand Down
12 changes: 6 additions & 6 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
import SMEditor from '@/components/SMEditor.vue'
// import SMEditor from '../../release/smeditor.js'
import VFooter from '@/views/VFooter.vue'
// import c from './config.json'
const config = {
// 接口地址
uploadUrl: 'https://jsonplaceholder.typicode.com/posts/',
// form 里的 filename
uploadName: '',
uploadName: 'upload_file',
// 其他参数
uploadParams: {},
// 上传成功回调
uploadCallback: (data) => {
console.log(data)
return 'https://ws1.sinaimg.cn/large/006tNc79gy1fp1rdw7e90j30rs0rsacb.jpg'
// console.log(data)
return data.image.url || 'https://ws1.sinaimg.cn/large/006tNc79gy1fp1rdw7e90j30rs0rsacb.jpg'
},
// 上传失败回调, 可选
uploadFailed: (err) => {
console.log(err + '仅供测试, 并非真正上传')
alert('仅供测试, 并非真正上传!')
// console.log('仅供测试, 并非真正上传')
alert('仅供测试, 并非真正上传!', err)
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/views/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"uploadUrl": "http://main_test.geekpark.net/api/v1/admin/images"
}

0 comments on commit 518784c

Please sign in to comment.