This commit is contained in:
hufeixiong
2021-07-12 15:32:21 +08:00
parent 0df7aff097
commit 740d3661d2
12 changed files with 49 additions and 34 deletions

View File

@@ -204,6 +204,6 @@ export default undo;
metakey与Controlkey相同写Control即可。 metakey与Controlkey相同写Control即可。
目前第三个参数只能获得store后续需要修改下。 目前第三个参数只能获得store后续需要修改下。 0.2.0 版本第二个参数可以获得config同时commander不从index中导出需要使用时从config中获取。
最后个参数是展示名。 最后个参数是展示名。

View File

@@ -2,8 +2,8 @@
* @Author: yehuozhili * @Author: yehuozhili
* @Date: 2021-07-07 11:11:52 * @Date: 2021-07-07 11:11:52
* @LastEditors: yehuozhili * @LastEditors: yehuozhili
* @LastEditTime: 2021-07-07 20:18:39 * @LastEditTime: 2021-07-12 13:58:33
* @FilePath: \visual-editor\.umirc.ts * @FilePath: \dooringx\packages\dooringx-example\.umirc.ts
*/ */
import { defineConfig } from 'umi'; import { defineConfig } from 'umi';

View File

@@ -2,13 +2,14 @@
* @Author: yehuozhili * @Author: yehuozhili
* @Date: 2021-01-31 20:44:16 * @Date: 2021-01-31 20:44:16
* @LastEditors: yehuozhili * @LastEditors: yehuozhili
* @LastEditTime: 2021-07-11 23:11:14 * @LastEditTime: 2021-07-12 15:22:17
* @FilePath: \dooringx\packages\dooringx-lib\README.md * @FilePath: \dooringx\packages\dooringx-lib\README.md
--> -->
## Dooringx-lib ## Dooringx-lib
## changelog ## changelog
- 0.2.0 commander的传递进行修改可以获得config了commander不再从index中导出 需要使用时从config中获取。增加左侧类名方便自定义。
- 0.1.10 修改eslint依赖推荐 - 0.1.10 修改eslint依赖推荐
- 0.1.9 增加全局body设置 - 0.1.9 增加全局body设置
- 0.1.8 增加弹窗设置移除modalContainer - 0.1.8 增加弹窗设置移除modalContainer
@@ -21,5 +22,4 @@
## todo ## todo
1、制作标尺 1、制作标尺
2、重构命令,传递config。 2、重构拖拽,优化性能与config传递
3、重构拖拽优化性能与config传递。

View File

@@ -1,5 +1,5 @@
{ {
"version": "0.1.10", "version": "0.2.0",
"license": "MIT", "license": "MIT",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",

View File

@@ -2,7 +2,7 @@
* @Author: yehuozhili * @Author: yehuozhili
* @Date: 2021-02-04 10:32:45 * @Date: 2021-02-04 10:32:45
* @LastEditors: yehuozhili * @LastEditors: yehuozhili
* @LastEditTime: 2021-07-11 13:34:00 * @LastEditTime: 2021-07-12 15:21:27
* @FilePath: \dooringx\packages\dooringx-lib\src\components\leftConfig.tsx * @FilePath: \dooringx\packages\dooringx-lib\src\components\leftConfig.tsx
*/ */
import React, { ReactNode, useEffect, useMemo, useState } from 'react'; import React, { ReactNode, useEffect, useMemo, useState } from 'react';
@@ -44,6 +44,7 @@ function LeftConfig(props: LeftConfigProps) {
setLeftRender( setLeftRender(
<div className={`${styles.leftco} yh-leftcomp`}> <div className={`${styles.leftco} yh-leftcomp`}>
<div <div
className="yh-left-top-wrapper"
style={{ style={{
display: 'flex', display: 'flex',
justifyContent: 'center', justifyContent: 'center',
@@ -69,6 +70,7 @@ function LeftConfig(props: LeftConfigProps) {
{leftMapRenderListCategory[parseInt(menuSelect, 10)].displayName} {leftMapRenderListCategory[parseInt(menuSelect, 10)].displayName}
</div> </div>
<Input <Input
className="yh-left-top-input"
style={{ style={{
borderRadius: '40px', borderRadius: '40px',
}} }}
@@ -91,8 +93,12 @@ function LeftConfig(props: LeftConfigProps) {
return prev; return prev;
}, []) }, [])
.map((v, index) => ( .map((v, index) => (
<div className={styles.coitem} key={index} {...dragEventResolve(v)}> <div
<div className={styles.redbox}> className={`${styles.coitem} yh-left-item-wrap`}
key={index}
{...dragEventResolve(v)}
>
<div className={`${styles.redbox} yh-left-item-img-wrap`}>
{v.imgCustom ? v.imgCustom : <img src={v.img} alt="component"></img>} {v.imgCustom ? v.imgCustom : <img src={v.img} alt="component"></img>}
</div> </div>
@@ -110,8 +116,12 @@ function LeftConfig(props: LeftConfigProps) {
))} ))}
{(!search || search === '') && {(!search || search === '') &&
cache.map((v, index) => ( cache.map((v, index) => (
<div className={styles.coitem} key={index} {...dragEventResolve(v)}> <div
<div className={styles.redbox}> className={`${styles.coitem} yh-left-item-wrap`}
key={index}
{...dragEventResolve(v)}
>
<div className={`${styles.redbox} yh-left-item-img-wrap`}>
{v.imgCustom ? v.imgCustom : <img src={v.img} alt="component"></img>} {v.imgCustom ? v.imgCustom : <img src={v.img} alt="component"></img>}
</div> </div>
<div <div

View File

@@ -2,8 +2,8 @@
* @Author: yehuozhili * @Author: yehuozhili
* @Date: 2021-03-14 04:29:09 * @Date: 2021-03-14 04:29:09
* @LastEditors: yehuozhili * @LastEditors: yehuozhili
* @LastEditTime: 2021-03-14 04:58:51 * @LastEditTime: 2021-07-12 15:24:29
* @FilePath: \dooring-v2\src\core\wrapperMove\index.tsx * @FilePath: \dooringx\packages\dooringx-lib\src\components\wrapperMove\index.tsx
*/ */
import { AllHTMLAttributes, CSSProperties, PropsWithChildren, useRef } from 'react'; import { AllHTMLAttributes, CSSProperties, PropsWithChildren, useRef } from 'react';
import { wrapperEvent } from './event'; import { wrapperEvent } from './event';
@@ -20,7 +20,7 @@ function ContainerWrapper(props: PropsWithChildren<ContainerWrapperProps>) {
const ref = useRef<HTMLDivElement>(null); const ref = useRef<HTMLDivElement>(null);
return ( return (
<div <div
className={`ant-menu ${classNames}`} className={`ant-menu ${classNames ? classNames : ''}`}
ref={ref} ref={ref}
style={{ style={{
backgroundColor: '#f0f0f0', backgroundColor: '#f0f0f0',

View File

@@ -2,12 +2,12 @@
* @Author: yehuozhili * @Author: yehuozhili
* @Date: 2021-02-25 21:16:58 * @Date: 2021-02-25 21:16:58
* @LastEditors: yehuozhili * @LastEditors: yehuozhili
* @LastEditTime: 2021-07-10 21:22:42 * @LastEditTime: 2021-07-12 14:49:32
* @FilePath: \dooringx\packages\dooringx-lib\src\config\index.tsx * @FilePath: \dooringx\packages\dooringx-lib\src\config\index.tsx
*/ */
import { IBlockType, IStoreData } from '../core/store/storetype'; import { IBlockType, IStoreData } from '../core/store/storetype';
import { store } from '../runtime/store'; import { store } from '../runtime/store';
import { formRegister, componentRegister, commander, storeChanger } from '../runtime'; import { formRegister, componentRegister, storeChanger } from '../runtime';
import { ComponentClass, FunctionComponent, ReactNode } from 'react'; import { ComponentClass, FunctionComponent, ReactNode } from 'react';
import { ComponentItemFactory } from '../core/components/abstract'; import { ComponentItemFactory } from '../core/components/abstract';
import { marklineConfig } from '../core/markline/marklineConfig'; import { marklineConfig } from '../core/markline/marklineConfig';
@@ -23,6 +23,7 @@ import { createModal, unmountMap } from '../components/modalRender';
import { scaleState } from '../core/scale/state'; import { scaleState } from '../core/scale/state';
import { CommanderItemFactory } from '../core/command/abstract'; import { CommanderItemFactory } from '../core/command/abstract';
import MmodalMask from '../core/components/defaultFormComponents/modalMask'; import MmodalMask from '../core/components/defaultFormComponents/modalMask';
import CommanderWrapper from '../core/command';
// 组件部分 // 组件部分
@@ -313,7 +314,7 @@ export class UserConfig {
public componentCache = {}; public componentCache = {};
public asyncComponentUrlMap = {} as AsyncCacheComponentType; public asyncComponentUrlMap = {} as AsyncCacheComponentType;
public marklineConfig = marklineConfig; public marklineConfig = marklineConfig;
public commanderRegister = commander; public commanderRegister: CommanderWrapper;
public contextMenuState = contextMenuState; public contextMenuState = contextMenuState;
public formRegister = formRegister; public formRegister = formRegister;
public storeChanger = storeChanger; public storeChanger = storeChanger;
@@ -323,6 +324,7 @@ export class UserConfig {
constructor(initConfig?: Partial<InitConfig>) { constructor(initConfig?: Partial<InitConfig>) {
const mergeConfig = userConfigMerge(defaultConfig, initConfig); const mergeConfig = userConfigMerge(defaultConfig, initConfig);
this.initConfig = mergeConfig; this.initConfig = mergeConfig;
this.commanderRegister = new CommanderWrapper(store, {}, this);
this.eventCenter = new EventCenter({}, mergeConfig.initFunctionMap); this.eventCenter = new EventCenter({}, mergeConfig.initFunctionMap);
this.dataCenter = new DataCenter(mergeConfig.initDataCenterMap); this.dataCenter = new DataCenter(mergeConfig.initDataCenterMap);
this.init(); this.init();

View File

@@ -2,9 +2,10 @@
* @Author: yehuozhili * @Author: yehuozhili
* @Date: 2021-03-14 04:29:09 * @Date: 2021-03-14 04:29:09
* @LastEditors: yehuozhili * @LastEditors: yehuozhili
* @LastEditTime: 2021-03-14 04:39:43 * @LastEditTime: 2021-07-12 14:52:12
* @FilePath: \dooring-v2\src\core\command\commanderType.ts * @FilePath: \dooringx\packages\dooringx-lib\src\core\command\commanderType.ts
*/ */
import UserConfig from '../../config';
import Store from '../store'; import Store from '../store';
export interface CommanderItem { export interface CommanderItem {
@@ -12,6 +13,6 @@ export interface CommanderItem {
display: string; display: string;
name: string; name: string;
keyboard: string; keyboard: string;
excute: (store: Store, options?: any) => void; excute: (store: Store, config: UserConfig, options?: Record<string, any>) => void;
destroy: () => void; destroy: () => void;
} }

View File

@@ -2,15 +2,20 @@
* @Author: yehuozhili * @Author: yehuozhili
* @Date: 2021-03-14 04:29:09 * @Date: 2021-03-14 04:29:09
* @LastEditors: yehuozhili * @LastEditors: yehuozhili
* @LastEditTime: 2021-07-08 20:42:15 * @LastEditTime: 2021-07-12 14:52:28
* @FilePath: \DooringV2\packages\dooringx-lib\src\core\command\index.ts * @FilePath: \dooringx\packages\dooringx-lib\src\core\command\index.ts
*/ */
import UserConfig from '../../config';
import Store from '../store'; import Store from '../store';
import { CommanderItem } from './commanderType'; import { CommanderItem } from './commanderType';
import { keycodeFilter } from './keycode'; import { keycodeFilter } from './keycode';
class CommanderWrapper { class CommanderWrapper {
constructor(public store: Store, public commandMap: Record<string, CommanderItem> = {}) {} constructor(
public store: Store,
public commandMap: Record<string, CommanderItem> = {},
public config: UserConfig
) {}
getList() { getList() {
return this.commandMap; return this.commandMap;
} }
@@ -55,7 +60,7 @@ class CommanderWrapper {
} }
const keyname = keyString.join('+'); const keyname = keyString.join('+');
if (current.keyboard === keyname) { if (current.keyboard === keyname) {
current.excute(this.store); current.excute(this.store, this.config);
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
} }
@@ -78,7 +83,7 @@ class CommanderWrapper {
console.error(`${name} commander not found`); console.error(`${name} commander not found`);
return; return;
} }
this.commandMap[name].excute(this.store, options); this.commandMap[name].excute(this.store, this.config, options);
} }
} }
export default CommanderWrapper; export default CommanderWrapper;

View File

@@ -2,7 +2,7 @@
* @Author: yehuozhili * @Author: yehuozhili
* @Date: 2021-03-14 05:35:15 * @Date: 2021-03-14 05:35:15
* @LastEditors: yehuozhili * @LastEditors: yehuozhili
* @LastEditTime: 2021-07-10 17:46:26 * @LastEditTime: 2021-07-12 14:48:38
* @FilePath: \dooringx\packages\dooringx-lib\src\hooks\index.ts * @FilePath: \dooringx\packages\dooringx-lib\src\hooks\index.ts
*/ */
import { useEffect, useMemo, useState } from 'react'; import { useEffect, useMemo, useState } from 'react';

View File

@@ -2,8 +2,8 @@
* @Author: yehuozhili * @Author: yehuozhili
* @Date: 2021-03-14 04:22:18 * @Date: 2021-03-14 04:22:18
* @LastEditors: yehuozhili * @LastEditors: yehuozhili
* @LastEditTime: 2021-07-07 03:38:44 * @LastEditTime: 2021-07-12 14:43:28
* @FilePath: \dooringv2\packages\dooringx-lib\src\index.tsx * @FilePath: \dooringx\packages\dooringx-lib\src\index.tsx
*/ */
// 初始化store用 // 初始化store用
@@ -27,7 +27,7 @@ export { innerContainerDragUp } from './core/innerDrag';
// 用于修改store // 用于修改store
export { store } from './runtime/store'; export { store } from './runtime/store';
// 用于获取运行中的实例 // 用于获取运行中的实例
export { commander, componentRegister, formRegister, storeChanger } from './runtime'; export { componentRegister, formRegister, storeChanger } from './runtime';
export { unmountContextMenu } from './core/contextMenu'; export { unmountContextMenu } from './core/contextMenu';

View File

@@ -2,15 +2,12 @@
* @Author: yehuozhili * @Author: yehuozhili
* @Date: 2021-03-14 04:33:52 * @Date: 2021-03-14 04:33:52
* @LastEditors: yehuozhili * @LastEditors: yehuozhili
* @LastEditTime: 2021-07-10 18:18:15 * @LastEditTime: 2021-07-12 14:43:03
* @FilePath: \dooringx\packages\dooringx-lib\src\runtime\index.ts * @FilePath: \dooringx\packages\dooringx-lib\src\runtime\index.ts
*/ */
import CommanderWrapper from '../core/command';
import ComponentRegister from '../core/components'; import ComponentRegister from '../core/components';
import { FormComponentRegister } from '../core/components/formComponentRegister'; import { FormComponentRegister } from '../core/components/formComponentRegister';
import { StoreChanger } from '../core/storeChanger'; import { StoreChanger } from '../core/storeChanger';
import { store } from './store';
export const commander = new CommanderWrapper(store);
export const componentRegister = new ComponentRegister(); export const componentRegister = new ComponentRegister();
export const formRegister = new FormComponentRegister(); export const formRegister = new FormComponentRegister();
export const storeChanger = new StoreChanger(); export const storeChanger = new StoreChanger();