chore: re-org

This commit is contained in:
gchust 2025-04-16 14:29:22 +08:00
parent 84d8ccf83b
commit 9f20bc307f
12 changed files with 18 additions and 68 deletions

View File

@ -362,7 +362,6 @@ const EventFilterTableDemo: React.FC = (props) => {
// 应用 FilterFlow 获取列配置
const applyColumnFilter = useCallback(async () => {
const context: FilterHandlerContext = {
props: {},
payload: {
hooks: hooks,
},

View File

@ -1,7 +1,7 @@
import { Modal, Form, Input, Select, Switch, InputNumber } from 'antd';
import React, { useState } from 'react';
import { EventFlowActionOptions, EventFlowManager } from '../libs/eventflow-manager';
import { EventContext } from '../libs/types';
import { EventFlowActionOptions } from '@nocobase/client';
import { EventContext } from '@nocobase/client';
import { SchemaComponent, SchemaComponentProvider } from '@nocobase/client';
import { createForm } from '@formily/core';
import { ISchema, connect, mapProps, mapReadPretty } from '@formily/react';

View File

@ -1,5 +1,5 @@
import { Modal, Input } from 'antd';
import { EventFlowActionOptions } from '../libs/eventflow-manager';
import { EventFlowActionOptions } from '@nocobase/client';
import React from 'react';
/**

View File

@ -1,5 +1,5 @@
import { notification, Button, Flex } from 'antd';
import { EventFlowActionOptions } from '../libs/eventflow-manager';
import { EventFlowActionOptions } from '@nocobase/client';
import React from 'react';
/**

View File

@ -1,5 +1,5 @@
import { Modal } from 'antd';
import { EventFlowActionOptions } from '../libs/eventflow-manager';
import { EventFlowActionOptions } from '@nocobase/client';
import React from 'react';
/**

View File

@ -1,50 +0,0 @@
import { useFieldSchema } from '@formily/react';
import { useBlockResource } from '@nocobase/client';
import { Spin, Table, Button, Space, Row, Flex } from 'antd';
import React, { useMemo } from 'react';
import { EventContext } from '../libs/types';
import { useAddEventListener, useApplyFilter } from '../libs/hooks';
const DemoTable = (props) => {
const { done, result } = useApplyFilter('core:block:table', { props });
const fieldSchema = useFieldSchema();
const resource = useBlockResource();
useAddEventListener('core:block:table:refresh', (ctx: EventContext) => {
console.log('core:block:table:refresh', ctx);
resource.list();
});
const actionEventContext: EventContext = useMemo(() => {
return {
source: {
uischema: fieldSchema.toJSON(),
},
};
}, [fieldSchema]);
if (!done) {
return <Spin />;
}
const columns = result?.columns || [];
const data = result?.data?.data || [];
const actions = result?.actions || [];
return (
<Flex vertical style={{ height: result?.height, width: result?.width }}>
<Row justify="end" style={{ marginBottom: '16px' }}>
<Space>
{actions.map((action) => (
<Button key={action.label} onClick={async () => await action.handle(actionEventContext)}>
{action.label}
</Button>
))}
</Space>
</Row>
<Table style={{ width: '100%' }} columns={columns} dataSource={data} />
</Flex>
);
};
export default DemoTable;

View File

@ -1,4 +1,4 @@
import { Button, Space, Alert, Card, Divider } from 'antd';
import { Button, Space, Card } from 'antd';
import { EventBus } from '@nocobase/client';
import React, { useState } from 'react';
import { openFormDialogAction } from '../actions/open-form-dialog';

View File

@ -170,7 +170,7 @@ const ConfigurableFilter = () => {
try {
// 创建FilterFlow上下文
const context = {
props: {
payload: {
inputText,
},
};

View File

@ -231,7 +231,7 @@ const DataTransformFilterFlow = () => {
try {
// 创建FilterFlow上下文
const context = {
props: {},
payload: {},
};
// 应用FilterFlow

View File

@ -130,7 +130,7 @@ const MultiStepFilterFlow = () => {
try {
// 创建过滤上下文
const context = {
props: {
payload: {
inputText,
},
};

View File

@ -27,6 +27,7 @@ export interface EventContext<T = any> {
event?: string | string[]; // 事件名称, 一个事件是可以触发多个eventflow的与filterflow不同
[key: string]: any;
};
payload?: T;
results?: Record<string, any>;
}
export interface EventListenerOptions {

View File

@ -64,14 +64,6 @@ export class FilterFlowStep {
return filter?.handler;
}
/**
* Filter UI Schema
*/
getUiSchema(): ISchema | undefined {
const filter = this.filterFlow.getFilter(this.filterName);
return filter?.uiSchema;
}
get(key: string) {
return _.get(this.options, key);
}
@ -91,6 +83,14 @@ export class FilterFlowStep {
// 可根据需要添加 save 等方法,如果需要持久化步骤配置
// async save() { /* ... */ }
/**
* Filter UI Schema
*/
private getUiSchema(): ISchema | undefined {
const filter = this.filterFlow.getFilter(this.filterName);
return filter?.uiSchema;
}
}
export class FilterFlow {