Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
levy committed Nov 6, 2019
2 parents 2b07070 + 4775fcf commit cd958a5
Show file tree
Hide file tree
Showing 6 changed files with 652 additions and 216 deletions.
27 changes: 27 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
root: true,
env: {
browser: true,
node: true
},
parserOptions: {
parser: 'babel-eslint'
},
extends: [
'eslint:recommended',
'plugin:vue/recommended',
'plugin:prettier/recommended',
'prettier/vue'
],
plugins: ['vue', 'prettier'],
rules: {
'no-console': [
'error',
{
allow: ['warn', 'error']
}
],
'no-debugger': 'error',
'prettier/prettier': 'error'
}
}
21 changes: 21 additions & 0 deletions docs/on-oversize.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
可以自定义如何处理文件大小超出的情况(默认是alert警告)

```vue
<template>
<upload-to-ali v-model="url" :onOversize="onOversize" />
</template>
<script>
export default {
data() {
return {
url: ''
}
},
methods: {
onOversize() {
alert('所选文件大小溢出')
},
}
}
</script>
```
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@
"@babel/core": "^7.4.3",
"@babel/plugin-transform-runtime": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.5",
"dotenv": "^7.0.0",
"eslint": "^6.6.0",
"eslint-config-prettier": "^6.5.0",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-vue": "^5.2.3",
"file-loader": "^3.0.1",
"github-release-notes": "^0.17.0",
"glob": "^7.1.3",
Expand Down Expand Up @@ -80,15 +85,22 @@
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"post-commit": "git update-index --again"
"post-commit": "git update-index --again",
"pre-push": "yarn test"
}
},
"lint-staged": {
"*.(js|md|json)": [
"*.@(md|json)": [
"prettier --write",
"git add"
],
"*.js": [
"eslint --fix",
"prettier --write",
"git add"
],
"*.vue": [
"eslint --fix",
"prettier --write",
"stylelint --fix",
"git add"
Expand Down
10 changes: 6 additions & 4 deletions src/components/draggable-list.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<transition-group name="draggable-list" tag="div" class="draggable-list">
<slot />
<slot name="footer" />
</transition-group>
</template>
<script>
Expand Down Expand Up @@ -30,22 +31,22 @@ export default {
},
methods: {
initDraggable() {
let nodes = this.$slots.default
const nodes = this.$slots.default
if (!nodes || !Array.isArray(nodes)) return
nodes.forEach(({elm}, i) => {
const img = elm.querySelector('img')
if (!img) return
img.ondragstart = e => {
img.ondragstart = () => {
this.dragging = elm
// 用上transition-group组件后,拖拽中途ghost类有时会消失
elm.classList.add('ghost')
}
img.ondragend = e => {
img.ondragend = () => {
this.dragging = null
elm.classList.remove('ghost')
}
img.ondragenter = e => {
img.ondragenter = () => {
if (elm === this.dragging) return
const j = nodes.findIndex(n => n.elm === this.dragging)
Expand All @@ -69,5 +70,6 @@ export default {
.draggable-list {
display: inline-flex;
flex-wrap: wrap;
}
</style>
Loading

0 comments on commit cd958a5

Please sign in to comment.