From 500b2436f73735a3dd6b7e35ca50c50c9fc02fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Wed, 20 Apr 2022 18:09:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=A0=E6=B3=A2=E6=B5=AA?= =?UTF-8?q?=E5=8A=A8=E7=94=BB=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/styles/index.scss | 1 + src/assets/styles/waves.scss | 101 +++++++++++++++++++++++++++++ src/directive/index.js | 2 + src/directive/module/waves.js | 52 +++++++++++++++ src/views/dashboard/PanelGroup.vue | 10 +-- 5 files changed, 161 insertions(+), 5 deletions(-) create mode 100644 src/assets/styles/waves.scss create mode 100644 src/directive/module/waves.js diff --git a/src/assets/styles/index.scss b/src/assets/styles/index.scss index 909811c..eee4926 100644 --- a/src/assets/styles/index.scss +++ b/src/assets/styles/index.scss @@ -4,6 +4,7 @@ @import './element-ui.scss'; @import './sidebar.scss'; @import './btn.scss'; +@import './waves.scss'; body { height: 100%; diff --git a/src/assets/styles/waves.scss b/src/assets/styles/waves.scss new file mode 100644 index 0000000..23add2c --- /dev/null +++ b/src/assets/styles/waves.scss @@ -0,0 +1,101 @@ +/* Waves v0.6.0 +* http://fian.my.id/Waves +* +* Copyright 2014 Alfiana E. Sibuea and other contributors +* Released under the MIT license +* https://github.com/fians/Waves/blob/master/LICENSE +*/ +.waves-effect { + position: relative; + cursor: pointer; + display: inline-block; + overflow: hidden; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + -webkit-tap-highlight-color: transparent; + vertical-align: middle; + z-index: 1; + will-change: opacity, transform; + transition: all 0.3s ease-out; +} +.waves-effect .waves-ripple { + position: absolute; + border-radius: 50%; + width: 20px; + height: 20px; + margin-top: -10px; + margin-left: -10px; + opacity: 0; + background: rgba(0, 0, 0, 0.2); + transition: all 0.7s ease-out; + transition-property: opacity, -webkit-transform; + transition-property: transform, opacity; + transition-property: transform, opacity, -webkit-transform; + -webkit-transform: scale(0); + transform: scale(0); + pointer-events: none; +} +.waves-effect.waves-light .waves-ripple { + background-color: rgba(255, 255, 255, 0.45); +} +.waves-effect.waves-red .waves-ripple { + background-color: rgba(244, 67, 54, 0.7); +} +.waves-effect.waves-yellow .waves-ripple { + background-color: rgba(255, 235, 59, 0.7); +} +.waves-effect.waves-orange .waves-ripple { + background-color: rgba(255, 152, 0, 0.7); +} +.waves-effect.waves-purple .waves-ripple { + background-color: rgba(156, 39, 176, 0.7); +} +.waves-effect.waves-green .waves-ripple { + background-color: rgba(76, 175, 80, 0.7); +} +.waves-effect.waves-teal .waves-ripple { + background-color: rgba(0, 150, 136, 0.7); +} +.waves-effect input[type='button'], +.waves-effect input[type='reset'], +.waves-effect input[type='submit'] { + border: 0; + font-style: normal; + font-size: inherit; + text-transform: inherit; + background: none; +} +.waves-notransition { + transition: none !important; +} +.waves-circle { + -webkit-transform: translateZ(0); + transform: translateZ(0); + -webkit-mask-image: -webkit-radial-gradient(circle, #fff 100%, #000 100%); +} +.waves-input-wrapper { + border-radius: 0.2em; + vertical-align: bottom; +} +.waves-input-wrapper .waves-button-input { + position: relative; + top: 0; + left: 0; + z-index: 1; +} +.waves-circle { + text-align: center; + width: 2.5em; + height: 2.5em; + line-height: 2.5em; + border-radius: 50%; + -webkit-mask-image: none; +} +.waves-block { + display: block; +} +a.waves-effect .waves-ripple { + z-index: -1; +} diff --git a/src/directive/index.js b/src/directive/index.js index a4e1a3c..c7e412e 100644 --- a/src/directive/index.js +++ b/src/directive/index.js @@ -2,10 +2,12 @@ import hasRole from './permission/hasRole' import hasPermi from './permission/hasPermi' import clipboard from './module/clipboard' import drag from './module/drag' +import waves from './module/waves' export default function directive(app){ app.directive('hasRole', hasRole) app.directive('hasPermi', hasPermi) app.directive('clipboard', clipboard) app.directive('drag', drag) + app.directive('waves', waves) } \ No newline at end of file diff --git a/src/directive/module/waves.js b/src/directive/module/waves.js new file mode 100644 index 0000000..08a2f4f --- /dev/null +++ b/src/directive/module/waves.js @@ -0,0 +1,52 @@ +/** + * 按钮波浪指令 + * @directive 默认方式:v-waves,如 `
` + * @directive 参数方式:v-waves=" |light|red|orange|purple|green|teal",如 `
` + */ +export default { + mounted(el, binding) { + el.classList.add('waves-effect'); + binding.value && el.classList.add(`waves-${binding.value}`); + + function setConvertStyle(obj) { + let style = ''; + for (let i in obj) { + if (obj.hasOwnProperty(i)) style += `${i}:${obj[i]};`; + } + return style; + } + + function onCurrentClick(e) { + let elDiv = document.createElement('div'); + elDiv.classList.add('waves-ripple'); + el.appendChild(elDiv); + let styles = { + left: `${e.layerX}px`, + top: `${e.layerY}px`, + opacity: 1, + transform: `scale(${(el.clientWidth / 100) * 10})`, + 'transition-duration': `750ms`, + 'transition-timing-function': `cubic-bezier(0.250, 0.460, 0.450, 0.940)`, + }; + elDiv.setAttribute('style', setConvertStyle(styles)); + setTimeout(() => { + elDiv.setAttribute( + 'style', + setConvertStyle({ + opacity: 0, + transform: styles.transform, + left: styles.left, + top: styles.top, + }) + ); + setTimeout(() => { + elDiv && el.removeChild(elDiv); + }, 750); + }, 450); + } + el.addEventListener('mousedown', onCurrentClick, false); + }, + unmounted(el) { + el.addEventListener('mousedown', () => {}); + }, +} \ No newline at end of file diff --git a/src/views/dashboard/PanelGroup.vue b/src/views/dashboard/PanelGroup.vue index e137a24..f2a9aeb 100644 --- a/src/views/dashboard/PanelGroup.vue +++ b/src/views/dashboard/PanelGroup.vue @@ -6,10 +6,10 @@
-
+
在线用户
- +
@@ -19,7 +19,7 @@
-
+
消息
@@ -32,7 +32,7 @@
-
+
金额
@@ -45,7 +45,7 @@
-
+
订单