Skip to content

Instantly share code, notes, and snippets.

View TimRChen's full-sized avatar
:bowtie:
flowchart-core.js is a nice tool.

睿晨 TimRChen

:bowtie:
flowchart-core.js is a nice tool.
  • flowchart-core.js
  • Beijing
View GitHub Profile
@Elandlord
Elandlord / use-keydown.js
Created September 17, 2021 09:37
Vue 3 use-keydown composable (Composition API)
import {onBeforeUnmount} from "vue";
let useKeyDown = (keyCombos) => {
let onKeyDown = (event) => {
let kc = keyCombos.find(kc => kc.key === event.key);
if(kc) {
kc.fn();
}
}
@TimRChen
TimRChen / useActiveVersionDetect.ts
Last active March 11, 2021 03:39
pc浏览器 active version detect hooks
import axios, { AxiosInstance } from 'axios'
import { Button, notification } from 'ant-design-vue'
import { h } from 'vue'
/**
* 无http请求最大时长
*/
const EXPIRE_TIME = 24 * 3600 * 1000 // 24小时
/**
* http请求最后活跃时间
@TimRChen
TimRChen / useInfiniteScroll.ts
Last active December 2, 2022 06:34
vue 3 pc浏览器 infinite scroll hook - useInfiniteScroll
import { unref, isRef, Ref, onUnmounted } from 'vue'
type IntersectTarget = Element | Ref
/**
* 采用Intersection Observer API 实现无限滚动
* more_help: https://developer.mozilla.org/zh-CN/docs/Web/API/Intersection_Observer_API#intersection_observer_%E7%9A%84%E6%A6%82%E5%BF%B5%E5%92%8C%E7%94%A8%E6%B3%95
* @author <timrchen@foxmail.com>
* @param target 目标元素,可在可增加列表末尾设置一个标志标签
* @param callback 正在相交时执行回调,请注意!如果有一些耗时的操作需要执行,建议使用 Window.requestIdleCallback() 方法
* @param options IntersectionObserver()构造函数的 options 对象,可选值参考:https://developer.mozilla.org/zh-CN/docs/Web/API/IntersectionObserver/IntersectionObserver#%E5%8F%82%E6%95%B0
*/