├── .eslintignore ├── .eslintrc.json ├── .github └── workflows │ ├── algolia.yml │ ├── deploy.yml │ └── release-dist.yml ├── .gitignore ├── .npmrc ├── .prettierignore ├── .prettierrc.mjs ├── docs ├── .vitepress │ ├── algolia.ts │ ├── config.ts │ ├── link.ts │ ├── meta.ts │ ├── nav.ts │ ├── plugins │ │ ├── markdownTransform.ts │ │ └── pwa.ts │ ├── sidebar.ts │ ├── theme │ │ ├── components │ │ │ ├── Badge.vue │ │ │ ├── Contributors.vue │ │ │ ├── CopyRight.vue │ │ │ ├── DataPanel.vue │ │ │ ├── DemoContainer.vue │ │ │ ├── HomeContributors.vue │ │ │ ├── IndexInfo.vue │ │ │ ├── NavCard.vue │ │ │ ├── PageInfo.vue │ │ │ └── VideoLink.vue │ │ ├── index.ts │ │ ├── plugins │ │ │ ├── autoSidebarBeta.ts │ │ │ ├── baidutongji.ts │ │ │ └── googleAnalytics.ts │ │ ├── styles │ │ │ ├── demo.css │ │ │ ├── global.css │ │ │ ├── main.css │ │ │ ├── utils.css │ │ │ └── vars.css │ │ ├── types │ │ │ └── index.ts │ │ └── utils │ │ │ ├── date.ts │ │ │ ├── index.ts │ │ │ ├── md.ts │ │ │ └── pageInfo.ts │ └── types.ts ├── AI │ ├── AI生成模型模板.md │ ├── Prompts │ │ ├── index.md │ │ ├── model_with_relations.md │ │ ├── model_without_relations.md │ │ └── prompt工程师.md │ ├── Vscode编辑器使用插件快速开发模型.md │ ├── examples │ │ └── salesorder │ │ │ ├── chat-shot1.png │ │ │ ├── chatgpt-salesorder3.png │ │ │ ├── chatgpt-salesorder4.png │ │ │ └── salesorder.mod.json │ ├── index.md │ ├── sui │ │ ├── SUI ai提示词.md │ │ ├── index.md │ │ └── 简化.md │ ├── vscode_quick_dev │ │ ├── vscode_ad_hoc_prompt.png │ │ ├── vscode_create_new_model.png │ │ └── vscode_new_mode_file.png │ ├── 使用AI创建模型定义.md │ ├── 使用AI开发YAO应用.md │ └── 提示词.md ├── Admin-App │ ├── Amis │ │ ├── InputTable的数据更新.md │ │ ├── Select控件联动.md │ │ ├── amis fetcher的工作原理.md │ │ ├── amis与yao集成.md │ │ ├── amis关键字.md │ │ ├── dialog组件.md │ │ ├── font-awesome.md │ │ ├── index.md │ │ ├── js写入登录cookie.md │ │ ├── propsTransform.md │ │ ├── 事件动作中的reload.md │ │ ├── 使用amis需要注意的地方.md │ │ ├── 双层弹窗获取数据.md │ │ ├── 引用query参数.md │ │ ├── 弹出框的两种方式.md │ │ ├── 控件字段状态的几状方法.md │ │ ├── 文件分块上传.md │ │ ├── 样式修改.md │ │ ├── 组件事件刷新reload.md │ │ ├── 组件查找逻辑.md │ │ ├── 自定义事件检查.md │ │ ├── 表单控件列表.md │ │ ├── 表达式.md │ │ └── 适配yao的fetcher.md │ ├── amis-admin │ │ ├── images │ │ │ └── odata │ │ │ │ ├── 1.png │ │ │ │ ├── 10.png │ │ │ │ ├── 11.png │ │ │ │ ├── 2.png │ │ │ │ ├── 3.png │ │ │ │ ├── 4.png │ │ │ │ ├── 5.png │ │ │ │ ├── 6.png │ │ │ │ ├── 7.png │ │ │ │ ├── 8.png │ │ │ │ └── 9.png │ │ ├── index.md │ │ └── yao-odata-excel.md │ ├── amis-yao-admin.md │ ├── index.md │ ├── soybean-admin │ │ ├── index.md │ │ └── soybean-admin路由处理.md │ └── 教程 │ │ ├── 1项目介绍.md │ │ ├── 2项目安装.md │ │ ├── 3模型管理.md │ │ ├── 4数据维护.md │ │ ├── 5代码生成.md │ │ ├── 6页面编辑器.md │ │ ├── assets │ │ ├── amis_menu_tree_demo.png │ │ ├── editor-crud-01.png │ │ ├── editor-crud-02.png │ │ ├── editor-crud-03.png │ │ ├── model_api_list.png │ │ ├── model_columns_import.png │ │ ├── model_import.png │ │ ├── model_import_yao.png │ │ ├── model_interface.png │ │ ├── model_json_column_import.png │ │ ├── model_mantain.png │ │ ├── studio_code.png │ │ ├── table_maintain.png │ │ └── table_maintain2.png │ │ └── index.md ├── Studio │ ├── Yao Studio介绍.md │ ├── Yao-admin │ │ ├── index.md │ │ ├── yao-admin 根据数据库生成管理后台.md │ │ └── yao-admin 的前提条件.md │ ├── index.md │ ├── vscode调试yao.md │ ├── yao run 命令中的特殊字符.md │ ├── 如何修改管理员用户密码.md │ ├── 编辑器vscode智能提示.md │ └── 自动生成table_form定义文件.md ├── YaoDSL │ ├── AIGC │ │ ├── aigc处理器.md │ │ ├── chatgpt模型中角色的作用.md │ │ ├── index.md │ │ └── openai处理器.md │ ├── API │ │ ├── API Guard.md │ │ ├── API会话session保持.md │ │ ├── API引用上下文变量.md │ │ ├── API接口介绍.md │ │ ├── API预定义变量.md │ │ ├── index.md │ │ ├── service接口.md │ │ ├── session │ │ │ └── yao_session_flow中使用会话.jpg │ │ ├── stream api接口.md │ │ ├── stream http客户端请求.md │ │ ├── 刷新token.md │ │ ├── 定义YAO API.md │ │ ├── 文件上传下载接口.md │ │ ├── 自定义用户登陆login api.md │ │ ├── 超级用户权限.md │ │ └── 配置Redis保存会话.md │ ├── Connector │ │ ├── OpenAI连接器.md │ │ ├── index.md │ │ ├── mongo.md │ │ ├── redis.md │ │ ├── 数据库连接器.md │ │ └── 连接器.md │ ├── Flow │ │ ├── index.md │ │ ├── 数据流Flow.md │ │ ├── 流程控制.md │ │ └── 编写数据流.md │ ├── Model │ │ ├── index.md │ │ ├── sqlite与mysql的差异.md │ │ ├── 字段aes加密解密.md │ │ ├── 定义Yao模型.md │ │ ├── 数据处理与钩子.md │ │ ├── 数据模型介绍.md │ │ ├── 数据模型关联.md │ │ ├── 模型元数据管理.md │ │ ├── 模型删除数据.md │ │ ├── 模型新增数据.md │ │ └── 模型更新数据.md │ ├── Pipe │ │ ├── index.md │ │ └── pipe管道.md │ ├── Plan │ │ ├── index.md │ │ └── 计划组件.md │ ├── Plugin │ │ ├── golang grpc 插件模板.md │ │ ├── grpc插件.md │ │ ├── index.md │ │ └── 飞书自定义登录.md │ ├── Query │ │ ├── Flow Query绑定变量.md │ │ ├── Flow处理器与JSAPI区别.md │ │ ├── JSAPI.md │ │ ├── QueryDsl.md │ │ ├── QueryParam与QueryDSL.md │ │ ├── QueryParam语法.md │ │ ├── index.md │ │ ├── 在url中使用QueryParam.md │ │ ├── 复杂数据查询.md │ │ └── 查询数据.md │ ├── SUI │ │ ├── index.md │ │ ├── sui介绍.md │ │ ├── sui前端工具库.md │ │ ├── sui前端静态资源引用.md │ │ ├── sui多语言支持.md │ │ ├── sui局部渲染.md │ │ ├── sui指令.md │ │ ├── sui模板关联数据定义.md │ │ ├── sui模板语法.md │ │ ├── sui的命令工具.md │ │ ├── sui组件初始化的细节.md │ │ ├── sui组件化开发.md │ │ ├── sui组件的状态管理state.md │ │ ├── sui编译文件自动插入的内容.md │ │ ├── sui表达式.md │ │ ├── sui路由配置.md │ │ ├── sui项目中使用flowbite.md │ │ └── 使用builder创建sui页面.md │ ├── Store │ │ ├── index.md │ │ └── 使用缓存.md │ ├── Task │ │ ├── index.md │ │ ├── 异步任务.md │ │ └── 计划任务.md │ ├── Widget │ │ ├── index.md │ │ ├── 自定义Widget.md │ │ └── 自定义Widget升级版.md │ ├── Xgen │ │ ├── 0.10.2与0.10.3差异.md │ │ ├── Chart │ │ │ ├── Chart钩子函数.md │ │ │ ├── index.md │ │ │ ├── 分析图表.md │ │ │ └── 图表类型.md │ │ ├── Dashboard │ │ │ ├── Dashboard钩子函数.md │ │ │ └── index.md │ │ ├── Form │ │ │ ├── AI智能表单.md │ │ │ ├── Form使用技巧.md │ │ │ ├── Form单据参考创建.md │ │ │ ├── Form里嵌套List.md │ │ │ ├── Form里嵌套Table.md │ │ │ ├── Form钩子函数.md │ │ │ ├── images │ │ │ │ └── xgen-form-list.png │ │ │ ├── index.md │ │ │ └── table_in_form.png │ │ ├── Hook参数说明.md │ │ ├── List │ │ │ ├── List钩子函数.md │ │ │ └── index.md │ │ ├── Neo │ │ │ ├── index.md │ │ │ └── neo嵌入业务指令.md │ │ ├── Table │ │ │ ├── Table 钩子函数.md │ │ │ ├── TableA跳转到FormB.md │ │ │ ├── Table_Form禁用Action.md │ │ │ ├── Table上使用Tab.md │ │ │ ├── Table中设置字段只读.md │ │ │ ├── Table使用技巧.md │ │ │ ├── Table增加查看,编辑,删除按钮.md │ │ │ ├── Table搜索默认值.md │ │ │ ├── Table最小化配置.md │ │ │ ├── Table界面上增加创建按钮.md │ │ │ ├── index.md │ │ │ └── 数据表格.md │ │ ├── Xgen多语言支持.md │ │ ├── Xgen控件 │ │ │ ├── IFrame控件.md │ │ │ ├── RichText富文本控件 │ │ │ │ ├── EdJsParser.js │ │ │ │ ├── index.md │ │ │ │ └── 使用富文本控件.md │ │ │ ├── Switch控件.md │ │ │ ├── Upload在List下视频样式错乱.md │ │ │ ├── Xgen登录界面邮件电话校验规则.md │ │ │ ├── Xgen自定义远程控件.md │ │ │ ├── index.md │ │ │ ├── 使用Hook转换日期控件的值.md │ │ │ ├── 图片控件.md │ │ │ ├── 控件onSelect回调.md │ │ │ ├── 文件上传UploadFile.md │ │ │ ├── 禁用编辑控件.md │ │ │ ├── 菜单配置.md │ │ │ ├── 视频上传.md │ │ │ ├── 设置控件的必输属性.md │ │ │ └── 远程select控件.md │ │ ├── images │ │ │ └── form_on_change_event.gif │ │ ├── index.md │ │ ├── xgen命令汇总.md │ │ ├── xgen登录过程.md │ │ ├── xgen远程onChange事件.md │ │ ├── 使用compute.md │ │ ├── 模板替换.md │ │ ├── 系统默认的用户名.md │ │ └── 菜单结构.md │ ├── index.md │ ├── neo │ │ ├── AI助手 │ │ │ ├── AI助手.md │ │ │ ├── index.md │ │ │ └── 回调函数.md │ │ ├── index.md │ │ ├── neo_api接口.md │ │ ├── neo命令.md │ │ ├── neo聊天助手.md │ │ └── sse函数.md │ ├── v8go │ │ ├── Promise.md │ │ ├── index.md │ │ ├── 使用npm库.md │ │ ├── 使用ts的注意事项.md │ │ ├── 使用typescript进行开发.md │ │ ├── 在js脚本中异步执行作业.md │ │ ├── 在js脚本中抛出异常.md │ │ ├── 在yao中使用外部库.md │ │ └── 小心字节处理.md │ ├── 处理器 │ │ ├── Array转树形结构.md │ │ ├── Log.md │ │ ├── index.md │ │ ├── 会话数据.md │ │ ├── 使用处理器.md │ │ ├── 加密解密.md │ │ ├── 处理器列表.md │ │ ├── 应用引擎.md │ │ ├── 数据图表.md │ │ ├── 数据处理.md │ │ ├── 数据导入.md │ │ ├── 数据表格.md │ │ ├── 文件处理.md │ │ ├── 日期处理.md │ │ └── 网络请求.md │ └── 环境变量.md ├── algolia.json ├── contributing.md ├── contributors.json ├── contributors.ts ├── index.md ├── postcss.config.mjs ├── public │ ├── images │ │ └── keep.git │ └── robots.txt ├── socialIcons.ts ├── template.txt ├── vite.config.ts ├── 入门指南 │ ├── Yao学习路线图.md │ ├── Yao简单介绍.md │ ├── index.md │ ├── readme.md │ ├── 上手系列 │ │ ├── 1 Yao下载与安装.md │ │ ├── 2 创建第一个Yao应用.md │ │ ├── 3 增加模型定义.md │ │ ├── 4 生成数据库表.md │ │ ├── 5 配置表格.md │ │ ├── 6 配置表单.md │ │ ├── 7 配置外部API.md │ │ ├── 8 处理器.md │ │ ├── 9 数据增删改查.md │ │ └── index.md │ ├── 基础 │ │ ├── YAO命令.md │ │ ├── YAO编程基础.md │ │ ├── assets │ │ │ ├── admin-menu-done.jpg │ │ │ ├── admin-menu.jpg │ │ │ ├── admin-stat-done.jpg │ │ │ └── yao-setup-tree.jpg │ │ ├── index.md │ │ ├── 使用Widgets.md │ │ ├── 使用处理器.md │ │ ├── 创建数据模型.md │ │ ├── 安装配置.md │ │ ├── 应用目录结构.md │ │ ├── 应用语言包.md │ │ ├── 文件上传.md │ │ ├── 编写API接口.md │ │ ├── 编写图表.md │ │ ├── 编写界面.md │ │ └── 逻辑编排.md │ └── 进阶系列 │ │ ├── index.md │ │ ├── yao源代码安装.md │ │ ├── 使用会话保存信息.md │ │ └── 后台执行.md ├── 流程图 │ ├── Yao 架构概览.md │ ├── api请求过程.md │ ├── drawio │ │ ├── yao_app.drawio │ │ ├── yao_connector.drawio │ │ ├── yao_database.drawio │ │ ├── yao_session.drawio │ │ ├── yao_task.drawio │ │ └── yao_widget.drawio │ ├── index.md │ ├── png │ │ ├── yao_app_api请求过程.drawio.png │ │ ├── yao_app_flow.process.drawio.png │ │ ├── yao_app_参数查询.drawio.png │ │ ├── yao_app_数据库更新流程.drawio.png │ │ ├── yao_app_数据读取数据过程.drawio.png │ │ ├── yao_database_database_xun.drawio.png │ │ ├── yao_database_migrate.drawio.png │ │ ├── yao_database_xun_schema.drawio.png │ │ ├── yao_session_用户登录流程会话.drawio.png │ │ ├── yao_task.drawio.png │ │ └── yao_widget.drawio.png │ ├── yao migrate.md │ ├── 任务Task处理.md │ ├── 数据库schema.md │ ├── 数据库xun架构.md │ ├── 数据库更新流程.md │ ├── 数据库读取流程.md │ ├── 查询参数QueryParam.md │ ├── 用户登录流程会话.md │ └── 自定义widget.md └── 源代码 │ ├── Github Commit List.md │ ├── Gou │ ├── Null值转换成Int类型值时panic.md │ ├── index.md │ ├── jsapi中的undefined转换.md │ ├── 两个HasMany问题.md │ ├── 加密处理器调用错误.md │ └── 数据库Schema默认值转换异常.md │ ├── Kun │ ├── console_log无法输出正确格式.md │ └── index.md │ ├── Xgen │ ├── index.md │ ├── xgen List控件保存数据时数据被清空.md │ ├── xgen remoteSearch.md │ └── xgen 批量上传功能.md │ ├── Xun │ ├── Mysql数据库事务.md │ ├── PG数据库增加自定义类型.md │ ├── index.md │ ├── sqlite数据库bug.md │ ├── 使用postgresql保存Embedding.md │ └── 数据库连接配置.md │ ├── Yao │ ├── Compute 处理器无法处理关联表.md │ ├── index.md │ ├── yao 应用打包功能pack.md │ └── 处理器yao.component.selectoptions修正.md │ ├── index.md │ └── 源码编译 │ ├── 0.10.3-pre To 0.10.3-dev.md │ ├── index.md │ ├── windows版本适配 │ ├── index.md │ ├── windows pack功能适配.md │ └── 编译yao windows修改版本.md │ └── 编译yao源代码.md ├── knowledge-base ├── yao-dsl.md └── 入门指南.md ├── package.json ├── pnpm-lock.yaml ├── readme.md ├── scripts ├── cleanup.ts ├── compile_md.ts ├── generate.ts ├── generate_config.ts ├── generate_index.ts ├── postbuild.ts ├── release.ts ├── update.ts ├── utils.ts └── watch.ts ├── shims.d.ts ├── tsconfig.json └── unocss.config.ts /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | node_modules 3 | node_modules/ 4 | types/ 5 | cache/ 6 | !docs/.vitepress 7 | !/.eslintrc.js 8 | !.test 9 | .temp 10 | 11 | docs/**/*.js 12 | -------------------------------------------------------------------------------- /.github/workflows/algolia.yml: -------------------------------------------------------------------------------- 1 | name: algolia 2 | on: 3 | workflow_run: 4 | workflows: ["Deploy"] 5 | types: 6 | - completed 7 | jobs: 8 | algolia: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | - name: Get the content of algolia.json as config 13 | id: algolia_config 14 | run: echo "config=$(cat docs/algolia.json | jq -r tostring)" >> $GITHUB_OUTPUT 15 | - name: Push indices to Algolia 16 | uses: signcl/docsearch-scraper-action@master 17 | env: 18 | APPLICATION_ID: ${{secrets.ALGOLIA_APPLICATION_ID}} 19 | ALGOLIA_API_KEY: ${{secrets.ALGOLIA_API_KEY}} 20 | CONFIG: ${{ steps.algolia_config.outputs.config }} 21 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy 2 | on: 3 | workflow_dispatch: {} 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - 'docs/**/*.md' 9 | 10 | pull_request: 11 | branches: 12 | - main 13 | paths: 14 | - 'docs/**/*.md' 15 | 16 | jobs: 17 | deploy: 18 | runs-on: ubuntu-latest 19 | permissions: 20 | pages: write 21 | id-token: write 22 | environment: 23 | name: github-pages 24 | url: ${{ steps.deployment.outputs.page_url }} 25 | steps: 26 | - uses: actions/checkout@v4 27 | with: 28 | fetch-depth: 0 29 | 30 | - name: Set up Node.js 31 | uses: actions/setup-node@v3 32 | with: 33 | node-version: 22.15.0 34 | 35 | - name: Install pnpm 36 | uses: pnpm/action-setup@v4 37 | with: 38 | version: 10.4.1 39 | 40 | - name: Install Dependencies 41 | run: pnpm install --no-frozen-lockfile 42 | 43 | - name: Build 44 | run: pnpm run build 45 | 46 | - uses: actions/configure-pages@v5 47 | - uses: actions/upload-pages-artifact@v3 48 | with: 49 | path: ./dist/yao-docs 50 | 51 | - name: Deploy 52 | id: deployment 53 | uses: actions/deploy-pages@v4 54 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | db/*.db 3 | data 4 | logs 5 | .session 6 | node_modules 7 | docs/.vitepress/cache 8 | *.bak 9 | 10 | node_modules 11 | .temp 12 | dist 13 | .vscode 14 | cache 15 | .eslintcache 16 | components.d.ts 17 | 18 | # local env files 19 | .env.local 20 | .env.*.local 21 | 22 | # Log files 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | pnpm-debug.log* 27 | 28 | # json 29 | meta.json 30 | *.bkp 31 | debug.log -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | shamefully-hoist=true 2 | strict-peer-dependencies=false 3 | side-effects-cache=false -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | **/*.svg 2 | **/*.ico 3 | package.json 4 | /dist 5 | .DS_Store 6 | .eslintignore 7 | *.png 8 | *.toml 9 | .editorconfig 10 | .gitignore 11 | .prettierignore 12 | LICENSE 13 | .eslintcache 14 | *.lock 15 | yarn-error.log 16 | /public 17 | **/node_modules/** 18 | .npmrc 19 | typing/auto* 20 | -------------------------------------------------------------------------------- /.prettierrc.mjs: -------------------------------------------------------------------------------- 1 | export default { 2 | printWidth: 80, 3 | tabWidth: 2, 4 | useTabs: false, 5 | semi: true, 6 | singleQuote: true, 7 | quoteProps: 'as-needed', 8 | jsxSingleQuote: false, 9 | trailingComma: 'none', 10 | bracketSpacing: true, 11 | bracketSameLine: false, 12 | arrowParens: 'always', 13 | rangeStart: 0, 14 | rangeEnd: Infinity, 15 | requirePragma: false, 16 | insertPragma: false, 17 | proseWrap: 'preserve', 18 | htmlWhitespaceSensitivity: 'css', 19 | endOfLine: 'auto', 20 | plugins: [] 21 | }; 22 | -------------------------------------------------------------------------------- /docs/.vitepress/algolia.ts: -------------------------------------------------------------------------------- 1 | import type { DefaultTheme } from 'vitepress'; 2 | 3 | const algolia: DefaultTheme.AlgoliaSearchOptions = { 4 | appId: 'Z0GOIBJSIG', 5 | apiKey: 'f3f332389d40f82741dc99678e577e5d', 6 | indexName: 'yao-docs', 7 | 8 | placeholder: '搜索文档', 9 | translations: { 10 | button: { 11 | buttonText: '搜索文档', 12 | buttonAriaLabel: '搜索文档' 13 | }, 14 | modal: { 15 | searchBox: { 16 | resetButtonTitle: '清除查询条件', 17 | resetButtonAriaLabel: '清除查询条件', 18 | cancelButtonText: '取消', 19 | cancelButtonAriaLabel: '取消' 20 | }, 21 | startScreen: { 22 | recentSearchesTitle: '搜索历史', 23 | noRecentSearchesText: '没有搜索历史', 24 | saveRecentSearchButtonTitle: '保存至搜索历史', 25 | removeRecentSearchButtonTitle: '从搜索历史中移除', 26 | favoriteSearchesTitle: '收藏', 27 | removeFavoriteSearchButtonTitle: '从收藏中移除' 28 | }, 29 | errorScreen: { 30 | titleText: '无法获取结果', 31 | helpText: '你可能需要检查你的网络连接' 32 | }, 33 | footer: { 34 | selectText: '选择', 35 | navigateText: '切换', 36 | closeText: '关闭', 37 | searchByText: '搜索提供者' 38 | }, 39 | noResultsScreen: { 40 | noResultsText: '无法找到相关结果', 41 | suggestedQueryText: '你可以尝试查询', 42 | reportMissingResultsText: '你认为该查询应该有结果?', 43 | reportMissingResultsLinkText: '点击反馈' 44 | } 45 | } 46 | } 47 | }; 48 | 49 | export default algolia; 50 | -------------------------------------------------------------------------------- /docs/.vitepress/link.ts: -------------------------------------------------------------------------------- 1 | const socialLinks = [ 2 | { 3 | icon: 'github', 4 | link: 'https://github.com/wwsheng009' 5 | } 6 | ]; 7 | 8 | export default socialLinks; 9 | -------------------------------------------------------------------------------- /docs/.vitepress/meta.ts: -------------------------------------------------------------------------------- 1 | import { version } from '../../package.json'; 2 | 3 | // base info 4 | export const name = 'YaoDocs'; 5 | export const site = 'https://wwsheng009.github.io/yao-docs'; 6 | export const logo = ''; 7 | export const keywords = 'yao、lowercode、coding、github'; 8 | export const description = 'Yao应用学习分享'; 9 | 10 | // social link 11 | export const bilibili = ''; 12 | export const github = 'https://github.com/wwsheng009/yao-docs'; 13 | 14 | // docs version 15 | export const docsVersion = version; 16 | 17 | /* PWA runtime caching urlPattern regular expressions */ 18 | /* eslint-disable prefer-regex-literals */ 19 | export const githubSourceContentRegex = new RegExp( 20 | '^https://(((raw|user-images|camo).githubusercontent.com))/.*', 21 | 'i' 22 | ); 23 | export const googleFontRegex = new RegExp( 24 | '^https://fonts.googleapis.com/.*', 25 | 'i' 26 | ); 27 | export const googleStaticFontRegex = new RegExp( 28 | '^https://fonts.gstatic.com/.*', 29 | 'i' 30 | ); 31 | export const jsdelivrCDNRegex = new RegExp('^https://cdn.jsdelivr.net/.*', 'i'); 32 | -------------------------------------------------------------------------------- /docs/.vitepress/nav.ts: -------------------------------------------------------------------------------- 1 | // nav.ts generated by script,don't edit manually 2 | export default [ 3 | { 4 | text: 'Admin-App', 5 | link: '/Admin-App/index' 6 | }, 7 | { 8 | text: 'AI', 9 | link: '/AI/index' 10 | }, 11 | { 12 | text: 'Studio', 13 | link: '/Studio/index' 14 | }, 15 | { 16 | text: 'YaoDSL', 17 | link: '/YaoDSL/index' 18 | }, 19 | { 20 | text: '入门指南', 21 | link: '/入门指南/index' 22 | }, 23 | { 24 | text: '流程图', 25 | link: '/流程图/index' 26 | }, 27 | { 28 | text: '源代码', 29 | link: '/源代码/index' 30 | } 31 | ]; 32 | -------------------------------------------------------------------------------- /docs/.vitepress/plugins/markdownTransform.ts: -------------------------------------------------------------------------------- 1 | import type { Plugin } from 'vite'; 2 | // import { replacer } from '../../../scripts/utils'; 3 | // import { getReadingTime } from './../theme/utils'; 4 | 5 | export function MarkdownTransform(): Plugin { 6 | return { 7 | name: 'yaodocs-md-transform', 8 | order: 'pre', 9 | async transform(code, id) { 10 | if (!id.match(/\.md\b/)) { 11 | return null; 12 | } 13 | // convert links to relative 14 | code = code.replace( 15 | /https?:\/\/github\.com\/wwsheng009\/yao-docs\//g, 16 | '/' 17 | ); 18 | const [_name, i] = id.split('/').slice(-2); 19 | 20 | // cut index.md 21 | if (_name === 'docs' && i === 'index.md') { 22 | return code; 23 | } 24 | 25 | // const { footer } = await getDocsMarkdown(); 26 | // code = replacer(code, footer, 'FOOTER', 'tail'); 27 | // const { readTime, words } = getReadingTime(code); 28 | // code = code.replace( 29 | // /(#\s.+?\n)/, 30 | // `$1\n\n\n`, 31 | // ); 32 | 33 | return code; 34 | } 35 | }; 36 | } 37 | 38 | export async function getDocsMarkdown() { 39 | const ContributorsSection = `## Contributors 40 | `; 41 | 42 | const CopyRightSection = ''; // '\n'; 43 | 44 | const footer = `${ContributorsSection}\n${CopyRightSection}`; 45 | 46 | return { 47 | footer 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/components/Badge.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 13 | 14 | 65 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/components/Contributors.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 43 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/components/CopyRight.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 67 | 68 | 73 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/components/DemoContainer.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 35 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/components/HomeContributors.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 40 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/components/IndexInfo.vue: -------------------------------------------------------------------------------- 1 | 13 | 24 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/components/NavCard.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 30 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/components/PageInfo.vue: -------------------------------------------------------------------------------- 1 | 21 | 22 | 58 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/components/VideoLink.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 28 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/index.ts: -------------------------------------------------------------------------------- 1 | import { inBrowser, useRoute } from 'vitepress'; 2 | import type { EnhanceAppContext, Theme } from 'vitepress'; 3 | import DefaultTheme from 'vitepress/theme'; 4 | import { nextTick, onMounted, watch } from 'vue'; 5 | import busuanzi from 'busuanzi.pure.js'; 6 | import mediumZoom from 'medium-zoom'; 7 | import { 8 | registerAnalytics, 9 | siteIds, 10 | trackPageview 11 | } from './plugins/baidutongji'; 12 | import googleAnalytics from './plugins/googleAnalytics'; 13 | import './styles/main.css'; 14 | import './styles/global.css'; 15 | import './styles/demo.css'; 16 | import './styles/utils.css'; 17 | import './styles/vars.css'; 18 | import 'uno.css'; 19 | 20 | const theme: Theme = { 21 | ...DefaultTheme, 22 | enhanceApp({ router }: EnhanceAppContext) { 23 | googleAnalytics({ 24 | id: 'G-0F3DLK5BSG' 25 | }); 26 | if (inBrowser) { 27 | registerAnalytics(siteIds); 28 | 29 | window.addEventListener('hashchange', () => { 30 | const { href: url } = window.location; 31 | trackPageview(siteIds, url); 32 | }); 33 | 34 | router.onAfterRouteChanged = (to) => { 35 | trackPageview(siteIds, to); 36 | busuanzi.fetch(); 37 | }; 38 | } 39 | }, 40 | setup() { 41 | const route = useRoute(); 42 | const initZoom = () => { 43 | mediumZoom('.main img', { background: 'var(--vp-c-bg)' }); // Should there be a new? 44 | }; 45 | onMounted(() => { 46 | initZoom(); 47 | }); 48 | watch( 49 | () => route.path, 50 | () => nextTick(() => initZoom()) 51 | ); 52 | } 53 | }; 54 | 55 | export default theme; 56 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/plugins/baidutongji.ts: -------------------------------------------------------------------------------- 1 | import { inBrowser } from 'vitepress'; 2 | 3 | /** 4 | * 统计站点的 ID 列表 5 | */ 6 | export const siteIds = 'eb1ef90b1e9476b8d3d43088d3ac9c49'; 7 | 8 | declare global { 9 | interface Window { 10 | _hmt: string[][]; 11 | } 12 | } 13 | 14 | /** 15 | * 注册统计 16 | */ 17 | export function registerAnalytics(siteId: string) { 18 | if (!inBrowser) { 19 | return; 20 | } 21 | if (document.querySelector(`#analytics-plugin-${siteId}`)) { 22 | return; 23 | } 24 | window._hmt = window._hmt ? window._hmt : []; 25 | const script = document.createElement('script'); 26 | script.id = `analytics-${siteId}`; 27 | script.async = true; 28 | script.src = `https://hm.baidu.com/hm.js?${siteId}`; 29 | document.querySelector('head')?.appendChild(script); 30 | } 31 | 32 | /** 33 | * 上报 PV 数据 34 | * @param siteId - 站点 ID 35 | * @param pageUrl - 页面 URL 36 | */ 37 | export function trackPageview(siteId: string, pageUrl: string) { 38 | if (!inBrowser) { 39 | return; 40 | } 41 | if (!pageUrl || typeof pageUrl !== 'string') { 42 | pageUrl = '/'; 43 | } 44 | 45 | if (pageUrl.startsWith('http')) { 46 | const urlFragment = pageUrl.split('/'); 47 | const origin = `${urlFragment[0]}//${urlFragment[2]}`; 48 | pageUrl = pageUrl.replace(origin, ''); 49 | } 50 | 51 | window._hmt.push(['_setAccount', siteId]); 52 | window._hmt.push(['_trackPageview', pageUrl]); 53 | } 54 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/plugins/googleAnalytics.ts: -------------------------------------------------------------------------------- 1 | declare const dataLayer: unknown[]; 2 | declare const gtag: (...args: unknown[]) => void; 3 | declare global { 4 | interface Window { 5 | dataLayer?: typeof dataLayer; 6 | gtag?: typeof gtag; 7 | } 8 | } 9 | 10 | const mountGoogleAnalytics = (id: string) => { 11 | if (window.dataLayer && window.gtag) return; 12 | 13 | const gtagScript = document.createElement('script'); 14 | gtagScript.src = `https://www.googletagmanager.com/gtag/js?id=${id}`; 15 | gtagScript.async = true; 16 | document.head.appendChild(gtagScript); 17 | window.dataLayer = window.dataLayer || []; 18 | window.gtag = function () { 19 | dataLayer.push(arguments); 20 | }; 21 | gtag('js', new Date()); 22 | gtag('config', id); 23 | }; 24 | export default ({ id }) => { 25 | if ( 26 | process.env.NODE_ENV === 'production' && 27 | id && 28 | typeof window !== 'undefined' 29 | ) 30 | mountGoogleAnalytics(id); 31 | }; 32 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/styles/global.css: -------------------------------------------------------------------------------- 1 | iframe { 2 | width: 100%; 3 | min-height: 600px; 4 | } 5 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/styles/main.css: -------------------------------------------------------------------------------- 1 | html.dark { 2 | color-scheme: dark; 3 | } 4 | 5 | .vp-doc h2 { 6 | border-top: 0px; 7 | margin-top: 10px; 8 | } 9 | 10 | .VPMenuLink .link { 11 | line-height: 28px !important; 12 | } 13 | 14 | .VPSidebarGroup .link { 15 | padding: 3px 0 !important; 16 | } 17 | 18 | .VPTeamPageTitle .title { 19 | line-height: 32px; 20 | font-size: 24px; 21 | opacity: 0.5; 22 | } 23 | 24 | .VPTeamPageTitle .lead { 25 | font-size: 14px; 26 | opacity: 0.4; 27 | } 28 | 29 | .medium-zoom-overlay { 30 | z-index: 20; 31 | } 32 | 33 | .medium-zoom-image { 34 | z-index: 21; 35 | } 36 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/styles/utils.css: -------------------------------------------------------------------------------- 1 | .text-orange { 2 | color: #db8742; 3 | } 4 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/types/index.ts: -------------------------------------------------------------------------------- 1 | export interface PageInfo { 2 | readTime: number | string; 3 | words: number | string; 4 | } 5 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/utils/date.ts: -------------------------------------------------------------------------------- 1 | import dayjs from 'dayjs'; 2 | import utc from 'dayjs/plugin/utc.js'; 3 | import relativeTime from 'dayjs/plugin/relativeTime'; 4 | import 'dayjs/locale/zh-cn'; 5 | dayjs.extend(utc); 6 | dayjs.locale('zh-cn'); 7 | dayjs.extend(relativeTime); 8 | 9 | export const getDate = (date: string | Date | undefined): string | null => { 10 | if (date) { 11 | const time = dayjs(date instanceof Date ? date : date.trim()); 12 | if (time.isValid()) { 13 | const currentTime = dayjs(date).utc().local().format('YYYY-MM-DD'); 14 | return currentTime; 15 | } 16 | } 17 | return null; 18 | }; 19 | 20 | export const getFromNow = (date: string | Date): string | null => { 21 | if (date) return dayjs(date).utc().local().fromNow(); 22 | 23 | return null; 24 | }; 25 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './md'; 2 | export * from './date'; 3 | export * from './pageInfo'; 4 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/utils/md.ts: -------------------------------------------------------------------------------- 1 | export function renderMarkdown(markdownText = '') { 2 | const htmlText = markdownText 3 | .replace(/^### (.*$)/gim, '

$1

') 4 | .replace(/^## (.*$)/gim, '

$1

') 5 | .replace(/^# (.*$)/gim, '

$1

') 6 | .replace(/^\> (.*$)/gim, '
$1
') 7 | .replace(/\*\*(.*)\*\*/gim, '$1') 8 | .replace(/\*(.*)\*/gim, '$1') 9 | .replace(/!\[(.*?)\]\((.*?)\)/gim, "$1") 10 | .replace(/\[(.*?)\]\((.*?)\)/gim, "$1") 11 | .replace(/`(.*?)`/gim, '$1') 12 | .replace(/\n$/gim, '
'); 13 | 14 | return htmlText.trim(); 15 | } 16 | 17 | export function renderCommitMessage(msg: string) { 18 | return renderMarkdown(msg).replace( 19 | /\#([0-9]+)/g, 20 | "#$1" 21 | ); 22 | } 23 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/utils/pageInfo.ts: -------------------------------------------------------------------------------- 1 | import type { PageInfo } from '../types'; 2 | 3 | export const getWords = (content: string): RegExpMatchArray | null => 4 | // \u00C0-\u024F are Latin Supplement letters, maybe used in language like french 5 | // \u0400-\u04FF are Cyrillic letters, used in russian 6 | content.match(/[\w\d\s,.\u00C0-\u024F\u0400-\u04FF]+/giu); 7 | 8 | export const getChinese = (content: string): RegExpMatchArray | null => 9 | content.match(/[\u4E00-\u9FD5]/gu); 10 | 11 | export const getEnWordCount = (content: string): number => 12 | getWords(content)?.reduce( 13 | (accumulator, word) => 14 | accumulator + (word.trim() === '' ? 0 : word.trim().split(/\s+/u).length), 15 | 0 16 | ) || 0; 17 | 18 | export const getCnWordCount = (content: string): number => 19 | getChinese(content)?.length || 0; 20 | 21 | export const getWordNumber = (content: string): number => 22 | getEnWordCount(content) + getCnWordCount(content); 23 | 24 | export const getReadingTime = ( 25 | content: string, 26 | cnWordPerMinute = 350, 27 | enwordPerMinute = 160 28 | ): PageInfo => { 29 | const count = getWordNumber(content || ''); 30 | const words = count >= 1000 ? `${Math.round(count / 100) / 10}k` : count; 31 | 32 | const enWord = getEnWordCount(content); 33 | const cnWord = getCnWordCount(content); 34 | 35 | const readingTime = cnWord / cnWordPerMinute + enWord / enwordPerMinute; 36 | const readTime = readingTime < 1 ? '1' : parseInt(`${readingTime}`, 10); 37 | 38 | return { 39 | readTime, 40 | words 41 | }; 42 | }; 43 | -------------------------------------------------------------------------------- /docs/.vitepress/types.ts: -------------------------------------------------------------------------------- 1 | export interface navItem { 2 | id: string | number; 3 | text: string; 4 | desc?: string; 5 | link: string; 6 | icon?: string; 7 | } 8 | -------------------------------------------------------------------------------- /docs/AI/AI生成模型模板.md: -------------------------------------------------------------------------------- 1 | # AI生成模型模板 2 | 3 | ## 概述 4 | 5 | AI生成模型模板是YAO平台提供的一种强大工具,它能够帮助开发者快速生成符合YAO DSL规范的模型定义。本文将介绍如何有效使用这些模板,以提高开发效率。 6 | 7 | ## 模板类型 8 | 9 | ### 1. 基础模型模板 10 | 11 | - [没有模型关联关系的模板](./Prompts/model_without_relations.md) 12 | - 适用于独立模型的定义 13 | - 包含基本的字段定义和验证规则 14 | - 简单直观,适合入门使用 15 | 16 | ### 2. 高级模型模板 17 | 18 | - [带模型关联关系的模板](./Prompts/model_with_relations.md) 19 | - 支持复杂的模型关联关系 20 | - 包含一对一、一对多、多对多等关系定义 21 | - 适用于复杂业务场景 22 | 23 | ## 使用指南 24 | 25 | ### 1. 模板选择 26 | 27 | - 根据业务需求的复杂度选择合适的模板 28 | - 考虑模型之间的关联关系 29 | - 评估数据结构的复杂性 30 | 31 | ### 2. 模板使用步骤 32 | 33 | 1. 选择适合的模板类型 34 | 2. 根据实际需求修改模板参数 35 | 3. 使用AI工具生成模型定义 36 | 4. 检查和优化生成的代码 37 | 38 | ### 3. 最佳实践 39 | 40 | - 先从简单模板开始,逐步过渡到复杂模板 41 | - 保持模型结构的清晰和合理 42 | - 注意字段命名的规范性 43 | - 适当添加注释和文档 44 | 45 | ## 模板示例 46 | 47 | ### 基础模型示例 48 | 49 | ```json 50 | { 51 | "name": "user", 52 | "table": { "name": "users", "comment": "用户表" }, 53 | "columns": [ 54 | { "name": "id", "type": "ID" }, 55 | { "name": "name", "type": "string", "comment": "用户名" }, 56 | { "name": "email", "type": "string", "comment": "邮箱" } 57 | ] 58 | } 59 | ``` 60 | 61 | ### 关联模型示例 62 | 63 | ```json 64 | { 65 | "name": "post", 66 | "table": { "name": "posts", "comment": "文章表" }, 67 | "columns": [ 68 | { "name": "id", "type": "ID" }, 69 | { "name": "title", "type": "string", "comment": "标题" }, 70 | { "name": "user_id", "type": "integer", "comment": "作者ID" } 71 | ], 72 | "relations": { 73 | "user": { 74 | "type": "belongsTo", 75 | "model": "user", 76 | "key": "user_id" 77 | } 78 | } 79 | } 80 | ``` 81 | -------------------------------------------------------------------------------- /docs/AI/Prompts/index.md: -------------------------------------------------------------------------------- 1 | # Prompts 2 | 3 | 4 | 5 | - [model_without_relations](model_without_relations.md) 6 | - [model_with_relations](model_with_relations.md) 7 | - [prompt工程师](prompt工程师.md) 8 | 9 | -------------------------------------------------------------------------------- /docs/AI/Prompts/model_without_relations.md: -------------------------------------------------------------------------------- 1 | 我们来学习一个新的基于 DSL 的低代码平台,DSL 使用 JSON 格式文件描述模型的属性。我给你提供一个模型的模板内容,你基于我提供的模板生成对应的模型。 2 | 下面是数据模型的简单实例: 3 | 4 | ```json 5 | { 6 | "name": "物资", 7 | "table": { "name": "表名", "comment": "备注" }, 8 | "columns": [ 9 | { "label": "ID", "name": "id", "type": "ID", "comment": "主键" }, 10 | { 11 | "label": "厂商", 12 | "name": "supplier_id", 13 | "type": "bigInteger", 14 | "comment": "所属厂商", 15 | "nullable": true 16 | }, 17 | { 18 | "label": "名称", 19 | "name": "name", 20 | "type": "string", 21 | "length": 200, 22 | "index": true, 23 | "unique": true, 24 | "validations": [ 25 | { 26 | "method": "typeof", 27 | "args": ["string"], 28 | "message": "{{input}}类型错误, {{label}}应该为字符串" 29 | }, 30 | { 31 | "method": "minLength", 32 | "args": [2], 33 | "message": "{{label}}至少需要2个字" 34 | }, 35 | { 36 | "method": "maxLength", 37 | "args": [200], 38 | "message": "{{label}}不能超过200个字" 39 | } 40 | ] 41 | }, 42 | { 43 | "label": "金额", 44 | "name": "amount", 45 | "precision": 10, 46 | "scale": 2, 47 | "type": "float", 48 | "comment": "金额", 49 | "nullable": true 50 | }, 51 | { 52 | "name": "status", 53 | "type": "enum", 54 | "label": "状态", 55 | "comment": "状态", 56 | "options": [ 57 | { "label": "启用", "value": "enabled" }, 58 | { "label": "禁用", "value": "disabled" } 59 | ], 60 | "validations": [ 61 | { 62 | "method": "enum", 63 | "args": ["enabled", "disabled"], 64 | "message": "::{{input}} Error, {{label}} should be enabled/disabled" 65 | } 66 | ] 67 | } 68 | ], 69 | "relations": {}, 70 | "values": [ 71 | { "supplier_id": 1, "name": "测试", "amount": 20.1, "status": "enabled" } 72 | ], 73 | "option": { "timestamps": true, "soft_deletes": true } 74 | } 75 | ``` 76 | 77 | 基于以上的模板,生成销售订单模型,模型的字段尽可能的丰富,不需要解释,只输出 json。 78 | -------------------------------------------------------------------------------- /docs/AI/Prompts/prompt工程师.md: -------------------------------------------------------------------------------- 1 | # Prompt 工程师任务:设计高效 AI 模型提示词 2 | 3 | ## 角色定义 4 | 5 | 您是一位专业的 Prompt 工程师,负责根据用户提供的文档或需求,设计清晰、简洁且结构化的提示词(Prompt),用于调用 AI 模型(如 ChatGPT、DeepSeek 等)。您的目标是确保 Prompt 能让目标 AI 准确理解用户意图,生成符合预期的完整、准确的响应。 6 | 7 | ## 任务目标 8 | 9 | - 根据用户文档或需求,设计逻辑清晰、简洁的 Prompt,确保包含所有关键信息。 10 | - 对于复杂任务,将其分解为明确的步骤,引导 AI 模型逐步完成。 11 | - 若需求不明确,设计澄清机制,促使 AI 模型在需要时向用户确认细节。 12 | - 对于涉及配置或代码的任务,提供具体示例以确保上下文清晰。 13 | 14 | ## 提示词结构 15 | 16 | 一个高效的 Prompt 应包含以下要素: 17 | 18 | 1. **角色定义**:明确 AI 的角色和职责。 19 | 2. **背景信息**:提供必要的任务背景和上下文。 20 | 3. **具体任务**:清晰描述任务目标和要求。 21 | 4. **输出格式**:指定期望的输出结构和格式。 22 | 5. **约束条件**:列明任何限制或特殊要求。 23 | 24 | ## 提示词设计最佳实践 25 | 26 | 1. **清晰具体**: 27 | - 使用明确、命令式的语言。 28 | - 避免模糊或冗余表述。 29 | - 提供具体示例以阐明期望。 30 | 2. **结构化设计**: 31 | - 采用模板化结构,逻辑分明。 32 | - 将复杂任务分解为简单步骤。 33 | - 按优先级组织信息。 34 | 3. **优化技巧**: 35 | - 以明确动词(如“生成”、“分析”)开始指令。 36 | - 使用分步说明分解复杂任务。 37 | - 提供示例输出,突出预期结果。 38 | - 使用标记(如 \*\*、-)突出关键信息。 39 | - 使用分隔符(如 "###")区分 Prompt 的不同部分,提高可读性。 40 | - 利用少样本学习或思维链提示,增强复杂任务的处理能力。 41 | 42 | ## 任务流程 43 | 44 | 1. **需求分析**: 45 | - 仔细分析用户提供的文档或问题,提取核心需求和关键信息。 46 | - 若需求不明确,设计澄清步骤,提示 AI 模型向用户确认细节。 47 | - 对于复杂或冗长文档,归纳关键点并按逻辑顺序组织。 48 | 2. **Prompt 设计**: 49 | - 编写简洁、准确的 Prompt,涵盖所有关键信息。 50 | - 对于代码或配置任务,嵌入规范的示例(如 JSON、Python)。 51 | - 对于多步骤任务,明确划分步骤并提供清晰指令。 52 | 3. **测试与优化**: 53 | - 使用设计的 Prompt 调用 AI 模型,评估生成响应的质量。 54 | - 根据响应结果,调整 Prompt 以改进准确性和完整性。 55 | - 重复此过程直至满意。 56 | 4. **Prompt 质量要求**: 57 | - 使用简洁、专业的语言,避免冗余。 58 | - 确保 Prompt 逻辑清晰、结构化,易于 AI 模型解析。 59 | 60 | ## 特殊情况处理 61 | 62 | - **复杂任务**:分解为子任务,设计分步 Prompt,明确每步目标和上下文。可考虑使用思维链提示引导 AI 逐步推理。 63 | - **需求不明确**:加入询问机制,提示 AI 模型向用户澄清具体需求。 64 | - **领域特定内容**:整理通用描述或示例,确保 AI 模型准确理解专业知识。 65 | - **长文档处理**:提取关键点,归纳为简洁要点,按优先级组织。 66 | 67 | ## 输出格式 68 | 69 | - 将生成的 Prompt 以 markdown 格式输出,使用代码块标记,即在 Prompt 内容前后分别添加 `md 和 `。 70 | - 若 Prompt 内容过长,需分多个消息输出。每个消息包含部分 Prompt,同样使用 `md 和 ` 包裹,并在消息末尾提示用户输入“继续”以获取下一部分。 71 | 72 | ## Prompt 设计模板 73 | 74 | 为了帮助您设计 Prompt,以下是一个基本模板: 75 | 76 | **角色**: [描述 AI 的角色] 77 | 78 | **背景**: [提供任务背景] 79 | 80 | **任务**: [具体任务描述] 81 | 82 | **输出格式**: [期望的输出格式] 83 | 84 | **约束**: [任何限制或特殊要求] 85 | 86 | 您可以根据具体需求调整和扩展此模板。 87 | -------------------------------------------------------------------------------- /docs/AI/examples/salesorder/chat-shot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/AI/examples/salesorder/chat-shot1.png -------------------------------------------------------------------------------- /docs/AI/examples/salesorder/chatgpt-salesorder3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/AI/examples/salesorder/chatgpt-salesorder3.png -------------------------------------------------------------------------------- /docs/AI/examples/salesorder/chatgpt-salesorder4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/AI/examples/salesorder/chatgpt-salesorder4.png -------------------------------------------------------------------------------- /docs/AI/examples/salesorder/salesorder.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "销售订单", 3 | "table": { "name": "sales_orders", "comment": "销售订单表" }, 4 | "columns": [ 5 | { "label": "ID", "name": "id", "type": "ID", "comment": "销售订单表主键" }, 6 | { 7 | "label": "客户", 8 | "name": "customer_id", 9 | "type": "bigInteger", 10 | "comment": "客户ID", 11 | "index": true, 12 | "nullable": true 13 | }, 14 | { 15 | "label": "销售员", 16 | "name": "salesman_id", 17 | "type": "bigInteger", 18 | "comment": "销售员ID", 19 | "index": true, 20 | "nullable": true 21 | }, 22 | { 23 | "label": "订单编号", 24 | "name": "order_no", 25 | "type": "string", 26 | "length": 50, 27 | "unique": true 28 | }, 29 | { 30 | "label": "订单状态", 31 | "name": "status", 32 | "type": "integer", 33 | "comment": "订单状态", 34 | "index": true, 35 | "nullable": true 36 | }, 37 | { 38 | "label": "订单总价", 39 | "name": "total_price", 40 | "type": "decimal", 41 | "precision": 10, 42 | "scale": 2, 43 | "nullable": true 44 | }, 45 | { 46 | "label": "订单备注", 47 | "name": "remark", 48 | "type": "text", 49 | "nullable": true 50 | } 51 | ], 52 | "relations": {}, 53 | "option": { "timestamps": true, "soft_deletes": true } 54 | } 55 | -------------------------------------------------------------------------------- /docs/AI/index.md: -------------------------------------------------------------------------------- 1 | # YAO与AI开发指南 2 | 3 | 本章节介绍如何利用AI技术来加速YAO应用的开发过程,包括使用AI生成模型定义、开发应用以及相关最佳实践。 4 | 5 | 6 | 7 | - [使用AI创建模型定义](使用AI创建模型定义.md) 8 | - [使用AI开发YAO应用](使用AI开发YAO应用.md) 9 | - [提示词](提示词.md) 10 | - [AI生成模型模板](AI生成模型模板.md) 11 | - [Vscode编辑器使用插件快速开发模型](Vscode编辑器使用插件快速开发模型.md) 12 | - [Prompts](Prompts/index) 13 | - [sui](sui/index) 14 | 15 | -------------------------------------------------------------------------------- /docs/AI/sui/index.md: -------------------------------------------------------------------------------- 1 | # sui 2 | 3 | 4 | 5 | - [简化](简化.md) 6 | - [SUI ai提示词](SUI%20ai提示词.md) 7 | 8 | -------------------------------------------------------------------------------- /docs/AI/vscode_quick_dev/vscode_ad_hoc_prompt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/AI/vscode_quick_dev/vscode_ad_hoc_prompt.png -------------------------------------------------------------------------------- /docs/AI/vscode_quick_dev/vscode_create_new_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/AI/vscode_quick_dev/vscode_create_new_model.png -------------------------------------------------------------------------------- /docs/AI/vscode_quick_dev/vscode_new_mode_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/AI/vscode_quick_dev/vscode_new_mode_file.png -------------------------------------------------------------------------------- /docs/AI/提示词.md: -------------------------------------------------------------------------------- 1 | # 提示词 2 | 3 | ## 提示词的重要性 4 | 5 | 在人工智能时代,提示词(Prompt)是人类与AI模型进行有效沟通的桥梁。好的提示词设计能够: 6 | 7 | - 提高AI输出的准确性和相关性 8 | - 减少误解和歧义 9 | - 节省时间和资源 10 | - 获得更符合预期的结果 11 | 12 | ## 提示词的基本结构 13 | 14 | 一个完整的提示词通常包含以下要素: 15 | 16 | 1. **角色定义**:明确告诉AI它应该扮演什么角色 17 | 2. **背景信息**:提供必要的上下文和背景 18 | 3. **具体任务**:清晰地描述需要完成的任务 19 | 4. **输出格式**:指定期望的输出格式和结构 20 | 5. **约束条件**:说明任何限制或特殊要求 21 | 22 | ## 提示词工程最佳实践 23 | 24 | ### 1. 清晰具体 25 | 26 | - 使用明确的指令和要求 27 | - 避免模糊不清的表述 28 | - 提供具体的示例 29 | 30 | ### 2. 结构化设计 31 | 32 | - 使用模板化的提示词结构 33 | - 将复杂任务分解为多个步骤 34 | - 合理组织信息的顺序 35 | 36 | ### 3. 迭代优化 37 | 38 | - 根据AI的响应调整提示词 39 | - 记录和分析效果较好的提示词 40 | - 建立提示词模板库 41 | 42 | ### 4. 安全性考虑 43 | 44 | - 避免敏感信息泄露 45 | - 设置适当的约束和限制 46 | - 验证AI输出的安全性 47 | 48 | ## 提示词模板示例 49 | 50 | ### 1. 翻译任务 51 | 52 | ``` 53 | 角色:你是一位专业的翻译专家 54 | 任务:将以下文本翻译成[目标语言] 55 | 要求: 56 | - 保持原文的专业术语 57 | - 确保翻译的准确性和流畅性 58 | - 对专业术语提供注释 59 | ``` 60 | 61 | ### 2. 代码生成 62 | 63 | ``` 64 | 角色:你是一位经验丰富的程序员 65 | 背景:[项目背景和技术栈] 66 | 任务:实现[具体功能] 67 | 要求: 68 | - 代码必须遵循最佳实践 69 | - 包含适当的注释和文档 70 | - 考虑性能和安全性 71 | ``` 72 | 73 | ## 动态提示词 74 | 75 | 在实际应用中,通常需要动态生成提示词以适应不同场景: 76 | 77 | 1. **模板 + 变量**:创建基础模板,通过变量注入具体内容 78 | 2. **上下文管理**:根据对话历史动态调整提示词 79 | 3. **多轮对话**:在对话过程中逐步细化和调整提示词 80 | 81 | ## 常见问题和解决方案 82 | 83 | ### 1. AI响应不准确 84 | 85 | - 提供更多具体示例 86 | - 细化任务要求 87 | - 增加约束条件 88 | 89 | ### 2. 输出格式不符合要求 90 | 91 | - 明确指定输出格式 92 | - 提供格式示例 93 | - 使用结构化模板 94 | 95 | ### 3. 响应过于冗长或简短 96 | 97 | - 设定字数限制 98 | - 指定详细程度 99 | - 明确输出重点 100 | 101 | ## 提示词优化技巧 102 | 103 | 1. **使用命令式语言**:使用明确的动词开始指令 104 | 2. **分步骤说明**:将复杂任务分解为简单步骤 105 | 3. **设置优先级**:明确说明任务的重要性顺序 106 | 4. **提供示例**:给出期望输出的具体示例 107 | 5. **使用标记符号**:用特殊符号标记重要信息 108 | 109 | ## 总结 110 | 111 | 提示词工程是人工智能应用中的关键技能。通过合理设计和优化提示词,我们可以更好地利用AI模型的能力,获得更优质的输出结果。持续的实践和优化将帮助我们掌握这门重要的技术。 112 | -------------------------------------------------------------------------------- /docs/Admin-App/Amis/InputTable的数据更新.md: -------------------------------------------------------------------------------- 1 | # InputTable setValue 更新 2 | 3 | 在使用 InputTable 时,如果通过使用`setValue`方法来更新表数据时,有时会发现,值更新了,但是界面没有更新。 4 | 5 | 比如这里使用 Button 来设置全选,点击按钮后并不生效。 6 | 7 | ```json 8 | { 9 | "type": "button", 10 | "label": "全选", 11 | "onEvent": { 12 | "click": { 13 | "actions": [ 14 | { 15 | "actionType": "custom", 16 | "script": "debugger;event.data.columns.forEach(col => {col.checked = true});\n\n" 17 | }, 18 | { 19 | "componentId": "model_columns", 20 | "actionType": "setValue", 21 | "args": { 22 | "value": "${event.data.columns}" 23 | } 24 | } 25 | ] 26 | } 27 | } 28 | } 29 | ``` 30 | 31 | 有两个方法,一个是先清空值,再设置值,但是界面会闪烁。 32 | 33 | ```json 34 | { 35 | "type": "button", 36 | "label": "全选", 37 | "onEvent": { 38 | "click": { 39 | "actions": [ 40 | { 41 | "actionType": "custom", 42 | "script": "debugger;event.data.columns.forEach(col => {col.checked = true});\n\n" 43 | }, 44 | { 45 | "componentId": "model_columns", 46 | "actionType": "clear" 47 | }, 48 | { 49 | "componentId": "model_columns", 50 | "actionType": "setValue", 51 | "args": { 52 | "value": "${event.data.columns}" 53 | } 54 | } 55 | ] 56 | } 57 | } 58 | } 59 | ``` 60 | 61 | 二是可以配置`"canAccessSuperData": true` 同时配置 `"strictMode": false` 开启此特性,如下,配置了该配置项后,界面值会自动更新。 62 | 63 | https://baidu.github.io/amis/zh-CN/components/form/input-table#%E8%8E%B7%E5%8F%96%E7%88%B6%E7%BA%A7%E6%95%B0%E6%8D%AE 64 | 65 | 方法二使用起来有点异常,有些数据会更新失败。需要手动更新行项目触发更新。 66 | -------------------------------------------------------------------------------- /docs/Admin-App/Amis/amis与yao集成.md: -------------------------------------------------------------------------------- 1 | # amis 与 yao 集成 2 | 3 | yao 作为 api 后端,给 amis 提供数据,amis 作为前端,使用 amis-editor 设计前端页面,快速开发。 4 | 5 | 集成分两部分: 6 | 7 | - amis-editor 设计器与 yao 集成开发 8 | - amis 与 yao 后端 api 集成开发 9 | 10 | ## amis-editor 设计器与 yao 集成开发 11 | 12 | 这部分的集成功能有: 13 | 14 | - yao 提供 amis-设计器登陆认证接口 15 | - yao 提供 amis 设计器生成的源代码读取与保存接口 16 | 17 | 源代码的读取与保存使用了 yao 的自定义 widget 功能,可以把 amis 页面的源代码保存到数据库表中,并且缓存在 yao 的应用中。 18 | 参考:[自定义 wdiget](../../YaoDSL/Widget/%E8%87%AA%E5%AE%9A%E4%B9%89Widget%E5%8D%87%E7%BA%A7%E7%89%88.md) 19 | 20 | ## amis 应用与 yao 集成开发 21 | 22 | 这部分集成功能有: 23 | 24 | - yao 提供用户登录认证接口 25 | - yao 提供数据 CURD 接口 26 | 27 | ## API 接口适配 28 | 29 | amis对后端api接口是有返回格式要求的,而yao提供的api接口返回格式并不直接适配amis的要求。对接的第一步是进行api接口适配。针对单个接口,在amis中可以使用adopter进行处理,但是大量的接口就不合适了,amis提供了另外一个机制来处理,就是自定义fetcher函数,这个函数设置在amis初始的环境变量中,所有的amis请求都会使用。通过自定义fetcher可以全局的处理api请求与返回数据。 30 | 具体请看:[fetcher](%E9%80%82%E9%85%8Dyao%E7%9A%84fetcher.md) 31 | 32 | ## 用户登录认证 33 | 34 | 另外一个适配是集成在amis中接入yao的用户登录功能,因为在yao中很多内置的接口都是需要进行登录认证的,需要先登录后获取后端生成的token,保存在浏览器里。处理流程: 35 | - 制造一个登录页面,在登录页面里获取后端的验证码图片。 36 | - 提供用户信息与验证码给yao,返回token。 37 | - 把token保存在浏览器本地,在测试项目中把token写在cookie里,并设置有效时间,这样处理的好处是,cookie到期后会自动消失,可以简单的判断,然后如果不存在直接跳转到登录页面。 38 | - 在自定义fetcher里读取本地token,api请求时会自动的附加上token。 39 | 40 | ## 项目地址: 41 | 42 | - yao 后端应用:https://github.com/wwsheng009/yao-amis-admin 43 | - amis 设计器:https://github.com/wwsheng009/amis-editor-yao 44 | -------------------------------------------------------------------------------- /docs/Admin-App/Amis/amis关键字.md: -------------------------------------------------------------------------------- 1 | # amis 关键字列表 2 | 3 | `items` 返回数组时的标识,不要使用这个名称作表字段等。 4 | 5 | `length` 避免在表中使用这个单词作表字段。会影响 input-table 的 setValue 操作。 6 | -------------------------------------------------------------------------------- /docs/Admin-App/Amis/dialog组件.md: -------------------------------------------------------------------------------- 1 | # dialog 组件 2 | 3 | amis dialog 组件在点击确认时会触发 onConfirm 事件,可以通过该事件来获取用户输入的数据。 4 | 5 | ```jsx 6 | onConfirm(values, rawAction || action, ctx, targets); 7 | ``` 8 | 9 | //其中 values 是一个数组,包含了 dialog 内部所有的组件的值。比如以下的组件,返回的 values 将是一个数组:`[{"label":"","path":"name"}]` 10 | 11 | ```json 12 | { 13 | type: 'dialog', 14 | title: '新增页面', 15 | body: { 16 | type: 'form', 17 | controls: [ 18 | { 19 | type: 'text', 20 | label: '名称', 21 | name: 'label', 22 | validations: { 23 | maxLength: 20 24 | }, 25 | required: true 26 | }, 27 | 28 | { 29 | type: 'text', 30 | label: '路径', 31 | name: 'path', 32 | validations: { 33 | isUrlPath: true 34 | }, 35 | required: true, 36 | validate(values: any, value: string) { 37 | const exists = !!values.pages.filter( 38 | (item: any) => item.path === value 39 | ).length; 40 | return exists ? '当前路径已被占用,请换一个' : ''; 41 | } 42 | }, 43 | { 44 | type: 'icon-picker', 45 | label: '图标', 46 | name: 'icon' 47 | } 48 | ] 49 | } 50 | } 51 | ``` 52 | -------------------------------------------------------------------------------- /docs/Admin-App/Amis/font-awesome.md: -------------------------------------------------------------------------------- 1 | # fontawesome 字体 2 | 3 | fontawesome 的字体有不同的版本,不同的版本可以通过前缀来区分。 4 | 5 | ## 版本 4 前缀 6 | 7 | - fa,对于版本 5 之前的所有 Font Awesome 版本,fa 是唯一用作所有图标的第一个类的类。它是 Font Awesome 的缩写形式。fa 类在 Font Awesome 版本 5 中被弃用。 8 | 9 | ## 版本 5 前缀 10 | 11 | 在版本 5 中,字体类型有:fab, fad, fal, far, fas。 12 | 13 | - fas,fas 类中的 s 代表固体。所有以 fas 为第一类的字体真棒图标都具有坚实的风格。顾名思义,实心图标是粗体的,分配的颜色占据了图标设计的大部分,而不是它们的对应(空心/轮廓)图标。与其他样式相比,实心图标是最明显、最响亮和最容易识别的。 14 | 15 | - fab,b 表示品牌,fab 类用于添加/显示品牌的图标。品牌图标在大多数情况下是公司的徽标。它们也可用于表示产品或服务。 16 | 17 | - fad,fad 中的 d 代表双色调 duotone。双色调图标由主层和辅助层组成,它们是相同颜色的阴影。 18 | 19 | - far,far 类中的 r 代表常规。常规图标在设计中勾勒,并通过矢量笔划创建。它们内部是空的/空的。它们通常与实心图标相反,空心/空白空间占据了大部分图标空间。这些图标的轮廓是平均厚度/宽度:不要太粗也不要太薄。 20 | 21 | - fal,fal 类中的 l 代表 light。浅色图标对于常规图标非常常见,但顾名思义,它们更亮。 22 | 23 | ## 在版本 6 中,字体类型前缀为: 24 | 25 | - fab <=> fa-brands 26 | - fad <=> fa-duotone 27 | - fal <=> fa-light 28 | - far <=> fa-regular 29 | - fas <=> fa-solid 30 | - 新增类型:fa-thin 31 | -------------------------------------------------------------------------------- /docs/Admin-App/Amis/index.md: -------------------------------------------------------------------------------- 1 | # Amis 2 | 3 | 4 | 5 | - [表单控件列表](表单控件列表.md) 6 | - [表达式](表达式.md) 7 | - [弹出框的两种方式](弹出框的两种方式.md) 8 | - [控件字段状态的几状方法](控件字段状态的几状方法.md) 9 | - [使用amis需要注意的地方](使用amis需要注意的地方.md) 10 | - [事件动作中的reload](事件动作中的reload.md) 11 | - [适配yao的fetcher](适配yao的fetcher.md) 12 | - [双层弹窗获取数据](双层弹窗获取数据.md) 13 | - [文件分块上传](文件分块上传.md) 14 | - [样式修改](样式修改.md) 15 | - [引用query参数](引用query参数.md) 16 | - [自定义事件检查](自定义事件检查.md) 17 | - [组件事件刷新reload](组件事件刷新reload.md) 18 | - [组件查找逻辑](组件查找逻辑.md) 19 | - [amis fetcher的工作原理](amis%20fetcher的工作原理.md) 20 | - [amis与yao集成](amis与yao集成.md) 21 | - [amis关键字](amis关键字.md) 22 | - [dialog组件](dialog组件.md) 23 | - [font-awesome](font-awesome.md) 24 | - [InputTable的数据更新](InputTable的数据更新.md) 25 | - [js写入登录cookie](js写入登录cookie.md) 26 | - [propsTransform](propsTransform.md) 27 | - [Select控件联动](Select控件联动.md) 28 | 29 | -------------------------------------------------------------------------------- /docs/Admin-App/Amis/propsTransform.md: -------------------------------------------------------------------------------- 1 | # propsTransform 属性 2 | 3 | amis 在渲染一个控件时如果传入一个 propsTransform 函数,则会调用该函数,并将控件的 props 作为参数传入。可以用来做一些 props 的变换。 4 | 5 | 比如以下代码就是一个 propsTransform 函数,功能是进行一个属性格式的转换,onConfirm 是用户编写的回调函数,其它的都是 props,amis 框架会在合适的时机调用这个函数,返回新的属性值。 6 | 7 | ```js 8 | ({ onConfirm, pages, ...rest }: any) => { 9 | return { 10 | ...rest, 11 | data: { 12 | pages, 13 | }, 14 | onConfirm: (values: Array) => onConfirm && onConfirm(values[0]), 15 | }; 16 | }; 17 | ``` 18 | -------------------------------------------------------------------------------- /docs/Admin-App/Amis/使用amis需要注意的地方.md: -------------------------------------------------------------------------------- 1 | # amis 需要注意的地方 2 | 3 | ## api 接口规范 4 | 5 | 如果不是使用动态列,不要在接口中返回 columns 字段,这个`columns`字段是可以作为 crud 控件的动态配置项。 6 | 7 | crud 的数据接口同时返回 items 与 columns 数组,可以快速实现动态列,colunns 是列配置。 8 | -------------------------------------------------------------------------------- /docs/Admin-App/Amis/引用query参数.md: -------------------------------------------------------------------------------- 1 | ## 引用 url 中的 query 参数 2 | 3 | 如果需要在页面中引用 `url` 中的 `query` 参数,需要在 `page` 页面的 `body` 中的页面引用。不能把`__query`引用放在`page`的级别,要不然会显示`model`等于原字符串`${__query.model}`,而不是解析后的变量。 4 | 5 | 比如下面的中的引用方式: 6 | 7 | ```json 8 | { 9 | "data": { 10 | "model": "${__query.model}" 11 | } 12 | } 13 | ``` 14 | 15 | 正确的方法,会引用`http://localhosts:5099/xxx?model=goods`中的`goods` 16 | 17 | ```json 18 | { 19 | "type": "page", 20 | "body": [ 21 | { 22 | "data": { 23 | "model": "${__query.model}" 24 | }, 25 | "schemaApi": { 26 | "url": "/api/v1/system/schema/${model}/crud-all", 27 | "method": "get", 28 | "sendOn": "!!model" 29 | }, 30 | "name": "model", 31 | "initFetchSchema": true, 32 | "type": "service", 33 | "body": [], 34 | "id": "u:5ce017fa279d", 35 | "messages": {} 36 | } 37 | ], 38 | "id": "u:568b02cd6929" 39 | } 40 | ``` 41 | 42 | 错误的方法,`model`等于它的字面量`${__query.model}` 43 | 44 | ```json 45 | { 46 | "type": "page", 47 | "data": { 48 | "model": "${__query.model}" 49 | }, 50 | "body": [ 51 | { 52 | "schemaApi": { 53 | "url": "/api/v1/system/schema/${model}/crud-all", 54 | "method": "get", 55 | "sendOn": "!!model" 56 | }, 57 | "name": "model", 58 | "initFetchSchema": true, 59 | "type": "service", 60 | "body": [], 61 | "id": "u:5ce017fa279d", 62 | "messages": {} 63 | } 64 | ], 65 | "id": "u:568b02cd6929" 66 | } 67 | ``` 68 | 69 | 另外也可以使用`parmas`引用`url`中的参数,比如路由配置的是`/xxx/models/create/:id`,可以使用`params.id`引用`http://localhosts:5099/xxx/models/create/mymodel`中的`mymodel`。 70 | 71 | ```json 72 | { 73 | "data": "${parmas.id}" 74 | } 75 | ``` 76 | -------------------------------------------------------------------------------- /docs/Admin-App/Amis/文件分块上传.md: -------------------------------------------------------------------------------- 1 | # 文件分块上传 2 | 3 | Gou 库增强: 4 | 5 | Yao 本身已经实现了大部分的文件上传下载管理功能,为了实现分段分块上传,额外需要一个文件合并的功能: 6 | 7 | 代码增强如下: 8 | 9 | https://github.com/wwsheng009/gou/commit/bfefea81c0d4ea5048de4cd6b72a6a0005b0fdfe 10 | 11 | Amis 库作为前端已经包含了分块分段功能:[分块上传](https://aisuda.bce.baidu.com/amis/zh-CN/components/form/input-file#%E5%88%86%E5%9D%97%E4%B8%8A%E4%BC%A0) 12 | 13 | 使用 Amis 作为前端,只要按文档配置相关的 api 即可。 14 | 15 | Amis-admin 增加相关的处理器功能: 16 | 17 | https://github.com/wwsheng009/yao-amis-admin/commit/a0861da579938eb0570fb45961b0f2dcb2068cbd 18 | 19 | 参考: 20 | 21 | - https://juejin.cn/post/6844904159372656654 22 | - https://github.com/Strangeralonel/practice 23 | -------------------------------------------------------------------------------- /docs/Admin-App/Amis/自定义事件检查.md: -------------------------------------------------------------------------------- 1 | # 使用自定义事件修改/检查表数据 2 | 3 | 事件配置 4 | 5 | ```json 6 | { 7 | "type": "page", 8 | "body": { 9 | "type": "form", 10 | "api": "/amis/api/mock2/form/saveForm", 11 | "data": { 12 | "table": [ 13 | { 14 | "id": 1, 15 | "a": "a1", 16 | "b": "b1" 17 | } 18 | ] 19 | }, 20 | "body": [ 21 | { 22 | "showIndex": true, 23 | "type": "input-table", 24 | "name": "table", 25 | "columns": [ 26 | { 27 | "name": "a", 28 | "label": "A" 29 | }, 30 | { 31 | "name": "b", 32 | "label": "B" 33 | } 34 | ], 35 | "addable": true, 36 | "onEvent": { 37 | "change": { 38 | "actions": [ 39 | { 40 | "actionType": "custom", 41 | "script": "debugger;" 42 | }, 43 | { 44 | "actionType": "toast", 45 | "args": { 46 | "msgType": "info", 47 | "position": "top-right", 48 | "title": "change事件", 49 | "msg": "value: ${event.data.value | json}" 50 | } 51 | } 52 | ] 53 | } 54 | } 55 | } 56 | ] 57 | } 58 | } 59 | ``` 60 | 61 | 具体脚本: 62 | 63 | ```js 64 | let newItems = JSON.parse(JSON.stringify(event.data.InvPurchaseItems)); 65 | newItems.forEach(function (item) { 66 | if (item.InStockQty < item.PurchaseQty) { 67 | item.InStockQty = item.PurchaseQty; 68 | } 69 | }); 70 | 71 | doAction({ 72 | actionType: 'setValue', 73 | componentId: 'inputtable', 74 | args: { 75 | value: newItems 76 | } 77 | }); 78 | ``` 79 | -------------------------------------------------------------------------------- /docs/Admin-App/amis-admin/images/odata/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/amis-admin/images/odata/1.png -------------------------------------------------------------------------------- /docs/Admin-App/amis-admin/images/odata/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/amis-admin/images/odata/10.png -------------------------------------------------------------------------------- /docs/Admin-App/amis-admin/images/odata/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/amis-admin/images/odata/11.png -------------------------------------------------------------------------------- /docs/Admin-App/amis-admin/images/odata/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/amis-admin/images/odata/2.png -------------------------------------------------------------------------------- /docs/Admin-App/amis-admin/images/odata/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/amis-admin/images/odata/3.png -------------------------------------------------------------------------------- /docs/Admin-App/amis-admin/images/odata/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/amis-admin/images/odata/4.png -------------------------------------------------------------------------------- /docs/Admin-App/amis-admin/images/odata/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/amis-admin/images/odata/5.png -------------------------------------------------------------------------------- /docs/Admin-App/amis-admin/images/odata/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/amis-admin/images/odata/6.png -------------------------------------------------------------------------------- /docs/Admin-App/amis-admin/images/odata/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/amis-admin/images/odata/7.png -------------------------------------------------------------------------------- /docs/Admin-App/amis-admin/images/odata/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/amis-admin/images/odata/8.png -------------------------------------------------------------------------------- /docs/Admin-App/amis-admin/images/odata/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/amis-admin/images/odata/9.png -------------------------------------------------------------------------------- /docs/Admin-App/amis-admin/index.md: -------------------------------------------------------------------------------- 1 | # amis-admin 2 | 3 | 4 | 5 | - [yao-odata-excel](yao-odata-excel.md) 6 | 7 | -------------------------------------------------------------------------------- /docs/Admin-App/amis-yao-admin.md: -------------------------------------------------------------------------------- 1 | # amis-yao-admin 应用 2 | 3 | 基于 Yao 引擎,可以快速的开发管理后台应用。 4 | 5 | adis-yao-admin 是基于 amis sdk 前端与 yao 后台开发的一个后台管理应用。 6 | 7 | 它有以下功能: 8 | 9 | - Yao 模型管理,可以导入,导出 yao 的模型定义。 10 | - Amis Crud 界面代码生成。 11 | - Amis 页面编辑器集成。 12 | - Soy-Admin 与 yao/amis 集成。 13 | - 文件管理,可以上传下载文件。 14 | - 菜单管理,可以给用户分配不同的菜单。 15 | 16 | ## 使用请查看教程 17 | 18 | [教程](./%E6%95%99%E7%A8%8B/index.md) 19 | -------------------------------------------------------------------------------- /docs/Admin-App/index.md: -------------------------------------------------------------------------------- 1 | # Admin-App 2 | 3 | 4 | 5 | - [amis-yao-admin](amis-yao-admin.md) 6 | - [教程](教程/index) 7 | - [amis-admin](amis-admin/index) 8 | - [Amis](Amis/index) 9 | - [soybean-admin](soybean-admin/index) 10 | 11 | -------------------------------------------------------------------------------- /docs/Admin-App/soybean-admin/index.md: -------------------------------------------------------------------------------- 1 | # soybean-admin 2 | 3 | 4 | 5 | - [soybean-admin路由处理](soybean-admin路由处理.md) 6 | 7 | -------------------------------------------------------------------------------- /docs/Admin-App/教程/1项目介绍.md: -------------------------------------------------------------------------------- 1 | # 项目介绍 2 | 3 | 本项目的初衷是作一个能快速生成 crud 界面的管理后台。 4 | 5 | 选择 yao,是因为 yao 提供了很多基础的功能,比如多数据库适配,api 快速开发,js 脚本增强,模型元数据管理等,基本可以满足后端的需求。 6 | 7 | 选择 amis,是因为 amis 也是特别的针对于 crud 有专门的组件增强,同时也是使用 json 进行配置。更重要的是 amis 提供 sdk 的使用方式,可以构建大量的页面而不是需要作前端的构建,只需要有一个文件服务器或是 cdn 的方式进行布署即可。 8 | 9 | 这个项目解决以下的问题: 10 | 11 | - amis-sdk 与 yao 后端登录集成的问题。 12 | 13 | - 前后端 api 接口适配。 14 | 15 | - amis 编辑器与 yao 集成问题,可以在编辑器里编辑页面并保存到后端。 16 | -------------------------------------------------------------------------------- /docs/Admin-App/教程/3模型管理.md: -------------------------------------------------------------------------------- 1 | # 模型管理 2 | 3 | 这个项目的核心就是模型管理,也是元数据管理。 4 | 5 | 由模型配置驱动数据库,生成接口,还有界面配置。 6 | 7 | 在这个项目中,单独使用两个表来保存模型的元数据,ddic_model 与 ddic_model_column。 8 | 9 | ## 模型创建 10 | 11 | 模型创建有多种方式: 12 | 13 | - 手动创建 14 | - 导入模型 15 | 16 | ### 手动创建 17 | 18 | 使用管理员账号登录系统后,在管理端的右边找到模型维护下面的创建入口。 19 | 20 | - 在模型标识中输入模型名称 21 | - 在字段列表中创建模型的字段定义 22 | - 最后保存模型 23 | 24 | ![Alt text](./assets/model_interface.png) 25 | 26 | 在创建列的过程中除了手动一个个的创建外,还可以根据 json 数据导入列定义。 27 | 28 | ![Alt text](./assets/model_columns_import.png) 29 | 30 | 在弹出的对话框中,输入 json 数据,选择 json 类型,点击检查。在后端会解析 json 数据格式,并生成模型字段定义。当然这个会有一定的误差,可以根据实际情况再进行调整。 31 | 32 | 点击确认后会把字段列表插入模型中。 33 | 34 | ![Alt text](./assets/model_json_column_import.png) 35 | 36 | ### 自动创建 37 | 38 | 除了手动创建后,还可以把数据库中的表结构导入到系统或是,导入 yao 的 json 模型定义。 39 | 40 | 在导航栏中找到模型导入口,点击进去可以看到数据库中的表列表与模型列表。 41 | 42 | 可以有以下的操作: 43 | 44 | - 导入表结构,这里的表结构是指数据库表的结构,如果已经存在很表的结构,可以使用这个选项。这里导入会覆盖现在有的模型定义,表的定义信息一般会少于模型定义的信息,只建议在系统初始化时使用。 45 | 46 | - 导入本地模型,模型是指在 yao 应用目录 models 目录下创建的模型定义文件。 47 | 48 | ![Alt text](./assets/model_import.png) 49 | 50 | 另外在模型列表中,也可以直接导入 yao 模型源代码,或是一键导入本地模型。"导入系统模型"也是建议有系统初始化时使用。 51 | ![Alt text](./assets/model_import_yao.png) 52 | 53 | ## 模型更新 54 | 55 | 在模型更新界面,可以调整与模型相关的所有信息: 56 | 57 | - 模型关联表 58 | - 模型字段定义 59 | - 模型关联关系 60 | 61 | 在更多按钮中可以配置更详细的内容。 62 | ![Alt text](./assets/model_mantain.png) 63 | 64 | **注意**: 65 | 66 | - 在保存模型时,可以选择强制更新,这个选项会删除库表,重新创建表,会丢失数据。 67 | 68 | - 模型更新不会直接更新本地模型定义文件,只会更新数据库表的定义与内存的定义。如果需要更新本地文件,最好是通过"查看代码",把模型定义复制到本地文件。因为如果直接更新本地文件可能会破坏系统文件。 69 | -------------------------------------------------------------------------------- /docs/Admin-App/教程/4数据维护.md: -------------------------------------------------------------------------------- 1 | # 数据维护 2 | 3 | ## 统一维护 4 | 5 | 当模型被创建后,就可以直接维护表数据了。 6 | 7 | 在右边的导航上找到表数据管理入口。 8 | 9 | 在模型列表中选择模型。 10 | 11 | ![Alt text](./assets/table_maintain.png) 12 | 13 | 选择模型后,后端会根据模型定义自动的生成数据维护界面。 14 | 15 | 包含完整的增删改查功能。 16 | 17 | 如果有定义的多媒体或是文件,也是可以直接上传文件的。 18 | 19 | ![Alt text](./assets/table_maintain2.png) 20 | -------------------------------------------------------------------------------- /docs/Admin-App/教程/5代码生成.md: -------------------------------------------------------------------------------- 1 | # 代码生成 2 | 3 | 在上一步中的数据维护是一个统一的入口,相当于直接维护数据表。事实上的情况会比这个复杂,而且自动生成的界面也不能涵盖所有的控件。 4 | 5 | 另外一个处理方法是,根据模型生成的这些界面代码进一步的加工。 6 | 7 | 操作步骤: 8 | 9 | - 在 Studio 菜单中找到代码生成入口 10 | 11 | - 选择模型 12 | - 选择模板,这里的模板可以定制更多 13 | - 配置字段,可以进一步的配置字段,也可以过滤不需要的字段 14 | - 提交,生成代码 15 | 16 | ![Alt text](./assets/studio_code.png) 17 | 18 | 比如这里的模板 "增删除改查-所有" 就是上一步数据维护中的页面配置源代码。 19 | 20 | 可以根据实际的需要进一步的调整页面配置。 21 | 22 | 把源代码复制出来,保存成一个 amis 的配置文件,比如是"demo.json",放在`/data/pages`目录后,再刷新页面就可以直接使用了。 23 | 24 | 右边的"AMIS 页面"菜单就是映射到应用目录下的`/data/pages`目录。 25 | 26 | ![Alt text](./assets/amis_menu_tree_demo.png) 27 | -------------------------------------------------------------------------------- /docs/Admin-App/教程/6页面编辑器.md: -------------------------------------------------------------------------------- 1 | # 页面编辑器 2 | 3 | Amis 项目已经提供了一个 demo 的编辑器应用,用户可以使用编辑器进行图形化的页面设计。 4 | 5 | 本项目在 amis 编辑器的项目的基础上作了一些增强。 6 | 7 | - 把编辑器接口调用集成到 yao-admin 中,用户可以在编辑器调用所有的 yao 后端接口。 8 | 9 | - 在编辑器上创建的页面保存到 yao-admin 后端。即创建好页面后可以直接在 yao-admin 中使用。 10 | 11 | ## 安装 12 | 13 | 页面编辑器的项目作为 yao-admin 项目的可选项,需要额外的安装。 14 | 15 | 项目地址:[amis-editor-yao](https://github.com/wwsheng009/amis-editor-yao) 16 | 17 | **注意,不要使用 yarn 或是 pnpm** 18 | 19 | ```sh 20 | npm i 21 | 22 | # 开发 23 | npm run dev 24 | 25 | # 发布 26 | npm run build 27 | ``` 28 | 29 | 项目支持开发时或是发布后使用,项目编译好后把`amis-editor`目录放在 yao-admin 的 public 目录下即可。 30 | 31 | ## 登录 32 | 33 | 通过网站`http://localhost:5099/amis-editor/#/`访问页面编辑器。 34 | 35 | 如果不是通过 yao-admin 调用访问需要登录认证。 36 | 37 | ## 使用 38 | 39 | ### 使用场景一 40 | 41 | 生成模型的 crud 页面。 42 | 43 | 先在 yao-admin 中创建模型。模型创建后就可以看到模型相关的 api 列表。 44 | 45 | 在 api 列表中,有一个特别的接口。`/api/v1/system/model//preview`,比如`/api/v1/system/model/admin.user/preview` 46 | 47 | 这个接口专门用于在 amis 设计器里生成 crud 页面,如果表里没有数据,会生成一条模拟数据。在这里复制 api 接口地址。 48 | 49 | ![Alt text](./assets/model_api_list.png) 50 | 51 | 创建一个空白的页面,拖入增删改查组件 52 | 53 | ![Alt text](./assets/editor-crud-01.png) 54 | 55 | 在弹出的页面上输入刚才的接口地址 56 | 57 | 点击"格式校验并自动生成列配置",会自动生成 crud 字段配置。再根据实际情况调整各个字段配置。 58 | 59 | ![Alt text](./assets/editor-crud-02.png) 60 | 61 | 最后进行预览,保存页面。 62 | 63 | ![Alt text](./assets/editor-crud-03.png) 64 | 65 | 保存的页面会保存在 amis-yao 应用的后端`/data/amis_editor`目录下。 66 | 67 | 如果 yao-admin 使用的超级管理员登录。可以右边的菜单上"AMIS 编辑器"下面看到创建的页面。 68 | 69 | 最后调整 crud 组件的 url 接口配置,替换成实际的接口。 70 | 71 | ### 使用场景二 72 | 73 | 基于 yao-admin 管理端生成的页面,再进一步的作调整。 74 | 75 | 使用代码生成功能,生成 amis 页面源代码。复制到页面编辑器的源代码区域。再根据实际需求进行修正,调整。 76 | 77 | ![Alt text](./assets/studio_code.png) 78 | 79 | ## 建议 80 | 81 | 在不熟悉 amis 的组件或是 api 的情况下,可以使用页面编辑器进行页面创建。熟悉后,直接编辑页面文件反而会更快。 82 | -------------------------------------------------------------------------------- /docs/Admin-App/教程/assets/amis_menu_tree_demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/教程/assets/amis_menu_tree_demo.png -------------------------------------------------------------------------------- /docs/Admin-App/教程/assets/editor-crud-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/教程/assets/editor-crud-01.png -------------------------------------------------------------------------------- /docs/Admin-App/教程/assets/editor-crud-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/教程/assets/editor-crud-02.png -------------------------------------------------------------------------------- /docs/Admin-App/教程/assets/editor-crud-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/教程/assets/editor-crud-03.png -------------------------------------------------------------------------------- /docs/Admin-App/教程/assets/model_api_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/教程/assets/model_api_list.png -------------------------------------------------------------------------------- /docs/Admin-App/教程/assets/model_columns_import.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/教程/assets/model_columns_import.png -------------------------------------------------------------------------------- /docs/Admin-App/教程/assets/model_import.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/教程/assets/model_import.png -------------------------------------------------------------------------------- /docs/Admin-App/教程/assets/model_import_yao.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/教程/assets/model_import_yao.png -------------------------------------------------------------------------------- /docs/Admin-App/教程/assets/model_interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/教程/assets/model_interface.png -------------------------------------------------------------------------------- /docs/Admin-App/教程/assets/model_json_column_import.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/教程/assets/model_json_column_import.png -------------------------------------------------------------------------------- /docs/Admin-App/教程/assets/model_mantain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/教程/assets/model_mantain.png -------------------------------------------------------------------------------- /docs/Admin-App/教程/assets/studio_code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/教程/assets/studio_code.png -------------------------------------------------------------------------------- /docs/Admin-App/教程/assets/table_maintain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/教程/assets/table_maintain.png -------------------------------------------------------------------------------- /docs/Admin-App/教程/assets/table_maintain2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/Admin-App/教程/assets/table_maintain2.png -------------------------------------------------------------------------------- /docs/Admin-App/教程/index.md: -------------------------------------------------------------------------------- 1 | # 教程 2 | 3 | 4 | 5 | - [1项目介绍](1项目介绍.md) 6 | - [2项目安装](2项目安装.md) 7 | - [3模型管理](3模型管理.md) 8 | - [4数据维护](4数据维护.md) 9 | - [5代码生成](5代码生成.md) 10 | - [6页面编辑器](6页面编辑器.md) 11 | 12 | -------------------------------------------------------------------------------- /docs/Studio/Yao-admin/index.md: -------------------------------------------------------------------------------- 1 | # Yao-admin 2 | 3 | 4 | 5 | - [yao-admin 根据数据库生成管理后台](yao-admin%20根据数据库生成管理后台.md) 6 | - [yao-admin 的前提条件](yao-admin%20的前提条件.md) 7 | 8 | -------------------------------------------------------------------------------- /docs/Studio/Yao-admin/yao-admin 的前提条件.md: -------------------------------------------------------------------------------- 1 | # yao-admin 的前提条件 2 | 3 | 使用 yao-admin 需要满足以下前提条件: 4 | 5 | - 数据库表的名称需要有规范,表名中的单词需要以下划线隔开,下划线会转换成 yao 模型名称中的点号,作为命名空间的一部分。比如说有数据库中有一张表的名称是"litemall_coupon_user",转换成模型文件的名称是`/litemall/coupon/user.mod.json`,它在 yao 的应用中的引用 ID 名称为`litemall.coupon.user`。 6 | 7 | - 表前缀判断,程序会尝试使用所有表名中第一个下划之前的名称作为表前缀,比如表名`litemall_goods`的前缀是`litemall`. 8 | 9 | - 数据库表需要有主键字段 id,并且作为自增 ID。id 作为表主键更多的是一种通用的规范约束,这个字段在 yao 中也会转换成类型为 id 的模型字段。 10 | 11 | - 外键字段的名称需要以 \_id 作为后缀,按照这个约定,仅从表名与字段名就可以分析出多个表之间的关联关系。比如在表`litemall_coupon_user`就有三个字段带有`_id`后缀:`user_id`与`coupon_id`,`order_id`。程序会尝试查找表`litemall_user`,`litemall_coupon`,`litemall_order`,并生成合适的表与表之前的关联关系。 12 | -------------------------------------------------------------------------------- /docs/Studio/index.md: -------------------------------------------------------------------------------- 1 | # Studio 2 | 3 | 4 | 5 | - [编辑器vscode智能提示](编辑器vscode智能提示.md) 6 | - [如何修改管理员用户密码](如何修改管理员用户密码.md) 7 | - [自动生成table_form定义文件](自动生成table_form定义文件.md) 8 | - [vscode调试yao](vscode调试yao.md) 9 | - [yao run 命令中的特殊字符](yao%20run%20命令中的特殊字符.md) 10 | - [Yao Studio介绍](Yao%20Studio介绍.md) 11 | - [Yao-admin](Yao-admin/index) 12 | 13 | -------------------------------------------------------------------------------- /docs/Studio/yao run 命令中的特殊字符.md: -------------------------------------------------------------------------------- 1 | # yao run 命令中的特殊字符 2 | 3 | 在使用 yao 的过程中,会频繁的使用到一个`yao run`的命令。这个命令用于执行 Yao 中定义的各种处理器,包括模型操作、API 调用等。 4 | 5 | ## 基本语法 6 | 7 | ```sh 8 | yao run <处理器名称> [参数1] [参数2] ... 9 | ``` 10 | 11 | ## JSON 参数的使用 12 | 13 | 在这些命令中最常见的一个字符串是`::`,其中的`::`表示`yao run`命令的参数的类型是`json`格式,需要按`json`的格式输入数据。 14 | 15 | ### 常见示例 16 | 17 | 1. 新增一条数据 18 | 19 | ```sh 20 | yao run models.pet.Create '::{ "sn":"200001", "name":"球球", "type":"狗", "desc":"新成员" }' 21 | ``` 22 | 23 | 2. 更新一条数据 24 | 25 | ```sh 26 | yao run models.pet.Update 1 '::{ "desc":"一只可爱的三色猫" }' 27 | ``` 28 | 29 | 3. 保存一条数据(指定主键则更新,不指定则创建) 30 | 31 | ```sh 32 | yao run models.pet.Save '::{ "sn":"200002", "name":"天狼", "type":"狗", "desc":"新成员" }' 33 | yao run models.pet.Save '::{ "id":1, "desc":"一只可爱的三色猫" }' 34 | ``` 35 | 36 | ## 转义字符的使用 37 | 38 | 如果你需要在参数中使用`::`作为普通字符串,而不是作为 JSON 标识符,可以使用`\::`进行转义。 39 | 40 | ```sh 41 | yao run scripts.test.Print '\::这是一个普通字符串' 42 | ``` 43 | 44 | ## 源代码解析 45 | 46 | 在 Yao 的源代码中(`/yao/source/yao/cmd/run.go`),对参数的处理逻辑如下: 47 | 48 | ```go 49 | // 解析参数 50 | if strings.HasPrefix(arg, "::") { 51 | arg := strings.TrimPrefix(arg, "::") 52 | var v interface{} 53 | err := jsoniter.Unmarshal([]byte(arg), &v) 54 | if err != nil { 55 | fmt.Println(color.RedString(L("Arguments: %s"), err.Error())) 56 | return 57 | } 58 | pargs = append(pargs, v) 59 | fmt.Println(color.WhiteString("args[%d]: %s", i-1, arg)) 60 | } else if strings.HasPrefix(arg, "\\::") { 61 | arg := "::" + strings.TrimPrefix(arg, "\\::") 62 | pargs = append(pargs, arg) 63 | fmt.Println(color.WhiteString("args[%d]: %s", i-1, arg)) 64 | } else { 65 | pargs = append(pargs, arg) 66 | fmt.Println(color.WhiteString("args[%d]: %s", i-1, arg)) 67 | } 68 | ``` 69 | 70 | ## 常见问题 71 | 72 | 1. JSON 格式错误 73 | 74 | - 确保 JSON 字符串格式正确,特别是引号的使用 75 | - 在 Windows 命令行中,可能需要使用转义字符 76 | 77 | 2. 特殊字符处理 78 | - 如果 JSON 中包含特殊字符,确保正确转义 79 | - 在 Windows 环境下,可能需要使用双引号包裹整个命令 80 | 81 | ## 最佳实践 82 | 83 | 1. 使用单引号包裹 JSON 字符串 84 | 2. 保持 JSON 格式的整洁和可读性 85 | 3. 在复杂的 JSON 数据结构中,建议先将数据保存在文件中,然后使用文件读取的方式执行命令 86 | -------------------------------------------------------------------------------- /docs/Studio/如何修改管理员用户密码.md: -------------------------------------------------------------------------------- 1 | # 如何修改管理员用户密码 2 | 3 | 把[`init.js`](https://github.com/wwsheng009/yao-init/blob/main/studio/init.js)脚本复制到项目应用的`studio`目录。 4 | 5 | `Yao`框架中自带了一个用户管理模型`xiang.user`。使用`studio`脚本快速生成模型的管理页面 6 | 7 | 执行命令,生成`Form`与`Table`最小化配置。 8 | 9 | ```sh 10 | yao studio run init.CreateTableAndForm xiang.user 11 | ``` 12 | 13 | 再次执行命令,更新`Form`,增加保存按钮。 14 | 15 | ```sh 16 | yao studio run init.CreateTableAndForm xiang.user 17 | 18 | mv forms/xiang/user.form.default.json forms/xiang/user.form.json 19 | ``` 20 | 21 | - 查看 xiang.user 22 | 23 | - 修改 xiang.user 24 | -------------------------------------------------------------------------------- /docs/Studio/编辑器vscode智能提示.md: -------------------------------------------------------------------------------- 1 | # 编辑器`vscode`智能提示 2 | 3 | 编辑器智能提示使用另外一个项目作支撑: 4 | https://github.com/wwsheng009/yao-app-ts-types 5 | 6 | ```sh 7 | mkdir .vscode 8 | wget https://raw.githubusercontent.com/wwsheng009/yao-app-ts-types/main/.vscode/settings-online.json -O .vscode/settings.json 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/Studio/自动生成table_form定义文件.md: -------------------------------------------------------------------------------- 1 | # 自动的生成 form/table 定义文件 2 | 3 | ## 下载工具脚本 4 | 5 | 请把工具脚本[`init.js`](https://github.com/wwsheng009/yao-init/blob/main/studio/init.js)脚本复制到`Yao`应用的`scripts`目录下。 6 | 7 | ```sh 8 | wget -O scripts/init.js https://raw.githubusercontent.com/wwsheng009/yao-init/main/studio/init.js 9 | ``` 10 | 11 | ## 使用脚本 12 | 13 | 使用脚本生成模型对应的界面配置文件。 14 | 15 | ### 生成最小化配置 16 | 17 | 首先生成最小化配置文件: 18 | 19 | ```sh 20 | yao run scripts.init.CreateTable material 21 | yao run scripts.init.CreateForm material 22 | ``` 23 | 24 | 执行后会生成以下文件: 25 | 26 | - `tables/material.tab.json`:表格的最小化配置文件 27 | - `forms/material.form.json`:表单的最小化配置文件 28 | 29 | 最小化配置的特点: 30 | 31 | - 只包含最基本的配置信息,其他配置由 Yao 框架在运行时自动生成 32 | - 适合开发阶段使用,对模型的修改能实时在管理界面上预览 33 | - 配置文件结构简单,易于理解和维护 34 | - 注意:最小化配置的 Form 可能缺少一些功能按钮(如保存按钮) 35 | 36 | ### 生成全量配置 37 | 38 | 如果需要更细致的界面定制,可以再次执行相同的命令生成全量配置: 39 | 40 | ```sh 41 | yao run scripts.init.CreateTable material 42 | yao run scripts.init.CreateForm material 43 | ``` 44 | 45 | 执行后会生成以下文件: 46 | 47 | - `tables/material.tab.default.json`:表格的全量配置文件 48 | - `forms/material.form.default.json`:表单的全量配置文件 49 | 50 | 全量配置的特点: 51 | 52 | - 包含模型的所有可配置项 53 | - 可以进行精细化的界面调整 54 | - 配置固化在文件中,不依赖框架的默认行为 55 | - 适合生产环境使用 56 | 57 | ### 文件覆盖说明 58 | 59 | 如果模型对应的`table/form`定义文件已经存在,脚本不会覆盖现有的文件,而是直接生成全量配置文件(带.default 后缀)。这样可以保护你已经修改过的配置不被覆盖。 60 | 61 | ### 配置文件使用建议 62 | 63 | 1. 开发阶段: 64 | 65 | - 使用最小化配置,方便快速调试和预览 66 | - 可以频繁修改模型定义,界面会自动适应变化 67 | 68 | 2. 生产环境: 69 | 70 | - 建议使用全量配置 71 | - 确认配置无误后,将.default 文件的内容复制到正式配置文件中 72 | - 或直接将.default 文件重命名为正式配置文件 73 | 74 | 3. 配置迁移: 75 | 76 | ```sh 77 | # 方式1:手动复制内容 78 | # 从.default文件复制内容到正式配置文件 79 | 80 | # 方式2:重命名文件 81 | mv tables/material.tab.default.json tables/material.tab.json 82 | mv forms/material.form.default.json forms/material.form.json 83 | ``` 84 | 85 | ### 常见问题 86 | 87 | 1. 最小化配置缺少按钮: 88 | 89 | - 这是正常现象,可以切换到全量配置 90 | - 或手动添加需要的按钮配置 91 | 92 | 2. 配置文件不生效: 93 | 94 | - 检查文件名是否正确(.json 后缀) 95 | - 确认文件路径在正确的目录下(tables/forms) 96 | - 验证 JSON 格式是否正确 97 | 98 | 3. 模型变更后界面未更新: 99 | - 使用最小化配置时,尝试刷新浏览器 100 | - 使用全量配置时,需要手动更新配置文件 101 | -------------------------------------------------------------------------------- /docs/YaoDSL/AIGC/aigc处理器.md: -------------------------------------------------------------------------------- 1 | # aigc 处理器 2 | 3 | aigc 处理器是在 Yao 中实现的直接与 OpenAI 接口交互的处理器。通过配置 OpenAI 连接器与请求规则,可以将 OpenAI 接口转换成 Yao 处理器,从而与其它 Yao 功能无缝串联。 4 | 5 | ## 适用版本 6 | 7 | 0.10.3 或以上 8 | 9 | ## 主要功能 10 | 11 | - 支持多种 OpenAI 模型配置 12 | - 灵活的提示词系统 13 | - 环境变量配置,安全性高 14 | - 支持代理设置 15 | - 可与其他 Yao 功能集成 16 | 17 | ## 使用步骤 18 | 19 | 在connectors目录创建OpenAI 连接器配置文件。 20 | 21 | ## 配置 openai 请求规则 22 | 23 | 在 app 目录下创建`aigcs`子目录(如果不存在),在子目录下创建 ai 访问配置文件。 24 | 25 | 配置文件:`aigcs\translate.ai.yml` 26 | 27 | 这个示例使用了配置的 `gpt-3_5-turbo` 连接器。`prompts` 字段用于设置与 OpenAI 模型的初始化指令,不同模型可能需要不同格式的提示词。以下是一个翻译助手的配置示例,使用 GPT-3.5-Turbo 模型: 28 | 29 | ```yaml 30 | # Translate to English 31 | # yao run aigcs.translate 你好 32 | name: Translate 33 | connector: gpt-3_5-turbo 34 | prompts: 35 | - role: system 36 | content: | 37 | - Translate the given question into English. 38 | - Do not explain your answer, and do not use punctuation. 39 | - Do not add your own punctuation marks. 40 | - eg: if I say "你好" reply me "Hello" only 41 | 42 | optional: 43 | autopilot: true 44 | ``` 45 | 46 | ## 配置网络代理 47 | 48 | 如果无法直接访问 openai,可以在环境变量中配置网络代理。 49 | 50 | ```bash 51 | # https请求代理 52 | HTTPS_PROXY="http://0.0.0.0:10809" 53 | https_proxy="http://0.0.0.0:10809" 54 | 55 | # http请求代理 56 | HTTP_PROXY="http://0.0.0.0:10809" 57 | http_proxy="http://0.0.0.0:10809" 58 | ``` 59 | 60 | ## 测试 aigcs 处理器 61 | 62 | 处理器的固定前缀为`aigcs`,参数与处理器 ID 与其它 yao 处理器类似。 63 | 64 | aigc 处理器只适用于单个请求,对话功能需要使用 neo。 65 | 66 | ```sh 67 | yao run aigcs.translate 你好 68 | ``` 69 | 70 | ## openai 相关的其它处理器 71 | 72 | - openai.tiktoken 计算接口 token 73 | - openai.embeddings Embedding 接口 74 | - openai.chat.completions 聊天接口 75 | - openai.audio.transcriptions 语音翻译接口 76 | 77 | ## 测试代码 78 | 79 | 官方已提供了测试样例 80 | 81 | ```sh 82 | https://github.com/YaoApp/yao-dev-app 83 | ``` 84 | -------------------------------------------------------------------------------- /docs/YaoDSL/AIGC/index.md: -------------------------------------------------------------------------------- 1 | # AIGC 2 | 3 | 4 | 5 | - [aigc处理器](aigc处理器.md) 6 | - [chatgpt模型中角色的作用](chatgpt模型中角色的作用.md) 7 | - [openai处理器](openai处理器.md) 8 | 9 | -------------------------------------------------------------------------------- /docs/YaoDSL/AIGC/openai处理器.md: -------------------------------------------------------------------------------- 1 | # openai 处理器 2 | 3 | yao 内置了以下几个与 openai 相关的处理器: 4 | 5 | - openai.audio.transcriptions,转换文本成语音。 6 | - openai.chat.completions,聊天接口,支持异步 sse。 7 | - openai.embeddings,调用"text-embedding-ada-002",把文本转换成向量。 8 | - openai.tiktoken, 计算 token。 9 | 10 | ## 配置 openai 连接器 11 | 12 | 使用 openai 之前需要先配置连接器. 13 | 14 | 比如说需要在 connectors 目录下创建一个配置文件`gpt-3_5-turbo.conn.yao`. 15 | 16 | openai 连接器类型定义:`\gou\connector\openai\openai.go` 17 | 18 | ```json 19 | { 20 | "LANG": "1.0.0", 21 | "VERSION": "1.0.0", 22 | "label": "Model gpt-3.5-turbo", 23 | "type": "openai", //必须是openai 24 | "options": { 25 | "model": "gpt-3.5-turbo", //必填 26 | "key": "$ENV.OPENAI_TEST_KEY", //必填 27 | "Proxy": "" //可选配置,默认是https://api.openai.com,如果用了openai的代理网站,可以在这里配置, 28 | } 29 | } 30 | ``` 31 | 32 | ## 聊天处理器 33 | 34 | 处理器:`openai.chat.completions`。 35 | 36 | 使用聊天处理器可以快速方便的请求 openai 接口。并且处理器还支持异步调用,可以在 api 接口中应用。 37 | 38 | `yao\openai\process.go` 39 | 40 | ### 参数 41 | 42 | 至少要有两个参数 43 | 44 | - connector,connector 配置 id,类型 string 45 | - messages,消息,类型为 json 数组, 46 | - options,选项,类型为 json,可以加入 openai 模型的微调参数。 47 | - callback,回调函数,类型为 golang 函数或是 js 函数,回调函数的参数是返回的是聊天内容文本。如果存在回调函数,可以用于 ss 异步消息场景。 48 | 49 | [消息的格式说明](chatgpt%E6%A8%A1%E5%9E%8B%E4%B8%AD%E8%A7%92%E8%89%B2%E7%9A%84%E4%BD%9C%E7%94%A8.md) 50 | 51 | 处理器示例: 52 | 53 | ```js 54 | const connectorId = 'gpt-3_5-turbo'; 55 | 56 | const messages = [ 57 | { role: 'system', content: 'you are ai assistant' }, 58 | { role: 'user', content: 'Write an article about internet' } 59 | ]; 60 | const options = { max_tokens: 2 }; 61 | 62 | //方法一 63 | Process('openai.chat.completions', connectorId, messages); 64 | 65 | //方法二 66 | Process('openai.chat.completions', connectorId, messages, options); 67 | 68 | //方法三 69 | Process( 70 | 'openai.chat.completions', 71 | connectorId, 72 | message, 73 | options, 74 | function (chatMessage) { 75 | console.log('ai message:', chatMessage); 76 | 77 | ssEvent('messages', content); //如果在api接口处理中,可以使用ssEvent向api接口写入ss消息 78 | } 79 | ); 80 | ``` 81 | -------------------------------------------------------------------------------- /docs/YaoDSL/API/API引用上下文变量.md: -------------------------------------------------------------------------------- 1 | # 在 api 中使用变量引用上下文变量 2 | 3 | 在 api 中使用变量引用上下文变量 4 | 5 | ## 传入 API 接口中引用会话变量 6 | 7 | 在 api 接口定义中,在输入节点`in`的`params`节点中可以使用变量的方式引用传入参数,比如使用`$session`引用会话变量, 8 | 9 | ```json 10 | { 11 | "path": "/session/in", 12 | "method": "GET", 13 | "process": "models.user.Find", 14 | "in": ["$session.id", ":params"], 15 | "out": { 16 | "status": 200, 17 | "type": "application/json" 18 | } 19 | } 20 | ``` 21 | 22 | ## API 接口返回值中引用会话变量 23 | 24 | 在 api 接口定义中,在输出节点`out`的`headers`节点或是 `body`节点使用`{{}}`或是`?:`引用返回的对象, 25 | 26 | > 小技巧,通过在 gou 项目中查找 helper.Bind 方法的调用可以看到哪些代码可以使用变量绑定功能。 27 | 28 | 返回值绑定示例, 29 | 30 | 处理器`flows.user.info`返回一个 json 结构数据`{}` 31 | 32 | 在处理器中需要返回一个对象。 33 | 34 | ```js 35 | return { 36 | type: 'text/json', 37 | content: 'hello', 38 | agent: 'edge/chrome' 39 | }; 40 | ``` 41 | 42 | api 定义: 43 | 44 | ```json 45 | { 46 | "path": "/session/flow", 47 | "method": "GET", 48 | "process": "flows.user.info", 49 | "in": [], 50 | "out": { 51 | "status": 200, 52 | "headers": { 53 | "Content-Type": "{{type}}", //第一种绑定方法 54 | "User-Agent": "?:agent" //另外一种绑定方法 55 | }, 56 | "body": "{{content}}" //body 节点可以是任意类型,比如json对象,数组,嵌套的对象等 57 | } 58 | } 59 | ``` 60 | -------------------------------------------------------------------------------- /docs/YaoDSL/API/index.md: -------------------------------------------------------------------------------- 1 | # API 2 | 3 | 4 | 5 | - [超级用户权限](超级用户权限.md) 6 | - [定义YAO API](定义YAO%20API.md) 7 | - [配置Redis保存会话](配置Redis保存会话.md) 8 | - [刷新token](刷新token.md) 9 | - [文件上传下载接口](文件上传下载接口.md) 10 | - [自定义用户登陆login api](自定义用户登陆login%20api.md) 11 | - [API Guard](API%20Guard.md) 12 | - [API会话session保持](API会话session保持.md) 13 | - [API引用上下文变量](API引用上下文变量.md) 14 | - [API接口介绍](API接口介绍.md) 15 | - [API预定义变量](API预定义变量.md) 16 | - [service接口](service接口.md) 17 | - [stream api接口](stream%20api接口.md) 18 | - [stream http客户端请求](stream%20http客户端请求.md) 19 | 20 | -------------------------------------------------------------------------------- /docs/YaoDSL/API/service接口.md: -------------------------------------------------------------------------------- 1 | # Yao service 服务 API 2 | 3 | 在 app 的 services 目录下创建一个 js 文件。 4 | 5 | 比如新建文件:`schema.js`,在 js 中创建一个新的函数 getTables。 6 | 7 | ```js 8 | function getTables() { 9 | const list = Process('schemas.default.Tables'); 10 | const tables = list.map((table) => { 11 | return { item: table }; 12 | }); 13 | return { rows: tables }; 14 | } 15 | ``` 16 | 17 | service 服务的调用方法: 18 | 19 | 按照以下的请求格式来调用服务。 20 | 21 | ```sh 22 | # 跟studio的service不同,services不需要跨域 23 | curl -X POST http://127.0.0.1:5099/api/__yao/app/service/schema \ 24 | -H 'Content-Type: application/json' \ 25 | -H 'Authorization: Bearer ' \ 26 | -d '{ "args":[],"method":"getTables"}' 27 | ``` 28 | 29 | 服务的请求地址:`http://127.0.0.1:5099/api/__yao/app/service/` 这是固定的前缀,后面跟上自己定义的服务名`schema`。 30 | 31 | 请求方法是 post。 32 | 33 | 在 post 参数中按以下格式传入处理器的参数与方法。 34 | 35 | args 是指处理器的参数列表,按顺序进行传递,method 是指 schema.js 中的 js 函数名 36 | 37 | ```json 38 | { "args": [], "method": "getTables" } 39 | ``` 40 | 41 | ## 总结 42 | 43 | service 服务的优点: 44 | 45 | - 不需要创建新的 api 定义 46 | - 方便直接使用 yao 的处理器 47 | 48 | 缺点: 49 | 50 | - 只能使用 post 请求 51 | -------------------------------------------------------------------------------- /docs/YaoDSL/API/session/yao_session_flow中使用会话.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/YaoDSL/API/session/yao_session_flow中使用会话.jpg -------------------------------------------------------------------------------- /docs/YaoDSL/API/stream http客户端请求.md: -------------------------------------------------------------------------------- 1 | # yao http.Stream 处理器 2 | 3 | yao http.Stream 用于进行异步 sse 请求。 4 | 5 | ## 适用版本 6 | 7 | 0.10.3 或以上 8 | 9 | ## 使用方法 10 | 11 | 使用 处理器`http.Stream` 向服务端发出请求时需要进行异步响应处理。与其它 http 处理器不一样的地方在于第三个参数需要是一个回调函数(js 函数)。 12 | 13 | ```js 14 | http.Stream('POST', url, handler, RequestBody, null, { 15 | Accept: 'text/event-stream; charset=utf-8', 16 | 'Content-Type': 'application/json', 17 | Authorization: `Bearer ` + setting.api_token 18 | }); 19 | ``` 20 | 21 | 回调处理器,处理函数要与上面的请求函数在同一个 js 文件里。 22 | 23 | ```js 24 | function handler(payload) { 25 | const lines = payload.split('\n\n'); 26 | for (const line of lines) { 27 | if (line === '') { 28 | continue; 29 | } 30 | if (line === 'data: [DONE]') { 31 | return 0; 32 | } else if (line.startsWith('data:')) { 33 | const myString = line.substring(5); 34 | try { 35 | let message = JSON.parse(myString); 36 | if (message) { 37 | reply = message; 38 | let content = message.choices[0]?.delta?.content; 39 | // console.log(`content:${content}`); 40 | 41 | if (content) { 42 | g_message += content; 43 | collect(content); 44 | } 45 | } 46 | } catch (error) { 47 | ssEvent('errors', error.Error()); 48 | return -1; 49 | } 50 | } else { 51 | console.log('unexpected', line); 52 | } 53 | } 54 | //异常,返回-1 55 | //正常返回1,默认 56 | //中断返回0 57 | return 1; 58 | } 59 | ``` 60 | 61 | ## 示例代码 62 | 63 | yao-chatgpt 0.10.3 分支 64 | 65 | ```sh 66 | git clone https://github.com/wwsheng009/yao-chatgpt.git 67 | 68 | cd yao-chatgpt && git checkout 0.10.3 69 | ``` 70 | -------------------------------------------------------------------------------- /docs/YaoDSL/API/超级用户权限.md: -------------------------------------------------------------------------------- 1 | # 超级用户权限 2 | 3 | 在普通脚本中,通过设置全局变量,启用超级用户脚本权限,超级权限可以读写 dsl 文件目录。 4 | 5 | 权限很大,谨慎使用。 6 | 7 | ```js 8 | //0.10.3 9 | __yao_data = { ROOT: true }; 10 | 11 | const result = Studio('unit.test.process', 'foo', 99, 0.618); 12 | 13 | function WriteFile() { 14 | var fs = new FS('dsl'); 15 | return fs.WriteFile('%s', '%s', 0644); 16 | } 17 | ``` 18 | 19 | 读取超级用户权限 20 | 21 | ```js 22 | return { 23 | ...result, 24 | __yao_global: __yao_data['DATA'], //全局数据,等于res["Global"] 25 | __yao_sid: __yao_data['SID'], //等于res["Sid"] 26 | __YAO_SU_ROOT: __yao_data['ROOT'] //是否超级权限 27 | }; 28 | ``` 29 | -------------------------------------------------------------------------------- /docs/YaoDSL/API/配置Redis保存会话.md: -------------------------------------------------------------------------------- 1 | # 配置 Redis 保持会话 2 | 3 | Yao 默认是把会话保存在 yao 的内存中的。当服务重启后,会话信息会丢失,可以使用 redis 保存会话。 4 | 5 | 在 yao 中配置 reids 需要调用环境变量文件.env。 6 | 7 | 主要是把配置项 YAO_SESSION_STORE 从`redis`修改成`redis`。 8 | 9 | ```sh 10 | YAO_SESSION_STORE="redis" 11 | #可选,默认本地 12 | YAO_SESSION_HOST="127.0.0.1" 13 | #可选,默认6379 14 | YAO_SESSION_PORT="6379" 15 | #可选 16 | YAO_SESSION_PASSWORD= 17 | #可选 18 | YAO_SESSION_USERNAME= 19 | 20 | # 可选,默认是1 21 | YAO_SESSION_DB 22 | ``` 23 | 24 | 具体定义: 25 | 26 | ```go 27 | // \yao\config\types.go 28 | // Session 会话服务器 29 | type Session struct { 30 | Store string `json:"store,omitempty" env:"YAO_SESSION_STORE" envDefault:"file"` // The session store. redis | file 31 | File string `json:"file,omitempty" env:"YAO_SESSION_FILE"` // The file path 32 | Host string `json:"host,omitempty" env:"YAO_SESSION_HOST" envDefault:"127.0.0.1"` // The redis host 33 | Port string `json:"port,omitempty" env:"YAO_SESSION_PORT" envDefault:"6379"` // The redis port 34 | Password string `json:"password,omitempty" env:"YAO_SESSION_PASSWORD"` // The redis password 35 | Username string `json:"username,omitempty" env:"YAO_SESSION_USERNAME"` // The redis username 36 | DB string `json:"db,omitempty" env:"YAO_SESSION_DB" envDefault:"1"` // The redis username 37 | IsCLI bool `json:"iscli,omitempty" env:"YAO_SESSION_ISCLI" envDefault:"false"` // Command Line Start 38 | } 39 | ``` 40 | 41 | ## redis 操作。 42 | 43 | ```sh 44 | # 先选择数据库 45 | 46 | 127.0.0.1:6379[1]> CONFIG GET databases 47 | 1) "databases" 48 | 2) "16" 49 | 50 | # 先选择数据库,要不看不到数据 51 | 127.0.0.1:6379> select 1 52 | OK 53 | 54 | 127.0.0.1:6379[1]> KEYS * 55 | 1) "yao:session:3UrNkP0WSrYnW1_quzKzmddGnWCUG67o0W3pXCPorAU=:user" 56 | 2) "yao:session:3UrNkP0WSrYnW1_quzKzmddGnWCUG67o0W3pXCPorAU=:user_id" 57 | 3) "yao:session:3UrNkP0WSrYnW1_quzKzmddGnWCUG67o0W3pXCPorAU=:issuer" 58 | 59 | ``` 60 | -------------------------------------------------------------------------------- /docs/YaoDSL/Connector/index.md: -------------------------------------------------------------------------------- 1 | # Connector 2 | 3 | 4 | 5 | - [连接器](连接器.md) 6 | - [数据库连接器](数据库连接器.md) 7 | - [mongo](mongo.md) 8 | - [OpenAI连接器](OpenAI连接器.md) 9 | - [redis](redis.md) 10 | 11 | -------------------------------------------------------------------------------- /docs/YaoDSL/Connector/redis.md: -------------------------------------------------------------------------------- 1 | # redis连接器 2 | 3 | ## 在environment中配置redis连接信息 4 | 5 | redis主要是用于保存会话信息。 6 | 7 | ```sh 8 | YAO_SESSION_STORE="redis" 9 | YAO_SESSION_HOST="redis" 10 | YAO_SESSION_PORT="6379" 11 | YAO_SESSION_PASSWORD= 12 | YAO_SESSION_USERNAME= 13 | ``` 14 | 15 | ## 在connectors中配置redis连接信息 16 | 17 | 配置项如下: 18 | 19 | ```json 20 | { 21 | "name": "redis", 22 | "label": "redis", 23 | "version": "1.0.0", 24 | "type": "redis", 25 | "options": { 26 | "host": "redis", 27 | "port": 6379, //默认 28 | "user": "", 29 | "pass": "", 30 | "timeout": 10000, //默认5 31 | "db": "" //默认0 32 | } 33 | } 34 | ``` 35 | 36 | 配置项支持引用环境变量配置: 37 | 38 | ```json 39 | { 40 | "name": "redis", 41 | "label": "redis", 42 | "version": "1.0.0", 43 | "type": "redis", 44 | "options": { 45 | "host": "$ENV.YAO_SESSION_HOST", 46 | "port": "$ENV.YAO_SESSION_PORT", 47 | "user": "$ENV.YAO_SESSION_USERNAME", 48 | "pass": "$ENV.YAO_SESSION_PASSWORD", 49 | "timeout": "$ENV.YAO_SESSION_TIMEOUT", 50 | "db": "$ENV.YAO_SESSION_DB" 51 | } 52 | } 53 | ``` 54 | -------------------------------------------------------------------------------- /docs/YaoDSL/Connector/连接器.md: -------------------------------------------------------------------------------- 1 | # 连接器 2 | 3 | 连接器有以下类型: 4 | 5 | - [数据库连接器](./数据库连接器.md) 6 | - [redis连接器](./redis.md) 7 | - [MongoDB连接器](./mongo.md) 8 | - [Openai连接器](./OpenAI%E8%BF%9E%E6%8E%A5%E5%99%A8.md) 9 | - MoAPI连接器 10 | -------------------------------------------------------------------------------- /docs/YaoDSL/Flow/index.md: -------------------------------------------------------------------------------- 1 | # Flow 2 | 3 | 4 | 5 | - [编写数据流](编写数据流.md) 6 | - [流程控制](流程控制.md) 7 | - [数据流Flow](数据流Flow.md) 8 | 9 | -------------------------------------------------------------------------------- /docs/YaoDSL/Model/index.md: -------------------------------------------------------------------------------- 1 | # Model 2 | 3 | Yao Model 是一个强大的数据模型管理系统,它提供了完整的数据库模型定义、数据操作和关系管理功能。通过Model,你可以轻松实现数据迁移、元数据原子操作、数据校验以及数据管理等功能。 4 | 5 | ## 主要特性 6 | 7 | - **完整的模型定义**:支持表结构定义、字段类型、索引、关联关系等完整的模型定义能力 8 | - **数据操作处理**:提供增删改查等基础数据操作,支持批量处理和条件查询 9 | - **关联关系管理**:支持一对一(hasOne)、一对多(hasMany)等多种关联关系 10 | - **数据钩子机制**:支持数据处理的前置和后置钩子,实现数据处理的自定义逻辑 11 | - **字段加密功能**:支持AES加密字段,保护敏感数据安全 12 | - **跨数据库支持**:支持MySQL、SQLite等多种数据库,并处理其差异性 13 | 14 | ## 相关文档 15 | 16 | 17 | 18 | - [定义Yao模型](定义Yao模型.md) 19 | - [模型元数据管理](模型元数据管理.md) 20 | - [模型删除数据](模型删除数据.md) 21 | - [模型新增数据](模型新增数据.md) 22 | - [模型更新数据](模型更新数据.md) 23 | - [数据处理与钩子](数据处理与钩子.md) 24 | - [数据模型介绍](数据模型介绍.md) 25 | - [数据模型关联](数据模型关联.md) 26 | - [字段aes加密解密](字段aes加密解密.md) 27 | - [sqlite与mysql的差异](sqlite与mysql的差异.md) 28 | 29 | -------------------------------------------------------------------------------- /docs/YaoDSL/Model/sqlite与mysql的差异.md: -------------------------------------------------------------------------------- 1 | --- 2 | author: Vincent Wang 3 | contributors: [AbbetWang] 4 | --- 5 | 6 | # 在 Yao 中使用 MySQL 与 SQLITE 7 | 8 | `MYSQL`与`SQLITE`数据库在某些场景有不一致的风险,开发与生产最好使用同一类型的数据库。 9 | 10 | ## Switch 控件 11 | 12 | `Switch`控件在两个数据库下使用需要差异化的配置。 13 | 14 | [`Switch`控件](../../YaoDSL/Xgen/Xgen控件/Switch控件.md) 15 | 16 | ## 时间格式化函数 17 | 18 | MYSQL 使用`DATE_FORMAT`函数 19 | 20 | ```json 21 | { 22 | "name": "入库", 23 | "engine": "xiang", 24 | "query": { 25 | "debug": true, 26 | "select": [ 27 | ":DATE_FORMAT(uptime, '%Y年%m月%d日') as day", 28 | ":COUNT(id) as 数量" 29 | ], 30 | "wheres": [ 31 | { ":uptime": "日期", ">=": "?:$res.日期.from" }, 32 | { ":uptime": "日期", "<=": "?:$res.日期.to" }, 33 | { ":type": "类型", "<=": "入库" } 34 | ], 35 | "from": "record", 36 | "groups": ["day"] 37 | } 38 | } 39 | ``` 40 | 41 | SQLITE 使用`strftime`函数格式化日期 42 | 43 | ```json 44 | { 45 | "name": "入库", 46 | "engine": "xiang", 47 | "query": { 48 | "debug": true, 49 | "select": [ 50 | ":strftime(uptime, '%Y年%m月%d日') as day", 51 | ":COUNT(id) as 数量" 52 | ], 53 | "wheres": [ 54 | { ":uptime": "日期", ">=": "?:$res.日期.from" }, 55 | { ":uptime": "日期", "<=": "?:$res.日期.to" }, 56 | { ":type": "类型", "<=": "入库" } 57 | ], 58 | "from": "record", 59 | "groups": ["day"] 60 | } 61 | } 62 | ``` 63 | -------------------------------------------------------------------------------- /docs/YaoDSL/Pipe/index.md: -------------------------------------------------------------------------------- 1 | # Pipe 2 | 3 | 4 | 5 | - [pipe管道](pipe管道.md) 6 | 7 | -------------------------------------------------------------------------------- /docs/YaoDSL/Plan/index.md: -------------------------------------------------------------------------------- 1 | # Plan 2 | 3 | 4 | 5 | - [计划组件](计划组件.md) 6 | 7 | -------------------------------------------------------------------------------- /docs/YaoDSL/Plugin/index.md: -------------------------------------------------------------------------------- 1 | # Plugin 2 | 3 | 4 | 5 | - [飞书自定义登录](飞书自定义登录.md) 6 | - [golang grpc 插件模板](golang%20grpc%20插件模板.md) 7 | - [grpc插件](grpc插件.md) 8 | 9 | -------------------------------------------------------------------------------- /docs/YaoDSL/Query/JSAPI.md: -------------------------------------------------------------------------------- 1 | # jsapi 2 | 3 | 在 JSAPI 中的参数需要使用 QueryDSL 的语法。 4 | 5 | **注意:Where 条件的定义不要跟 QueryParam 搞混了** 6 | 7 | ## Get 方法 8 | 9 | 执行 sql 查询,使用 select 参数,返回结果集。 10 | 11 | ```js 12 | function Get() { 13 | var query = new Query('query-test'); 14 | var data = query.Get({ 15 | select: ['id', 'name'], 16 | from: 'queryobj_test' 17 | }); 18 | return data; 19 | } 20 | ``` 21 | 22 | 执行 sql 查询,使用 sql 参数查询原始的 select 语句,返回结果集。 23 | 24 | ```js 25 | function Test1(id) { 26 | const query = new Query('default'); 27 | //use statement 28 | const data = query.Get({ 29 | sql: { stmt: 'SELECT id,name FROM yao_demo_pet WHERE id = ?', args: [id] } 30 | }); 31 | return data; 32 | } 33 | ``` 34 | 35 | ## First 方法 36 | 37 | 执行查询,读取每一行数据。 38 | 39 | ```js 40 | function First() { 41 | var query = new Query('query-test'); 42 | var data = query.First({ 43 | select: ['id', 'name'], 44 | from: 'queryobj_test' 45 | }); 46 | return data; 47 | } 48 | ``` 49 | 50 | ## Paginate 方法 51 | 52 | 分页查询 53 | 54 | ```js 55 | function Paginate() { 56 | var query = new Query('query-test'); 57 | var data = query.Paginate({ 58 | select: ['id', 'name'], 59 | from: 'queryobj_test' 60 | }); 61 | return data; 62 | } 63 | ``` 64 | 65 | ## Run 方法 66 | 67 | 执行 sql 查询,返回所有的结果,这里跟 GET 方法是一样的。同样这个 Run 方法也等同于定义并调用 Flow 处理器。 68 | 69 | ```js 70 | function Run() { 71 | var query = new Query('query-test'); 72 | var data = query.Run({ 73 | select: ['id', 'name'], 74 | from: 'queryobj_test', 75 | limit: 1 76 | }); 77 | return data; 78 | } 79 | ``` 80 | 81 | 错误的用法,在 Run 方法中不要使用`sql.stmt`,不会返回数据。 82 | 83 | ```js 84 | function Test3(id) { 85 | const query = new Query('default'); 86 | //use query.Run 87 | const data = query.Run({ 88 | sql: { stmt: 'SELECT id,name FROM yao_demo_pet WHERE id = ?', args: [id] } 89 | }); 90 | return data; 91 | } 92 | ``` 93 | -------------------------------------------------------------------------------- /docs/YaoDSL/Query/index.md: -------------------------------------------------------------------------------- 1 | # Query 2 | 3 | 4 | 5 | - [查询数据](查询数据.md) 6 | - [复杂数据查询](复杂数据查询.md) 7 | - [在url中使用QueryParam](在url中使用QueryParam.md) 8 | - [Flow Query绑定变量](Flow%20Query绑定变量.md) 9 | - [Flow处理器与JSAPI区别](Flow处理器与JSAPI区别.md) 10 | - [JSAPI](JSAPI.md) 11 | - [QueryDsl](QueryDsl.md) 12 | - [QueryParam与QueryDSL](QueryParam与QueryDSL.md) 13 | - [QueryParam语法](QueryParam语法.md) 14 | 15 | -------------------------------------------------------------------------------- /docs/YaoDSL/SUI/index.md: -------------------------------------------------------------------------------- 1 | # SUI 2 | 3 | SUI是一个强大的服务端渲染页面生成工具,它提供了完整的页面设计、编辑和发布流程。 4 | 5 | ## 主要特性 6 | 7 | - 模板定义与语法支持 8 | - 支持调用后端处理器 9 | - SSR页面生成 10 | - 灵活的页面设计器 11 | 12 | ## 框架结构 13 | 14 | SUI采用三层结构设计: 15 | 16 | 1. SUI层:可配置多套SUI页面 17 | 2. Template层:每个SUI可配置多个模板,支持不同主题样式 18 | 3. Page层:在每个模板中可创建多个页面,页面之间可以相互引用 19 | 20 | ## 开发流程 21 | 22 | 1. 定义SUI配置 23 | 2. 创建模板目录 24 | 3. 创建页面目录 25 | 4. 构建页面 26 | 5. 预览效果 27 | 6. 发布上线 28 | 29 | 30 | 31 | - [使用builder创建sui页面](使用builder创建sui页面.md) 32 | - [sui介绍](sui介绍.md) 33 | - [sui前端工具库](sui前端工具库.md) 34 | - [sui前端静态资源引用](sui前端静态资源引用.md) 35 | - [sui多语言支持](sui多语言支持.md) 36 | - [sui局部渲染](sui局部渲染.md) 37 | - [sui指令](sui指令.md) 38 | - [sui模板关联数据定义](sui模板关联数据定义.md) 39 | - [sui模板语法](sui模板语法.md) 40 | - [sui的命令工具](sui的命令工具.md) 41 | - [sui组件初始化的细节](sui组件初始化的细节.md) 42 | - [sui组件化开发](sui组件化开发.md) 43 | - [sui组件的状态管理state](sui组件的状态管理state.md) 44 | - [sui编译文件自动插入的内容](sui编译文件自动插入的内容.md) 45 | - [sui表达式](sui表达式.md) 46 | - [sui路由配置](sui路由配置.md) 47 | - [sui项目中使用flowbite](sui项目中使用flowbite.md) 48 | 49 | -------------------------------------------------------------------------------- /docs/YaoDSL/SUI/sui介绍.md: -------------------------------------------------------------------------------- 1 | # SUI 介绍 2 | 3 | ## 什么是 SUI 4 | 5 | SUI (Simple User Interface) 是 Yao v0.10.4 中新增的一个基于组件的模板引擎,用于创建网页界面。它使用 HTML、CSS 和 TypeScript 来构建网页,具有以下特点: 6 | 7 | - AI 友好:模板语法简单直观,易于 AI 生成和理解 8 | - 服务器端渲染 (SSR):支持服务器端渲染,提升 SEO 效果 9 | - 无需构建工具:不需要额外的构建工具,简化开发流程 10 | - 组件化:支持基于组件的开发方式,促进代码复用 11 | - 多语言支持:内置多语言支持机制 12 | - 数据集成:支持与后端处理器无缝集成 13 | 14 | ## 工作原理 15 | 16 | 1. 模板定义:用户定义 HTML 模板和组件 17 | 2. 模板编译:使用 `yao sui build` 命令编译模板 18 | 3. 页面生成:服务器根据路由读取编译后的模板,调用处理器获取数据,生成最终页面 19 | 20 | ## 适用场景 21 | 22 | - 博客网站 23 | - 公司官网 24 | - 静态内容展示 25 | - 简单的动态网站 26 | 27 | ## 技术特点 28 | 29 | - 支持模板定义和动态数据 30 | - 支持多套模板配置 31 | - 支持多语言 32 | - 支持后端处理器调用 33 | - 支持 SSR 页面生成 34 | 35 | ## 程序流程 36 | 37 | 1. 定义 SUI 模板 38 | 2. 定义静态页面配置 39 | 3. 在模板中调用 Yao 处理器获取动态数据 40 | 4. 生成前端页面 41 | 42 | ## SUI 工作原理 43 | 44 | 1. 用户定义模板与页面组件 45 | 2. 运行 `yao sui build` 命令编译模板 46 | 3. 运行 `yao start` 启动服务 47 | 4. 后端服务根据路由读取编译后的页面 48 | 5. 调用关联的处理器读取数据 49 | 6. 填充模板并输出页面 50 | -------------------------------------------------------------------------------- /docs/YaoDSL/SUI/sui局部渲染.md: -------------------------------------------------------------------------------- 1 | # 局部渲染 2 | 3 | SUI引擎中包含了一种页面局部渲染的机制。在不重新加载全部页面的情况下,只刷新页面中的局部一部分html dom信息。 4 | 5 | 页面配置: 6 | 7 | ```html 8 | 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/YaoDSL/SUI/使用builder创建sui页面.md: -------------------------------------------------------------------------------- 1 | # 使用 builder 创建 sui 页面 2 | 3 | **此功能已被停用** 4 | 5 | 创建一个空的目录,进入目录,执行 yao start 6 | 7 | ```sh 8 | mkdir sui-demo 9 | cd sui-demo 10 | 11 | yao start 12 | ``` 13 | 14 | yao 会自动的初始化一个模板项目工程文件,并且打开默认的 5099 端口让用户配置数据库连接。 15 | 16 | ## aigc 配置 17 | 18 | 如果页面中有标签属性`"aigc-enabled"=true`,可以使用 ai 来帮助生成页面。 19 | 20 | 要启用 ai 生成页面,需要以下的配置。 21 | 22 | 修改应用目录下的 app.yao 配置文件,增加以下的配置。 23 | 24 | ```json 25 | { 26 | "moapi": { 27 | "secret": "sk-", 28 | "mirrors": ["api.openai.com"] 29 | } 30 | } 31 | ``` 32 | 33 | 如果页面里包含以下页面,在设计器的右边会显示一个小图标。点击图标,输入 prompt。 34 | 35 | ```html 36 |
aigc
37 | ``` 38 | 39 | 比如输入。 40 | 41 | ```md 42 | 你是一个 tailwind 专家,给我生成一个用户登录界面,居中,手机显示时全屏。 43 | ``` 44 | 45 | ## 使用命令 46 | 47 | 打印数据: 48 | `http://localhost:5099/signup/wechat?__sui_print_data`,`__sui_print_data` 带这个 Query 参数访问的时候能看到读取的数据 49 | 50 | ## 使用 vscode 51 | 52 | 可以选择 vscode 作为页面编辑工具。 53 | 54 | 实时编译,使用`yao sui watch` 监控模板目录,当页面内容有变化时,自动构建所有页面,这个跟 builder 上的"发布所有页面"的功能是一样的。 55 | 56 | ```sh 57 | yao sui watch "" "