Skip to content

Commit 79e1e2a

Browse files
committed
playground
1 parent 74ca7dc commit 79e1e2a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2645
-86
lines changed

README.md

Lines changed: 169 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,202 @@
1-
# @codingapi/flow-mobile
1+
# Flow-Mobile
22

3-
[English](#english) | [中文](#chinese)
3+
基于Mobile的流程引擎
44

5-
## English
6-
7-
A mobile-friendly flow designer component library built with React and TypeScript, based on LogicFlow.
8-
9-
### Installation
5+
## 安装
106

117
```bash
8+
# npm
129
npm install @codingapi/flow-mobile
13-
# or
14-
yarn add @codingapi/flow-mobile
15-
```
1610

17-
### Features
18-
19-
- 🎯 Mobile-optimized flow designer
20-
- 📱 Built on LogicFlow core
21-
- 🎨 Integrated with antd-mobile UI components
22-
- 🔧 Full TypeScript support
23-
- ⚡️ Redux state management
24-
- 🛠 Easy integration with React applications
11+
# yarn
12+
yarn add @codingapi/flow-mobile
2513

26-
### Dependencies
14+
# pnpm
15+
pnpm add @codingapi/flow-mobile
16+
```
2717

28-
- React 16.8+ / 17 / 18
29-
- React DOM 16.8+ / 17 / 18
30-
- @codingapi/ui-framework
31-
- @codingapi/form-mobile
32-
- @logicflow/core
33-
- @logicflow/extension
34-
- antd-mobile
18+
## 使用
3519

36-
### Quick Start
20+
### 流程审批
3721

3822
```tsx
39-
import { FlowDesigner } from '@codingapi/flow-mobile';
40-
41-
function App() {
42-
return (
43-
<FlowDesigner
44-
// Add your flow configuration here
45-
/>
46-
);
23+
import React from "react";
24+
import {useLocation, useNavigate} from "react-router";
25+
import {FlowView} from "@codingapi/flow-mobile";
26+
import {Result} from "antd-mobile";
27+
import {flowViews} from "@/config/flows";
28+
29+
const FlowDetailPage = () => {
30+
31+
const location = useLocation();
32+
const state = location.state;
33+
const navigate = useNavigate();
34+
35+
if (state) {
36+
return (
37+
<>
38+
<FlowView
39+
view={flowViews}
40+
id={state.id}
41+
visible={true}
42+
setVisible={()=>{
43+
navigate(-1);
44+
}}
45+
/>
46+
</>
47+
)
48+
}
49+
50+
return (
51+
<>
52+
<Result
53+
status={"error"}
54+
title={"页面参数错误"}
55+
/>
56+
</>
57+
)
4758
}
48-
```
49-
50-
### Documentation
5159

52-
For detailed documentation and examples, please visit our [GitHub repository](https://github.com/codingapi/flow-mobile).
60+
export default FlowDetailPage;
5361

54-
### Contributing
62+
```
5563

56-
We welcome contributions! Please see our [GitHub Issues](https://github.com/codingapi/flow-mobile/issues) for details.
64+
### 自定义视图拓展
5765

58-
### License
66+
* 自定义延期提醒
67+
```tsx
68+
import React from "react";
69+
import {PostponedFormProps} from "@codingapi/ui-framework";
70+
import Popup from "@/components/popup";
71+
import {DatePickerView} from "antd-mobile";
72+
import dayjs from "dayjs";
73+
import {dateLabelRenderer} from "@codingapi/form-mobile";
74+
75+
const PostponedFormView: React.FC<PostponedFormProps> = (props) => {
76+
77+
const [value, setValue] = React.useState(new Date());
78+
// 获取一小时后的日期
79+
const now = dayjs().add(1, 'hour').toDate();
80+
81+
return (
82+
<Popup
83+
visible={props.visible}
84+
setVisible={props.setVisible}
85+
position='bottom'
86+
title={"延期截止日期"}
87+
bodyStyle={{height: '50vh'}}
88+
onOk={() => {
89+
const diff = dayjs(value).diff(dayjs(now), 'hour') + 1;
90+
props.onFinish(diff);
91+
}}
92+
>
93+
<div>
94+
<DatePickerView
95+
precision={"hour"}
96+
renderLabel={dateLabelRenderer}
97+
value={value}
98+
min={now}
99+
onChange={(value) => {
100+
setValue(value);
101+
}}
102+
/>
103+
</div>
104+
</Popup>
105+
)
106+
}
59107

60-
Apache-2.0 © CodingAPI
108+
export default PostponedFormView;
61109

62-
---
63110

64-
## Chinese
111+
```
112+
添加自定义视图到配置中
113+
```
114+
import {PostponedFormViewKey} from "@codingapi/ui-framework";
115+
import {ComponentBus} from "@codingapi/ui-framework";
116+
import {FlowApiContent,FlowApi} from "@codingapi/flow-mobile";
117+
import PostponedFormView from "@/components/flow/PostponedFormView";
65118
66-
一个基于 LogicFlow 的移动端流程设计器组件库,使用 React 和 TypeScript 构建。
119+
ComponentBus.getInstance().registerComponent(PostponedFormViewKey,PostponedFormView);
120+
```
121+
* 自定义选人组件
122+
```
123+
import React, {useEffect} from "react";
124+
import {UserSelectFormProps} from "@codingapi/ui-framework";
125+
import Popup from "@/components/popup";
126+
import {Form,FormInput} from "@codingapi/form-mobile";
127+
128+
const UserSelectFormView: React.FC<UserSelectFormProps> = (props) => {
129+
130+
const formInstance = Form.useForm();
131+
132+
useEffect(() => {
133+
if(props.visible){
134+
if(props.specifyUserIds){
135+
formInstance.setFieldValue("users", props.specifyUserIds.join(","));
136+
}
137+
}
138+
}, [props.visible]);
139+
140+
return (
141+
<Popup
142+
visible={props.visible}
143+
setVisible={props.setVisible}
144+
position='bottom'
145+
title={"选人人员"}
146+
bodyStyle={{height: '50vh'}}
147+
onOk={() => {
148+
const users = formInstance.getFieldValue("users");
149+
if(users){
150+
const userIds = Array.of(...users.split(",")).map(item =>{
151+
return {
152+
id: item,
153+
name: item
154+
}
155+
});
156+
props.onFinish(userIds);
157+
}
158+
}}
159+
>
160+
<div>
161+
<Form
162+
form={formInstance}
163+
>
164+
<FormInput
165+
name={"users"}
166+
label={"人员"}
167+
placeholder={"请选择人员"}
168+
/>
169+
</Form>
170+
171+
</div>
172+
</Popup>
173+
)
174+
}
67175
68-
### 安装
176+
export default UserSelectFormView;
69177
70-
```bash
71-
npm install @codingapi/flow-mobile
72-
#
73-
yarn add @codingapi/flow-mobile
74178
```
179+
然后再注册到配置中。
75180

76-
### 特性
181+
更多的实例请参考:https://github.com/codingapi/flow-mobile/tree/main/playground
77182

78-
- 🎯 移动端优化的流程设计器
79-
- 📱 基于 LogicFlow 核心
80-
- 🎨 集成 antd-mobile UI 组件
81-
- 🔧 完整的 TypeScript 支持
82-
- ⚡️ Redux 状态管理
83-
- 🛠 易于与 React 应用集成
183+
## 开发
84184

85-
### 依赖
185+
```bash
186+
# Install dependencies
187+
yarn install
86188

87-
- React 16.8+ / 17 / 18
88-
- React DOM 16.8+ / 17 / 18
89-
- @codingapi/ui-framework
90-
- @codingapi/form-mobile
91-
- @logicflow/core
92-
- @logicflow/extension
93-
- antd-mobile
189+
# Start development server
190+
yarn dev
94191

95-
### 快速开始
192+
# Build for production
193+
yarn build
96194

97-
```tsx
98-
import { FlowDesigner } from '@codingapi/flow-mobile';
99-
100-
function App() {
101-
return (
102-
<FlowDesigner
103-
// 在这里添加流程配置
104-
/>
105-
);
106-
}
195+
# Run tests
196+
yarn test
107197
```
198+
## 许可
108199

109-
### 文档
110-
111-
详细的文档和示例,请访问我们的 [GitHub 仓库](https://github.com/codingapi/flow-mobile)
112-
113-
### 贡献
114-
115-
我们欢迎各种形式的贡献!详情请查看我们的 [GitHub Issues](https://github.com/codingapi/flow-mobile/issues)
200+
Apache-2.0 © [CodingAPI](https://github.com/codingapi/flow-mobile/blob/main/LICENSE)
116201

117-
### 许可证
118202

119-
Apache-2.0 © CodingAPI

playground/.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
25+
yarn.lock
26+
package-lock.json

playground/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# playground
2+
3+
4+
## 运行步骤
5+
### 编译flow-mobile
6+
```
7+
yarn build
8+
```
9+
在flow-mobile目录下执行编译命令,编译完成后会在dist目录下生成flow-mobile的代码包。
10+
11+
### 运行实例
12+
13+
```
14+
# 开发模式
15+
yarn start
16+
# 调试模式
17+
yarn dev
18+
# 生产模式
19+
yarn build
20+
```

playground/jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'jsdom',
4+
moduleNameMapper: {
5+
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
6+
},
7+
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
8+
};

playground/jest.setup.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import '@testing-library/jest-dom';
2+
3+
Object.defineProperty(window, 'matchMedia', {
4+
writable: true,
5+
value: jest.fn().mockImplementation(query => ({
6+
matches: false,
7+
media: query,
8+
onchange: null,
9+
addListener: jest.fn(), // 旧版 API
10+
removeListener: jest.fn(), // 旧版 API
11+
addEventListener: jest.fn(), // 新版 API
12+
removeEventListener: jest.fn(), // 新版 API
13+
dispatchEvent: jest.fn(),
14+
})),
15+
});

0 commit comments

Comments
 (0)