From a8bad4ff3d78d880843e4d9ea50091b96de19e9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=8B=E4=BA=8E=E5=88=9D=E8=A7=81?= <752204717@qq.com> Date: Mon, 25 Mar 2024 18:02:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=9B=BE=E4=B9=A6=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=20=20=E5=9B=BE=E4=B9=A6=E8=90=A5=E9=94=80=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=20=20=E5=B0=8F=E5=BA=97=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/main.js | 13 +- src/utils/dbucTrtl.js | 34 ++ src/utils/index.js | 33 + src/views/modules/shop/bookmarketingtags.vue | 370 ++++++----- src/views/modules/shop/booktags.vue | 234 ++++--- .../shop/commonBookTags/commonTags.vue | 574 ++++++++++++++++++ .../shop/commonBookTags/shopproduct.vue | 278 +++++++-- .../shop/commonBookTags/shopproductTable.vue | 429 +++++++++++++ .../modules/shop/commonBookTags/tags.vue | 243 ++++++-- src/views/modules/shop/commonStore/add.vue | 318 ++++++++++ src/views/modules/shop/shopproduct.vue | 368 ++++++----- .../shopproduct copy.vue => smallstore.vue} | 220 +++---- static/config/index.js | 4 +- 14 files changed, 2539 insertions(+), 581 deletions(-) create mode 100644 src/utils/dbucTrtl.js create mode 100644 src/views/modules/shop/commonBookTags/commonTags.vue create mode 100644 src/views/modules/shop/commonBookTags/shopproductTable.vue create mode 100644 src/views/modules/shop/commonStore/add.vue rename src/views/modules/shop/{commonBookTags/shopproduct copy.vue => smallstore.vue} (53%) diff --git a/package.json b/package.json index 30fd446..40c5c82 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "axios": "0.17.1", "babel-plugin-component": "0.10.1", "babel-polyfill": "6.26.0", - "element-ui": "^2.8.2", + "element-ui": "^2.15.14", "gulp": "4.0.2", "gulp-concat": "2.6.1", "gulp-load-plugins": "2.0.5", diff --git a/src/main.js b/src/main.js index 2b83d72..727754f 100644 --- a/src/main.js +++ b/src/main.js @@ -2,8 +2,11 @@ import Vue from 'vue' import App from '@/App' import router from '@/router' // api: https://github.com/vuejs/vue-router import store from '@/store' // api: https://github.com/vuejs/vuex -import VueCookie from 'vue-cookie' // api: https://github.com/alfhen/vue-cookie -import '@/element-ui' // api: https://github.com/ElemeFE/element +import VueCookie from 'vue-cookie' +import ElementUI from 'element-ui'; +import 'element-ui/lib/theme-chalk/index.css'; +Vue.use(ElementUI); // api: https://github.com/alfhen/vue-cookie +// import '@/element-ui' // api: https://github.com/ElemeFE/element import '@/icons' // api: http://www.iconfont.cn/ import '@/element-ui-theme' import '@/assets/scss/index.scss' @@ -12,6 +15,12 @@ import Bus from '@/assets/js/eventBus.js' import httpRequest from '@/utils/httpRequest' // api: https://github.com/axios/axios import { isAuth } from '@/utils' import cloneDeep from 'lodash/cloneDeep' +// import { debounce, throttle } from './utils/dbucTrtl.js'; +// +// import debounce from 'lodash/debounce' //导入lodash中的debounce +// 在Vue实例上扩展全局方法 +// Vue.prototype.debounce = debounce; +// Vue.prototype.$throttle = throttle; Vue.use(VueCookie) Vue.config.productionTip = false diff --git a/src/utils/dbucTrtl.js b/src/utils/dbucTrtl.js new file mode 100644 index 0000000..0045620 --- /dev/null +++ b/src/utils/dbucTrtl.js @@ -0,0 +1,34 @@ +// 防抖函数 +function debounce(func, wait, immediate) { + let timeout; // 定义一个计时器变量,用于延迟执行函数 + return function (...args) { // 返回一个包装后的函数 + const context = this; // 保存函数执行上下文对象 + const later = function () { // 定义延迟执行的函数 + timeout = null; // 清空计时器变量 + if (!immediate) func.apply(context, args); // 若非立即执行,则调用待防抖函数 + }; + const callNow = immediate && !timeout; // 是否立即调用函数的条件 + clearTimeout(timeout); // 清空计时器 + timeout = setTimeout(later, wait); // 创建新的计时器,延迟执行函数 + if (callNow) func.apply(context, args); // 如果满足立即调用条件,则立即执行函数 + }; +} + +// 节流函数 +function throttle(func, wait) { + let timeout; // 定义一个计时器变量,用于限制函数调用频率 + return function (...args) { // 返回一个包装后的函数 + const context = this; // 保存函数执行上下文对象 + if (!timeout) { // 如果计时器不存在 + func.apply(context, args); // 执行函数 + timeout = setTimeout(() => { + timeout = null; // 清空计时器变量 + }, wait); // 创建计时器,在指定时间后重置计时器变量 + } + }; +} + +export { + debounce, + throttle +}; // 导出防抖函数和节流函数 diff --git a/src/utils/index.js b/src/utils/index.js index 30ac571..04464ba 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -57,3 +57,36 @@ export function clearLoginInfo () { store.commit('resetStore') router.options.isAddDynamicMenuRoutes = false } + + +export function debounce(func, wait, immediate) { + let timeout; // 定义一个计时器变量,用于延迟执行函数 + return function (...args) { // 返回一个包装后的函数 + const context = this; // 保存函数执行上下文对象 + const later = function () { // 定义延迟执行的函数 + timeout = null; // 清空计时器变量 + if (!immediate) func.apply(context, args); // 若非立即执行,则调用待防抖函数 + }; + const callNow = immediate && !timeout; // 是否立即调用函数的条件 + clearTimeout(timeout); // 清空计时器 + timeout = setTimeout(later, wait); // 创建新的计时器,延迟执行函数 + if (callNow) func.apply(context, args); // 如果满足立即调用条件,则立即执行函数 + }; +} + +// 节流函数 +export function throttle(func, wait) { + let timeout; // 定义一个计时器变量,用于限制函数调用频率 + return function (...args) { // 返回一个包装后的函数 + const context = this; // 保存函数执行上下文对象 + if (!timeout) { // 如果计时器不存在 + func.apply(context, args); // 执行函数 + timeout = setTimeout(() => { + timeout = null; // 清空计时器变量 + }, wait); // 创建计时器,在指定时间后重置计时器变量 + } + }; +} + + + diff --git a/src/views/modules/shop/bookmarketingtags.vue b/src/views/modules/shop/bookmarketingtags.vue index 0770154..1475cf2 100644 --- a/src/views/modules/shop/bookmarketingtags.vue +++ b/src/views/modules/shop/bookmarketingtags.vue @@ -1,84 +1,18 @@