From 2e35d3f97ee99a4e3f6008f8c0e4facc9e8e19f4 Mon Sep 17 00:00:00 2001 From: 07akioni <07akioni2@gmail.com> Date: Mon, 17 Feb 2020 15:36:36 +0800 Subject: [PATCH] feat(upload): commit as a checkpoint, wip --- .../components/upload/zhCN/basic.md | 8 +- playground/uploadServer.js | 26 ++- src/Upload/src/Upload.vue | 203 ++++++++++++------ src/Upload/src/UploadFile.vue | 130 +++++++++++ styles/Upload.scss | 25 ++- styles/themes/transition.scss | 16 +- think.md | 3 + 7 files changed, 330 insertions(+), 81 deletions(-) create mode 100644 src/Upload/src/UploadFile.vue diff --git a/demo/documentation/components/upload/zhCN/basic.md b/demo/documentation/components/upload/zhCN/basic.md index ab32406e1..c2870128a 100644 --- a/demo/documentation/components/upload/zhCN/basic.md +++ b/demo/documentation/components/upload/zhCN/basic.md @@ -1,6 +1,8 @@ # 基础用法 ```html - - 上传文件 - +
+ + 上传文件 + +
``` \ No newline at end of file diff --git a/playground/uploadServer.js b/playground/uploadServer.js index e6d98f867..1e7bdd947 100644 --- a/playground/uploadServer.js +++ b/playground/uploadServer.js @@ -2,14 +2,30 @@ const express = require('express') const multer = require('multer') const cors = require('cors') const path = require('path') +const fs = require('fs') const app = express() -const upload = multer({ dest: path.resolve(__dirname, 'temp') }) +const dest = path.resolve(__dirname, 'temp') +const upload = multer({ dest }) app.options('/upload-test', cors()) -app.post('/upload-test', cors(), upload.any(), function (req, res, next) { - console.log(req.files) - res.send('very good') -}) +app.post( + '/upload-test', + cors(), + function (req, res, next) { + req.on('close', () => { + console.log('文件上传取消') + }) + req.on('error', () => { + console.log('文件上传出错') + }) + next() + }, + upload.any(), + function (req, res, next) { + if (!fs.existsSync(dest)) fs.mkdirSync(dest) + res.send('very good') + } +) app.listen(3000) diff --git a/src/Upload/src/Upload.vue b/src/Upload/src/Upload.vue index 8b84880d1..d015b89ba 100644 --- a/src/Upload/src/Upload.vue +++ b/src/Upload/src/Upload.vue @@ -18,70 +18,45 @@
diff --git a/styles/Upload.scss b/styles/Upload.scss index b55a5ffe9..f33a9b053 100644 --- a/styles/Upload.scss +++ b/styles/Upload.scss @@ -14,8 +14,10 @@ margin-top: 8px; line-height: 1.5; @include b(upload-file) { + @include fade-in-height-expand-transition; + box-sizing: border-box; cursor: pointer; - padding: 6px 12px 0 12px; + padding: 0px 12px 0 6px; transition: background-color .3s $--n-ease-in-out-cubic-bezier; border-radius: 6px; &:hover { @@ -42,13 +44,24 @@ } @include b(upload-file-info) { position: relative; + padding-top: 6px; padding-bottom: 6px; @include e(name) { + text-overflow: ellipsis; + overflow: hidden; + @include b(icon) { + font-size: 18px; + margin-right: 2px; + fill: $--n-meta-text-color; + stroke: $--n-meta-text-color; + vertical-align: middle; + } font-size: 14px; color: $--n-secondary-text-color; transition: color .3s $--n-ease-in-out-cubic-bezier; } @include e(action) { + padding-top: inherit; padding-bottom: inherit; position: absolute; right: 0; @@ -59,15 +72,23 @@ align-items: center; transition: opacity .2s $--n-ease-in-out-cubic-bezier; flex-direction: row-reverse; + // opacity: 0; @include b(button) { &:not(:first-child) { margin-right: 8px; } + @include b(icon) { + svg { + @include icon-switch-transition; + } + } } } } @include b(progress) { - @include fade-in-height-expand-transition; + @include fade-in-height-expand-transition($fold-padding: true); + box-sizing: border-box; + padding-bottom: 6px; margin-bottom: 6px; } } diff --git a/styles/themes/transition.scss b/styles/themes/transition.scss index 7ecae7ccf..6ba0166fc 100644 --- a/styles/themes/transition.scss +++ b/styles/themes/transition.scss @@ -135,12 +135,22 @@ } } -@mixin fade-in-height-expand-transition ($name: 'fade-in-height-expand', $duration: .3s, $original-transition: (), $leave-delay: 0s) { +@mixin fade-in-height-expand-transition ( + $name: 'fade-in-height-expand', + $duration: .3s, + $original-transition: (), + $leave-delay: 0s, + $fold-padding: false +) { &.#{$namespace}-#{$name}-transition-leave, &.#{$namespace}-#{$name}-transition-enter-to { opacity: 1; } &.#{$namespace}-#{$name}-transition-leave-to, &.#{$namespace}-#{$name}-transition-enter { opacity: 0; + @if $fold-padding { + padding-top: 0 !important; + padding-bottom: 0 !important; + } margin-top: 0 !important; margin-bottom: 0 !important; } @@ -151,6 +161,8 @@ opacity $duration $--n-ease-out-cubic-bezier $leave-delay, margin-top $duration $--n-ease-in-out-cubic-bezier $leave-delay, margin-bottom $duration $--n-ease-in-out-cubic-bezier $leave-delay, + padding-top $duration $--n-ease-in-out-cubic-bezier $leave-delay, + padding-bottom $duration $--n-ease-in-out-cubic-bezier $leave-delay, $original-transition; } &.#{$namespace}-#{$name}-transition-enter-active { @@ -160,6 +172,8 @@ opacity $duration $--n-ease-in-cubic-bezier, margin-top $duration $--n-ease-in-out-cubic-bezier, margin-bottom $duration $--n-ease-in-out-cubic-bezier, + padding-top $duration $--n-ease-in-out-cubic-bezier, + padding-bottom $duration $--n-ease-in-out-cubic-bezier, $original-transition; } } diff --git a/think.md b/think.md index 98cf6e4b8..6cf448335 100644 --- a/think.md +++ b/think.md @@ -148,6 +148,9 @@ Previously, it would not work with single quotes: 35. backtop mounted blink 36. Tab keep alive 37. Cascader submenu 的 lightbar 用 base tracking rect 代替 +38. Dropdown 样式微调 +39. Card 用 padding 代替 margin 来避免 margin 折叠的问题 +40. 检查 Icon 在 button 中切换有没有问题,直觉来说应该没问题 ```