update 0.15.1

This commit is contained in:
yehuozhili
2022-04-28 00:33:36 +08:00
parent 1a77517d74
commit 7ae87f157e
13 changed files with 554 additions and 271 deletions

View File

@@ -1,5 +1,5 @@
{
"version": "0.15.0",
"version": "0.15.1",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/dooringx-lib.esm.js",

View File

@@ -0,0 +1,30 @@
/*
* @Author: yehuozhili
* @Date: 2022-04-27 22:15:24
* @LastEditors: yehuozhili
* @LastEditTime: 2022-04-27 22:38:59
* @FilePath: \dooringx\packages\dooringx-lib\src\hooks\useRegistFunc.ts
*/
import { useEffect } from 'react';
/**
*
*
* @export 用于简化注册函数代码
* @param {boolean} dep 配置的开关
* @param {('preview' | 'edit')} context 传递的环境变量
* @param {Function} registFn 注册的函数
*/
export function useRegistFunc(dep: boolean, context: 'preview' | 'edit', registFn: Function) {
useEffect(() => {
let unRegist: Function = () => {};
if (dep) {
unRegist = registFn;
}
return () => {
if (context === 'preview') {
unRegist(); // 必须在预览时注销,否则影响二次点击效果,不在预览注销影响编辑时跨弹窗
}
};
}, [context, dep, registFn]);
}

View File

@@ -2,7 +2,7 @@
* @Author: yehuozhili
* @Date: 2021-03-14 04:22:18
* @LastEditors: yehuozhili
* @LastEditTime: 2022-04-23 23:02:04
* @LastEditTime: 2022-04-27 22:45:42
* @FilePath: \dooringx\packages\dooringx-lib\src\index.tsx
*/
@@ -53,6 +53,9 @@ export { changeUserValue } from './core/utils/index';
// 用于制作快捷键
export { CommanderItemFactory } from './core/command/abstract';
// 用于制作函数
export { useRegistFunc } from './hooks/useRegistFunc';
export { defaultStore } from './config';
//state
export { focusState } from './core/focusHandler/state';