diff --git a/.gitignore b/.gitignore index e6d79c3d..a7555afa 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,6 @@ build/ .DS_Store ### Worktrees ### -.worktrees/ \ No newline at end of file +.worktrees/ + +### fornt-end ### \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..ec9ba7c6 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "flow-frontend"] + path = flow-frontend + url = git@github.com:codingapi/flow-frontend.git diff --git a/CLAUDE.md b/CLAUDE.md index b75fa675..6f3282fe 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -31,7 +31,7 @@ cd flow-engine-example && mvn spring-boot:run ```bash # 安装依赖(使用 pnpm,而非 npm) -cd frontend && pnpm install +cd flow-frontend && pnpm install # 构建所有包 pnpm run build @@ -96,7 +96,7 @@ pnpm run dev:app-mobile # 移动端应用 |--------|-------------|------| | `flow-core` | 核心框架库(HTTP、Hooks、Presenter 等),不包含 UI 组件 | 无 | | `flow-types` | TypeScript 类型定义(流程实例、表单、审批等业务类型) | flow-core | -| `flow-pc-ui` | PC 端基础 UI 组件库(按钮、输入框等原子组件) | 无 | +| `flow-pc-ui` | PC 端基础 UI 组件库(按钮、输入框等原子组件) | flow-core | | `flow-pc-form` | PC 端表单相关组件(表单设计器、表单渲染等) | flow-core, flow-types | | `flow-pc-design` | PC 端流程设计器组件(节点配置、属性面板等) | flow-core, flow-types, flow-pc-ui | | `flow-pc-approval` | PC 端审批页面(待办/已办/审批处理等) | flow-pc-design, flow-pc-ui | @@ -105,21 +105,21 @@ pnpm run dev:app-mobile # 移动端应用 ``` flow-core (无UI) - ↑ + ↑ ↑ + │ └── flow-pc-ui (基础UI) + │ flow-types (类型定义) ↑ ↑ │ └── flow-pc-form │ ↑ └───────→ flow-pc-design ──→ flow-pc-approval - ↑ - flow-pc-ui (基础UI) ``` **模块划分原则**: - **flow-core**:全局框架依赖,只包含与 UI 无关的基础能力(HTTP、状态管理、工具函数等) - **flow-types**:全局类型定义,包含流程审批相关的业务类型(手机端和 PC 端共用) -- **flow-pc-ui**:PC 端基础 UI 组件库,提供原子化组件 +- **flow-pc-ui**:PC 端基础 UI 组件库,提供原子化组件,依赖 flow-core - **flow-pc-form**:表单相关功能,依赖 flow-core + flow-types - **flow-pc-design**:流程设计器功能,包含节点配置、属性面板、脚本配置等 - **flow-pc-approval**:审批页面功能,依赖 flow-pc-design diff --git a/README.md b/README.md index 7eeba77b..2a98ae60 100644 --- a/README.md +++ b/README.md @@ -208,7 +208,7 @@ flow-engine ├── flow-engine-starter # Spring Boot Starter ├── flow-engine-starter-infra # 持久化层 Starter ├── flow-engine-example # 示例项目 -└── frontend # 前端项目 +└── flow-frontend # 前端项目(Git Submodule) ├── apps │ ├── app-pc # PC端应用 │ └── app-mobile # 移动端应用 @@ -260,7 +260,7 @@ mvn spring-boot:run ### 前端 ```bash -cd frontend +cd flow-frontend # 安装依赖 pnpm install diff --git a/flow-frontend b/flow-frontend new file mode 160000 index 00000000..21c85c48 --- /dev/null +++ b/flow-frontend @@ -0,0 +1 @@ +Subproject commit 21c85c48d50223ad61f19461f3d09ca9407e5dbb diff --git a/frontend/.gitignore b/frontend/.gitignore deleted file mode 100644 index 77547f40..00000000 --- a/frontend/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -/.idea - -# claude -.serena - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# production -/build -/dist - -# misc -.DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local - -npm-debug.log* -yarn-debug.log* -yarn-error.log* -yarn.lock -package-lock.json - diff --git a/frontend/.tool-versions b/frontend/.tool-versions deleted file mode 100644 index 075da89d..00000000 --- a/frontend/.tool-versions +++ /dev/null @@ -1 +0,0 @@ -nodejs 20.19.5 diff --git a/frontend/apps/app-mobile/.gitignore b/frontend/apps/app-mobile/.gitignore deleted file mode 100644 index 6f3092c3..00000000 --- a/frontend/apps/app-mobile/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -# Local -.DS_Store -*.local -*.log* - -# Dist -node_modules -dist/ - -# Profile -.rspack-profile-*/ - -# IDE -.vscode/* -!.vscode/extensions.json -.idea diff --git a/frontend/apps/app-mobile/AGENTS.md b/frontend/apps/app-mobile/AGENTS.md deleted file mode 100644 index fbca121d..00000000 --- a/frontend/apps/app-mobile/AGENTS.md +++ /dev/null @@ -1,14 +0,0 @@ -# AGENTS.md - -You are an expert in JavaScript, Rsbuild, and web application development. You write maintainable, performant, and accessible code. - -## Commands - -- `pnpm run dev` - Start the dev server -- `pnpm run build` - Build the app for production -- `pnpm run preview` - Preview the production build locally - -## Docs - -- Rsbuild: https://rsbuild.rs/llms.txt -- Rspack: https://rspack.rs/llms.txt diff --git a/frontend/apps/app-mobile/README.md b/frontend/apps/app-mobile/README.md deleted file mode 100644 index 78dc6277..00000000 --- a/frontend/apps/app-mobile/README.md +++ /dev/null @@ -1,67 +0,0 @@ -# Flow Engine 移动端应用 - -Flow Engine 的移动端流程管理应用(开发中)。 - -## 简介 - -`app-mobile` 是 Flow Engine 的移动端 Web 应用,将提供简化的移动操作界面。 - -> **注意**: 此应用目前处于开发阶段,功能尚未完整实现。 - -### 核心依赖 - -- `@flow-engine/flow-core` - 核心 API 库 -- `@flow-engine/flow-types` - TypeScript 类型定义 -- `antd` - Ant Design 组件库(移动端适配) -- `react-router` + `react-router-dom` - 路由管理 - -## Setup - -安装依赖: - -```bash -pnpm install -``` - -## 开发 - -启动开发服务器,应用将在 [http://localhost:3000](http://localhost:3000) 访问。 - -```bash -pnpm run dev -``` - -## 构建 - -构建生产版本: - -```bash -pnpm run build -``` - -预览生产构建: - -```bash -pnpm run preview -``` - -## 计划功能 - -### 移动端优化 - -- 响应式设计适配移动设备 -- 触摸优化的交互体验 -- 简化的流程处理界面 - -### 核心功能 - -- 待办任务列表 -- 流程审批操作 -- 流程进度查看 -- 消息通知 - -## Learn more - -- [Rsbuild documentation](https://rsbuild.rs) - Rsbuild 特性和 API -- [Rspack documentation](https://rspack.rs) - 底层打包工具 -- [Flow Engine Docs](https://github.com/codingapi/flow-engine) - 完整文档 diff --git a/frontend/apps/app-mobile/package.json b/frontend/apps/app-mobile/package.json deleted file mode 100644 index 87d4b980..00000000 --- a/frontend/apps/app-mobile/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "@flow-example/app-mobile", - "version": "1.0.0", - "private": true, - "type": "module", - "scripts": { - "build": "rsbuild build", - "dev": "rsbuild dev --open", - "preview": "rsbuild preview" - }, - "dependencies": { - "@flow-engine/flow-core": "workspace:*", - "@flow-engine/flow-types": "workspace:*", - "antd": "^6.2.1", - "react": "^18.3.1", - "react-dom": "^18.3.1", - "react-router": "^7.13.0", - "react-router-dom": "^7.13.0" - }, - "devDependencies":{ - "@flow-engine/flow-core": "workspace:*", - "@flow-engine/flow-types": "workspace:*" - } -} diff --git a/frontend/apps/app-mobile/public/favicon.png b/frontend/apps/app-mobile/public/favicon.png deleted file mode 100644 index af06119f..00000000 Binary files a/frontend/apps/app-mobile/public/favicon.png and /dev/null differ diff --git a/frontend/apps/app-mobile/rsbuild.config.ts b/frontend/apps/app-mobile/rsbuild.config.ts deleted file mode 100644 index 0dc15ef3..00000000 --- a/frontend/apps/app-mobile/rsbuild.config.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { defineConfig } from '@rsbuild/core'; -import { pluginReact } from '@rsbuild/plugin-react'; -import * as path from "path"; - -// Docs: https://rsbuild.rs/config/ -export default defineConfig({ - plugins: [pluginReact()], - resolve: { - alias: { - "@/": path.resolve(__dirname, "src"), - } -} -}); diff --git a/frontend/apps/app-mobile/src/config/routers.tsx b/frontend/apps/app-mobile/src/config/routers.tsx deleted file mode 100644 index 19d511b2..00000000 --- a/frontend/apps/app-mobile/src/config/routers.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { createHashRouter, type RouteObject } from "react-router"; -import LoginPage from "@/pages/login"; -import HomePage from "@/pages/home"; - - -const routers:RouteObject[] = [ - { - path:'/login', - element: - }, - { - path:'/', - element: - } -] - - -export const hashRouters = createHashRouter(routers); \ No newline at end of file diff --git a/frontend/apps/app-mobile/src/env.d.ts b/frontend/apps/app-mobile/src/env.d.ts deleted file mode 100644 index 698ba8bb..00000000 --- a/frontend/apps/app-mobile/src/env.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -/** - * Imports the SVG file as a React component. - * @requires [@rsbuild/plugin-svgr](https://npmjs.com/package/@rsbuild/plugin-svgr) - */ -declare module '*.svg?react' { - import type React from 'react'; - const ReactComponent: React.FunctionComponent>; - export default ReactComponent; -} diff --git a/frontend/apps/app-mobile/src/index.tsx b/frontend/apps/app-mobile/src/index.tsx deleted file mode 100644 index 9cd10972..00000000 --- a/frontend/apps/app-mobile/src/index.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom/client'; -import { RouterProvider } from 'react-router'; -import { hashRouters } from './config/routers'; - -const rootEl = document.getElementById('root'); -if (rootEl) { - const root = ReactDOM.createRoot(rootEl); - root.render( - - - , - ); -} diff --git a/frontend/apps/app-mobile/src/pages/home.tsx b/frontend/apps/app-mobile/src/pages/home.tsx deleted file mode 100644 index 3575dee0..00000000 --- a/frontend/apps/app-mobile/src/pages/home.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from "react"; -import { useNavigate } from "react-router"; - - -const HomePage:React.FC = ()=>{ - - const navigate = useNavigate(); - - return ( -
- - - -
- ) -} - -export default HomePage; \ No newline at end of file diff --git a/frontend/apps/app-mobile/src/pages/login.tsx b/frontend/apps/app-mobile/src/pages/login.tsx deleted file mode 100644 index b036aa33..00000000 --- a/frontend/apps/app-mobile/src/pages/login.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from "react"; - -const LoginPage:React.FC = ()=>{ - - return ( - <>login - ) -} - -export default LoginPage; \ No newline at end of file diff --git a/frontend/apps/app-mobile/tsconfig.json b/frontend/apps/app-mobile/tsconfig.json deleted file mode 100644 index 8af95354..00000000 --- a/frontend/apps/app-mobile/tsconfig.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "compilerOptions": { - "lib": ["DOM", "ES2020"], - "jsx": "react-jsx", - "target": "ES2020", - "noEmit": true, - "skipLibCheck": true, - "useDefineForClassFields": true, - - /* modules */ - "module": "ESNext", - "moduleDetection": "force", - "moduleResolution": "bundler", - "verbatimModuleSyntax": true, - "resolveJsonModule": true, - "allowImportingTsExtensions": true, - "noUncheckedSideEffectImports": true, - - /* type checking */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "baseUrl": ".", - "paths": { - "@/*": ["src/*"] - } - }, - "include": ["src"] -} diff --git a/frontend/apps/app-pc/.gitignore b/frontend/apps/app-pc/.gitignore deleted file mode 100644 index 6f3092c3..00000000 --- a/frontend/apps/app-pc/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -# Local -.DS_Store -*.local -*.log* - -# Dist -node_modules -dist/ - -# Profile -.rspack-profile-*/ - -# IDE -.vscode/* -!.vscode/extensions.json -.idea diff --git a/frontend/apps/app-pc/AGENTS.md b/frontend/apps/app-pc/AGENTS.md deleted file mode 100644 index fbca121d..00000000 --- a/frontend/apps/app-pc/AGENTS.md +++ /dev/null @@ -1,14 +0,0 @@ -# AGENTS.md - -You are an expert in JavaScript, Rsbuild, and web application development. You write maintainable, performant, and accessible code. - -## Commands - -- `pnpm run dev` - Start the dev server -- `pnpm run build` - Build the app for production -- `pnpm run preview` - Preview the production build locally - -## Docs - -- Rsbuild: https://rsbuild.rs/llms.txt -- Rspack: https://rspack.rs/llms.txt diff --git a/frontend/apps/app-pc/README.md b/frontend/apps/app-pc/README.md deleted file mode 100644 index ee6ac44c..00000000 --- a/frontend/apps/app-pc/README.md +++ /dev/null @@ -1,77 +0,0 @@ -# Flow Engine PC 端应用 - -Flow Engine 的 PC 端流程管理应用。 - -## 简介 - -`app-pc` 是 Flow Engine 的 PC 端 Web 应用,提供完整的流程管理功能。 - -### 核心依赖 - -- `@flow-engine/flow-design` - 流程设计器组件库 -- `@flow-engine/flow-core` - 核心 API 库 -- `@flow-engine/flow-types` - TypeScript 类型定义 -- `antd` - Ant Design 组件库 -- `react-router` + `react-router-dom` - 路由管理 - -## Setup - -安装依赖: - -```bash -pnpm install -``` - -## 开发 - -启动开发服务器,应用将在 [http://localhost:3000](http://localhost:3000) 访问。 - -```bash -pnpm run dev -``` - -## 构建 - -构建生产版本: - -```bash -pnpm run build -``` - -预览生产构建: - -```bash -pnpm run preview -``` - -## 核心功能 - -### 流程设计 - -- 可视化流程设计器 -- 15 种节点类型支持 -- 节点配置面板 -- 表单设计 -- 高级设置 - -### 流程管理 - -- 流程定义管理 -- 流程实例管理 -- 待办/已办列表 -- 流程历史记录 - -### 流程操作 - -- 通过/拒绝审批 -- 保存草稿 -- 加签/委派 -- 退回/转办 -- 流程撤回 - -## Learn more - -- [Rsbuild documentation](https://rsbuild.rs) - Rsbuild 特性和 API -- [Rspack documentation](https://rspack.rs) - 底层打包工具 -- [Flow Engine Docs](https://github.com/codingapi/flow-engine) - 完整文档 -- [AGENTS.md](./AGENTS.md) - 开发指南 diff --git a/frontend/apps/app-pc/package.json b/frontend/apps/app-pc/package.json deleted file mode 100644 index 71c6c2bf..00000000 --- a/frontend/apps/app-pc/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "@flow-example/app-pc", - "version": "1.0.0", - "private": true, - "type": "module", - "scripts": { - "build": "rsbuild build", - "dev": "rsbuild dev --open", - "preview": "rsbuild preview" - }, - "dependencies": { - "@flow-engine/flow-core": "workspace:*", - "@flow-engine/flow-types": "workspace:*", - "@flow-engine/flow-pc-design": "workspace:*", - "@flow-engine/flow-pc-ui": "workspace:*", - "@flow-engine/flow-pc-approval":"workspace:*", - "antd": "^6.2.1", - "dayjs": "^1.11.19", - "react": "^18.3.1", - "react-dom": "^18.3.1", - "react-router": "^7.13.0", - "react-router-dom": "^7.13.0" - }, - "devDependencies": { - "@flow-engine/flow-core": "workspace:*", - "@flow-engine/flow-types": "workspace:*", - "@flow-engine/flow-pc-design": "workspace:*" - } -} diff --git a/frontend/apps/app-pc/public/favicon.png b/frontend/apps/app-pc/public/favicon.png deleted file mode 100644 index af06119f..00000000 Binary files a/frontend/apps/app-pc/public/favicon.png and /dev/null differ diff --git a/frontend/apps/app-pc/rsbuild.config.ts b/frontend/apps/app-pc/rsbuild.config.ts deleted file mode 100644 index 3bec6ff5..00000000 --- a/frontend/apps/app-pc/rsbuild.config.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { defineConfig } from '@rsbuild/core'; -import { pluginReact } from '@rsbuild/plugin-react'; -import { pluginLess } from '@rsbuild/plugin-less'; -import { pluginSass } from '@rsbuild/plugin-sass'; -import * as path from "path"; - -// Docs: https://rsbuild.rs/config/ -export default defineConfig({ - plugins: [pluginReact(), pluginLess(), pluginSass()], - resolve: { - alias: { - "@/": path.resolve(__dirname, "src"), - } - }, - - source: { - entry: { - index: ['./src/index.tsx'], - }, - - /** - * support inversify @injectable() and @inject decorators - */ - decorators: { - version: 'legacy', - }, - }, - server: { - proxy: { - '/api': 'http://127.0.0.1:8090', - '/open': 'http://127.0.0.1:8090', - '/user': 'http://127.0.0.1:8090', - } - }, - tools: { - rspack: { - /** - * ignore warnings from @coze-design-editor/design-editor/language-typescript - */ - ignoreWarnings: [/Critical dependency: the request of a dependency is an expression/], - // 添加 node 配置来模拟 __filename 和 __dirname - node: { - __filename: false, - __dirname: false, - global: true, - }, - }, - }, -}); diff --git a/frontend/apps/app-pc/src/api/index.ts b/frontend/apps/app-pc/src/api/index.ts deleted file mode 100644 index 8d65b389..00000000 --- a/frontend/apps/app-pc/src/api/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -import {HttpClient} from "@flow-engine/flow-core"; -import { message } from "antd"; - -export const httpClient = new HttpClient(10000,{ - success:(msg:string)=>{ - message.success(msg) - }, - error:(msg:string)=>{ - console.log(msg); - message.error(msg) - } -}) \ No newline at end of file diff --git a/frontend/apps/app-pc/src/api/login.ts b/frontend/apps/app-pc/src/api/login.ts deleted file mode 100644 index 8c08ea8c..00000000 --- a/frontend/apps/app-pc/src/api/login.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { httpClient } from "." - -export const login = (body:any) =>{ - return httpClient.post('/user/login',body); -} \ No newline at end of file diff --git a/frontend/apps/app-pc/src/api/record.ts b/frontend/apps/app-pc/src/api/record.ts deleted file mode 100644 index 1af11fa6..00000000 --- a/frontend/apps/app-pc/src/api/record.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { httpClient } from "." - -export const list = (request: any) => { - return httpClient.page('/api/query/record/list', request, {}, {}, []); -} - -export const todo = (request: any) => { - return httpClient.page('/api/query/record/todo', request, {}, {}, []); -} - -export const done = (request: any) => { - return httpClient.page('/api/query/record/done', request, {}, {}, []); -} - -export const notify = (request: any) => { - return httpClient.page('/api/query/record/notify', request, {}, {}, []); -} \ No newline at end of file diff --git a/frontend/apps/app-pc/src/api/user.ts b/frontend/apps/app-pc/src/api/user.ts deleted file mode 100644 index 77b25f79..00000000 --- a/frontend/apps/app-pc/src/api/user.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { httpClient } from "." - -export const list = (request: any) => { - return httpClient.page('/api/user/list', request, {}, {}, []); -} - -export const remove = (id:string) => { - return httpClient.post('/api/user/remove',{id}); -} - -export const save = (body:any) => { - return httpClient.post('/api/user/save',body); -} \ No newline at end of file diff --git a/frontend/apps/app-pc/src/config/routers.tsx b/frontend/apps/app-pc/src/config/routers.tsx deleted file mode 100644 index 17b481ce..00000000 --- a/frontend/apps/app-pc/src/config/routers.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import {createHashRouter} from "react-router"; -import LoginPage from "@/pages/login"; -import HomePage from "@/pages/home"; -import DesignPage from "@/pages/desgin"; -import TodoPage from "@/pages/todo"; -import UserPage from "@/pages/user.tsx"; - - -export const routers = [ - { - path:'/login', - element:, - name:'登陆界面', - }, - { - path:'/user', - element:, - name: '用户管理' - }, - { - path:'/design', - element:, - name: '流程设计' - }, - { - path:'/todo', - element:, - name: '待办中心' - }, - { - path:'/', - element:, - name: '系统主页' - } -] - - -export const hashRouters = createHashRouter(routers); \ No newline at end of file diff --git a/frontend/apps/app-pc/src/env.d.ts b/frontend/apps/app-pc/src/env.d.ts deleted file mode 100644 index 698ba8bb..00000000 --- a/frontend/apps/app-pc/src/env.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -/** - * Imports the SVG file as a React component. - * @requires [@rsbuild/plugin-svgr](https://npmjs.com/package/@rsbuild/plugin-svgr) - */ -declare module '*.svg?react' { - import type React from 'react'; - const ReactComponent: React.FunctionComponent>; - export default ReactComponent; -} diff --git a/frontend/apps/app-pc/src/index.css b/frontend/apps/app-pc/src/index.css deleted file mode 100644 index 43634ff1..00000000 --- a/frontend/apps/app-pc/src/index.css +++ /dev/null @@ -1,4 +0,0 @@ -body { - padding: 0 !important; - border: 0 !important; -} diff --git a/frontend/apps/app-pc/src/index.tsx b/frontend/apps/app-pc/src/index.tsx deleted file mode 100644 index b3a719ca..00000000 --- a/frontend/apps/app-pc/src/index.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom/client'; -import {RouterProvider} from 'react-router'; -import {hashRouters} from './config/routers'; -import {ConfigProvider} from "antd"; -import zhCN from 'antd/locale/zh_CN'; -import dayjs from 'dayjs'; -import 'dayjs/locale/zh-cn'; -import "./index.css"; - -dayjs.locale('zh'); - -const rootEl = document.getElementById('root'); -if (rootEl) { - const root = ReactDOM.createRoot(rootEl); - root.render( - - - - - , - ); -} diff --git a/frontend/apps/app-pc/src/pages/desgin.tsx b/frontend/apps/app-pc/src/pages/desgin.tsx deleted file mode 100644 index 447bdd96..00000000 --- a/frontend/apps/app-pc/src/pages/desgin.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import React from "react"; -import {DesignList} from '@flow-engine/flow-pc-design'; - - -const DesignPage = () => { - - return ( -
- -
- ) -} - -export default DesignPage; \ No newline at end of file diff --git a/frontend/apps/app-pc/src/pages/home.tsx b/frontend/apps/app-pc/src/pages/home.tsx deleted file mode 100644 index f8fd3d2e..00000000 --- a/frontend/apps/app-pc/src/pages/home.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import React from "react"; -import { useNavigate } from "react-router"; -import { Button, Flex, Space } from "antd"; -import {routers} from "@/config/routers.tsx"; - -const HomePage: React.FC = () => { - - const navigate = useNavigate(); - - const routerButtons = routers.filter(item=>item.path!=='/'); - - return ( -
-

Flow-Engine Home Page

- - {routerButtons.map((item)=>{ - return ( - - ) - })} - -
- ) -} - -export default HomePage; \ No newline at end of file diff --git a/frontend/apps/app-pc/src/pages/login.tsx b/frontend/apps/app-pc/src/pages/login.tsx deleted file mode 100644 index 798fdc50..00000000 --- a/frontend/apps/app-pc/src/pages/login.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import { login } from "@/api/login"; -import { Button, Flex, Form, Input, message } from "antd"; -import React from "react"; -import { useNavigate } from "react-router"; - -const LoginPage: React.FC = () => { - - const navigate = useNavigate(); - - const [form] = Form.useForm(); - - return ( - -
-

Login Page

-
{ - login(body).then(res => { - if (res.success) { - const token = res.data.token; - localStorage.setItem('token', token); - message.success('login success'); - navigate('/'); - }else{ - message.error(res.errMessage); - } - }) - }}> - - - - - - -
- - - -
-
- ) -} - -export default LoginPage; \ No newline at end of file diff --git a/frontend/apps/app-pc/src/pages/todo.tsx b/frontend/apps/app-pc/src/pages/todo.tsx deleted file mode 100644 index b3d47239..00000000 --- a/frontend/apps/app-pc/src/pages/todo.tsx +++ /dev/null @@ -1,235 +0,0 @@ -import React from "react"; -import {done, list, notify, todo} from "@/api/record.ts"; -import {WorkflowSelectModal} from "@flow-engine/flow-pc-design"; -import {Table, type TableProps} from "@flow-engine/flow-pc-ui"; -import {Button, Space, Tabs, type TabsProps} from "antd"; -import dayjs from "dayjs"; -import {ApprovalPanelDrawer,FlowTitle} from "@flow-engine/flow-pc-approval"; -import type { ActionType } from "@flow-engine/flow-core"; - -const TodoPage: React.FC = () => { - - const actionAll = React.useRef(null); - const actionTodo = React.useRef(null); - const actionDone = React.useRef(null); - const actionNotify = React.useRef(null); - - const [selectVisible, setSelectVisible] = React.useState(false); - const [approvalVisible, setApprovalVisible] = React.useState(false); - const [reviewVisible, setReviewVisible] = React.useState(false); - const [workflowCode, setWorkflowCode] = React.useState(''); - const [currentRecordId, setCurrentRecordId] = React.useState(''); - const [currentTab, setCurrentTab] = React.useState('todo'); - - const columns: TableProps['columns'] = [ - { - dataIndex: 'recordId', - title: '编号', - }, - { - dataIndex: 'processId', - title: '流程编码', - }, - { - dataIndex: 'title', - title: '流程名称', - render:(value)=>{ - return - } - }, - { - dataIndex: 'readTime', - title: '读取状态', - render: (value) => { - return value ? '已读' : '未读'; - } - }, - { - dataIndex: 'nodeName', - title: '节点名称', - }, - { - dataIndex: 'createTime', - title: '创建时间', - render: (text) => { - return dayjs(text).format('YYYY-MM-DD HH:mm:ss'); - } - }, - { - dataIndex: 'currentOperatorId', - title: '审批人', - hidden: true, - }, - { - dataIndex: 'currentOperatorName', - title: '审批人', - }, - { - dataIndex: 'recordState', - title: '状态', - render: (text) => { - return text ? '已办' : '待办'; - } - }, - { - dataIndex: 'option', - title: '操作', - render: (_, record) => { - if(currentTab==='todo'){ - return ( - - { - setCurrentRecordId(record.recordId); - setReviewVisible(false); - setApprovalVisible(true); - }} - >办理 - - ) - }else { - return ( - - { - setCurrentRecordId(record.recordId); - setReviewVisible(true); - setApprovalVisible(true); - }} - >详情 - - ) - } - - } - } - ]; - - const items: TabsProps['items'] = [ - { - key: 'todo', - label: '我的待办', - children: ( - { - return todo(request); - }} - /> - ) - }, - { - key: 'done', - label: '我的已办', - children: ( -
{ - return done(request); - }} - /> - ) - }, - { - key: 'notify', - label: '我的抄送', - children: ( -
{ - return notify(request); - }} - /> - ) - }, - { - key: 'all', - label: '全部流程', - children: ( -
{ - return list(request); - }} - /> - ) - }, - ]; - - const reloadCurrentTab = () => { - if (currentTab === 'all') { - actionAll.current?.reload(); - } - if (currentTab === 'done') { - actionDone.current?.reload(); - } - if (currentTab === 'todo') { - actionTodo.current?.reload(); - } - if (currentTab === 'notify') { - actionNotify.current?.reload(); - } - } - - React.useEffect(() => { - reloadCurrentTab(); - },[currentTab]); - - return ( -
- { - setCurrentTab(currentKey); - }} - tabBarExtraContent={{ - right: ( - - ) - }} - /> - - { - setWorkflowCode(code); - setSelectVisible(false); - setApprovalVisible(true); - }} - onClose={() => { - setSelectVisible(false); - }} - /> - - { - setApprovalVisible(false); - reloadCurrentTab(); - }} - /> -
- ) -} - -export default TodoPage; \ No newline at end of file diff --git a/frontend/apps/app-pc/src/pages/user.tsx b/frontend/apps/app-pc/src/pages/user.tsx deleted file mode 100644 index 21221184..00000000 --- a/frontend/apps/app-pc/src/pages/user.tsx +++ /dev/null @@ -1,182 +0,0 @@ -import React from "react"; -import {type ActionType, Table, type TableProps} from "@flow-engine/flow-pc-ui"; -import {Button, Form, Input, message, Modal, Popconfirm, Space, Switch} from "antd"; -import {list, remove, save} from "@/api/user.ts"; - -const UserPage = () => { - const actionType = React.useRef(null); - const [visible, setVisible] = React.useState(false); - const [form] = Form.useForm(); - - const columns: TableProps['columns'] = [ - { - dataIndex: 'id', - title: '编号', - }, - { - dataIndex: 'name', - title: '姓名', - }, - { - dataIndex: 'account', - title: '账户', - }, - { - dataIndex: 'flowManager', - title: '角色', - render: (value, record) => { - return value ? '流程管理员' : '普通用户' - } - }, - { - dataIndex: 'flowOperatorId', - title: '流程委托人', - render: (value, record) => { - if (!value) { - return '无' - } - return value - } - }, - { - dataIndex: 'option', - title: '操作', - render: (value, record) => { - return ( - - { - form.setFieldsValue({ - ...record, - password: '' - }); - setVisible(true); - }}>编辑 - {record.account !== 'admin' && ( - { - remove(record.id).then(() => { - message.success("用户已删除"); - actionType.current?.reload(); - }) - }} - > - 删除 - - )} - - ) - } - } - ]; - - return ( -
-
{ - return [ - - ] - }} - columns={columns} - request={(request) => { - return list(request); - }} - /> - - { - setVisible(false); - }} - onOk={() => { - form.submit(); - }} - > -
{ - save(values).then(() => { - message.success("用户已保存"); - actionType.current?.reload(); - setVisible(false); - }) - }} - > - - - - - - - - - - - - - - - - - - - - - - - -
- - ) -} - -export default UserPage; \ No newline at end of file diff --git a/frontend/apps/app-pc/tsconfig.json b/frontend/apps/app-pc/tsconfig.json deleted file mode 100644 index 8af95354..00000000 --- a/frontend/apps/app-pc/tsconfig.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "compilerOptions": { - "lib": ["DOM", "ES2020"], - "jsx": "react-jsx", - "target": "ES2020", - "noEmit": true, - "skipLibCheck": true, - "useDefineForClassFields": true, - - /* modules */ - "module": "ESNext", - "moduleDetection": "force", - "moduleResolution": "bundler", - "verbatimModuleSyntax": true, - "resolveJsonModule": true, - "allowImportingTsExtensions": true, - "noUncheckedSideEffectImports": true, - - /* type checking */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "baseUrl": ".", - "paths": { - "@/*": ["src/*"] - } - }, - "include": ["src"] -} diff --git a/frontend/package.json b/frontend/package.json deleted file mode 100644 index 1e80a4e0..00000000 --- a/frontend/package.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "name": "@flow-engine/root", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "build:flow-core": "pnpm -F @flow-engine/flow-core build", - "build:flow-types": "pnpm -F @flow-engine/flow-types build", - "build:flow-pc-design": "pnpm -F @flow-engine/flow-pc-design build", - "build:flow-pc-form": "pnpm -F @flow-engine/flow-pc-form build", - "build:flow-pc-ui": "pnpm -F @flow-engine/flow-pc-ui build", - "build:flow-pc-approval": "pnpm -F @flow-engine/flow-pc-approval build", - "build:flow-pc": "pnpm run build:flow-pc-ui && pnpm run build:flow-pc-form && pnpm run build:flow-pc-approval && pnpm run build:flow-pc-design", - "build": "pnpm run build:flow-core && pnpm run build:flow-types && pnpm run build:flow-pc ", - "build:app-pc": "pnpm -F @flow-example/app-pc build", - "build:app-mobile": "pnpm -F @flow-example/app-mobile build", - "dev:app-pc": "pnpm -F @flow-example/app-pc dev", - "dev:app-mobile": "pnpm -F @flow-example/app-mobile dev", - "watch:flow-core": "pnpm -F @flow-engine/flow-core dev", - "watch:flow-types": "pnpm -F @flow-engine/flow-types dev", - "watch:flow-pc-design": "pnpm -F @flow-engine/flow-pc-design dev", - "watch:flow-pc-form": "pnpm -F @flow-engine/flow-pc-form dev", - "watch:flow-pc-ui": "pnpm -F @flow-engine/flow-pc-ui dev", - "watch:flow-pc-approval": "pnpm -F @flow-engine/flow-pc-approval dev", - "test:flow-core": "pnpm -F @flow-engine/flow-core test", - "test:flow-pc-approval": "pnpm -F @flow-engine/flow-pc-approval test", - "test:flow-pc-design": "pnpm -F @flow-engine/flow-pc-design test", - "test:flow-pc-form": "pnpm -F @flow-engine/flow-pc-form test", - "test:flow-pc-ui": "pnpm -F @flow-engine/flow-pc-ui test", - "test": "pnpm run test:flow-core && pnpm run test:flow-pc-approval && pnpm run test:flow-pc-design && pnpm run test:flow-pc-form && pnpm run test:flow-pc-ui", - "clean": "pnpm cleaninstall-node " - }, - "keywords": [], - "author": "", - "license": "ISC", - "packageManager": "pnpm@10.27.0", - "devDependencies": { - "@rsbuild/core": "^1.7.2", - "@rsbuild/plugin-less": "^1.6.0", - "@rsbuild/plugin-react": "^1.4.2", - "@rsbuild/plugin-sass": "^1.5.0", - "@rslib/core": "^0.19.3", - "@rstest/core": "^0.8.1", - "@testing-library/jest-dom": "^6.8.0", - "@testing-library/react": "^16.3.0", - "@types/node": "^25.0.10", - "@types/react": "^18.3.18", - "@types/react-dom": "^18.3.5", - "cleaninstall-node": "^2.2.3", - "jsdom": "^26.1.0", - "typescript": "^5.9.3" - } -} diff --git a/frontend/packages/flow-core/.gitignore b/frontend/packages/flow-core/.gitignore deleted file mode 100644 index b538abcd..00000000 --- a/frontend/packages/flow-core/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -# Local -.DS_Store -*.local -*.log* - -# Dist -node_modules -dist/ -storybook-static - -# IDE -.vscode/* -!.vscode/extensions.json -.idea diff --git a/frontend/packages/flow-core/AGENTS.md b/frontend/packages/flow-core/AGENTS.md deleted file mode 100644 index 3dd7b9c2..00000000 --- a/frontend/packages/flow-core/AGENTS.md +++ /dev/null @@ -1,14 +0,0 @@ -# AGENTS.md - -You are an expert in JavaScript, Rspack, Rsbuild, Rslib, and library development. You write maintainable, performant, and accessible code. - -## Commands - -- `pnpm run build` - Build the library for production -- `pnpm run dev` - Turn on watch mode, watch for changes and rebuild the library - -## Docs - -- Rslib: https://rslib.rs/llms.txt -- Rsbuild: https://rsbuild.rs/llms.txt -- Rspack: https://rspack.rs/llms.txt diff --git a/frontend/packages/flow-core/README.md b/frontend/packages/flow-core/README.md deleted file mode 100644 index d9e70d30..00000000 --- a/frontend/packages/flow-core/README.md +++ /dev/null @@ -1,131 +0,0 @@ -# @flow-engine/flow-core - -Flow Engine 前端核心框架库,提供 HTTP 客户端、Hooks、Presenter 等基础能力(不包含 UI 组件)。 - -## 简介 - -`flow-core` 是 Flow Engine 的核心框架库,提供与 UI 无关的基础能力: - -- HTTP 客户端封装(基于 axios) -- React Hooks 工具 -- Presenter 模式实现 -- 通用工具函数 -- 全局状态管理 - -### 依赖关系 - -- **依赖**: 无 - -## Setup - -安装依赖: - -```bash -pnpm install -``` - -## 开发 - -构建库: - -```bash -pnpm run build -``` - -监听模式构建: - -```bash -pnpm run dev -``` - -## 核心功能 - -### HTTP 客户端 - -基于 axios 封装的 HTTP 客户端,提供: - -- 请求拦截器/响应拦截器 -- 统一的错误处理 -- 类型安全的请求/响应 -- 请求取消支持 - -```typescript -import { httpClient } from '@flow-engine/flow-core'; - -// GET 请求 -const workflow = await httpClient.get('/api/workflows/1'); - -// POST 请求 -const result = await httpClient.post('/api/workflows', workflowData); -``` - -### React Hooks - -提供常用的业务 Hooks: - -- `useWorkflow` - 工作流相关操作 -- `useFlowRecord` - 流程记录相关操作 -- `useApproval` - 审批相关操作 -- 自定义 Hooks 工具 - -### Presenter 模式 - -实现业务逻辑与 UI 分离的 Presenter 模式: - -```typescript -import { Presenter } from '@flow-engine/flow-core'; - -class WorkflowPresenter extends Presenter { - async loadWorkflow(id: string): Promise { - // 加载工作流 - } - - async saveWorkflow(workflow: Workflow): Promise { - // 保存工作流 - } -} -``` - -### 工具函数 - -提供通用工具函数: - -- 日期格式化 -- 字符串处理 -- 对象深拷贝 -- 类型判断 - -## 模块结构 - -``` -flow-core/ -├── src/ -│ ├── http/ # HTTP 客户端 -│ ├── hooks/ # React Hooks -│ ├── presenter/ # Presenter 基类 -│ ├── utils/ # 工具函数 -│ └── types/ # 基础类型定义 -└── README.md -``` - -## 使用示例 - -```typescript -import { httpClient, useWorkflow, WorkflowPresenter } from '@flow-engine/flow-core'; - -// 使用 HTTP 客户端 -const workflows = await httpClient.get('/api/workflows'); - -// 使用 Hooks -const { data, loading, error } = useWorkflow('wf-001'); - -// 使用 Presenter -const presenter = new WorkflowPresenter(); -await presenter.loadWorkflow('wf-001'); -``` - -## Learn more - -- [Rslib documentation](https://lib.rsbuild.io/) - Rslib 特性和 API -- [Flow Engine Docs](https://github.com/codingapi/flow-engine) - 完整文档 -- [CLAUDE.md](../../CLAUDE.md) - 开发指南 diff --git a/frontend/packages/flow-core/package.json b/frontend/packages/flow-core/package.json deleted file mode 100644 index 640b35a3..00000000 --- a/frontend/packages/flow-core/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "@flow-engine/flow-core", - "version": "1.0.0", - "type": "module", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.js" - } - }, - "types": "./dist/index.d.ts", - "files": [ - "dist" - ], - "scripts": { - "build": "rslib build", - "dev": "rslib build --watch", - "test": "rstest" - }, - "peerDependencies": { - "react": ">=18", - "react-dom": ">=18" - }, - "dependencies": { - "axios": "^1.13.5", - "react": "^18.3.1", - "react-dom": "^18.3.1" - } -} diff --git a/frontend/packages/flow-core/rslib.config.ts b/frontend/packages/flow-core/rslib.config.ts deleted file mode 100644 index 8ad6bbe8..00000000 --- a/frontend/packages/flow-core/rslib.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { pluginReact } from '@rsbuild/plugin-react'; -import { defineConfig } from '@rslib/core'; -import * as path from 'node:path'; - -export default defineConfig({ - source: { - entry: { - index: './src/**', - }, - }, - resolve: { - alias: { - "@/": path.resolve(__dirname, "src"), - } - }, - lib: [ - { - bundle: false, - dts: true, - format: 'esm', - }, - ], - output: { - target: 'web', - }, - plugins: [pluginReact()], -}); diff --git a/frontend/packages/flow-core/rstest.config.ts b/frontend/packages/flow-core/rstest.config.ts deleted file mode 100644 index 9057a186..00000000 --- a/frontend/packages/flow-core/rstest.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import {pluginReact} from '@rsbuild/plugin-react'; -import {defineConfig} from '@rstest/core'; -import {pluginSass} from "@rsbuild/plugin-sass"; -import * as path from "path"; - -export default defineConfig({ - testEnvironment: 'jsdom', - setupFiles: ['./rstest.setup.ts'], - plugins: [pluginReact(), pluginSass()], - resolve: { - alias: { - "@/": path.resolve(__dirname, "src"), - } - } -}); diff --git a/frontend/packages/flow-core/rstest.setup.ts b/frontend/packages/flow-core/rstest.setup.ts deleted file mode 100644 index 32b38ae2..00000000 --- a/frontend/packages/flow-core/rstest.setup.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { expect } from '@rstest/core'; -import * as jestDomMatchers from '@testing-library/jest-dom/matchers'; - -expect.extend(jestDomMatchers); diff --git a/frontend/packages/flow-core/src/base64.ts b/frontend/packages/flow-core/src/base64.ts deleted file mode 100644 index 21862d82..00000000 --- a/frontend/packages/flow-core/src/base64.ts +++ /dev/null @@ -1,25 +0,0 @@ -export class Base64Utils{ - - public static base64ToBlob = (base64: string, type: string) => { - const binStr = atob(base64.split(',')[1]); - const len = binStr.length; - const arr = new Uint8Array(len); - for (let i = 0; i < len; i++) { - arr[i] = binStr.charCodeAt(i); - } - return new Blob([arr], {type: type}); - } - - public static base64ToString = (base64: string) => { - if (base64.indexOf('base64') !== -1) { - base64 = base64.split(',')[1]; - } - return atob(base64); - } - - - public static stringToBase64 = (str: string) => { - return btoa(str); - } - -} \ No newline at end of file diff --git a/frontend/packages/flow-core/src/dispatch.ts b/frontend/packages/flow-core/src/dispatch.ts deleted file mode 100644 index 4800032a..00000000 --- a/frontend/packages/flow-core/src/dispatch.ts +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Dispatch对象,对应React的useState的dispatch函数能力 - */ -export type Dispatch = (updater: ((prevState: T) => T) | T) => void; \ No newline at end of file diff --git a/frontend/packages/flow-core/src/event.ts b/frontend/packages/flow-core/src/event.ts deleted file mode 100644 index 974b44fb..00000000 --- a/frontend/packages/flow-core/src/event.ts +++ /dev/null @@ -1,56 +0,0 @@ -export class EventBus { - private static instance: EventBus; - private events: Map; - - private constructor() { - this.events = new Map(); - } - - public static getInstance(): EventBus { - if (!this.instance) { - this.instance = new EventBus(); - } - return this.instance; - } - - public on(eventName: string, callback: Function): void { - const callbacks = this.events.get(eventName) || []; - callbacks.push(callback); - this.events.set(eventName, callbacks); - } - - public emit(eventName: string, ...args: any[]): void { - const callbacks = this.events.get(eventName); - if (callbacks) { - callbacks.forEach((callback) => { - try { - callback(...args); - } catch (err) { - console.error( - `Error executing callback for event: ${eventName}`, - err - ); - } - }); - } - } - - public off(eventName: string, callback?: Function): void { - if (callback) { - const callbacks = this.events.get(eventName); - if (callbacks) { - const callbackIndex = callbacks.indexOf(callback); - if (callbackIndex > -1) { - callbacks.splice(callbackIndex, 1); - if (callbacks.length === 0) { - this.events.delete(eventName); - } else { - this.events.set(eventName, callbacks); - } - } - } - } else { - this.events.delete(eventName); - } - } -} \ No newline at end of file diff --git a/frontend/packages/flow-core/src/groovy.ts b/frontend/packages/flow-core/src/groovy.ts deleted file mode 100644 index b823e008..00000000 --- a/frontend/packages/flow-core/src/groovy.ts +++ /dev/null @@ -1,459 +0,0 @@ -/** 自定义脚本标记 */ -export const CUSTOM_SCRIPT = '@CUSTOM_SCRIPT'; - -/** 脚本标题标记 */ -export const SCRIPT_TITLE = '@SCRIPT_TITLE'; - - -/** 脚本元数据标记 */ -export const SCRIPT_META = '@SCRIPT_META'; - - -/** - * Groovy脚本格式化器 - */ -export class GroovyFormatter { - /** - * 格式化Groovy脚本内容 - * @param script Groovy脚本内容 - * @returns 格式化后的脚本 - */ - static formatScript(script: string): string { - if (!script || script.trim().length === 0) { - return ''; - } - - let formatted = script; - - // 1. 基础trim处理 - formatted = formatted.trim(); - - // 2. 统一换行符为\n - formatted = formatted.replace(/\r\n/g, '\n').replace(/\r/g, '\n'); - - // 3. 去除多余空行(保留单个空行) - formatted = formatted.replace(/\n\s*\n/g, '\n\n'); - - // 4. 去除行尾空白 - const lines = formatted.split('\n'); - formatted = lines - .map(line => line.replace(/\s+$/, '')) - .join('\n'); - - // 5. 移除末尾多余的换行符 - formatted = formatted.replace(/\n+$/, '\n'); - - // 6. 缩进规范化 - formatted = this.normalizeIndentation(formatted); - - return formatted; - } - - /** - * 规范化缩进 - */ - private static normalizeIndentation(script: string): string { - const lines = script.split('\n'); - const result: string[] = []; - let indentLevel = 0; - let inMultilineString = false; - let multilineStringDelimiter = ''; - - for (let i = 0; i < lines.length; i++) { - let line = lines[i]; - const trimmedLine = line.trim(); - - // 跳过空行但保留空行 - if (trimmedLine.length === 0) { - result.push(''); - continue; - } - - // 处理多行字符串(Groovy支持'''和""") - if (!inMultilineString) { - if (trimmedLine.includes("'''") || trimmedLine.includes('"""')) { - const delimiter = trimmedLine.includes("'''") ? "'''" : '"""'; - const count = (trimmedLine.match(new RegExp(delimiter, 'g')) || []).length; - - if (count % 2 === 1) { - inMultilineString = true; - multilineStringDelimiter = delimiter; - } - } - } else { - // 检查多行字符串结束 - if (trimmedLine.includes(multilineStringDelimiter)) { - const count = (trimmedLine.match(new RegExp(multilineStringDelimiter, 'g')) || []).length; - if (count % 2 === 1) { - inMultilineString = false; - multilineStringDelimiter = ''; - } - } - } - - // 如果不是在多行字符串内,进行缩进调整 - if (!inMultilineString) { - // 减少缩进的条件 - const shouldDecreaseIndent = this.shouldDecreaseIndent(trimmedLine); - if (shouldDecreaseIndent) { - indentLevel = Math.max(0, indentLevel - 1); - } - - // 添加当前行的缩进 - const indentation = ' '.repeat(indentLevel); - - // 增加缩进的条件 - if (this.shouldIncreaseIndent(trimmedLine)) { - indentLevel++; - } - - result.push(indentation + trimmedLine); - } else { - // 在多行字符串内,保持原样但保留基础缩进 - result.push(line); - } - } - - return result.join('\n'); - } - - /** - * 判断是否需要增加缩进 - */ - private static shouldIncreaseIndent(line: string): boolean { - // Groovy中需要增加缩进的语法结构 - const increasePatterns = [ - /.*\{\s*$/, // 代码块开始 { - /.*\(\s*$/, // 方法参数开始 ( - /.*\[\s*$/, // 列表/映射开始 [ - /^if\s*\(.*\)\s*$/, // if语句 - /^for\s*\(.*\)\s*$/, // for循环 - /^while\s*\(.*\)\s*$/, // while循环 - /^switch\s*\(.*\)\s*$/, // switch语句 - /^try\s*$/, // try语句 - /^catch\s*\(.*\)\s*$/, // catch语句 - /^finally\s*$/, // finally语句 - /^else\s*$/, // else语句 - /^else\s+if\s*\(.*\)\s*$/, // else if语句 - /.*->\s*$/, // Groovy闭包 - /^def\s+\w+\s*=\s*\{/, // 定义闭包 - /^class\s+\w+/, // 类定义 - /^interface\s+\w+/, // 接口定义 - /^enum\s+\w+/, // 枚举定义 - /^annotation\s+\w+/, // 注解定义 - /^trait\s+\w+/, // trait定义 - /^static\s*\{/, // 静态初始化块 - ]; - - return increasePatterns.some(pattern => pattern.test(line)); - } - - /** - * 判断是否需要减少缩进 - */ - private static shouldDecreaseIndent(line: string): boolean { - // Groovy中需要减少缩进的语法结构 - const decreasePatterns = [ - /^\}/, // 闭包结束 } - /^\]/, // 列表/映射结束 ] - /^\)/, // 参数结束 ) - /^else\b/, // else语句(如果else在新行) - /^catch\b/, // catch语句 - /^finally\b/, // finally语句 - /^case\b/, // case语句 - /^default\s*:/, // default语句 - ]; - - return decreasePatterns.some(pattern => pattern.test(line)); - } - - /** - * 增强版格式化:包含更多Groovy特定处理 - */ - static formatGroovyScript(script: string, options?: FormatOptions): string { - if (!script || script.trim().length === 0) { - return ''; - } - - const opts = { - indentSize: 4, - addSpacesAroundOperators: true, - formatComments: true, - ...options - }; - - let formatted = script; - - // 1. 基础清理 - formatted = formatted.trim(); - formatted = formatted.replace(/\r\n/g, '\n').replace(/\r/g, '\n'); - - // 2. 格式化注释 - if (opts.formatComments) { - formatted = this.formatComments(formatted); - } - - // 3. 操作符周围添加空格 - if (opts.addSpacesAroundOperators) { - formatted = this.addSpacesAroundOperators(formatted); - } - - // 4. 逗号和分号后添加空格 - formatted = formatted.replace(/,(?!\s)/g, ', '); - formatted = formatted.replace(/;(?!\s)/g, '; '); - - // 5. 去除多余空格 - formatted = formatted.replace(/\s+/g, ' '); - - // 6. 还原必要的换行 - const lines = formatted.split(';'); - if (lines.length > 1) { - formatted = lines - .map(line => line.trim()) - .filter(line => line.length > 0) - .join(';\n'); - } - - // 7. 应用缩进规范化 - formatted = this.normalizeIndentation(formatted); - - // 8. 特殊处理Groovy特定的语法 - formatted = this.formatGroovySpecific(formatted); - - return formatted; - } - - /** - * 格式化注释 - */ - private static formatComments(script: string): string { - // 处理单行注释 - let formatted = script.replace(/\/\/\s*/g, '// '); - - // 处理多行注释 - formatted = formatted.replace(/\/\*(\s*)\*\//g, '/**$1*/'); - - return formatted; - } - - /** - * 操作符周围添加空格 - */ - private static addSpacesAroundOperators(script: string): string { - // 操作符列表 - const operators = [ - '=', '==', '!=', '===', '!==', - '>', '<', '>=', '<=', - '+', '-', '*', '/', '%', - '&&', '||', '&', '|', '^', - '<<', '>>', '>>>', - '+=', '-=', '*=', '/=', '%=', '&=', '|=', '^=', '<<=', '>>=', '>>>=' - ]; - - let formatted = script; - - // 为每个操作符添加空格(避免在字符串内操作) - operators.forEach(op => { - // 使用正则表达式,确保不在字符串内 - const regex = new RegExp(`(?/g, '{ $2 ->'); - - // 3. 格式化列表和映射 - formatted = formatted.replace(/\[(\s*)(\w+)(\s*):/g, '[$2:'); - - // 4. 格式化注解 - formatted = formatted.replace(/@(\w+)\((\s*)(\w+)(\s*)=/g, '@$1($3='); - - // 5. 格式化安全导航操作符 - formatted = formatted.replace(/(\w+)(\s*)\?\.(\s*)(\w+)/g, '$1?.$4'); - - // 6. 格式化展开操作符 - formatted = formatted.replace(/(\w+)(\s*)\*\.(\s*)(\w+)/g, '$1*.$4'); - - return formatted; - } - - /** - * 压缩脚本(移除所有非必要空白) - */ - static minifyScript(script: string): string { - if (!script || script.trim().length === 0) { - return ''; - } - - let minified = script; - - // 移除注释 - minified = minified.replace(/\/\/.*$/gm, ''); - minified = minified.replace(/\/\*[\s\S]*?\*\//g, ''); - - // 移除多余空白 - minified = minified.replace(/\s+/g, ' '); - - // 移除不必要的空格 - minified = minified.replace(/\s*([{}();,=+\-*/%&|<>!])\s*/g, '$1'); - - // 移除空行 - minified = minified.replace(/\n\s*\n/g, '\n'); - - return minified.trim(); - } -} - -/** - * 格式化选项接口 - */ -export interface FormatOptions { - indentSize?: number; // 缩进大小(空格数) - addSpacesAroundOperators?: boolean; // 操作符周围添加空格 - formatComments?: boolean; // 格式化注释 - maxLineLength?: number; // 最大行长度 - preserveEmptyLines?: boolean; // 保留空行 -} - - - -/** - * Groovy脚本转换器工具类,提供一些通用的脚本处理方法 - */ -export class GroovyScriptConvertorUtil { - - /** - * 判断脚本是否包含自定义注释标记 - * @param script - */ - public static isCustomScript(script: string): boolean { - return script.includes(CUSTOM_SCRIPT); - } - - - /** - * 格式化脚本内容,去除多余空白等 - * @param script - */ - public static formatScript(script: string): string { - // 这里可以添加一些格式化逻辑,比如统一换行、缩进等 - return GroovyFormatter.formatScript(script); - } - - - /** - * 将普通脚本转换为包含自定义注释标记的脚本 - * @param script - */ - public static toCustomScript(script: string): string { - if (GroovyScriptConvertorUtil.isCustomScript(script)) { - return GroovyFormatter.formatScript(script); - } - return GroovyFormatter.formatScript(`// ${CUSTOM_SCRIPT}\n${script}`); - } - - - /** - * 获取脚本中的标题注释内容 - * @param script - */ - public static getScriptTitle(script: string): string { - const titleMatch = script.match(new RegExp(`//\\s*${SCRIPT_TITLE}\\s*(.+)`)); - if (titleMatch) { - return titleMatch[1].trim(); - } - return ''; - } - - /** - * 更新脚本中的标题注释内容,如果不存在则添加 - * @param script - * @param title - */ - public static updateScriptTitle(script: string, title: string): string { - const titleComment = `// ${SCRIPT_TITLE} ${title}`; - if (GroovyScriptConvertorUtil.getScriptTitle(script)) { - return script.replace(new RegExp(`//\\s*${SCRIPT_TITLE}\\s*.+`), titleComment); - } else { - return `${titleComment}\n${script}`; - } - } - - - /** - * 获取脚本中的元数据 - * @param script - */ - public static getScriptMeta(script: string): string { - const titleMatch = script.match(new RegExp(`//\\s*${SCRIPT_META}\\s*(.+)`)); - if (titleMatch) { - return titleMatch[1].trim(); - } - return ''; - } - - - /** - * 更新脚本中的元数据内容,如果不存在则添加 - * @param script - * @param meta - */ - public static updateScriptMeta(script: string, meta: string): string { - const metaComment = `// ${SCRIPT_META} ${meta}`; - if (GroovyScriptConvertorUtil.getScriptMeta(script)) { - return script.replace(new RegExp(`//\\s*${SCRIPT_META}\\s*.+`), metaComment); - } else { - return `${metaComment}\n${script}`; - } - } - - - /** - * 清除脚本中的注释 - * @param script - */ - public static clearComments(script: string): string { - return script.replace(/\/\/.*$/gm, '').trim(); - } - - /** - * 提取脚本中的return表达式 - * @param script - */ - public static getReturnScript(script: string): string { - try { - let result = GroovyScriptConvertorUtil.clearComments(script); - const funcMatch = result.match(/def\s+run\s*\([^)]*\)\s*\{([\s\S]*)\}/); - if (funcMatch) { - result = funcMatch[1]; - } - const returnMatch = result.match(/return\s+(.+?);?\s*$/m); - if (returnMatch) { - result = returnMatch[1].trim(); - } else { - // 如果没有找到return语句,可能整个脚本就是表达式 - result = result.trim(); - } - - return result; - } catch (e) { - return ''; - } - } - -} \ No newline at end of file diff --git a/frontend/packages/flow-core/src/hooks.ts b/frontend/packages/flow-core/src/hooks.ts deleted file mode 100644 index a99e93c5..00000000 --- a/frontend/packages/flow-core/src/hooks.ts +++ /dev/null @@ -1,27 +0,0 @@ -import React from "react"; -import {BasePresenter, PresenterConstructor} from "@/presenter.ts"; - -export class PresenterHooks { - - public static create

,S,M>(PresenterClass:PresenterConstructor, - initStata:S, - model:M){ - const [state, dispatch] = React.useState(initStata); - - const ref = React.useRef

(null); - - if (!ref.current) { - ref.current = new PresenterClass(state, dispatch, model); - } - - React.useEffect(() => { - ref.current?.syncState(state); - }, [state]); - - return { - state, - presenter: ref.current - } - } - -} \ No newline at end of file diff --git a/frontend/packages/flow-core/src/http.ts b/frontend/packages/flow-core/src/http.ts deleted file mode 100644 index 261aa977..00000000 --- a/frontend/packages/flow-core/src/http.ts +++ /dev/null @@ -1,233 +0,0 @@ -import axios, {AxiosInstance} from "axios"; -import {sleep} from "./sleep"; -import {Base64Utils} from "./base64"; - -export interface MessageBox { - success: (msg: string) => void; - error: (msg: string) => void; -} - -export type Response = { - success: boolean; - errCode?: string; - errMessage?: string; - data?: any; - total?: number; -} - -export class HttpClient { - private readonly api: AxiosInstance; - private readonly messageBox: MessageBox; - - constructor(timeout: number, messageBox: MessageBox, baseUrl = '') { - this.messageBox = messageBox; - this.api = axios.create({ - timeout: timeout, - baseURL: baseUrl, - headers: { - "Content-Type": "application/json", - }, - }); - - this.addRequestInterceptors(); - this.addResponseInterceptors(); - } - - private addRequestInterceptors() { - this.api.interceptors.request.use((config: any) => { - const token = localStorage.getItem("token"); - if (token) { - config.headers = { - Authorization: `${token}`, - } as any; - } - return config; - }, (error: any) => { - return Promise.reject(error); - }); - } - - private addResponseInterceptors() { - this.api.interceptors.response.use(async (response: any) => { - const headers = response.headers; - const token = headers['authorization']; - - const state = response.status; - if (state === 200) { - if (token) { - console.log('reset token', token); - localStorage.setItem("token", token) - } - - if (response.data) { - const success = response.data.success; - if (!success) { - const errMessage = response.data.errMessage; - const errCode = response.data.errCode; - if ("token.expire" === errCode || "token.error" === errCode) { - this.messageBox.error('登录已过期,请退出再重新打开'); - await sleep(1500); - localStorage.clear(); - window.location.href = '/#login'; - } else { - if ("login.error" === errCode) { - return response; - } - this.messageBox.error(errMessage) - } - } - } else { - this.messageBox.error('抱歉,该账户无权限访问'); - } - } - return response; - }, - (error: any) => { - const response = error.response; - const state = response.data.status; - - if (state === 403) { - this.messageBox.error('抱歉,该账户无权限访问'); - return { - data: { - success: false, - } - } - } - return Promise.reject(error); - } - ) - } - - public get = async (url: string, params?: any): Promise => { - try { - const response = await this.api.get(url, { - params - }); - return response.data as Response; - } catch (err:any) { - return { - success: false, - errMessage:err.message, - errCode:'http.error' - } - } - } - - public put = async (url: string, data: any): Promise => { - try { - const response = await this.api.put(url, data); - return response.data as Response; - } catch (err:any) { - return { - success: false, - errMessage:err.message, - errCode:'http.error' - } - } - } - - public delete = async (url: string, params?: any): Promise => { - try { - const response = await this.api.delete(url, { - params - }); - return response.data as Response; - } catch (err:any) { - return { - success: false, - errMessage:err.message, - errCode:'http.error' - } - } - } - - public post = async (url: string, data: any): Promise => { - try { - const response = await this.api.post(url, data); - return response.data as Response; - } catch (err:any) { - return { - success: false, - errMessage:err.message, - errCode:'http.error' - } - } - } - - - public page = async (url: string, params: any, sort: any, filter: any, match: { - key: string, - type: string - }[]): Promise => { - const base64Match = Base64Utils.stringToBase64(JSON.stringify(match)); - const base64Sort = Base64Utils.stringToBase64(JSON.stringify(sort)); - const base64Filter = Base64Utils.stringToBase64(JSON.stringify(filter)); - - const response = await this.get(url, { - ...params, - sort: base64Sort, - filter: base64Filter, - params: base64Match, - }); - - if (response.success) { - const list = response.data.total > 0 ? response.data.list : []; - return { - data: list, - success: response.success, - total: response.data.total - }; - } else { - return { - data: [], - success: response.success, - total: 0 - } - } - } - - - public download = async (url: string, filename?: string) => { - try { - const token = localStorage.getItem("token"); - const response = await axios.get(url, { - responseType: 'blob', - headers: { - 'Authorization': token, - } - }); - const bytes = await response.data; - const blob = new Blob([bytes]); - const downloadUrl = window.URL.createObjectURL(blob); - const a = document.createElement('a'); - a.href = downloadUrl; - a.download = filename || 'result.csv'; - a.click(); - } catch (e) { - console.log(e); - } - } - - public postDownload = async (url: string, data: any, filename?: string) => { - try { - const token = localStorage.getItem("token"); - const response = await axios.post(url, data, { - responseType: 'blob', - headers: { - 'Authorization': token, - } - }); - const bytes = await response.data; - const blob = new Blob([bytes]); - const downloadUrl = window.URL.createObjectURL(blob); - const a = document.createElement('a'); - a.href = downloadUrl; - a.download = filename || 'result.csv'; - a.click(); - } catch (e) { - console.log(e); - } - } - -} \ No newline at end of file diff --git a/frontend/packages/flow-core/src/index.ts b/frontend/packages/flow-core/src/index.ts deleted file mode 100644 index fd629ef4..00000000 --- a/frontend/packages/flow-core/src/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export * from "./base64"; -export * from "./dispatch"; -export * from "./http"; -export * from "./presenter"; -export * from "./hooks.ts"; -export * from "./object.ts"; -export * from "./table.ts"; -export * from "./view-plugin.ts"; -export * from "./groovy.ts"; -export * from "./event.ts"; \ No newline at end of file diff --git a/frontend/packages/flow-core/src/object.ts b/frontend/packages/flow-core/src/object.ts deleted file mode 100644 index 7013adc9..00000000 --- a/frontend/packages/flow-core/src/object.ts +++ /dev/null @@ -1,61 +0,0 @@ -export class ObjectUtils { - - public static isEmptyObject(obj: any) { - return Object.keys(obj).length === 0 && obj.constructor === Object; - } - - public static isEqual(obj1: any, obj2: any): boolean { - return JSON.stringify(obj1) === JSON.stringify(obj2); - } - - public static cleanObject(obj: any, options = { - removeNull: true, - removeUndefined: true, - removeEmptyString: true, - removeEmptyArray: true, - removeEmptyObject: true, - }) { - const { - removeNull, - removeUndefined, - removeEmptyString, - removeEmptyArray, - removeEmptyObject, - } = options; - - let newObj: any = {}; - - for (const [key, value] of Object.entries(obj)) { - // 跳过 null - if (removeNull && value === null) continue; - - // 跳过 undefined - if (removeUndefined && value === undefined) continue; - - // 跳过空字符串 - if (removeEmptyString && value === '') continue; - - // 跳过空数组 - if (removeEmptyArray && Array.isArray(value) && value.length === 0) continue; - - // 跳过空对象 - if (removeEmptyObject && - value && - typeof value === 'object' && - !Array.isArray(value) && - Object.keys(value).length === 0) continue; - - // 递归处理嵌套对象 - if (value && typeof value === 'object' && !Array.isArray(value)) { - const cleaned = ObjectUtils.cleanObject(value, options); - // 只有当清理后的对象不为空时才保留 - if (Object.keys(cleaned).length > 0) { - newObj[key] = cleaned; - } - } else { - newObj[key] = value; - } - } - return newObj; - } -} \ No newline at end of file diff --git a/frontend/packages/flow-core/src/presenter.ts b/frontend/packages/flow-core/src/presenter.ts deleted file mode 100644 index 80215202..00000000 --- a/frontend/packages/flow-core/src/presenter.ts +++ /dev/null @@ -1,22 +0,0 @@ -import {Dispatch} from "@/dispatch.ts"; - -export class BasePresenter { - - protected state:S; - protected readonly dispatch:Dispatch; - protected readonly model:M; - - public constructor(state:S, dispatch:Dispatch,model:M){ - this.state = state; - this.dispatch = dispatch; - this.model = model; - } - - public syncState(state:S){ - this.state = state; - } -} - -export type PresenterConstructor

, S, M> = { - new(state: S, dispatch: Dispatch, model: M): P; -}; diff --git a/frontend/packages/flow-core/src/sleep.ts b/frontend/packages/flow-core/src/sleep.ts deleted file mode 100644 index 67d15ea1..00000000 --- a/frontend/packages/flow-core/src/sleep.ts +++ /dev/null @@ -1,7 +0,0 @@ -export const sleep = async (time: number) => { - return new Promise((resolve:any) => { - setTimeout(() => { - resolve(); - }, time); - }) -} \ No newline at end of file diff --git a/frontend/packages/flow-core/src/table.ts b/frontend/packages/flow-core/src/table.ts deleted file mode 100644 index 50626a39..00000000 --- a/frontend/packages/flow-core/src/table.ts +++ /dev/null @@ -1,15 +0,0 @@ -export interface Result { - data:T[] - total: number; - success: boolean -} - -export interface ActionType { - reload(): void; -} - -export interface ParamRequest { - current: number; - pageSize: number; - [key: string]: any; -} \ No newline at end of file diff --git a/frontend/packages/flow-core/src/view-plugin.ts b/frontend/packages/flow-core/src/view-plugin.ts deleted file mode 100644 index 6f9a3393..00000000 --- a/frontend/packages/flow-core/src/view-plugin.ts +++ /dev/null @@ -1,28 +0,0 @@ -import React from "react"; - -/** - * 视图绑定插件,提供视图组件注册和获取功能 - */ -export class ViewBindPlugin { - - private readonly cache:Map>; - - private static readonly instance:ViewBindPlugin = new ViewBindPlugin(); - - private constructor(){ - this.cache = new Map(); - } - - public static getInstance(){ - return this.instance; - } - - public register(name:string,view:React.ComponentType){ - this.cache.set(name,view); - } - - public get(name:string){ - return this.cache.get(name); - } - -} \ No newline at end of file diff --git a/frontend/packages/flow-core/tests/groovy.test.ts b/frontend/packages/flow-core/tests/groovy.test.ts deleted file mode 100644 index 30505833..00000000 --- a/frontend/packages/flow-core/tests/groovy.test.ts +++ /dev/null @@ -1,113 +0,0 @@ -import {describe, expect, it} from '@rstest/core'; -import {GroovyScriptConvertorUtil} from "@/groovy"; - -describe('GroovyScriptUtil', () => { - - describe('getReturnScript1', () => { - it('get groovy script return data', () => { - const script = ` -// @CUSTOM_SCRIPT -def run(request){ - return "你有一条" + request.getOperatorName() + "的" + request.getWorkflowTitle() + "待办消息 【" + request.getNodeName() + "】" -}` - const result = GroovyScriptConvertorUtil.getReturnScript(script) - expect(result).toEqual(`"你有一条" + request.getOperatorName() + "的" + request.getWorkflowTitle() + "待办消息 【" + request.getNodeName() + "】"`); - }); - }); - - describe('getReturnScript2', () => { - it('get groovy script return data', () => { - const script = ` -def run(request){ - return [request.getCreateOperator(),request.getCurrentOperator()] -}` - const result = GroovyScriptConvertorUtil.getReturnScript(script) - expect(result).toEqual(`[request.getCreateOperator(),request.getCurrentOperator()]`); - }); - }); - - - describe('getScriptTitle', () => { - it('get groovy script display title', () => { - const script = ` -// @SCRIPT_TITLE 这是一个实例的标题 -def run(request){ - return "你有一条" + request.getOperatorName() + "的" + request.getWorkflowTitle() + "待办消息 【" + request.getNodeName() + "】" -}` - const result = GroovyScriptConvertorUtil.getScriptTitle(script) - expect(result).toEqual(`这是一个实例的标题`); - }); - }); - - describe('updateScriptTitle', () => { - it('update groovy script display title', () => { - const script = ` -// @SCRIPT_TITLE 这是一个实例的标题 -def run(request){ - return "你有一条" + request.getOperatorName() + "的" + request.getWorkflowTitle() + "待办消息 【" + request.getNodeName() + "】" -}` - const result = GroovyScriptConvertorUtil.updateScriptTitle(script,'这就是一个实例的标题'); - console.log(result); - const title = GroovyScriptConvertorUtil.getScriptTitle(result) - expect(title).toEqual(`这就是一个实例的标题`); - }); - }); - - - describe('getScriptMeta1', () => { - it('get groovy script meta', () => { - const script = ` -// @SCRIPT_TITLE 这是一个实例的标题 -// @SCRIPT_META {name:"name"} -def run(request){ - return "你有一条" + request.getOperatorName() + "的" + request.getWorkflowTitle() + "待办消息 【" + request.getNodeName() + "】" -}` - const result = GroovyScriptConvertorUtil.getScriptMeta(script) - expect(result).toEqual(`{name:"name"}`); - }); - }); - - describe('getScriptMeta2', () => { - it('get groovy script meta', () => { - const script = ` -// @CUSTOM_SCRIPT 自定义脚本,返回的数据为动作类型 -// @SCRIPT_META {"trigger":"PASS"} -def run(request){ - return 'SAVE'; -}` - const result = GroovyScriptConvertorUtil.getScriptMeta(script) - expect(result).toEqual(`{"trigger":"PASS"}`); - }); - }); - - - describe('updateScriptMeta1', () => { - it('update groovy script meta', () => { - const script = ` -// @SCRIPT_TITLE 这是一个实例的标题 -// @SCRIPT_META {name:"name"} -def run(request){ - return "你有一条" + request.getOperatorName() + "的" + request.getWorkflowTitle() + "待办消息 【" + request.getNodeName() + "】" -}` - const result = GroovyScriptConvertorUtil.updateScriptMeta(script,'{name:"test"}'); - console.log(result); - const title = GroovyScriptConvertorUtil.getScriptMeta(result) - expect(title).toEqual(`{name:"test"}`); - }); - }); - - describe('updateScriptMeta2', () => { - it('update groovy script meta', () => { - const script = ` -// @CUSTOM_SCRIPT 自定义脚本,返回的数据为动作类型 -// @SCRIPT_META {"trigger":"PASS"} -def run(request){ - return 'SAVE'; -}` - const result = GroovyScriptConvertorUtil.updateScriptMeta(script,'{trigger:"SAVE"}'); - console.log(result); - const title = GroovyScriptConvertorUtil.getScriptMeta(result) - expect(title).toEqual(`{trigger:"SAVE"}`); - }); - }); -}); \ No newline at end of file diff --git a/frontend/packages/flow-core/tests/test.d.ts b/frontend/packages/flow-core/tests/test.d.ts deleted file mode 100644 index e48dee96..00000000 --- a/frontend/packages/flow-core/tests/test.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/frontend/packages/flow-core/tests/tsconfig.json b/frontend/packages/flow-core/tests/tsconfig.json deleted file mode 100644 index 5eac80a2..00000000 --- a/frontend/packages/flow-core/tests/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../tsconfig.json", - "include": [".", "../rstest.setup.ts"], - "compilerOptions": { - "baseUrl": ".", - "paths": { - "@/*": ["../src/*"] - } - } -} diff --git a/frontend/packages/flow-core/tsconfig.json b/frontend/packages/flow-core/tsconfig.json deleted file mode 100644 index 130b702a..00000000 --- a/frontend/packages/flow-core/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "lib": ["DOM", "ES2022"], - "module": "ESNext", - "noEmit": true, - "strict": true, - "skipLibCheck": true, - "isolatedModules": true, - "resolveJsonModule": true, - "moduleResolution": "bundler", - "useDefineForClassFields": true, - "allowImportingTsExtensions": true, - "baseUrl": ".", - "paths": { - "@/*": ["src/*"] - } - }, - "include": ["src"] -} diff --git a/frontend/packages/flow-pc/flow-pc-approval/.gitignore b/frontend/packages/flow-pc/flow-pc-approval/.gitignore deleted file mode 100644 index 6f3092c3..00000000 --- a/frontend/packages/flow-pc/flow-pc-approval/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -# Local -.DS_Store -*.local -*.log* - -# Dist -node_modules -dist/ - -# Profile -.rspack-profile-*/ - -# IDE -.vscode/* -!.vscode/extensions.json -.idea diff --git a/frontend/packages/flow-pc/flow-pc-approval/AGENTS.md b/frontend/packages/flow-pc/flow-pc-approval/AGENTS.md deleted file mode 100644 index 992bc6fa..00000000 --- a/frontend/packages/flow-pc/flow-pc-approval/AGENTS.md +++ /dev/null @@ -1,23 +0,0 @@ -# AGENTS.md - -You are an expert in JavaScript, Rsbuild, and web application development. You write maintainable, performant, and accessible code. - -## Commands - -- `pnpm run dev` - Start the dev server -- `pnpm run build` - Build the app for production -- `pnpm run preview` - Preview the production build locally - -## Docs - -- Rsbuild: https://rsbuild.rs/llms.txt -- Rspack: https://rspack.rs/llms.txt - -- Rstest: https://rstest.rs/llms.txt - -## Tools - -### Rstest - -- Run `pnpm run test` to run tests -- Run `pnpm run test:watch` to run tests in watch mode diff --git a/frontend/packages/flow-pc/flow-pc-approval/README.md b/frontend/packages/flow-pc/flow-pc-approval/README.md deleted file mode 100644 index f3f11922..00000000 --- a/frontend/packages/flow-pc/flow-pc-approval/README.md +++ /dev/null @@ -1,261 +0,0 @@ -# @flow-engine/flow-pc-approval - -Flow Engine PC 端审批组件库,提供待办/已办/审批处理等功能。 - -## 简介 - -`flow-pc-approval` 是 Flow Engine PC 端的审批页面组件库,提供: - -- 待办列表(我的待办) -- 已办列表(我的已办) -- 我发起的(我的申请) -- 审批处理(审批操作) -- 流程详情查看 -- 审批记录展示 - -### 依赖关系 - -- **依赖**: `@flow-engine/flow-pc-design`, `@flow-engine/flow-pc-ui` - -## Setup - -安装依赖: - -```bash -pnpm install -``` - -## 开发 - -构建组件库: - -```bash -pnpm run build -``` - -监听模式构建: - -```bash -pnpm run dev -``` - -## 核心功能 - -### 待办列表 - -我的待办任务列表: - -- 任务筛选(按状态、类型、时间等) -- 任务搜索 -- 批量操作 -- 分页加载 - -```typescript -import { TodoList } from '@flow-engine/flow-pc-approval'; - - -``` - -### 已办列表 - -我的已办任务列表: - -- 历史记录查询 -- 筛选和搜索 -- 查看审批详情 - -```typescript -import { DoneList } from '@flow-engine/flow-pc-approval'; - - -``` - -### 我发起的 - -我发起的流程列表: - -- 流程状态查看 -- 流程跟踪 -- 撤回/取消操作 - -```typescript -import { MyRequestsList } from '@flow-engine/flow-pc-approval'; - - -``` - -### 审批处理 - -审批操作组件: - -- 表单展示(只读/编辑) -- 审批意见填写 -- 审批操作(通过/拒绝/保存/转交/退回/委托) -- 附件上传 - -```typescript -import { ApprovalForm } from '@flow-engine/flow-pc-approval'; - - -``` - -### 流程详情 - -流程详情查看: - -- 流程基本信息 -- 节点状态展示 -- 审批记录时间轴 -- 表单数据展示 - -```typescript -import { FlowDetail } from '@flow-engine/flow-pc-approval'; - - -``` - -### 审批记录 - -审批记录展示: - -- 时间轴展示 -- 审批人信息 -- 审批意见 -- 审批时间 -- 操作记录 - -```typescript -import { ApprovalTimeline } from '@flow-engine/flow-pc-approval'; - - -``` - -## 模块结构 - -``` -flow-pc-approval/ -├── src/ -│ ├── todo/ # 待办列表 -│ ├── done/ # 已办列表 -│ ├── my-requests/ # 我发起的 -│ ├── approval-form/ # 审批表单 -│ ├── flow-detail/ # 流程详情 -│ ├── timeline/ # 审批记录时间轴 -│ ├── components/ # 公共组件 -│ └── index.ts # 统一导出 -└── README.md -``` - -## 使用示例 - -### 待办页面 - -```typescript -import { TodoList, ApprovalModal } from '@flow-engine/flow-pc-approval'; - -const TodoPage = () => { - const [selectedTask, setSelectedTask] = useState(null); - const [showApprovalModal, setShowApprovalModal] = useState(false); - - const handleTaskClick = async (task) => { - setSelectedTask(task); - setShowApprovalModal(true); - }; - - return ( - <> - - {showApprovalModal && ( - setShowApprovalModal(false)} - onApproved={handleRefresh} - /> - )} - - ); -}; -``` - -### 审批操作 - -```typescript -import { ApprovalForm } from '@flow-engine/flow-pc-approval'; - -const MyApprovalForm = () => { - const handleSubmit = async (action, opinion) => { - await approvalApi.submit({ - taskId, - action, - opinion, - formData - }); - }; - - return ( - handleSubmit('PASS', opinion)} - onReject={(opinion) => handleSubmit('REJECT', opinion)} - onSave={(data) => handleSubmit('SAVE', data)} - onTransfer={(userId) => handleSubmit('TRANSFER', { userId })} - onReturn={(nodeId) => handleSubmit('RETURN', { nodeId })} - onDelegate={(userId) => handleSubmit('DELEGATE', { userId })} - /> - ); -}; -``` - -## 审批动作 - -支持以下审批动作: - -- `PASS` - 通过 -- `REJECT` - 拒绝 -- `SAVE` - 保存 -- `ADD_AUDIT` - 加签 -- `DELEGATE` - 委托 -- `RETURN` - 退回 -- `TRANSFER` - 转交 -- `CUSTOM` - 自定义动作 - -## Learn more - -- [Rslib documentation](https://lib.rsbuild.io/) - Rslib 特性和 API -- [Flow Engine Docs](https://github.com/codingapi/flow-engine) - 完整文档 -- [CLAUDE.md](../../../CLAUDE.md) - 开发指南 diff --git a/frontend/packages/flow-pc/flow-pc-approval/package.json b/frontend/packages/flow-pc/flow-pc-approval/package.json deleted file mode 100644 index f9892a2c..00000000 --- a/frontend/packages/flow-pc/flow-pc-approval/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "@flow-engine/flow-pc-approval", - "version": "1.0.0", - "private": true, - "type": "module", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.js" - } - }, - "types": "./dist/index.d.ts", - "files": [ - "dist" - ], - "scripts": { - "build": "rslib build", - "dev": "rslib build --watch", - "test": "rstest" - }, - "peerDependencies": { - "react": ">=18", - "react-dom": ">=18" - }, - "dependencies": { - "@ant-design/icons": "~6.1.0", - "@flow-engine/flow-core": "workspace:*", - "@flow-engine/flow-types": "workspace:*", - "@flow-engine/flow-pc-design": "workspace:*", - "@flow-engine/flow-pc-ui": "workspace:*", - "@flow-engine/flow-pc-form": "workspace:*", - "@reduxjs/toolkit": "^2.11.2", - "antd": "^6.2.1", - "dayjs": "^1.11.19", - "immer": "^11.1.3", - "react-redux": "^9.2.0" - }, - "devDependencies": { - "@flow-engine/flow-types": "workspace:*" - } -} diff --git a/frontend/packages/flow-pc/flow-pc-approval/public/favicon.png b/frontend/packages/flow-pc/flow-pc-approval/public/favicon.png deleted file mode 100644 index af06119f..00000000 Binary files a/frontend/packages/flow-pc/flow-pc-approval/public/favicon.png and /dev/null differ diff --git a/frontend/packages/flow-pc/flow-pc-approval/rslib.config.ts b/frontend/packages/flow-pc/flow-pc-approval/rslib.config.ts deleted file mode 100644 index 66f24187..00000000 --- a/frontend/packages/flow-pc/flow-pc-approval/rslib.config.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { pluginReact } from '@rsbuild/plugin-react'; -import { defineConfig } from '@rslib/core'; -import {pluginSass} from '@rsbuild/plugin-sass'; -import {pluginLess} from '@rsbuild/plugin-less'; -import * as path from 'node:path'; - -export default defineConfig({ - source: { - entry: { - index: './src/**', - }, - }, - resolve: { - alias: { - "@/": path.resolve(__dirname, "src"), - } - }, - lib: [ - { - bundle: false, - dts: true, - format: 'esm', - }, - ], - output: { - target: 'web', - }, - plugins: [pluginReact(),pluginSass(),pluginLess()], -}); diff --git a/frontend/packages/flow-pc/flow-pc-approval/rstest.config.ts b/frontend/packages/flow-pc/flow-pc-approval/rstest.config.ts deleted file mode 100644 index 9057a186..00000000 --- a/frontend/packages/flow-pc/flow-pc-approval/rstest.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import {pluginReact} from '@rsbuild/plugin-react'; -import {defineConfig} from '@rstest/core'; -import {pluginSass} from "@rsbuild/plugin-sass"; -import * as path from "path"; - -export default defineConfig({ - testEnvironment: 'jsdom', - setupFiles: ['./rstest.setup.ts'], - plugins: [pluginReact(), pluginSass()], - resolve: { - alias: { - "@/": path.resolve(__dirname, "src"), - } - } -}); diff --git a/frontend/packages/flow-pc/flow-pc-approval/rstest.setup.ts b/frontend/packages/flow-pc/flow-pc-approval/rstest.setup.ts deleted file mode 100644 index 32b38ae2..00000000 --- a/frontend/packages/flow-pc/flow-pc-approval/rstest.setup.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { expect } from '@rstest/core'; -import * as jestDomMatchers from '@testing-library/jest-dom/matchers'; - -expect.extend(jestDomMatchers); diff --git a/frontend/packages/flow-pc/flow-pc-approval/src/api/index.ts b/frontend/packages/flow-pc/flow-pc-approval/src/api/index.ts deleted file mode 100644 index 8d65b389..00000000 --- a/frontend/packages/flow-pc/flow-pc-approval/src/api/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -import {HttpClient} from "@flow-engine/flow-core"; -import { message } from "antd"; - -export const httpClient = new HttpClient(10000,{ - success:(msg:string)=>{ - message.success(msg) - }, - error:(msg:string)=>{ - console.log(msg); - message.error(msg) - } -}) \ No newline at end of file diff --git a/frontend/packages/flow-pc/flow-pc-approval/src/api/record.ts b/frontend/packages/flow-pc/flow-pc-approval/src/api/record.ts deleted file mode 100644 index 5504fa8a..00000000 --- a/frontend/packages/flow-pc/flow-pc-approval/src/api/record.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { httpClient } from "."; - -export const detail = (id:string) => { - return httpClient.get('/api/cmd/record/detail',{id}); -} - -export const processNodes = (body:any) => { - return httpClient.post('/api/cmd/record/processNodes',body); -} - -export const create = (body:any) => { - return httpClient.post('/api/cmd/record/create',body); -} - -export const action = (body:any) => { - return httpClient.post('/api/cmd/record/action',body); -} \ No newline at end of file diff --git a/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action-button.tsx b/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action-button.tsx deleted file mode 100644 index 6e10fe98..00000000 --- a/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action-button.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import {Button} from "antd"; -import React from "react"; -import {DisplayStyle, FlowActionDisplay} from "@flow-engine/flow-types"; -import {Icon} from "@flow-engine/flow-pc-ui"; - -interface ActionButtonProps { - onClick: () => void; - title: string; - display: FlowActionDisplay; -} - -export const ActionButton: React.FC = (props) => { - - const display = props.display; - const title = display.title || props.title; - - const style = React.useMemo(() => { - if (display) { - const data = JSON.parse(display.style) as DisplayStyle | undefined; - if (data) { - let style = {} - if (data.backgroundColor) { - style = Object.assign(data, {backgroundColor: `#${data.backgroundColor}`}); - } - if (data.borderColor) { - style = Object.assign(data, {borderColor: `#${data.borderColor}`}); - } - if (data.borderRadius) { - style = Object.assign(data, {borderRadius: Number.parseInt(data.borderRadius)}); - } - if (data.borderSize) { - style = Object.assign(data, {borderWidth: Number.parseInt(data.borderSize)}); - } - return style; - } - } - return {} - }, [display]); - - - return ( - - ) -} \ No newline at end of file diff --git a/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/add-audit.tsx b/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/add-audit.tsx deleted file mode 100644 index 3646d32b..00000000 --- a/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/add-audit.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import React from "react"; -import {FlowActionProps} from "./type"; -import {Form, message, Modal} from "antd"; -import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context"; -import {AddAuditView} from "@/plugins/view/add-audit-view"; -import {ActionButton} from "@/components/flow-approval/components/action-button"; - -/** - * 加签 - * @param props - * @constructor - */ -export const AddAuditAction: React.FC = (props) => { - - const action = props.action; - const {context} = useApprovalContext(); - const [form] = Form.useForm(); - - const actionPresenter = context.getPresenter().getFlowActionPresenter(); - - const [modalVisible, setModalVisible] = React.useState(false); - - const handleSubmit = (params?: any) => { - actionPresenter.action(action.id, params).then((res) => { - if (res.success) { - message.success("操作成功"); - setModalVisible(false); - context.close(); - } - }); - } - return ( - <> - { - form.resetFields(); - setModalVisible(true); - }} - title={action.title} - /> - - setModalVisible(false)} - onOk={() => { - form.submit(); - }} - > -
{ - handleSubmit(values); - }} - > - - - - -
- - ) -} \ No newline at end of file diff --git a/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/custom.tsx b/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/custom.tsx deleted file mode 100644 index 79defc8c..00000000 --- a/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/custom.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import React from "react"; -import {FlowActionProps} from "./type"; -import {message} from "antd"; -import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context"; -import {GroovyScriptConvertorUtil} from "@flow-engine/flow-core"; -import {ActionFactory} from "@/components/flow-approval/components/action/factory"; -import {ActionButton} from "@/components/flow-approval/components/action-button"; -import {ActionType} from "@flow-engine/flow-types"; - -/** - * 自定义 - * @param props - * @constructor - */ -export const CustomAction: React.FC = (props) => { - - const action = props.action; - const {context} = useApprovalContext() - const actionPresenter = context.getPresenter().getFlowActionPresenter(); - - const script = action.script || ''; - const returnData = GroovyScriptConvertorUtil.getReturnScript(script); - const triggerType = returnData.replaceAll('\'', ''); - - - const ActionView = ActionFactory.getInstance().render({ - ...props.action, - type: triggerType as ActionType, - }); - - if (ActionView) { - return ActionView - } - - return ( - { - actionPresenter.action(action.id).then((res) => { - if (res.success) { - message.success("操作成功"); - context.close(); - } - }); - }} - title={action.title} - /> - ) -} \ No newline at end of file diff --git a/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/delegate.tsx b/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/delegate.tsx deleted file mode 100644 index b20df469..00000000 --- a/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/delegate.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import React from "react"; -import {FlowActionProps} from "./type"; -import {Form, message, Modal} from "antd"; -import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context"; -import {DelegateView} from "@/plugins/view/delegate-view"; -import {ActionButton} from "@/components/flow-approval/components/action-button"; - -/** - * 委派 - * @param props - * @constructor - */ -export const DelegateAction: React.FC = (props) => { - - const action = props.action; - const {context} = useApprovalContext(); - const [form] = Form.useForm(); - - const actionPresenter = context.getPresenter().getFlowActionPresenter(); - - const [modalVisible, setModalVisible] = React.useState(false); - - const handleSubmit = (params?: any) => { - actionPresenter.action(action.id, params).then((res) => { - if (res.success) { - message.success("操作成功"); - setModalVisible(false); - context.close(); - } - }); - } - return ( - <> - { - form.resetFields(); - setModalVisible(true); - }} - title={action.title} - /> - - setModalVisible(false)} - onOk={() => { - form.submit(); - }} - > -
{ - handleSubmit(values); - }} - > - - - - -
- - ) -} \ No newline at end of file diff --git a/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/factory.tsx b/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/factory.tsx deleted file mode 100644 index 8145498b..00000000 --- a/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/factory.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import React from "react"; -import {FlowActionProps} from "./type"; -import {FlowAction} from "@flow-engine/flow-types"; -import {PassAction} from "@/components/flow-approval/components/action/pass"; -import {AddAuditAction} from "@/components/flow-approval/components/action/add-audit"; -import {CustomAction} from "@/components/flow-approval/components/action/custom"; -import {DelegateAction} from "@/components/flow-approval/components/action/delegate"; -import {RejectAction} from "@/components/flow-approval/components/action/reject"; -import {ReturnAction} from "@/components/flow-approval/components/action/return"; -import {SaveAction} from "@/components/flow-approval/components/action/save"; -import {TransferAction} from "@/components/flow-approval/components/action/transfer"; - -export class ActionFactory { - - private readonly cache: Map>; - - private constructor() { - this.cache = new Map(); - this.initActions(); - } - - private static readonly instance = new ActionFactory(); - - public static getInstance() { - return ActionFactory.instance; - } - - - private initActions() { - this.cache.set("ADD_AUDIT", AddAuditAction); - this.cache.set("CUSTOM", CustomAction); - this.cache.set("DELEGATE", DelegateAction); - this.cache.set("PASS", PassAction); - this.cache.set("REJECT", RejectAction); - this.cache.set("RETURN", ReturnAction); - this.cache.set("SAVE", SaveAction); - this.cache.set("TRANSFER", TransferAction); - - } - - public render(action: FlowAction) { - const FlowActionComponent = this.cache.get(action.type); - if (FlowActionComponent) { - return ( - - ) - } - } - -} \ No newline at end of file diff --git a/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/pass.tsx b/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/pass.tsx deleted file mode 100644 index 4cc3ffbc..00000000 --- a/frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/pass.tsx +++ /dev/null @@ -1,111 +0,0 @@ -import React from "react"; -import {FlowActionProps} from "./type"; -import {Form, Input, message, Modal} from "antd"; -import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context"; -import {SignKeyView} from "@/plugins/view/sign-key-view"; -import {ActionButton} from "@/components/flow-approval/components/action-button"; - -const {TextArea} = Input; - -/** - * 通过 - * @param props - * @constructor - */ -export const PassAction: React.FC = (props) => { - - const action = props.action; - const {state, context} = useApprovalContext() - const actionPresenter = context.getPresenter().getFlowActionPresenter(); - - const [modalVisible, setModalVisible] = React.useState(false); - - const isStartNode = state.flow?.nodeType === 'START'; - - const currentOperator = state.flow?.currentOperator; - - const [form] = Form.useForm(); - - const handleSubmit = (params?: any) => { - actionPresenter.action(action.id, params).then((res) => { - if (res.success) { - message.success("操作成功"); - setModalVisible(false); - context.close(); - } - }); - } - - const adviceRules = state.flow?.adviceRequired ? [ - { - required: state.flow?.adviceRequired || false, - message: '请输入审批意见' - } - ] : []; - - return ( - <> - { - if (isStartNode) { - handleSubmit(); - } else { - form.resetFields(); - setModalVisible(true); - } - }} - title={action.title} - /> - - setModalVisible(false)} - onOk={() => { - form.submit(); - }} - > -
{ - handleSubmit(values); - }} - > - - - -