Skip to content

Commit 0a3f2da

Browse files
committed
重构
1 parent 61e0924 commit 0a3f2da

30 files changed

+62
-54
lines changed

src/example/WorkflowEditor/PublishButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Button, Modal, message } from "antd"
22
import { memo, useState } from "react"
3-
import { useEditorStore } from "../../workflow-editor"
3+
import { useEditorEngine } from "../../workflow-editor"
44
import { useTranslate } from "../../workflow-editor/react-locales"
55
import { CloseCircleOutlined } from "@ant-design/icons"
66
import { styled } from "styled-components"
@@ -49,7 +49,7 @@ export const PublishButton = memo(() => {
4949
const [errors, setErrors] = useState<IErrorItem[]>();
5050

5151
const t = useTranslate()
52-
const editorStore = useEditorStore()
52+
const editorStore = useEditorEngine()
5353

5454
const handleValidate = () => {
5555
const result = editorStore?.validate()

src/workflow-editor/WorkflowDiagram/OperationBar/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { MiniFloatContainer } from "../ZoomBar"
44
import { undoIcon, redoIcon } from "../../icons"
55
import { useRedoList } from "../../hooks/useRedoList"
66
import { useUndoList } from "../../hooks/useUndoList"
7-
import { useEditorStore } from "../../hooks"
7+
import { useEditorEngine } from "../../hooks"
88

99
export const OperationBar = memo((
1010
props: {
@@ -15,7 +15,7 @@ export const OperationBar = memo((
1515
const redoList = useRedoList();
1616
const undoList = useUndoList();
1717

18-
const store = useEditorStore();
18+
const store = useEditorEngine();
1919

2020
const handleUndo = useCallback(()=>{
2121
store?.undo()

src/workflow-editor/WorkflowDiagram/SettingsPanel/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { memo, useCallback } from "react"
44
import { NodeTitle } from "./NodeTitle"
55
import { Footer } from "./Footer"
66
import { useSelectedNode } from "../../hooks/useSelectedNode"
7-
import { useEditorStore } from "../../hooks"
7+
import { useEditorEngine } from "../../hooks"
88
import { styled } from "styled-components"
99
import { useMaterialUI } from "../../hooks/useMaterialUI"
1010

@@ -15,7 +15,7 @@ const Content = styled.div`
1515
export const SettingsPanel = memo(() => {
1616
const selectedNode = useSelectedNode()
1717
const materialUi = useMaterialUI(selectedNode)
18-
const store = useEditorStore()
18+
const store = useEditorEngine()
1919
const handelClose = useCallback(() => {
2020
store?.selectNode(undefined)
2121
}, [store])

src/workflow-editor/WorkflowDiagram/WorkFlowScope.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { memo, useEffect, useMemo, useState } from "react"
22
import { ThemeProvider } from "styled-components"
33
import { IThemeToken } from "../theme"
44
import { useToken } from "antd/es/theme/internal"
5-
import { EditorStore } from "../classes"
5+
import { EditorEngine } from "../classes"
66
import { WorkflowEditorStoreContext } from "../contexts"
77
import { ConfigRoot } from "./ConfigRoot"
88
import { ILocales, LocalesManager } from "@rxdrag/locales"
@@ -28,8 +28,8 @@ const WorkFlowScopeInner = memo((props: {
2828
mode
2929
}
3030
}, [mode, themeToken, token])
31-
const store: EditorStore = useMemo(() => {
32-
return new EditorStore()
31+
const store: EditorEngine = useMemo(() => {
32+
return new EditorEngine()
3333
}, [])
3434

3535
useEffect(() => {

src/workflow-editor/classes/EditorStore.ts renamed to src/workflow-editor/classes/EditorEngine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Action, ActionType, AddNodeAction, ChangeNodeAction, DeleteNodeAction,
88
import { IMaterialUIs, INodeMaterial, Translate } from "../interfaces/material"
99
import { createUuid } from "../utils/create-uuid"
1010

11-
export class EditorStore {
11+
export class EditorEngine {
1212
store: Store<IState>
1313
t: Translate = (msg: string) => msg
1414
materials: INodeMaterial[] = []

src/workflow-editor/classes/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from "./EditorStore"
1+
export * from "./EditorEngine"

src/workflow-editor/contexts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { createContext } from "react";
2-
import { EditorStore } from "./classes";
2+
import { EditorEngine } from "./classes";
33

4-
export const WorkflowEditorStoreContext = createContext<EditorStore | undefined>(undefined)
4+
export const WorkflowEditorStoreContext = createContext<EditorEngine | undefined>(undefined)

src/workflow-editor/hooks/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export * from "./useEditorStore"
1+
export * from "./useEditorEngine"
22
export * from "./useExport"
33
export * from "./useImport"
44
export * from "./useSelectedNode"
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useContext } from "react";
22
import { WorkflowEditorStoreContext } from "../contexts";
33

4-
export function useEditorStore() {
4+
export function useEditorEngine() {
55
return useContext(WorkflowEditorStoreContext)
66
}

src/workflow-editor/hooks/useError.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { useCallback, useEffect, useState } from "react"
22
import { IErrors } from "../interfaces/state"
3-
import { useEditorStore } from "./useEditorStore"
3+
import { useEditorEngine } from "./useEditorEngine"
44

55
export function useError(nodeId: string) {
66
const [errors, setErrors] = useState<IErrors>()
77

8-
const store = useEditorStore()
8+
const store = useEditorEngine()
99

1010
const handleErrorsChange = useCallback((errs: IErrors) => {
1111
setErrors(errs)

0 commit comments

Comments
 (0)