Pre Merge pull request !148 from wslyx/master
commit
86d67c21b4
|
@ -1,7 +1,7 @@
|
||||||
import $store from '@/sheep/store';
|
import $store from '@/sheep/store';
|
||||||
import { showAuthModal, showShareModal } from '@/sheep/hooks/useModal';
|
import { showAuthModal, showShareModal } from '@/sheep/hooks/useModal';
|
||||||
import { isNumber, isString, isEmpty, startsWith, isObject, isNil, clone } from 'lodash-es';
|
import { isNumber, isString, isEmpty, startsWith, isObject, isNil, clone } from 'lodash-es';
|
||||||
import throttle from '@/sheep/helper/throttle';
|
import { debounce } from 'lodash';
|
||||||
|
|
||||||
const _go = (
|
const _go = (
|
||||||
path,
|
path,
|
||||||
|
@ -68,7 +68,7 @@ const _go = (
|
||||||
url += `?${query}`;
|
url += `?${query}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 跳转底部导航
|
// 跳转底部导航,TABBAR由Vite配置插件注入的,在uniReadPagesV3Plugin中
|
||||||
if (TABBAR.includes(page)) {
|
if (TABBAR.includes(page)) {
|
||||||
uni.switchTab({
|
uni.switchTab({
|
||||||
url,
|
url,
|
||||||
|
@ -89,11 +89,27 @@ const _go = (
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 限流 防止重复点击跳转
|
// 防抖 防止重复点击跳转
|
||||||
|
let go_args;
|
||||||
|
const debouncedGoFunc = debounce(
|
||||||
|
() => {
|
||||||
|
_go(...go_args);
|
||||||
|
},
|
||||||
|
500,
|
||||||
|
{
|
||||||
|
//在延迟开始前立即调用事件
|
||||||
|
leading: true,
|
||||||
|
//在延时结束后不调用,保证事件只被触发一次
|
||||||
|
trailing: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
function go(...args) {
|
function go(...args) {
|
||||||
throttle(() => {
|
// 向新的路径跳转时清除遗留debounce的状态
|
||||||
_go(...args);
|
if (args !== go_args) {
|
||||||
});
|
debouncedGoFunc.cancel();
|
||||||
|
}
|
||||||
|
go_args = args;
|
||||||
|
debouncedGoFunc();
|
||||||
}
|
}
|
||||||
|
|
||||||
function paramsToQuery(params) {
|
function paramsToQuery(params) {
|
||||||
|
|
Loading…
Reference in New Issue