mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-15 14:03:36 +08:00
style: format code for all
This commit is contained in:
@@ -4,7 +4,7 @@ import reSeamlessScroll from "./src/index.vue";
|
||||
export const ReSeamlessScroll = Object.assign(reSeamlessScroll, {
|
||||
install(app: App) {
|
||||
app.component(reSeamlessScroll.name, reSeamlessScroll);
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
export default ReSeamlessScroll;
|
||||
|
||||
@@ -1,13 +1,23 @@
|
||||
<template>
|
||||
<div :ref="'wrap' + classOption['key']">
|
||||
<div :style="leftSwitch" v-if="navigation" :class="leftSwitchClass" @click="leftSwitchClick">
|
||||
<div
|
||||
:style="leftSwitch"
|
||||
v-if="navigation"
|
||||
:class="leftSwitchClass"
|
||||
@click="leftSwitchClick"
|
||||
>
|
||||
<slot name="left-switch"></slot>
|
||||
</div>
|
||||
<div :style="rightSwitch" v-if="navigation" :class="rightSwitchClass" @click="rightSwitchClick">
|
||||
<div
|
||||
:style="rightSwitch"
|
||||
v-if="navigation"
|
||||
:class="rightSwitchClass"
|
||||
@click="rightSwitchClick"
|
||||
>
|
||||
<slot name="right-switch"></slot>
|
||||
</div>
|
||||
<div
|
||||
:ref="'realBox'+ classOption['key']"
|
||||
:ref="'realBox' + classOption['key']"
|
||||
:style="pos"
|
||||
@mouseenter="enter"
|
||||
@mouseleave="leave"
|
||||
@@ -16,7 +26,7 @@
|
||||
@touchend="touchEnd"
|
||||
@mousewheel="wheel"
|
||||
>
|
||||
<div :ref="'slotList'+ classOption['key']" :style="float">
|
||||
<div :ref="'slotList' + classOption['key']" :style="float">
|
||||
<slot></slot>
|
||||
</div>
|
||||
<div v-html="copyHtml" :style="float"></div>
|
||||
@@ -24,15 +34,8 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang='ts'>
|
||||
import {
|
||||
defineComponent,
|
||||
computed,
|
||||
ref,
|
||||
unref,
|
||||
watchEffect,
|
||||
nextTick
|
||||
} from "vue";
|
||||
<script lang="ts">
|
||||
import { defineComponent, computed, ref, unref, nextTick } from "vue";
|
||||
import {
|
||||
tryOnMounted,
|
||||
tryOnUnmounted,
|
||||
@@ -85,7 +88,8 @@ export default defineComponent({
|
||||
let isHover = false;
|
||||
let ease = "ease-in";
|
||||
|
||||
let { data, classOption } = props;
|
||||
// eslint-disable-next-line vue/no-setup-props-destructure
|
||||
let { classOption } = props;
|
||||
|
||||
if (classOption["key"] === undefined) {
|
||||
classOption["key"] = 0;
|
||||
@@ -165,8 +169,9 @@ export default defineComponent({
|
||||
let rightSwitch = computed(() => {
|
||||
return {
|
||||
position: "absolute",
|
||||
margin: `${unref(height) / 2}px 0 0 ${unref(width) +
|
||||
unref(options).switchOffset}px`,
|
||||
margin: `${unref(height) / 2}px 0 0 ${
|
||||
unref(width) + unref(options).switchOffset
|
||||
}px`,
|
||||
transform: "translateY(-50%)"
|
||||
};
|
||||
});
|
||||
@@ -372,7 +377,7 @@ export default defineComponent({
|
||||
if (isHover) return;
|
||||
//进入move立即先清除动画 防止频繁touchMove导致多动画同时进行
|
||||
// scrollCancle();
|
||||
reqFrame = requestAnimationFrame(function() {
|
||||
reqFrame = requestAnimationFrame(function () {
|
||||
//实际高度
|
||||
const h = unref(realBoxHeight) / 2;
|
||||
//宽度
|
||||
@@ -408,7 +413,7 @@ export default defineComponent({
|
||||
xPos.value += step.value;
|
||||
}
|
||||
if (singleWaitTime) clearTimeout(singleWaitTime);
|
||||
if (!!unref(realSingleStopHeight)) {
|
||||
if (unref(realSingleStopHeight)) {
|
||||
//是否启动了单行暂停配置
|
||||
if (
|
||||
Math.abs(unref(yPos)) % unref(realSingleStopHeight) <
|
||||
@@ -421,7 +426,7 @@ export default defineComponent({
|
||||
} else {
|
||||
scrollMove();
|
||||
}
|
||||
} else if (!!unref(realSingleStopWidth)) {
|
||||
} else if (unref(realSingleStopWidth)) {
|
||||
if (
|
||||
Math.abs(unref(xPos)) % unref(realSingleStopWidth) <
|
||||
unref(step)
|
||||
@@ -577,4 +582,4 @@ export default defineComponent({
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -3,16 +3,18 @@
|
||||
*/
|
||||
export const animationFrame = () => {
|
||||
window.cancelAnimationFrame = (function () {
|
||||
return window.cancelAnimationFrame ||
|
||||
return (
|
||||
window.cancelAnimationFrame ||
|
||||
window.webkitCancelAnimationFrame ||
|
||||
window.mozCancelAnimationFrame ||
|
||||
window.oCancelAnimationFrame ||
|
||||
window.msCancelAnimationFrame ||
|
||||
function (id) {
|
||||
return window.clearTimeout(id)
|
||||
return window.clearTimeout(id);
|
||||
}
|
||||
})()
|
||||
window.requestAnimationFrame = function () {
|
||||
);
|
||||
})();
|
||||
window.requestAnimationFrame = (function () {
|
||||
return (
|
||||
window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
@@ -20,25 +22,26 @@ export const animationFrame = () => {
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function (callback) {
|
||||
return window.setTimeout(callback, 1000 / 60)
|
||||
return window.setTimeout(callback, 1000 / 60);
|
||||
}
|
||||
)
|
||||
}()
|
||||
}
|
||||
);
|
||||
})();
|
||||
};
|
||||
|
||||
/**
|
||||
* @desc 判断数组是否相等
|
||||
* @param {arr1,arr2}
|
||||
* @return {Boolean}
|
||||
* @param arr1
|
||||
* @param arr2
|
||||
*/
|
||||
export const arrayEqual = (arr1: Array<any>, arr2: Array<any>) => {
|
||||
if (arr1 === arr2) return true
|
||||
if (arr1.length !== arr2.length) return false
|
||||
if (arr1 === arr2) return true;
|
||||
if (arr1.length !== arr2.length) return false;
|
||||
for (let i = 0; i < arr1.length; ++i) {
|
||||
if (arr1[i] !== arr2[i]) return false
|
||||
if (arr1[i] !== arr2[i]) return false;
|
||||
}
|
||||
return true
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @desc 深浅合并拷贝
|
||||
@@ -47,62 +50,68 @@ export function copyObj() {
|
||||
if (!Array.isArray) {
|
||||
// @ts-expect-error
|
||||
Array.isArray = function (arg) {
|
||||
return Object.prototype.toString.call(arg) === '[object Array]'
|
||||
}
|
||||
return Object.prototype.toString.call(arg) === "[object Array]";
|
||||
};
|
||||
}
|
||||
let name, options, src, copy, copyIsArray, clone,
|
||||
let name,
|
||||
options,
|
||||
src,
|
||||
copy,
|
||||
copyIsArray,
|
||||
clone,
|
||||
i = 1,
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
target = arguments[0] || {}, // 使用||运算符,排除隐式强制类型转换为false的数据类型
|
||||
deep = false,
|
||||
len = arguments.length
|
||||
if (typeof target === 'boolean') {
|
||||
deep = target
|
||||
target = arguments[1] || {}
|
||||
i++
|
||||
// eslint-disable-next-line prefer-const
|
||||
len = arguments.length;
|
||||
if (typeof target === "boolean") {
|
||||
deep = target;
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
target = arguments[1] || {};
|
||||
i++;
|
||||
}
|
||||
if (typeof target !== 'object' && typeof target !== 'function') {
|
||||
target = {}
|
||||
if (typeof target !== "object" && typeof target !== "function") {
|
||||
target = {};
|
||||
}
|
||||
// 如果arguments.length === 1 或typeof arguments[0] === 'boolean',且存在arguments[1],则直接返回target对象
|
||||
if (i === len) {
|
||||
return target
|
||||
return target;
|
||||
}
|
||||
for (; i < len; i++) {
|
||||
//所以如果源对象中数据类型为Undefined或Null那么就会跳过本次循环,接着循环下一个源对象
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
if ((options = arguments[i]) != null) {
|
||||
// 如果遇到源对象的数据类型为Boolean, Number for in循环会被跳过,不执行for in循环// src用于判断target对象是否存在name属性
|
||||
for (name in options) {
|
||||
// src用于判断target对象是否存在name属性
|
||||
src = target[name]
|
||||
src = target[name];
|
||||
// 需要复制的属性当前源对象的name属性
|
||||
copy = options[name]
|
||||
copy = options[name];
|
||||
// 判断copy是否是数组
|
||||
copyIsArray = Array.isArray(copy)
|
||||
copyIsArray = Array.isArray(copy);
|
||||
// 如果是深复制且copy是一个对象或数组则需要递归直到copy成为一个基本数据类型为止
|
||||
if (deep && copy && (typeof copy === 'object' || copyIsArray)) {
|
||||
if (deep && copy && (typeof copy === "object" || copyIsArray)) {
|
||||
if (copyIsArray) {
|
||||
copyIsArray = false
|
||||
copyIsArray = false;
|
||||
// 如果目标对象存在name属性且是一个数组
|
||||
// 则使用目标对象的name属性,否则重新创建一个数组,用于复制
|
||||
clone = src && Array.isArray(src) ? src : []
|
||||
clone = src && Array.isArray(src) ? src : [];
|
||||
} else {
|
||||
// 如果目标对象存在name属性且是一个对象则使用目标对象的name属性,否则重新创建一个对象,用于复制
|
||||
clone = src && typeof src === 'object' ? src : {}
|
||||
clone = src && typeof src === "object" ? src : {};
|
||||
}
|
||||
// 深复制,所以递归调用copyObject函数
|
||||
// 返回值为target对象,即clone对象
|
||||
// copy是一个源对象
|
||||
// @ts-expect-error
|
||||
target[name] = copyObj(deep, clone, copy)
|
||||
target[name] = copyObj(deep, clone, copy);
|
||||
} else if (copy !== undefined) {
|
||||
// 浅复制,直接复制到target对象上
|
||||
target[name] = copy
|
||||
target[name] = copy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user