diff --git a/cutejava-front/src/main.js b/cutejava-front/src/main.js index ddcd32ee..6bb8d0a7 100644 --- a/cutejava-front/src/main.js +++ b/cutejava-front/src/main.js @@ -9,9 +9,6 @@ import Element from 'element-ui' // 数据字典 import dict from './components/Dict' -// 防止二次提交 -import { preventReClick } from '@/plugins/PreventReClickDirective' - // 一键复制插件 import VueClipboard from 'vue-clipboard2' @@ -35,10 +32,11 @@ import './router/index' // 过滤器 import * as filters from './utils/filters' +// 指令 +import * as directives from './utils/directives' Vue.use(checkPer) Vue.use(permission) -Vue.directive(preventReClick) Vue.use(dict) Vue.use(VueClipboard) Vue.use(Element, { @@ -48,11 +46,17 @@ Vue.use(Element, { Vue.component('split-pane', SplitPane) // 注册全局过滤器 -// 使用方法:{{ value | filter-key }} +// 使用方法:{{ value | 过滤器方法名 }} Object.keys(filters).forEach(key => { Vue.filter(key, filters[key]) }) +// 注册全局指令 +// 使用方法: +Object.keys(directives).forEach(key => { + Vue.directive(directives[key]) +}) + Vue.config.productionTip = false Vue.config.errorHandler = function(err, vm, info) { diff --git a/cutejava-front/src/plugins/PreventReClickDirective.js b/cutejava-front/src/utils/directives.js similarity index 96% rename from cutejava-front/src/plugins/PreventReClickDirective.js rename to cutejava-front/src/utils/directives.js index bc5d305c..a55d6a89 100644 --- a/cutejava-front/src/plugins/PreventReClickDirective.js +++ b/cutejava-front/src/utils/directives.js @@ -1,21 +1,21 @@ -import Vue from 'vue' - -/** - * 防止重复提交指令,需要在main.js中全局注册 Vue.directive('preventReClick', preventReClick) - * 使用默认的 3000 毫秒防重复点击时间 - * 例子: 提交 - * 自定义防重复点击时间为 5000 毫秒 - * 例子: 提交 - */ -export const preventReClick = Vue.directive('preventReClick', { - inserted(el, binding) { - el.addEventListener('click', () => { - if (!el.disabled) { - el.disabled = true - setTimeout(() => { - el.disabled = false - }, binding.value || 3000) - } - }) - } -}) +import Vue from 'vue' + +/** + * 防止重复提交指令,需要在main.js中全局注册 Vue.directive('preventReClick', preventReClick) + * 使用默认的 3000 毫秒防重复点击时间 + * 例子: 提交 + * 自定义防重复点击时间为 5000 毫秒 + * 例子: 提交 + */ +export const preventReClick = Vue.directive('preventReClick', { + inserted(el, binding) { + el.addEventListener('click', () => { + if (!el.disabled) { + el.disabled = true + setTimeout(() => { + el.disabled = false + }, binding.value || 3000) + } + }) + } +}) diff --git a/cutejava-front/src/views/components/dev/CuteScreenShot.vue b/cutejava-front/src/views/components/dev/CuteScreenShot.vue index 27507fb6..f7a57ff3 100644 --- a/cutejava-front/src/views/components/dev/CuteScreenShot.vue +++ b/cutejava-front/src/views/components/dev/CuteScreenShot.vue @@ -17,7 +17,7 @@ 截屏 -
+