10 changed files with 253 additions and 440 deletions
			
			
		- 
					14.env.staging
 - 
					12build/plugins.ts
 - 
					17package.json
 - 
					542pnpm-lock.yaml
 - 
					7src/layout/components/sidebar/sidebarItem.vue
 - 
					5src/main.ts
 - 
					6src/style/element-plus.scss
 - 
					43src/style/sidebar.scss
 - 
					35src/utils/debounce/index.ts
 - 
					12vite.config.ts
 
@ -0,0 +1,14 @@ | 
			
		|||||
 | 
				# 预发布也需要生产环境的行为 | 
			
		||||
 | 
				# https://cn.vitejs.dev/guide/env-and-mode.html#modes | 
			
		||||
 | 
				NODE_ENV=production | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				VITE_PUBLIC_PATH = / | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				# 线上环境路由历史模式 | 
			
		||||
 | 
				VITE_ROUTER_HISTORY = "hash" | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				# 线上环境后端地址 | 
			
		||||
 | 
				VITE_PROXY_DOMAIN_REAL = "" | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				# 是否为打包后的文件提供传统浏览器兼容性支持 支持 true 不支持 false | 
			
		||||
 | 
				VITE_LEGACY = false | 
			
		||||
						
							
						
						
							542
	
						
						pnpm-lock.yaml
						
							File diff suppressed because it is too large
							
							
								
									View File
								
							
						
					
				File diff suppressed because it is too large
							
							
								
									View File
								
							
						@ -1,12 +1,39 @@ | 
			
		|||||
 | 
				import { unref } from "vue"; | 
			
		||||
 | 
				import type { Ref } from "vue"; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				type FunctionArgs<Args extends any[] = any[], Return = void> = ( | 
			
		||||
 | 
				  ...args: Args | 
			
		||||
 | 
				) => Return; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				type MaybeRef<T> = T | Ref<T>; | 
			
		||||
 | 
				
 | 
			
		||||
// 延迟函数
 | 
				// 延迟函数
 | 
			
		||||
export const delay = (timeout: number) => | 
				export const delay = (timeout: number) => | 
			
		||||
  new Promise(resolve => setTimeout(resolve, timeout)); | 
				  new Promise(resolve => setTimeout(resolve, timeout)); | 
			
		||||
 | 
				
 | 
			
		||||
// 防抖函数
 | 
				 | 
			
		||||
export const debounce = (fn: () => Fn, timeout: number) => { | 
				 | 
			
		||||
 | 
				/** | 
			
		||||
 | 
				 * 防抖函数 | 
			
		||||
 | 
				 * @param fn 函数 | 
			
		||||
 | 
				 * @param timeout 延迟时间 | 
			
		||||
 | 
				 * @param immediate 是否立即执行 | 
			
		||||
 | 
				 * @returns | 
			
		||||
 | 
				 */ | 
			
		||||
 | 
				export const debounce = <T extends FunctionArgs>( | 
			
		||||
 | 
				  fn: T, | 
			
		||||
 | 
				  timeout: MaybeRef<number> = 200, | 
			
		||||
 | 
				  immediate = false | 
			
		||||
 | 
				) => { | 
			
		||||
  let timmer: TimeoutHandle; | 
				  let timmer: TimeoutHandle; | 
			
		||||
 | 
				  const wait = unref(timeout); | 
			
		||||
  return () => { | 
				  return () => { | 
			
		||||
    timmer ? clearTimeout(timmer) : null; | 
				 | 
			
		||||
    timmer = setTimeout(fn, timeout); | 
				 | 
			
		||||
 | 
				    timmer && clearTimeout(timmer); | 
			
		||||
 | 
				    if (immediate) { | 
			
		||||
 | 
				      if (!timmer) { | 
			
		||||
 | 
				        fn(); | 
			
		||||
 | 
				      } | 
			
		||||
 | 
				      timmer = setTimeout(() => (timmer = null), wait); | 
			
		||||
 | 
				    } else { | 
			
		||||
 | 
				      timmer = setTimeout(fn, wait); | 
			
		||||
 | 
				    } | 
			
		||||
  }; | 
				  }; | 
			
		||||
}; | 
				}; | 
			
		||||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue