From 323408f8d981bd3c75727a16ed046f2260aa258e Mon Sep 17 00:00:00 2001 From: Pan Date: Wed, 10 Oct 2018 17:43:33 +0800 Subject: [PATCH 01/15] fix[ExternalLink]: fixed bug when url include chinese #1182 --- src/utils/index.js | 4 ++++ src/views/layout/components/Sidebar/Link.vue | 4 ++-- src/views/layout/components/Sidebar/SidebarItem.vue | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/utils/index.js b/src/utils/index.js index f607910c..3af8b29b 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -296,3 +296,7 @@ export function deepClone(source) { export function uniqueArr(arr) { return Array.from(new Set(arr)) } + +export function isExternal(path) { + return /^(https?:|mailto:|tel:)/.test(path) +} diff --git a/src/views/layout/components/Sidebar/Link.vue b/src/views/layout/components/Sidebar/Link.vue index 07793b9a..5d366f24 100644 --- a/src/views/layout/components/Sidebar/Link.vue +++ b/src/views/layout/components/Sidebar/Link.vue @@ -7,7 +7,7 @@ + + diff --git a/src/utils/index.js b/src/utils/index.js index 3af8b29b..0445827b 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -164,17 +164,6 @@ export function objectMerge(target, source) { return target } -export function scrollTo(element, to, duration) { - if (duration <= 0) return - const difference = to - element.scrollTop - const perTick = (difference / duration) * 10 - setTimeout(() => { - element.scrollTop = element.scrollTop + perTick - if (element.scrollTop === to) return - scrollTo(element, to, duration - 10) - }, 10) -} - export function toggleClass(element, className) { if (!element || !className) { return diff --git a/src/utils/scrollTo.js b/src/utils/scrollTo.js new file mode 100644 index 00000000..8affede6 --- /dev/null +++ b/src/utils/scrollTo.js @@ -0,0 +1,50 @@ +Math.easeInOutQuad = function(t, b, c, d) { + t /= d / 2 + if (t < 1) { + return c / 2 * t * t + b + } + t-- + return -c / 2 * (t * (t - 2) - 1) + b +} + +// requestAnimationFrame for Smart Animating http://goo.gl/sx5sts +var requestAnimFrame = (function() { + return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(callback) { window.setTimeout(callback, 1000 / 60) } +})() + +// because it's so fucking difficult to detect the scrolling element, just move them all +function move(amount) { + document.documentElement.scrollTop = amount + document.body.parentNode.scrollTop = amount + document.body.scrollTop = amount +} + +function position() { + return document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop +} + +export function scrollTo(to, duration, callback) { + const start = position() + const change = to - start + const increment = 20 + let currentTime = 0 + duration = (typeof (duration) === 'undefined') ? 500 : duration + var animateScroll = function() { + // increment the time + currentTime += increment + // find the value with the quadratic in-out easing function + var val = Math.easeInOutQuad(currentTime, start, change, duration) + // move the document.body + move(val) + // do the animation unless its over + if (currentTime < duration) { + requestAnimFrame(animateScroll) + } else { + if (callback && typeof (callback) === 'function') { + // the animation is done so lets callback + callback() + } + } + } + animateScroll() +} diff --git a/src/views/example/list.vue b/src/views/example/list.vue index 4ab61d38..85ae4e43 100644 --- a/src/views/example/list.vue +++ b/src/views/example/list.vue @@ -50,26 +50,18 @@ -
- -
+ + + diff --git a/src/lang/en.js b/src/lang/en.js index 021bc66c..930f0ad1 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -22,6 +22,7 @@ export default { componentMixin: 'Mixin', backToTop: 'BackToTop', dragDialog: 'Drag Dialog', + dragSelect: 'Drag Select', dragKanban: 'Drag Kanban', charts: 'Charts', keyboardChart: 'Keyboard Chart', diff --git a/src/lang/es.js b/src/lang/es.js index 19171904..f16044c4 100755 --- a/src/lang/es.js +++ b/src/lang/es.js @@ -22,6 +22,7 @@ export default { componentMixin: 'Mixin', backToTop: 'Ir arriba', dragDialog: 'Drag Dialog', + dragSelect: 'Drag Select', dragKanban: 'Drag Kanban', charts: 'Gráficos', keyboardChart: 'Keyboard Chart', diff --git a/src/lang/zh.js b/src/lang/zh.js index 9da9e9e4..46e96ccf 100644 --- a/src/lang/zh.js +++ b/src/lang/zh.js @@ -22,6 +22,7 @@ export default { componentMixin: '小组件', backToTop: '返回顶部', dragDialog: '拖拽 Dialog', + dragSelect: '拖拽 Select', dragKanban: '可拖拽看板', charts: '图表', keyboardChart: '键盘图表', diff --git a/src/router/modules/components.js b/src/router/modules/components.js index 56dad2b1..5fd9bd29 100644 --- a/src/router/modules/components.js +++ b/src/router/modules/components.js @@ -78,6 +78,12 @@ const componentsRouter = { name: 'DragDialogDemo', meta: { title: 'dragDialog' } }, + { + path: 'drag-select', + component: () => import('@/views/components-demo/dragSelect'), + name: 'DragSelectDemo', + meta: { title: 'dragSelect' } + }, { path: 'dnd-list', component: () => import('@/views/components-demo/dndList'), diff --git a/src/views/components-demo/dragSelect.vue b/src/views/components-demo/dragSelect.vue new file mode 100644 index 00000000..559e8a57 --- /dev/null +++ b/src/views/components-demo/dragSelect.vue @@ -0,0 +1,43 @@ + + + From cbdad9cb1b836edccf9e25a3154bca9fc097326a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E8=A3=A4=E8=A1=A9?= Date: Thu, 25 Oct 2018 10:42:18 +0800 Subject: [PATCH 14/15] fix[TagsView]: fix openMenu boundary display bug (#1256) --- src/views/layout/components/TagsView.vue | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/views/layout/components/TagsView.vue b/src/views/layout/components/TagsView.vue index c9413129..c16827b6 100644 --- a/src/views/layout/components/TagsView.vue +++ b/src/views/layout/components/TagsView.vue @@ -121,11 +121,21 @@ export default { this.$router.push('/') }, openMenu(tag, e) { + const menuMinWidth = 105 + const offsetLeft = this.$el.getBoundingClientRect().left // container margin left + const offsetWidth = this.$el.offsetWidth // container width + const maxLeft = offsetWidth - menuMinWidth // left boundary + const left = e.clientX - offsetLeft + 15 // 15: margin right + + if (left > maxLeft) { + this.left = maxLeft + } else { + this.left = left + } + this.top = e.clientY + this.visible = true this.selectedTag = tag - const offsetLeft = this.$el.getBoundingClientRect().left // container margin left - this.left = e.clientX - offsetLeft + 15 // 15: margin right - this.top = e.clientY }, closeMenu() { this.visible = false From 1d684b76328e3f6bcd3f75ea011087cce1c13a3c Mon Sep 17 00:00:00 2001 From: Pan Date: Fri, 26 Oct 2018 10:44:18 +0800 Subject: [PATCH 15/15] [release] 3.9.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7bbaa960..d795d163 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-element-admin", - "version": "3.9.2", + "version": "3.9.3", "description": "A magical vue admin. Typical templates for enterprise applications. Newest development stack of vue. Lots of awesome features", "author": "Pan ", "license": "MIT",