Skip to content

Commit

Permalink
Feat: 增加 scroll 与 change 埋点,增加字符串转化方法 loadStr。
Browse files Browse the repository at this point in the history
  • Loading branch information
pandaoh committed May 8, 2024
1 parent f2ce984 commit d7ebe25
Show file tree
Hide file tree
Showing 324 changed files with 4,876 additions and 2,005 deletions.
29 changes: 26 additions & 3 deletions dist/Dom/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,35 @@ export declare function printDom(selector: string, styles?: {
/**
* 创建全局 click 事件埋点与回调
* @example
* const statusMap = createClickLogListener((key, data) => console.log({ key, data })); /// 页面加载完成后创建监听器
* const clickListenerObj = createClickLogListener((event, key, data) => console.log({ event, key, data })); /// 页面加载完成后创建监听器,取消监听器 clickListenerObj.cancel(); 。
* <div data-log={JSON.stringify({ trigger: 'click', params: { name: '普通日志' }, logKey: 'example-key-0' })}>普通埋点元素</div> /// 普通埋点元素写法
* <div data-log={JSON.stringify({ maxSequence: 2, sequence: 1, trigger: 'click', params: { name: '顺序日志' }, logKey: 'example-key-1' })}>顺序埋点元素 1</div> /// 顺序埋点元素写法
* <div data-log={JSON.stringify({ maxSequence: 2, sequence: 2, trigger: 'click', params: { name: '顺序日志' }, logKey: 'example-key-1' })}>顺序埋点元素 2</div> /// 顺序埋点元素写法
* <div data-log={JSON.stringify({ maxSequence: 2, sequence: 1, trigger: 'click', params: { name: '固定顺序日志' }, logKey: 'example-key-1' })}>固定顺序埋点元素 1</div> /// 固定顺序埋点元素写法
* <div data-log={JSON.stringify({ maxSequence: 2, sequence: 2, trigger: 'click', params: { name: '固定顺序日志' }, logKey: 'example-key-1' })}>固定顺序埋点元素 2</div> /// 固定顺序埋点元素写法
* <div data-log={JSON.stringify({ isOrder: true, orderKey: '元素 1', params: { name: '非固定顺序日志' }, logKey: 'example-key-2' })}>非固定顺序埋点元素 1</div> /// 非固定顺序埋点元素写法
* <div data-log={JSON.stringify({ isOrder: true, orderKey: '元素 2', params: { name: '非固定顺序日志' }, logKey: 'example-key-2' })}>非固定顺序埋点元素 2</div> /// 非固定顺序埋点元素写法
* @param callback 监听 Track 回调
* @returns
*/
export declare function createClickLogListener(callback?: any): any;
/**
* 创建元素 scroll 事件埋点与回调
* @example
* const cancel = createScrollLogListener(document.querySelector('.demo-scroll-dom'), (event, eventKey, data) => console.log({ event, eventKey, data })); /// 页面加载完成后创建监听器,取消监听器 cancel(); 。
* @param element 元素
* @param callback 监听 Track 回调
* @param delay 防抖延迟
* @param threshold 触发滚动事件阈值
* @returns
*/
export declare function createScrollLogListener(element?: any, callback?: any, delay?: number, threshold?: number): (() => void) | undefined;
/**
* 创建全局 change 事件埋点与回调
* @example
* const cancel = createChangeLogListener((event, key, data) => console.log({ event, key, data })); /// 页面加载完成后创建监听器,取消监听器 cancel(); 。
* <div data-change={JSON.stringify({ logKey: 'div-input-change-0' })}><input /></div> /// 父元素总监听
* <input data-change={JSON.stringify({ logKey: 'input-change-1' })} /> /// 普通监听
* @param callback 监听 Track 回调
* @returns
*/
export declare function createChangeLogListener(callback?: any): () => void;
//# sourceMappingURL=index.d.ts.map
2 changes: 1 addition & 1 deletion dist/Dom/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/Object/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export declare function findMaxKey(objArray: any[]): never[];
* /// [{ value: 1, label: "A", key: "test1" }, { value: 2, label: "B", key: "test2" }]
* @param arr 数组
* @param options 配置 { label?: 'label', value: 'value', key?: 'key' }
* @returns 转换后的 Select 数据数组
* @returns
*/
export declare function arr2select(arr: any[], options: {
label?: string;
Expand Down
13 changes: 13 additions & 0 deletions dist/String/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,17 @@ export declare function leftJoin(str: string | number, length?: string | number,
* @returns
*/
export declare function rightJoin(str: string | number, length?: string | number, char?: string | number): string;
/**
* 将字符串中的占位符替换为对应的值
* @example
* loadStr('hello ${test}', { test: 123 }); // 'hello 123'
* loadStr('hello ${test}', undefined); // 'hello ${test}'
* loadStr('hello ${test}', undefined, '$'); // 'hello $'
* loadStr('hello ${name.first}-${name.last} ${ test }', { name: { first: 'A', last: 'B' }, test: '!' }); // 'hello A-B !'
* @param str 原始字符串
* @param params 参数对象,包含占位符的键值对。
* @param emptyStr 对象不存在键值时的占位符,默认不变。
* @returns
*/
export declare function loadStr(str: string, params: any, emptyStr?: string): string;
//# sourceMappingURL=index.d.ts.map
2 changes: 1 addition & 1 deletion dist/String/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions dist/index.js

Large diffs are not rendered by default.

Loading

0 comments on commit d7ebe25

Please sign in to comment.