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
@TimRChen
TimRChen / useInfiniteScroll-react.ts
Last active August 3, 2021 12:19
react 版 useInfiniteScroll
import { useRef, MutableRefObject } from 'react'
import { useUpdateEffect, useUnmount } from 'ahooks'
/**
* 采用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
@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
*/
@TimRChen
TimRChen / throttle-demo.js
Created March 12, 2020 10:46
simple throttle demo by timrchen
const $box = document.querySelector(".mouse-move-box");
let timer = null;
const options = {
capture: false
};
const listener = e => {
const { x, y } = e;
@TimRChen
TimRChen / run.js
Last active March 12, 2020 10:44
fast coding script use js
const { prompt } = require("inquirer");
const { readdirSync } = require("fs");
const { exec } = require("child_process");
async function run() {
const folder = `${__dirname}/public`;
const choices = await readdirSync(folder);
const promptList = [
@TimRChen
TimRChen / App.vue
Created August 21, 2018 10:16
simple count down handler for vue.js
<script>
// 未来的终止时间 2018.10.10 23:59:59
const futureDate = new Date(2018, 10, 10, 23, 59, 59)
export default {
data () {
return {
time: {
day: '69', // String
hour: '59', // String