├── .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 |
9 |
10 | {{ text }}
11 |
12 |
13 |
14 |
65 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/components/Contributors.vue:
--------------------------------------------------------------------------------
1 |
22 |
23 |
24 |
36 |
37 |
38 |
39 |
40 | {{ 'Vincent Wang' }}
41 |
42 |
43 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/components/CopyRight.vue:
--------------------------------------------------------------------------------
1 |
22 |
23 |
24 |
66 |
67 |
68 |
73 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/components/DemoContainer.vue:
--------------------------------------------------------------------------------
1 |
18 |
19 |
20 |
21 |
22 | source
23 |
24 |
25 |
26 |
27 | Loading demo...
28 |
29 |
30 |
31 | {{ error }}
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/components/HomeContributors.vue:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
感谢以下所有人的贡献与参与
8 |
9 | 以下排名不分先后(参与或主动提 PR 申请加入)
10 |
11 |
12 |
39 |
40 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/components/IndexInfo.vue:
--------------------------------------------------------------------------------
1 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/components/NavCard.vue:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
29 |
30 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/components/PageInfo.vue:
--------------------------------------------------------------------------------
1 |
21 |
22 |
23 |
24 |
27 |
28 |
29 | 作者:
30 | {{ author }}
31 |
32 |
33 |
34 |
35 | 发表于:{{ publishedTime }}
36 |
37 |
38 |
39 | 更新于:{{ timeFormNow }}
40 |
41 |
42 |
43 | 字数统计:{{ words }} 字
44 |
45 |
46 |
47 | 阅读时长:{{ readTime }} 分钟
48 |
49 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/components/VideoLink.vue:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
27 |
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, "
")
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 | 
25 |
26 | 在创建列的过程中除了手动一个个的创建外,还可以根据 json 数据导入列定义。
27 |
28 | 
29 |
30 | 在弹出的对话框中,输入 json 数据,选择 json 类型,点击检查。在后端会解析 json 数据格式,并生成模型字段定义。当然这个会有一定的误差,可以根据实际情况再进行调整。
31 |
32 | 点击确认后会把字段列表插入模型中。
33 |
34 | 
35 |
36 | ### 自动创建
37 |
38 | 除了手动创建后,还可以把数据库中的表结构导入到系统或是,导入 yao 的 json 模型定义。
39 |
40 | 在导航栏中找到模型导入口,点击进去可以看到数据库中的表列表与模型列表。
41 |
42 | 可以有以下的操作:
43 |
44 | - 导入表结构,这里的表结构是指数据库表的结构,如果已经存在很表的结构,可以使用这个选项。这里导入会覆盖现在有的模型定义,表的定义信息一般会少于模型定义的信息,只建议在系统初始化时使用。
45 |
46 | - 导入本地模型,模型是指在 yao 应用目录 models 目录下创建的模型定义文件。
47 |
48 | 
49 |
50 | 另外在模型列表中,也可以直接导入 yao 模型源代码,或是一键导入本地模型。"导入系统模型"也是建议有系统初始化时使用。
51 | 
52 |
53 | ## 模型更新
54 |
55 | 在模型更新界面,可以调整与模型相关的所有信息:
56 |
57 | - 模型关联表
58 | - 模型字段定义
59 | - 模型关联关系
60 |
61 | 在更多按钮中可以配置更详细的内容。
62 | 
63 |
64 | **注意**:
65 |
66 | - 在保存模型时,可以选择强制更新,这个选项会删除库表,重新创建表,会丢失数据。
67 |
68 | - 模型更新不会直接更新本地模型定义文件,只会更新数据库表的定义与内存的定义。如果需要更新本地文件,最好是通过"查看代码",把模型定义复制到本地文件。因为如果直接更新本地文件可能会破坏系统文件。
69 |
--------------------------------------------------------------------------------
/docs/Admin-App/教程/4数据维护.md:
--------------------------------------------------------------------------------
1 | # 数据维护
2 |
3 | ## 统一维护
4 |
5 | 当模型被创建后,就可以直接维护表数据了。
6 |
7 | 在右边的导航上找到表数据管理入口。
8 |
9 | 在模型列表中选择模型。
10 |
11 | 
12 |
13 | 选择模型后,后端会根据模型定义自动的生成数据维护界面。
14 |
15 | 包含完整的增删改查功能。
16 |
17 | 如果有定义的多媒体或是文件,也是可以直接上传文件的。
18 |
19 | 
20 |
--------------------------------------------------------------------------------
/docs/Admin-App/教程/5代码生成.md:
--------------------------------------------------------------------------------
1 | # 代码生成
2 |
3 | 在上一步中的数据维护是一个统一的入口,相当于直接维护数据表。事实上的情况会比这个复杂,而且自动生成的界面也不能涵盖所有的控件。
4 |
5 | 另外一个处理方法是,根据模型生成的这些界面代码进一步的加工。
6 |
7 | 操作步骤:
8 |
9 | - 在 Studio 菜单中找到代码生成入口
10 |
11 | - 选择模型
12 | - 选择模板,这里的模板可以定制更多
13 | - 配置字段,可以进一步的配置字段,也可以过滤不需要的字段
14 | - 提交,生成代码
15 |
16 | 
17 |
18 | 比如这里的模板 "增删除改查-所有" 就是上一步数据维护中的页面配置源代码。
19 |
20 | 可以根据实际的需要进一步的调整页面配置。
21 |
22 | 把源代码复制出来,保存成一个 amis 的配置文件,比如是"demo.json",放在`/data/pages`目录后,再刷新页面就可以直接使用了。
23 |
24 | 右边的"AMIS 页面"菜单就是映射到应用目录下的`/data/pages`目录。
25 |
26 | 
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 | 
50 |
51 | 创建一个空白的页面,拖入增删改查组件
52 |
53 | 
54 |
55 | 在弹出的页面上输入刚才的接口地址
56 |
57 | 点击"格式校验并自动生成列配置",会自动生成 crud 字段配置。再根据实际情况调整各个字段配置。
58 |
59 | 
60 |
61 | 最后进行预览,保存页面。
62 |
63 | 
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 | 
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 "" "" -d '::{sessiong data}'
58 |
59 | yao sui watch "blog" "website" -d '::{}'
60 | ```
61 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Store/index.md:
--------------------------------------------------------------------------------
1 | # Store
2 |
3 |
4 |
5 | - [使用缓存](使用缓存.md)
6 |
7 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Task/index.md:
--------------------------------------------------------------------------------
1 | # Task
2 |
3 | Yao 提供了多种任务处理机制,用于处理不同场景下的任务需求:
4 |
5 | ## 任务类型
6 |
7 | - [计划任务](计划任务.md)
8 | - [异步任务](异步任务.md)
9 |
10 | ## 任务类型说明
11 |
12 | ### 异步任务 vs 计划任务
13 |
14 | #### 异步任务
15 |
16 | - 主要用于处理耗时的操作
17 | - 通过任务池管理,避免并发处理导致服务器资源短缺
18 | - 可以实时查看任务进度和状态
19 | - 支持任务重试机制
20 | - 适用场景:数据导入、大文件处理、批量操作等
21 |
22 | #### 计划任务
23 |
24 | - 按照预定的时间计划执行
25 | - 使用Cron表达式配置执行时间
26 | - 可以与异步任务结合使用
27 | - 支持参数传递
28 | - 适用场景:数据备份、定时同步、系统维护等
29 |
30 | ## 最佳实践
31 |
32 | 1. 任务类型选择
33 |
34 | - 对于需要立即执行但耗时的操作,使用异步任务
35 | - 对于需要定期执行的操作,使用计划任务
36 | - 对于定期执行的耗时操作,可以将计划任务和异步任务结合使用
37 |
38 | 2. 资源管理
39 |
40 | - 合理设置异步任务的worker数量
41 | - 避免在业务高峰期执行耗时任务
42 | - 对关键任务进行监控和告警
43 |
44 | 3. 异常处理
45 | - 实现完善的错误处理机制
46 | - 合理设置重试次数和间隔
47 | - 保存详细的任务执行日志
48 |
49 |
50 |
51 | - [计划任务](计划任务.md)
52 | - [异步任务](异步任务.md)
53 |
54 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Widget/index.md:
--------------------------------------------------------------------------------
1 | # Widget
2 |
3 |
4 |
5 | - [自定义Widget](自定义Widget.md)
6 | - [自定义Widget升级版](自定义Widget升级版.md)
7 |
8 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/0.10.2与0.10.3差异.md:
--------------------------------------------------------------------------------
1 | # yao 应用引擎模板
2 |
3 | 注意:0.10.2 与 0.10.3 引擎并不兼容,所以使用的模板也不一样。
4 |
5 | ## 菜单
6 |
7 | 菜单的数据格式不一样。可以对比以下两个文件
8 | 0.10.2 的菜单输出是一个数组
9 | 0.10.3 的菜单输出是一个对象
10 |
11 | ## form/table dsl 不一样
12 |
13 | 2 个版本中的 form/table dsl 中的 action 对象结构不一样
14 |
15 | ## 模板使用
16 |
17 | 0.10.2 的请直接使用官方的模板
18 |
19 | ```sh
20 | mkdir your-app
21 | cd your-app
22 | yao start
23 | ```
24 |
25 | 0.10.3 的请使用以下模板
26 |
27 | ```sh
28 | git clone https://github.com/wwsheng009/yao-init
29 | yao start
30 | ```
31 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Chart/Chart钩子函数.md:
--------------------------------------------------------------------------------
1 | # Chart 钩子函数
2 |
3 | 替换 Chart 的默认处理器,可自定义 Chart 处理的过程
4 |
5 | 注意:在钩子函数中报错或是 error 只会记录在日志文件里,不会影响整个流程。
6 |
7 | ## action
8 |
9 | - setting 默认处理器 "yao.chart.Setting"
10 | - component 默认处理器 "yao.chart.Component"
11 | - data 默认处理器 "yao.chart.Data"
12 |
13 | ```json
14 | {
15 | "action": {
16 | "data": {
17 | "process": "", //处理器名称
18 | "bind": "", //处理器名称,同process
19 | "guard": "bearer-jwt", //处理器名称,常见的有bearer-jwt,-。
20 | "default": [] //默认参数值
21 | }
22 | }
23 | }
24 | ```
25 |
26 | ## Hook:
27 |
28 | 使用 hook 函数可以增强 Chart 的处理过程,比如 data 处理器使用默认的处理器,使用 before 与 after 处理器增强默认处理器的行为。
29 |
30 | - before:data
31 | - after:data
32 |
33 | 比如:
34 |
35 | ```json
36 | {
37 | "action": {
38 | "after:data": "scripts.demo.AfterData",
39 | "before:data": "scripts.demo.BeforeData"
40 | }
41 | }
42 | ```
43 |
44 | ## hook 函数参数
45 |
46 | before 处理器的输入参数与默认处理器输入参数保持一致,before 处理器输出返回值需要与默认处理器的**输入参数**保持一致。
47 |
48 | after 处理器的输入参数是默认处理器的返回值,after 处理器输出返回值需要与默认处理器的**输出参数**保持一致。
49 |
50 | 也既是只要了解默认处理器的传入参数与返回值,可以推算出 before 与 after 处理器的参数与返回值。
51 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Chart/index.md:
--------------------------------------------------------------------------------
1 | # Chart
2 |
3 |
4 |
5 | - [分析图表](分析图表.md)
6 | - [图表类型](图表类型.md)
7 | - [Chart钩子函数](Chart钩子函数.md)
8 |
9 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Dashboard/Dashboard钩子函数.md:
--------------------------------------------------------------------------------
1 | # Dashboard 钩子函数
2 |
3 | 替换 Dashboard 的默认处理器,可自定义 Dashboard 处理的过程
4 |
5 | 注意:在钩子函数中报错或是 error 只会记录在日志文件里,不会影响整个流程。
6 |
7 | ## action
8 |
9 | - setting 默认处理器 "yao.dashboard.Setting"
10 | - component 默认处理器 "yao.dashboard.Component"
11 | - data 默认处理器 "yao.dashboard.Data"
12 |
13 | ```json
14 | {
15 | "action": {
16 | "data": {
17 | "process": "", //处理器名称
18 | "bind": "", //处理器名称,同process
19 | "guard": "bearer-jwt", //处理器名称,常见的有bearer-jwt,-。
20 | "default": [] //默认参数值
21 | }
22 | }
23 | }
24 | ```
25 |
26 | ## Hook:
27 |
28 | 使用 hook 函数可以增强 Dashboard 的处理过程,比如 data 处理器使用默认的处理器,使用 before 与 after 处理器增强默认处理器的行为。
29 |
30 | - before:data
31 | - after:data
32 |
33 | 比如:
34 |
35 | ```json
36 | {
37 | "action": {
38 | "after:data": "scripts.demo.AfterData",
39 | "before:data": "scripts.demo.BeforeData"
40 | }
41 | }
42 | ```
43 |
44 | ## hook 函数参数
45 |
46 | before 处理器的输入参数与默认处理器输入参数保持一致,before 处理器输出返回值需要与默认处理器的**输入参数**保持一致。
47 |
48 | after 处理器的输入参数是默认处理器的返回值,after 处理器输出返回值需要与默认处理器的**输出参数**保持一致。
49 |
50 | 也既是只要了解默认处理器的传入参数与返回值,可以推算出 before 与 after 处理器的参数与返回值。
51 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Dashboard/index.md:
--------------------------------------------------------------------------------
1 | # Dashboard
2 |
3 |
4 |
5 | - [Dashboard钩子函数](Dashboard钩子函数.md)
6 |
7 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Form/Form里嵌套Table.md:
--------------------------------------------------------------------------------
1 | # 在`Form`里显示子表
2 |
3 | 可在以`Form`显示子表内容,可惜无法在子表里增加新条目。
4 |
5 | - 配置字段的类型为:`type:Table`
6 | - 配置字段属性`edit.props.model`为`Table`的标识
7 | - 配置表的筛选条件`edit.props.query`
8 |
9 | ```json
10 | {
11 | "fileds": {
12 | "form": {
13 | "消息列表": {
14 | "edit": {
15 | "props": {
16 | "model": "chat.message_simple",
17 | "query": {
18 | "select": "id,prompt,completion,request_total_time",
19 | "where.conversation_id.eq": "{{id}}"
20 | }
21 | },
22 | "type": "Table"
23 | }
24 | }
25 | }
26 | }
27 | }
28 | ```
29 |
30 | 效果:
31 | 
32 |
33 | 如果需要在`Form`里增加新内容,可以使用`List`控件。
34 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Form/images/xgen-form-list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/YaoDSL/Xgen/Form/images/xgen-form-list.png
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Form/index.md:
--------------------------------------------------------------------------------
1 | # Form
2 |
3 |
4 |
5 | - [AI智能表单](AI智能表单.md)
6 | - [Form使用技巧](Form使用技巧.md)
7 | - [Form单据参考创建](Form单据参考创建.md)
8 | - [Form里嵌套List](Form里嵌套List.md)
9 | - [Form里嵌套Table](Form里嵌套Table.md)
10 | - [Form钩子函数](Form钩子函数.md)
11 |
12 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Form/table_in_form.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/YaoDSL/Xgen/Form/table_in_form.png
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Hook参数说明.md:
--------------------------------------------------------------------------------
1 | # hook 的参数
2 |
3 | `Table/Form`都可以使用`hook`来增强功能
4 |
5 | ## before:save
6 |
7 | `before hook`与`after hook`的`xpath`在`action`节点下
8 |
9 | `forms/record/total.form.json`
10 |
11 | ```json
12 | {
13 | "name": "记录",
14 | "action": {
15 | "bind": {
16 | "model": "record"
17 | },
18 | "before:save": "scripts.record.BeforeSave",
19 | "after:save": "scripts.record.AfterSave"
20 | }
21 | }
22 | ```
23 |
24 | `before:save`的输入参数是`payload`,输出是包含`payload`的数组
25 |
26 | ```js
27 | /** 数据保存之间调用 */
28 | function BeforeSave(payload) {
29 | // 输出数组,为下一个处理器save作准备,格式一定是数组
30 | return [payload];
31 | }
32 | ```
33 |
34 | ## save
35 |
36 | `Save`处理器的说明如下,第一个参数是结构体,不是数组,使用`[<记录>]`的形式是因为所有的处理器的调用用时的参数形式都是数组,在调用具体脚本函数时,参数列表会自动的解构。
37 |
38 | `models..Save [<记录>] 记录主键值 保存单条记录, 不存在创建记录, 存在更新记录, 返回记录 ID 示例 查看`
39 |
40 | ```js
41 | /**
42 | * Save Hook函数
43 | * payload 需要保存的记录结构
44 | * 返回保存的数据的id
45 | * */
46 | function Save(payload) {
47 | // 自定义的处理逻辑
48 |
49 | // 可以返回id或是返回数组[id]
50 | return id;
51 | }
52 | ```
53 |
54 | ## after:save
55 |
56 | `save`只会返回一个保存后的`id`,可以在`aftersave`中根据 id 把数据读取出来
57 |
58 | ```js
59 | /**
60 | * 数据保存之后
61 | * id,接收Save方法返回的id
62 | * 返回id
63 | * */
64 | function AfterSave(id) {
65 | // read the saved record
66 | var payload = Process('models.<模型名称>.Find', id, {});
67 |
68 | // 可以增加其它筛选条件
69 | var payload = Process('models.<模型名称>.Find', id, {
70 | select: ['id', 'name', 'user_sn', 'photo', 'status']
71 | });
72 |
73 | // 一般都返回id
74 | return id;
75 | }
76 | ```
77 |
78 | ## form hook
79 |
80 | form hook before / after 的源代码
81 |
82 | `/yao/widgets/hook/hook.go`
83 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/List/List钩子函数.md:
--------------------------------------------------------------------------------
1 | # List 钩子函数
2 |
3 | 替换 List 的默认处理器
4 |
5 | ## action
6 |
7 | - setting 默认处理器 "yao.list.Setting"
8 | - component 默认处理器 "yao.list.Component"
9 | - upload 默认处理器 "yao.list.Upload"
10 | - download 默认处理器 "yao.list.Download"
11 | - get 默认处理器 "yao.list.Get"
12 | - save 默认处理器 "yao.list.Save"
13 |
14 | ```json
15 | {
16 | "action": {
17 | "get": {
18 | "process": "", //处理器名称
19 | "bind": "", //处理器名称,同process
20 | "guard": "bearer-jwt", //处理器名称,常见的有bearer-jwt,-。
21 | "default": [] //默认参数值
22 | }
23 | }
24 | }
25 | ```
26 |
27 | ## Hook:
28 |
29 | - before:get
30 | - after:get ""
31 | - before:save
32 | - after:save
33 |
34 | 比如:
35 |
36 | ```json
37 | {
38 | "action": {
39 | "after:find": "scripts.license.AfterFind",
40 | "before:delete": "scripts.license.BeforeDelete"
41 | }
42 | }
43 | ```
44 |
45 | ## hook 函数参数
46 |
47 | before 处理器的输入参数与默认处理器输入参数保持一致,before 处理器输出返回值需要与默认处理器的**输入参数**保持一致。
48 |
49 | after 处理器的输入参数是默认处理器的返回值,after 处理器输出返回值需要与默认处理器的**输出参数**保持一致。
50 |
51 | 也既是只要了解默认处理器的传入参数与返回值,可以推算出 before 与 after 处理器的参数与返回值。
52 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/List/index.md:
--------------------------------------------------------------------------------
1 | # List
2 |
3 |
4 |
5 | - [List钩子函数](List钩子函数.md)
6 |
7 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Neo/index.md:
--------------------------------------------------------------------------------
1 | # Neo
2 |
3 |
4 |
5 | - [neo嵌入业务指令](neo嵌入业务指令.md)
6 |
7 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Table/TableA跳转到FormB.md:
--------------------------------------------------------------------------------
1 | # `tableA`跳转到`FormB`
2 |
3 | 通过使用类型`Common.historyPush`的`Action`实现关连 form 的跳转。form 的显示都需要一个`id`来关连。在 form 打开时会根据`id`抓取相关`form`的具体信息。
4 |
5 | ```json
6 | {
7 | "layout": {
8 | "table": {
9 | "operation": {
10 | "actions": [
11 | {
12 | "icon": "category-outline",
13 | "action": [
14 | {
15 | "name": "HistoryPush",
16 | "payload": {
17 | "pathname": "/x/Form/material.category/{{category.id}}/view"
18 | },
19 | "type": "Common.historyPush"
20 | }
21 | ],
22 | "title": "查看分类",
23 | "width": 3
24 | }
25 | ]
26 | }
27 | }
28 | }
29 | }
30 | ```
31 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Table/Table_Form禁用Action.md:
--------------------------------------------------------------------------------
1 | # 根据条件禁用`Table_Form Action`按钮
2 |
3 | 设置`action.disabled`属性,`action.disabled.bind`是绑定记录的值,`action.disabled.value`是`action`禁用条件,有以下两种情况。
4 |
5 | - 当`action.disabled.value`的类型是数组时,`value`的值包含`action.disabled.bind`的值时,`action`按钮被禁用。
6 |
7 | - 当`action.disabled.value`的类型不是数组时,`value`的值等于`action.disabled.bind`的值时,`action`按钮被禁用。
8 |
9 | 比如以下的代码,当记录的`id`是 1 或是 2 时,`action`按钮被禁用。
10 |
11 | ```json
12 | {
13 | "operation": {
14 | "fold": false,
15 | "width": 60,
16 | "actions": [
17 | {
18 | "title": "查看",
19 | "icon": "icon-eye",
20 | "disabled": {
21 | "bind": "{{id}}",
22 | "value": ["1", "2"]
23 | }
24 | }
25 | ]
26 | }
27 | }
28 | ```
29 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Table/Table上使用Tab.md:
--------------------------------------------------------------------------------
1 | # 在 Table 上使用 Tab 控件
2 |
3 | 在`form.json`中配置路径为`layout.form.sections[0].columns[0].tabs`
4 |
5 | `tabs`跟`column`同级别。在`tabs`中可以嵌套`columns`
6 |
7 | ```jsonc
8 | {
9 | "layout": {
10 | "form": {
11 | "props": {},
12 | "sections": [
13 | {
14 | "title": "基础信息",
15 | "desc": "宠物的一些基本信息",
16 | "columns": [
17 | {
18 | "width": 24,
19 | "tabs": [
20 | {
21 | "title": "Base",
22 | "columns": [
23 | {
24 | "name": "名称",
25 | "width": 12
26 | }
27 | ]
28 | },
29 | {
30 | "title": "More",
31 | "columns": [
32 | {
33 | "name": "状态",
34 | "width": 12
35 | }
36 | ]
37 | }
38 | ]
39 | }
40 | ]
41 | }
42 | ]
43 | }
44 | }
45 | }
46 | ```
47 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Table/Table中设置字段只读.md:
--------------------------------------------------------------------------------
1 | # 在 table 中设置字段只读
2 |
3 | 只需要把`fields`中的字段对应的编辑控件`edit`删除掉,只保留`view`配置。
4 |
5 | ```json
6 | {
7 | "fields": {
8 | "table": {
9 | "创建时间": {
10 | "bind": "created_at",
11 | "view": { "props": { "format": "YYYY-MM-DD HH:mm:ss" }, "type": "Text" }
12 | },
13 | "更新时间": {
14 | "bind": "updated_at",
15 | "view": { "props": { "format": "YYYY-MM-DD HH:mm:ss" }, "type": "Text" }
16 | }
17 | }
18 | }
19 | }
20 | ```
21 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Table/Table使用技巧.md:
--------------------------------------------------------------------------------
1 | # table 的一些使用技巧
2 |
3 | [使用`Studio`脚本生成`Table`配置](../../../Studio/%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90table_form%E5%AE%9A%E4%B9%89%E6%96%87%E4%BB%B6.md)
4 |
5 | ## 常见问题
6 |
7 | Q:在`fields`节点配置了字段,无法在界面上显示。
8 |
9 | A:需要在`layout.table.columns中增加对应字段`
10 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Table/Table增加查看,编辑,删除按钮.md:
--------------------------------------------------------------------------------
1 | # 增加查看,编辑,删除按钮
2 |
3 | 需要先增加模型对应的`form`配置文件
4 |
5 | 配置路径:`layout.table.operation.actions`,注意替换
6 |
7 | ```json
8 | {
9 | "layout": {
10 | "table": {
11 | "operation": {
12 | "actions": [
13 | {
14 | "icon": "icon-eye",
15 | "title": "查看",
16 | "action": [
17 | {
18 | "name": "OpenModal",
19 | "payload": {
20 | "Form": {
21 | "model": "",
22 | "type": "view"
23 | }
24 | },
25 | "type": "Common.openModal"
26 | }
27 | ]
28 | },
29 | {
30 | "icon": "icon-edit-2",
31 | "title": "编辑",
32 | "action": [
33 | {
34 | "name": "OpenModal",
35 | "payload": {
36 | "Form": {
37 | "model": "",
38 | "type": "edit"
39 | }
40 | },
41 | "type": "Common.openModal"
42 | }
43 | ]
44 | },
45 | {
46 | "icon": "icon-trash-2",
47 | "style": "danger",
48 | "title": "Delete",
49 | "action": [
50 | {
51 | "name": "Confirm",
52 | "type": "Common.confirm",
53 | "payload": {
54 | "title": "确认删除",
55 | "content": "删除后不可撤销!"
56 | }
57 | },
58 | {
59 | "name": "Delete",
60 | "payload": {
61 | "model": ""
62 | },
63 | "type": "Table.delete"
64 | }
65 | ]
66 | }
67 | ]
68 | }
69 | }
70 | }
71 | }
72 | ```
73 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Table/Table搜索默认值.md:
--------------------------------------------------------------------------------
1 | # `Table`搜索默认条件
2 |
3 | 设置 Table 分页搜索的默认条件。
4 |
5 | 方法一,设置`action.search.default`。
6 |
7 | `search`是指 Table 搜索接口的处理器的配置,而`default`是配置处理器的默认参数列表,`default`配置项的类型是一个数组,数组内容对应着相关处理器的参数。可以理解为配置处理器的默认参数列表。
8 |
9 | 比如这里的`search`对应的处理器是`yao.table.search`,它的参数是`[queryParam,page,pagesize]`,
10 | 这里的第一个参数类型是 QueryParam。
11 |
12 | ```json
13 | {
14 | "action": {
15 | "search": {
16 | "default": [
17 | {
18 | "wheres": [
19 | {
20 | "column": "type",
21 | "op": "in",
22 | "value": ["入库", "进入"]
23 | }
24 | ]
25 | }
26 | ]
27 | }
28 | }
29 | }
30 | ```
31 |
32 | 同理也可以设置其它的处理器默认参数。
33 |
34 | - setting
35 | - component
36 | - upload
37 | - download
38 | - search
39 | - get
40 | - find
41 | - save
42 | - create
43 | - insert
44 | - delete
45 | - delete-in
46 | - delete-where
47 | - update
48 | - update-in
49 | - update-where
50 |
51 | 方法二,设置`action.bind.option`
52 |
53 | ```json
54 | {
55 | "action": {
56 | "bind": {
57 | "option": {
58 | "wheres": [
59 | {
60 | "column": "type",
61 | "op": "in",
62 | "value": "入库,进入"
63 | }
64 | ]
65 | }
66 | }
67 | }
68 | }
69 | ```
70 |
71 | ## `Table`默认排序
72 |
73 | ```json
74 | {
75 | "$schema": "https://raw.githubusercontent.com/wwsheng009/yao-app-ts-types/main/json-schemas/0.10.3/table.json",
76 | "name": "Hero List",
77 | "action": {
78 | "bind": {
79 | "model": "hero",
80 | "option": {}
81 | },
82 | "search": {
83 | "default": [
84 | {
85 | "orders": [
86 | { "column": "defense", "option": "asc" },
87 | { "column": "name", "option": "desc" }
88 | ]
89 | }
90 | ]
91 | }
92 | }
93 | }
94 | ```
95 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Table/Table最小化配置.md:
--------------------------------------------------------------------------------
1 | # table 最小化配置
2 |
3 | 只需要以下最小的配置,即可在`xgen`上使用`table`.字段与控件的配置会根据`model`中的配置自动生成。
4 |
5 | `action.bind.option.form`的配置会自动的增加创建按钮与`table`行项目中的三个常用按钮
6 |
7 | ```json
8 | {
9 | "name": "用户",
10 | "action": {
11 | "bind": {
12 | "model": "",
13 | "option": {
14 | "withs": { "": {} },
15 | "form": ""
16 | }
17 | }
18 | }
19 | }
20 | ```
21 |
22 | **注意**
23 |
24 | 需要注意的是,使用最小化配置时,关联的模型需要需要有过滤器 filter 的设置。
25 |
26 | 也即是,需要确保在模型的字段定义中至少有一个字段的属性 index/unique/primary 设置成 true,会自动生成 filter。
27 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Table/Table界面上增加创建按钮.md:
--------------------------------------------------------------------------------
1 | # 在`table`界面上增加创建按钮
2 |
3 | 需要先增加相关的`form`配置文件。
4 |
5 | 方法一,在绑定节点使用 form 选项,配置路径:
6 | xpath:"action.bind.option.form".
7 |
8 | ```json
9 | {
10 | "action": {
11 | "bind": {
12 | "model": "user",
13 | "option": {
14 | "withs": { "supplier": {} },
15 | "form": "user"
16 | }
17 | }
18 | }
19 | }
20 | ```
21 |
22 | 方法二,手动配置路径:`layout.filter.actions`,注意替换\。不要使用 layout.header.actions,配置了也没效。
23 |
24 | ```json
25 | {
26 | "layout": {
27 | "filter": {
28 | "actions": [
29 | {
30 | "action": [
31 | {
32 | "name": "HistoryPush",
33 | "payload": {
34 | "pathname": "/x/Form//0/edit"
35 | },
36 | "type": "Common.historyPush"
37 | }
38 | ],
39 | "icon": "icon-plus",
40 | "title": "::Create",
41 | "width": 3
42 | }
43 | ]
44 | }
45 | }
46 | }
47 | ```
48 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Table/index.md:
--------------------------------------------------------------------------------
1 | # Table
2 |
3 |
4 |
5 | - [数据表格](数据表格.md)
6 | - [Table 钩子函数](Table%20钩子函数.md)
7 | - [TableA跳转到FormB](TableA跳转到FormB.md)
8 | - [Table_Form禁用Action](Table_Form禁用Action.md)
9 | - [Table上使用Tab](Table上使用Tab.md)
10 | - [Table中设置字段只读](Table中设置字段只读.md)
11 | - [Table使用技巧](Table使用技巧.md)
12 | - [Table增加查看,编辑,删除按钮](Table增加查看,编辑,删除按钮.md)
13 | - [Table搜索默认值](Table搜索默认值.md)
14 | - [Table最小化配置](Table最小化配置.md)
15 | - [Table界面上增加创建按钮](Table界面上增加创建按钮.md)
16 |
17 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Xgen多语言支持.md:
--------------------------------------------------------------------------------
1 | # Xgen 多语言支持
2 |
3 | ## 多语言配置使用
4 |
5 | 语言包分全局语言包与特定类型`DSL`语言包。两种语言包的功能一样,但是作用域不一样。
6 | 全局语言包在目录应用`langs`目录。特定类型的`DSL`语言包在语言包对应语言目录的子目录下
7 |
8 | 示例:
9 |
10 | - `/data/app/langs/zh-cn/global.yml` 全局语言包文件
11 | - `/data/app/langs/zh-cn/models/pet.mod.yml` Model pet 语言包
12 | - `/data/app/langs/zh-cn/models/user/pet.mod.yml` Model user.pet 语言包
13 | - `/data/app/langs/zh-cn/tables/pet.mod.yml` Table pet 语言包
14 |
15 | 语言包的作用主要是用于`xgen`框架,当然也可以使用`api`函数进行调用,读取相关的界面配置。相关的处理器有`(yao.table.Setting/yao.form.Setting)`
16 |
17 | ## 源代码分析:
18 |
19 | 如果`DSL`配置文件里的配置有包含`$L()`的表达式时,说明配置对象是一个需要翻译的文本对象。在输出到界面之前,程序会针对这类对象进行多语言翻译。
20 |
21 | 可以修改环境变量`YAO_LANG`变换多语言翻译项目,可选项有`en-us/zh-cn/zh-hk`
22 | 如果处理器中包含语言设置时,会覆盖默认值。
23 |
24 | - `yao/widgets/form/action.go`,在 json 中配置的前缀会转换成$L()表达式
25 | - `yao/i18n/i18n.go`
26 | - `gou/lang/lang.go` 处理多语言的过程
27 | - `yao/fields/model.trans.json` 在模型定义文件中有较多的使用场景
28 |
29 | ## 在`js`函数里可以直接使用`$L()`函数处理多语言描述
30 |
31 | ```js
32 | function Bar(...args) {
33 | return {
34 | message: $L('Another yao application') + ' (Cloud Function: foo.Bar)',
35 | args: args
36 | };
37 | }
38 | ```
39 |
40 | ## 在`json`配置文件中使用多语言
41 |
42 | 如果在`DSL`配置文件中需要翻译文本,在文本内容前面加上前缀::
43 | 适用范围是`api`文件,`model`文件,`table`文件,`form`文件,`app.json`文件
44 |
45 | ```json
46 | {
47 | "name": "::Pet",
48 | "table": { "name": "pet", "comment": "$L(Pet) Table" },
49 | "columns": [
50 | { "name": "id", "comment": "ID", "type": "ID" },
51 | {
52 | "name": "name",
53 | "comment": "::Pet Name",
54 | "type": "string",
55 | "length": 80,
56 | "index": true,
57 | "nullable": true
58 | }
59 | ]
60 | }
61 | ```
62 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Xgen控件/RichText富文本控件/index.md:
--------------------------------------------------------------------------------
1 | # RichText 富文本控件
2 |
3 |
4 |
5 | - [使用富文本控件](使用富文本控件.md)
6 |
7 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Xgen控件/Switch控件.md:
--------------------------------------------------------------------------------
1 | # Switch 控件
2 |
3 | ## 问题
4 |
5 | 比如,在模型中有字段的配置如下,你会发现,如果使用提`mysql`数据库,这个控件是无法使用的。
6 |
7 | ```json
8 | {
9 | "name": "online",
10 | "label": "是否在线",
11 | "type": "boolean",
12 | "default": false,
13 | "index": true
14 | }
15 | ```
16 |
17 | ## WHY
18 |
19 | - 在使用`sqlite3`作为数据库时,`Switch`控件的值需要设置成`true/false`。
20 |
21 | > sqlite 作为数据库时,`golang`中的`sqlite3`驱动会自动作数据转换。数据库表的字段数据类型是`boolean`,在数据库表里保存的数据是`0`或`1`。更新数据时在 `sql`语句中却需要使用 `true`,与 `false` 来更新数据。而数据从数据库中读取出来后会自动转换成 `true` 与 `false`.
22 |
23 | - 在使用 mysql 作为数据库时,`Switch`控件的值需要设置成`1/0`。
24 |
25 | > 在使用 `mysql` 作为数据库源时,`model` 中字段为 `boolean` 类型的字段生成的 `mysql` 数据库字段类型是 `tinyint(1)`。数据的保存与读取不会自动的转换,`0/1`。
26 |
27 | `Switch`控件默认的值是`false`或`true`。
28 |
29 | 如果在`tab.json`中定义字段中使用默认的字段绑定显示设置,即是在`fields.table`中不显式的定义控件属性,这时框架会自动生成字段定义,这个生成的定义只适用于 `sqlite3` 数据库。如果切换成 `mysql` 的数据后,显示就会异常。差不多也算是一个 bug。
30 |
31 | ## 解决方法
32 |
33 | 解决方法是,如果是使用的`mysql`数据库,在`fields.table`中替换显式的定义控件属性,`checkedValue=1`,`unCheckedValue=0`
34 |
35 | 使用 MYSQL 数据库时的配置:
36 |
37 | ```json
38 | {
39 | "是否在线": {
40 | "bind": "online",
41 | "view": {
42 | "type": "Switch",
43 | "props": {
44 | "checkedChildren": "是",
45 | "checkedValue": 1,
46 | "unCheckedChildren": "否",
47 | "unCheckedValue": 0
48 | }
49 | }
50 | }
51 | }
52 | ```
53 |
54 | 使用`SQLITE`数据库时的配置:
55 |
56 | ```json
57 | {
58 | "是否在线": {
59 | "bind": "online",
60 | "view": {
61 | "type": "Switch",
62 | "props": {
63 | "checkedChildren": "是",
64 | "checkedValue": true,
65 | "unCheckedChildren": "否",
66 | "unCheckedValue": false
67 | }
68 | }
69 | }
70 | }
71 | ```
72 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Xgen控件/Xgen登录界面邮件电话校验规则.md:
--------------------------------------------------------------------------------
1 | # Xgen 登录界面邮件电话校验规则
2 |
3 | 前端 xgen 登录 Form 有邮箱电话的校验。校验使用 regex 正则
4 |
5 | 源代码位置:`/xgen-v1.0/packages/xgen/utils/reg/index.ts`
6 |
7 | ```js
8 | export const reg_email = new RegExp(
9 | /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
10 | );
11 |
12 | export const reg_mobile = new RegExp(/^1[3|4|5|8|9][0-9]\d{4,8}$/);
13 | ```
14 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Xgen控件/index.md:
--------------------------------------------------------------------------------
1 | # Xgen 控件
2 |
3 |
4 |
5 | - [菜单配置](菜单配置.md)
6 | - [禁用编辑控件](禁用编辑控件.md)
7 | - [控件onSelect回调](控件onSelect回调.md)
8 | - [设置控件的必输属性](设置控件的必输属性.md)
9 | - [使用Hook转换日期控件的值](使用Hook转换日期控件的值.md)
10 | - [视频上传](视频上传.md)
11 | - [图片控件](图片控件.md)
12 | - [文件上传UploadFile](文件上传UploadFile.md)
13 | - [远程select控件](远程select控件.md)
14 | - [IFrame控件](IFrame控件.md)
15 | - [Switch控件](Switch控件.md)
16 | - [Upload在List下视频样式错乱](Upload在List下视频样式错乱.md)
17 | - [Xgen登录界面邮件电话校验规则](Xgen登录界面邮件电话校验规则.md)
18 | - [Xgen自定义远程控件](Xgen自定义远程控件.md)
19 | - [RichText富文本控件](RichText富文本控件/index)
20 |
21 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Xgen控件/使用Hook转换日期控件的值.md:
--------------------------------------------------------------------------------
1 | # 使用 Hook 转换日期控件的值
2 |
3 | 界面上的日期控件的格式是"YYYY-MM-DD hh:mm:ss",即使是只选当前日期,也会把当前的时间带入后台。
4 |
5 | 如果数据库字段的值是只有日期"YYYY-MM-DD"或是时间为"YYYY-MM-DD 00:00:00"时,关联搜索会失败。
6 |
7 | 使用`Hook`可以处理这个问题
8 |
9 | ```js
10 | /**
11 | * 搜索 Hook, 处理日期条件
12 | */
13 | function BeforeSearch(query, page, pagesize) {
14 | // console.log("old search:", query.wheres);
15 | query = query || {};
16 | wheres = query.wheres || [];
17 | for (const i in wheres) {
18 | const where = wheres[i] || {};
19 | if (where.column == 'day' && where.value) {
20 | // url的查询
21 | where.value = where.value.replaceAll('"', '');
22 | const value = new Date(where.value).toISOString().split('T')[0];
23 | query.wheres[i].value = `${value} 00:00:00`;
24 | }
25 | }
26 | return [query, page, pagesize];
27 | }
28 | ```
29 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Xgen控件/图片控件.md:
--------------------------------------------------------------------------------
1 | # 图片控件配置
2 |
3 | ## `model`字段设置
4 |
5 | 在相关的`model`中设置字段类型为`json`,
6 |
7 | ```json
8 | {
9 | "label": "照片",
10 | "name": "photo",
11 | "type": "json",
12 | "nullable": true
13 | }
14 | ```
15 |
16 | ## 图片显示与编辑
17 |
18 | 在`table/form`定义中设置图片相关的控件属性。
19 |
20 | 注意:在`form`里,需要同时设置`view/edit`属性
21 |
22 | ```json
23 | {
24 | "图片": {
25 | "bind": "images",
26 | "edit": {
27 | "type": "Upload",
28 | "compute": "Upload",
29 | "props": {
30 | "filetype": "image",
31 | "$api": {
32 | "process": "fs.system.Upload"
33 | }
34 | }
35 | },
36 | "view": {
37 | "type": "Image",
38 | "compute": "Download",
39 | "props": {
40 | "style": {
41 | "width": 36,
42 | "height": 36,
43 | "borderRadius": "50%"
44 | }
45 | }
46 | }
47 | }
48 | }
49 | ```
50 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Xgen控件/控件onSelect回调.md:
--------------------------------------------------------------------------------
1 | # select 控件动态搜索
2 |
3 | 这里有一个[bug](../../../%E6%BA%90%E4%BB%A3%E7%A0%81/Xgen/xgen%20remoteSearch.md)。
4 |
5 | xpath:`edit.props.xProps.$search`,
6 |
7 | ```json
8 | {
9 | "上级类目": {
10 | "bind": "parent_id",
11 | "edit": {
12 | "type": "Select",
13 | "props": {
14 | "xProps": {
15 | "$search": {
16 | "process": "scripts.category.Search",
17 | "query": {
18 | "key": "id",
19 | "id": "{{id}}"
20 | }
21 | }
22 | }
23 | }
24 | }
25 | }
26 | }
27 | ```
28 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Xgen控件/文件上传UploadFile.md:
--------------------------------------------------------------------------------
1 | # 文件上传
2 |
3 | 控件绑定的字段对应的模型的字段类型需要是`json`
4 |
5 | 文件上传的控件类型是`Upload`,文件类型`filetype`支持三种:`video`,`image`,`file`
6 |
7 | ```json
8 | {
9 | "下载地址": {
10 | "view": {
11 | "type": "A",
12 | "compute": "Download",
13 | "props": {}
14 | },
15 | "edit": {
16 | "type": "Upload",
17 | "compute": "Upload",
18 | "props": {
19 | "filetype": "file",
20 | "$api": {
21 | "process": "fs.system.Upload"
22 | }
23 | }
24 | },
25 | "bind": "url"
26 | }
27 | }
28 | ```
29 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Xgen控件/禁用编辑控件.md:
--------------------------------------------------------------------------------
1 | # 禁用编辑类的控件
2 |
3 | 在某些场景下,编辑类的控件需要设置成只读取状态,设置控件的属性`disabled:true`
4 |
5 | ```json
6 | {
7 | "实际数量": {
8 | "bind": "amount",
9 | "edit": {
10 | "props": {
11 | "placeholder": "请输入 实际数量",
12 | "disabled": true
13 | },
14 | "type": "InputNumber"
15 | },
16 | "view": { "props": {}, "type": "Text" }
17 | }
18 | }
19 | ```
20 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Xgen控件/视频上传.md:
--------------------------------------------------------------------------------
1 | # 显示视频
2 |
3 | xgen 视频的显示存在 bug: https://github.com/YaoApp/yao/issues/371
4 |
5 | 修正处理
6 |
7 | ```js
8 | // /xgen-v1.0/packages/xgen/knife/yao/getFileSrc.ts
9 |
10 | import getToken from './getToken';
11 |
12 | const Index = (name: string) => {
13 | //这里加个判断,因为在上传视频其间这个name是一个对象,而不是字符串
14 | if (typeof name !== 'string') {
15 | return;
16 | }
17 | if (name.startsWith('http')) return name;
18 |
19 | return `${name}&token=${getToken()}`;
20 | };
21 |
22 | export default Index;
23 | ```
24 |
25 | ## 模型配置
26 |
27 | 模型字段配置类型为 json
28 |
29 | ```json
30 | {
31 | "label": "video",
32 | "type": "json",
33 | "nullable": true,
34 | "name": "video"
35 | }
36 | ```
37 |
38 | ## 列表配置
39 |
40 | 配置字段的 edit 属性 `"filetype": "video"`
41 |
42 | ```json
43 | {
44 | "video": {
45 | "view": {
46 | "props": {},
47 | "type": "Image",
48 | "compute": "Download"
49 | },
50 | "edit": {
51 | "type": "Upload",
52 | "compute": "Upload",
53 | "props": {
54 | "maxCount": 100,
55 | "filetype": "video",
56 | "$api": {
57 | "process": "fs.system.Upload"
58 | }
59 | }
60 | },
61 | "bind": "video"
62 | }
63 | }
64 | ```
65 |
66 | ## 表单配置
67 |
68 | 表单的字段一定要配置 view 属性,并加上`"compute": "Download"`,才能正确的获取视频的下载地址
69 |
70 | ```json
71 | {
72 | "video": {
73 | "view": {
74 | "props": {},
75 | "type": "Image",
76 | "compute": "Download"
77 | },
78 | "edit": {
79 | "props": {
80 | "maxCount": 100,
81 | "filetype": "video",
82 | "$api": {
83 | "process": "fs.system.Upload"
84 | }
85 | },
86 | "type": "Upload",
87 | "compute": "Upload"
88 | },
89 | "bind": "video"
90 | }
91 | }
92 | ```
93 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/Xgen控件/设置控件的必输属性.md:
--------------------------------------------------------------------------------
1 | # 设置控件的必输,使用编辑控件的配置属性`itemProps`
2 |
3 | ```json
4 | {
5 | "名称": {
6 | "bind": "name",
7 | "edit": {
8 | "props": {
9 | "itemProps": {
10 | "rules": [{ "required": true }]
11 | },
12 | "placeholder": "请输入 名称"
13 | },
14 | "type": "Input"
15 | },
16 | "view": {
17 | "type": "Text"
18 | }
19 | }
20 | }
21 | ```
22 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/images/form_on_change_event.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/YaoDSL/Xgen/images/form_on_change_event.gif
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/index.md:
--------------------------------------------------------------------------------
1 | # Xgen
2 |
3 |
4 |
5 | - [0.10.2与0.10.3差异](0.10.2与0.10.3差异.md)
6 | - [菜单结构](菜单结构.md)
7 | - [模板替换](模板替换.md)
8 | - [使用compute](使用compute.md)
9 | - [系统默认的用户名](系统默认的用户名.md)
10 | - [Hook参数说明](Hook参数说明.md)
11 | - [xgen命令汇总](xgen命令汇总.md)
12 | - [xgen登录过程](xgen登录过程.md)
13 | - [xgen远程onChange事件](xgen远程onChange事件.md)
14 | - [Xgen多语言支持](Xgen多语言支持.md)
15 | - [Chart](Chart/index)
16 | - [Dashboard](Dashboard/index)
17 | - [Form](Form/index)
18 | - [List](List/index)
19 | - [Neo](Neo/index)
20 | - [Table](Table/index)
21 | - [Xgen控件](Xgen控件/index)
22 |
23 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/模板替换.md:
--------------------------------------------------------------------------------
1 | # 模板替换
2 |
3 | 在Xgen中,在多个场景下可以使用模板替换功能。
4 |
5 | 模板替换使用mustache.js实现的,主要有两种替换方法:
6 |
7 | :::v-pre
8 |
9 | - `{{}}`/ `[[]]` 替换对象中的字段
10 | - `{{{}}}` / `[[[]]]` 替换对象中的字段,未转义。
11 |
12 | :::
13 |
14 | 在actions中可以使用`${actionName}`引用上一个节点的返回值。
15 |
16 | 示例:
17 |
18 | ```json
19 | {
20 | "title": "Unpublish",
21 | "icon": "icon-arrow-down",
22 | "style": "danger",
23 | "disabled": { "bind": "{{status}}", "value": "draft" },
24 | "action": [
25 | { "name": "Submit", "type": "Form.submit" },
26 | {
27 | "name": "Draft",
28 | "type": "Service.article",
29 | "payload": {
30 | "method": "UpdateStatus",
31 | "args": [{ "id": "[[$Submit]]", "status": "draft" }] // 在actions中引用上一个节点的返回值
32 | }
33 | },
34 | { "name": "Refetch", "type": "Common.refetch" }
35 | ]
36 | }
37 | ```
38 |
39 | 使用场景,可以xgen项目中查询函数`getTemplateValue`的引用:
40 |
41 | - task中的payload对象
42 | - form中的action对象
43 | - form中的reference对象
44 | - form中的sections对象
45 | - table中的actions对象
46 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/系统默认的用户名.md:
--------------------------------------------------------------------------------
1 | # `Yao`应用默认用户名
2 |
3 | 默认的后台登录地址:http://127.0.0.1:5099/xiang/login/admin
4 |
5 | 系统初始化后的用户名密码
6 |
7 | > 用户名: xiang@iqka.com
8 | > 密码: A123456p+
9 |
--------------------------------------------------------------------------------
/docs/YaoDSL/Xgen/菜单结构.md:
--------------------------------------------------------------------------------
1 | # 菜单
2 |
3 | 在 0.10.3 版本中,菜单的结构如下。返回数据结构需要有两个节点`items`与`setting`。
4 |
5 | ```json
6 | {
7 | "items": [
8 | {
9 | "icon": "icon-activity",
10 | "name": "图表",
11 | "path": "/x/Chart/dashboard"
12 | },
13 | {
14 | "icon": "icon-book",
15 | "name": "表格",
16 | "path": "/x/Table/pet",
17 | "children": [
18 | {
19 | "icon": "icon-book",
20 | "name": "宠物列表",
21 | "path": "/x/Table/pet"
22 | }
23 | ]
24 | },
25 | {
26 | "icon": "icon-clipboard",
27 | "name": "表单",
28 | "path": "/x/Form/pet/0/edit",
29 | "children": [
30 | {
31 | "icon": "icon-clipboard",
32 | "name": "创建宠物",
33 | "path": "/x/Form/pet/0/edit"
34 | }
35 | ]
36 | }
37 | ],
38 | "setting": [
39 | {
40 | "icon": "icon-settings",
41 | "name": "设置",
42 | "path": "/setting",
43 | "children": [
44 | {
45 | "name": "系统设置",
46 | "path": "/setting"
47 | }
48 | ]
49 | }
50 | ]
51 | }
52 | ```
53 |
--------------------------------------------------------------------------------
/docs/YaoDSL/index.md:
--------------------------------------------------------------------------------
1 | # YaoDSL
2 |
3 |
4 |
5 | - [环境变量](环境变量.md)
6 | - [处理器](处理器/index)
7 | - [AIGC](AIGC/index)
8 | - [API](API/index)
9 | - [Connector](Connector/index)
10 | - [Flow](Flow/index)
11 | - [Model](Model/index)
12 | - [neo](neo/index)
13 | - [Pipe](Pipe/index)
14 | - [Plan](Plan/index)
15 | - [Plugin](Plugin/index)
16 | - [Query](Query/index)
17 | - [Store](Store/index)
18 | - [SUI](SUI/index)
19 | - [Task](Task/index)
20 | - [v8go](v8go/index)
21 | - [Widget](Widget/index)
22 | - [Xgen](Xgen/index)
23 |
24 |
--------------------------------------------------------------------------------
/docs/YaoDSL/neo/AI助手/index.md:
--------------------------------------------------------------------------------
1 | # AIAgent
2 |
3 |
4 |
5 | - [回调函数](回调函数.md)
6 | - [AI助手](AI助手.md)
7 |
8 |
--------------------------------------------------------------------------------
/docs/YaoDSL/neo/index.md:
--------------------------------------------------------------------------------
1 | # neo
2 |
3 |
4 |
5 | - [neo_api接口](neo_api接口.md)
6 | - [neo命令](neo命令.md)
7 | - [neo聊天助手](neo聊天助手.md)
8 | - [sse函数](sse函数.md)
9 | - [AI助手](AI助手/index)
10 |
11 |
--------------------------------------------------------------------------------
/docs/YaoDSL/neo/sse函数.md:
--------------------------------------------------------------------------------
1 | # yao 应用中的 sse 函数
2 |
3 | SSE函数是Yao应用中用于处理服务器发送事件(Server-Sent Events)的一组函数。主要包括ssEvent、cancel两个函数,其中最常用的是ssEvent函数,它可以在服务器端向客户端发送实时消息。这些函数通常在text/stream类型的API请求中使用,能够实现服务器向客户端的单向实时数据推送。ssEvent函数接收两个参数:事件名称(通常使用'message')和要发送的数据内容。需要注意的是,这些函数必须在API关联的处理函数中直接使用,不能通过间接调用的方式使用。
4 |
5 | 在 yao 应用的 js 脚本中,有几个与 sse 相关的处理函数。
6 |
7 | ## 函数 ssEvent
8 |
9 | 适用于所有的`text/stream` api 请求
10 |
11 | 在 js 脚本中可以使用 ssEvent 函数向客户端发送 sse 事件。这个函数在底层调用了 gin 的 SSEvent 函数。函数接收两个参数:
12 |
13 | - event,事件名称,字符串,一般默认情况下使用 message,使用 eventsource 的情况下会触发浏览器中的 onmessage 事件。
14 | - data,消息内容,任意数据
15 |
16 | 具体请参考:
17 |
18 | [使用服务器发送事件](https://developer.mozilla.org/zh-CN/docs/Web/API/Server-sent_events/Using_server-sent_events#%E4%BA%8B%E4%BB%B6%E6%B5%81%E6%A0%BC%E5%BC%8F)
19 |
20 | ## 函数 cancel
21 |
22 | 适用于所有的`text/stream` api 请求
23 |
24 | js 中的 cancel 函数实际上会调用 go 中的 context 的函数,取消请求连接。
25 |
26 | ```go
27 | ctx, cancel := context.WithCancel(context.Background())
28 | ```
29 |
30 | 需要注意的是在调用 ssEvent 与 cancel 时,需要在 api 关联的处理函数里直接使用,不能在 api 函数里通过调用处理器间接调用。
31 | 比如 api 定义如下,那么 ssEvent 函数需要在处理器`scripts.chatweb.process`或是其直接调用的 js 函数中调用,而不能在处理`scripts.chatweb.process`中通过`Process("")`间接调用。原因是 ssEvent 是一个特定函数,只在固定的 streamHandle 的函数上下文中才会的生效。
32 |
33 | ```json
34 | {
35 | "path": "/chat-process",
36 | "method": "POST",
37 | "guard": "scripts.security.CheckChatKey",
38 | "process": "scripts.chatweb.handler",
39 | "in": [":payload"],
40 | "out": {
41 | "status": 200,
42 | "type": "text/event-stream; charset=utf-8"
43 | }
44 | }
45 | ```
46 |
47 | 示例:
48 |
49 | ```js
50 | function handler(payload) {
51 | // console.log("payload:", payload)
52 | if (payload == null) {
53 | return 0;
54 | }
55 | const content = payload.replace(/^data:/, '');
56 | if (typeof ssEvent === 'function') {
57 | ssEvent('data', content);
58 | } else {
59 | console.print(content);
60 | }
61 | return 1;
62 | }
63 | ```
64 |
--------------------------------------------------------------------------------
/docs/YaoDSL/v8go/index.md:
--------------------------------------------------------------------------------
1 | # v8go
2 |
3 |
4 |
5 | - [使用npm库](使用npm库.md)
6 | - [使用ts的注意事项](使用ts的注意事项.md)
7 | - [使用typescript进行开发](使用typescript进行开发.md)
8 | - [小心字节处理](小心字节处理.md)
9 | - [在js脚本中异步执行作业](在js脚本中异步执行作业.md)
10 | - [在js脚本中抛出异常](在js脚本中抛出异常.md)
11 | - [在yao中使用外部库](在yao中使用外部库.md)
12 | - [Promise](Promise.md)
13 |
14 |
--------------------------------------------------------------------------------
/docs/YaoDSL/v8go/在js脚本中抛出异常.md:
--------------------------------------------------------------------------------
1 | # 在 js 脚本中报错的方法
2 |
3 | ## 使用 JS 标准的 Error 对象
4 |
5 | ```js
6 | function testException() {
7 | throw new Error('hello');
8 | }
9 | ```
10 |
11 | 报错结果:
12 |
13 | ```json
14 | {
15 | "code": 500,
16 | "message": "amis.curd.curdTemplate Error: 模型:书本不存在\n at getModelDefinition (scripts/amis/lib.js:22:17)\n at getFilterFormFields (scripts/amis/lib.js:272:23)\n at curdTemplate (scripts/amis/curd.js:16:20)"
17 | }
18 | ```
19 |
20 | ## 对象 Exception
21 |
22 | 使用 Yao 特定的对象 Exception,会被 Yao 框架捕获。只有一个参数时,异常代码会设置成 500。
23 |
24 | ```js
25 | function testException() {
26 | throw new Exception('hello');
27 | }
28 | ```
29 |
30 | 可以在第二个参数指定异常代码。
31 |
32 | ```js
33 | function testException() {
34 | throw new Exception('hello', 403);
35 | }
36 | ```
37 |
38 | 转换成错误对象
39 |
40 | ```json
41 | { "code": 500, "message": "模型:书本不存在" }
42 | ```
43 |
44 | 区别:
45 |
46 | 使用 Exception 得到的异常信息会更友好,在 api 接口调用中信息显示更友好。
47 |
48 | 使用 Error 会得到更具体的 js 堆栈信息,开发时会更好。
49 |
50 | 在开发代码时可以先把 Exception 设置成 Error,最后再注释掉。
51 |
52 | ```js
53 | let Exception = Error;
54 | throw new Exception(`模型:${modelName}不存在`);
55 | ```
56 |
57 | 异常测试:
58 |
59 | ```js
60 | var test = () => {
61 | var res = 1;
62 | try {
63 | throw new Exception('hello', 404);
64 | } catch (e) {
65 | res = {
66 | isError: e instanceof Error,
67 | message: e.message, //一定要使用e.message获取错误文本
68 | code: e.code, //404
69 | name: e.name //name的格式是:Exception|
70 | };
71 | }
72 | return res;
73 | };
74 | test();
75 | ```
76 |
--------------------------------------------------------------------------------
/docs/YaoDSL/v8go/小心字节处理.md:
--------------------------------------------------------------------------------
1 | # 小心字节处理
2 |
3 | ## 字节处理
4 |
5 | 在 yao 中使用 js 处理字节数组时需要小心.
6 |
7 | 这个脚本不正常,如果在 js 脚本中读取了字节数组,并把字节数组作为 json 对象的属性返回时,将得不到你想要的结果,比如这里读取的图片内容,在 API 中输出时会显示一系列的数组,而不是字节码。
8 |
9 | ```js
10 | function Download() {
11 | let fs = new FS('system');
12 |
13 | const buf = fs.ReadFileBuffer('/upload/1/20231115/微信图片.png');
14 | //
15 | return {
16 | content: buf,
17 | type: 'image/png'
18 | };
19 | }
20 | ```
21 |
22 | 这个脚本正常,可以直接返回字节数组,没有包含在对象中。
23 |
24 | ```js
25 | function Download() {
26 | let fs = new FS('system');
27 |
28 | const buf = fs.ReadFileBuffer(
29 | '/upload/1/20231115/微信图片_20220601141654.png'
30 | );
31 | return buf;
32 | }
33 | ```
34 |
35 | 问题在原因在于,在 yao 中把 js 对象转换成 go 对象时,使用的是 js 的 json.marshal 与 go 的 jsoniter.Unmarshal。这个转换过程中,js 的字节 uint32 数组会转换成 float64 的数组。最后导致数据结构发生变化。
36 |
37 | `/gou/runtime/v8/bridge/bridge.go`
38 |
39 | ```go
40 | func goValueParse(value *v8go.Value, v interface{}) (interface{}, error) {
41 |
42 | data, err := value.MarshalJSON()
43 | if err != nil {
44 | return nil, err
45 | }
46 |
47 | ptr := &v
48 | // 字节数组类型发生变化。
49 | err = jsoniter.Unmarshal(data, ptr)
50 | if err != nil {
51 | fmt.Printf("---\n%s\n---\n", data)
52 | return nil, err
53 | }
54 |
55 | return *ptr, nil
56 | }
57 | ```
58 |
59 | ## 替代方案
60 |
61 | 使用 flow,来操作文件的下载读取。
62 |
63 | ```json
64 | {
65 | "label": "下载文件",
66 | "version": "1.0.0",
67 | "description": "下载文件",
68 | "nodes": [
69 | {
70 | "name": "filename",
71 | "process": "scripts.system.file.getFileName",
72 | "args": ["{{$in.0}}"]
73 | },
74 | {
75 | "name": "下载文件",
76 | "process": "fs.system.Download",
77 | "args": ["{{$res.filename}}"]
78 | }
79 | ],
80 | "output": "{{$res.下载文件}}"
81 | }
82 | ```
83 |
84 | ## 总结
85 |
86 | 避免在 js 脚本中与 golang 之间进行大量的字节转换操作,比如读取转换文件。针对于类似的场景处理方案最好是使用 golang 的程序进行处理,避免使用脚本进行转换。同时 bytes 在转换过程也会消耗大量的内存,转换过程中也是按字节进行赋值处理。
87 |
--------------------------------------------------------------------------------
/docs/YaoDSL/处理器/Array转树形结构.md:
--------------------------------------------------------------------------------
1 | # Array 转树形结构
2 |
3 | 处理器`xiang.helper.ArrayTree`或是`utils.arr.Tree`,传入有父子节点关系的对象数组,返回转换后树形结构数据。转换后的子节点的数据保存在`children`属性中,可嵌套。
4 |
5 | 典型的应用是转换保存在数据库中的菜单数据成 JSON 对象。
6 |
7 | - 参数 1: 记录集合
8 | - 参数 2: 数据转换配置项,配置项定义:
9 |
10 | ```go
11 | // ArrayTreeOption Array转树形结构参数表
12 | type ArrayTreeOption struct {
13 | Key string `json:"id"` // 主键名称, 默认为 id
14 | Empty interface{} `json:"empty"` // Top节点 parent 数值, 默认为 0
15 | Parent string `json:"parent"` // 父节点字段名称, 默认为 parent
16 | Children string `json:"children"` // 子节点字段名称, 默认为 children
17 | }
18 |
19 | ```
20 |
21 | 一般会设置`empty=null`与`parent`,表示如果这个`parent`对应的字段如果是空值说明是树顶点。
22 |
23 | 示例
24 |
25 | ```js
26 | res = Process('xiang.helper.ArrayTree', cate, {
27 | parent: 'parent_id',
28 | empty: null
29 | });
30 | ```
31 |
32 | 删除空对象
33 |
34 | ```js
35 | function removeEmpty(obj) {
36 | for (var prop in obj) {
37 | if (obj[prop] === null || obj[prop] === undefined) {
38 | delete obj[prop];
39 | } else if (typeof obj[prop] === 'object') {
40 | removeEmpty(obj[prop]);
41 | if (Array.isArray(obj[prop]) && obj[prop].length === 0) {
42 | delete obj[prop];
43 | } else if (Object.keys(obj[prop]).length === 0) {
44 | delete obj[prop];
45 | }
46 | }
47 | }
48 | return obj;
49 | }
50 | ```
51 |
--------------------------------------------------------------------------------
/docs/YaoDSL/处理器/Log.md:
--------------------------------------------------------------------------------
1 | # log 打印调试信息
2 |
3 | Log 打印调试信息,方便定位问题。
4 |
5 | ## 示例
6 |
7 | log 打印位置 `logs/application.log` 打印日志:
8 |
9 | ```javascript
10 | log.Error('%v', foo);
11 | log.Info('foo');
12 | ```
13 |
14 | 输出以下信息:
15 |
16 | ```
17 | time="2022-08-25T10:00:28Z" level=error msg=foo
18 | time="2022-08-25T10:00:28Z" level=info msg=foo
19 |
20 | ```
21 |
--------------------------------------------------------------------------------
/docs/YaoDSL/处理器/index.md:
--------------------------------------------------------------------------------
1 | # 处理器
2 |
3 |
4 |
5 | - [处理器列表](处理器列表.md)
6 | - [会话数据](会话数据.md)
7 | - [加密解密](加密解密.md)
8 | - [日期处理](日期处理.md)
9 | - [使用处理器](使用处理器.md)
10 | - [数据图表](数据图表.md)
11 | - [数据处理](数据处理.md)
12 | - [数据导入](数据导入.md)
13 | - [数据表格](数据表格.md)
14 | - [网络请求](网络请求.md)
15 | - [文件处理](文件处理.md)
16 | - [应用引擎](应用引擎.md)
17 | - [Array转树形结构](Array转树形结构.md)
18 | - [Log](Log.md)
19 |
20 |
--------------------------------------------------------------------------------
/docs/YaoDSL/处理器/会话数据.md:
--------------------------------------------------------------------------------
1 | # 会话数据
2 |
3 | 用户会话数据处理器
4 |
5 | | 处理器 | 说明 | 文档 |
6 | | ---------------- | ---------------- | ---- |
7 | | session.Start | 启用会话 | |
8 | | session.ID | 读取会话 ID | |
9 | | session.Get | 读取会话变量 | |
10 | | session.Set | 设置会话变量 | |
11 | | session.MultiSet | 批量设置会话变量 | |
12 | | session.Dump | 返回所有会话数据 | |
13 |
14 | 设置 Session 的值,新建`flows/session.flow.json`,args 的三个参数分别对应:session 的 key,session 的值,过期时间
15 |
16 | ```json
17 | {
18 | "label": "session",
19 | "version": "1.0.0",
20 | "description": "session",
21 | "nodes": [
22 | {
23 | "name": "SID",
24 | "process": "session.start"
25 | },
26 | {
27 | "name": "设置会话数据",
28 | "process": "session.set",
29 | "args": ["user", "123456", 28800]
30 | }
31 | ],
32 | "output": "success"
33 | }
34 | ```
35 |
36 | 设置好 session 后,可以使用`Process("session.Get", "user")`来获取对应的值
37 |
--------------------------------------------------------------------------------
/docs/YaoDSL/处理器/加密解密.md:
--------------------------------------------------------------------------------
1 | # 加密解密
2 |
3 | 加密解密处理器,参考文档 对照表
4 |
5 | | 处理器 | 说明 | 使用方法 |
6 | | ---------------------- | ----------------------------------------------------------------- | --------------------------------------------------------- |
7 | | yao.crypto.hmac | 使用 SHA1 加密,自带 base64 加密 | Process("yao.crypto.hmac", "SHA1", value, key, "base64"); |
8 | | encoding.base64.Encode | 使用 base64 加密 | Process("encoding.base64.Encode", str); |
9 | | encoding.base64.Decode | 使用 base64 解密 | Process("encoding.base64.Decode", str); |
10 | | yao.crypto.hash | 使用各种加密方法 ,第一个参数可填写:MD4,MD5 ,SHA1 ,SHA256 ... | Process("yao.crypto.hash", "SHA1", str); |
11 | | |
12 |
--------------------------------------------------------------------------------
/docs/YaoDSL/处理器/数据图表.md:
--------------------------------------------------------------------------------
1 | # 数据图表
2 |
3 | 数据看板、分析图表、数据大屏相关处理器。
4 |
5 | | 处理器 | 说明 | 参数说明 |
6 | | ------------------- | ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
7 | | yao.chart.setting | 读取图表配置信息,用于前端界面渲染。通过图表的 Action.Setting 配置执行相应处理器。 | - |
8 | | yao.chart.xgen | 生成图表的前端配置数据。支持传入自定义数据和权限排除项,用于生成最终的图表展示配置。 | data: object 自定义数据
excludes: array 权限排除项 |
9 | | yao.chart.component | 执行图表组件相关的查询操作。用于处理图表中特定组件的数据获取需求。 | xpath: string 组件路径
method: string 方法名
query?: object 查询参数 |
10 | | yao.chart.data | 获取图表数据。通过图表的 Action.Data 配置执行相应处理器,返回图表所需的数据结果。 | - |
11 |
12 | ## 使用示例
13 |
14 | ### 在图表 DSL 中配置处理器
15 |
16 | ```json
17 | {
18 | "action": {
19 | "data": {
20 | "process": "scripts.stat.daily",
21 | "default": ["$G.TODAY"]
22 | },
23 | "setting": {
24 | "process": "scripts.chart.setting"
25 | }
26 | }
27 | }
28 | ```
29 |
30 | ### 在数据流中使用
31 |
32 | ```json
33 | {
34 | "nodes": [
35 | {
36 | "name": "图表数据",
37 | "process": "yao.chart.Data",
38 | "args": ["sales-chart"]
39 | }
40 | ]
41 | }
42 | ```
43 |
--------------------------------------------------------------------------------
/docs/YaoDSL/处理器/数据表格.md:
--------------------------------------------------------------------------------
1 | # 数据表格
2 |
3 | 数据表格相关处理器。
4 |
5 | 数据表格用来处理列表页面的表格布局
6 |
7 | `tables`表格中内置了许多处理器为我们提供完整的表格数据/布局处理,命名空间为 table.<表格名称>;
8 |
9 | | 处理器 | 说明 | 文档 ` |
10 | | --------------------- | ---------------------------------------- | ------ |
11 | | yao.table.Search | 按条件查询, 分页。 | |
12 | | yao.table.Find | 按主键查询单条数据。 | |
13 | | yao.table.Select | 返回数据集合,匹配选择器组件数据结构。 | |
14 | | yao.table.Save | 保存单条记录,指定主键更新,不指定创建。 | |
15 | | yao.table.Delete | 按主键删除单条记录。 | |
16 | | yao.table.Insert | 批量新增记录。 | |
17 | | yao.table.UpdateWhere | 批量更新符合条件的记录。 | |
18 | | yao.table.DeleteWhere | 批量删除符合条件的记录。 | |
19 | | yao.table.QuickSave | 保存多条记录,指定主键更新,不指定创建。 | |
20 | | yao.table.UpdateIn | 批量更新指定一组主键的的数据记录。 | |
21 | | yao.table.DeleteIn | 批量删除指定一组主键的的数据记录。 | |
22 | | yao.table.Setting | 读取数据表格配置信息, 用于前端界面渲染 | |
23 |
--------------------------------------------------------------------------------
/docs/YaoDSL/处理器/日期处理.md:
--------------------------------------------------------------------------------
1 | # 日期处理
2 |
--------------------------------------------------------------------------------
/docs/algolia.json:
--------------------------------------------------------------------------------
1 | {
2 | "index_name": "yao-docs",
3 | "start_urls": ["https://wwsheng009.github.io/yao-docs"],
4 | "rateLimit": 8,
5 | "maxDepth": 10,
6 | "selectors": {
7 | "lvl0": {
8 | "selector": "",
9 | "defaultValue": "Documentation"
10 | },
11 | "lvl1": ".content h1",
12 | "lvl2": ".content h2",
13 | "lvl3": ".content h3",
14 | "lvl4": ".content h4",
15 | "lvl5": ".content h5",
16 | "lang": {
17 | "selector": "/html/@lang",
18 | "type": "xpath",
19 | "defaultValue": ["zh-CN"]
20 | },
21 | "content": ".content p, .content li"
22 | },
23 | "selectors_exclude": [
24 | "aside",
25 | ".page-footer",
26 | ".next-and-prev-link",
27 | ".table-of-contents"
28 | ],
29 | "custom_settings": {
30 | "attributesForFaceting": ["lang"]
31 | },
32 | "js_render": true
33 | }
34 |
--------------------------------------------------------------------------------
/docs/contributing.md:
--------------------------------------------------------------------------------
1 | # 欢迎参与贡献,提 PR
2 |
3 | ## 贡献指南
4 |
5 | 可在 [github](https://github.com/wwsheng009/yao-docs) 页 fork 一份仓库代码,然后基于 fork 后的提 PR 过来。
6 |
7 | 推荐使用 pnpm 安装:
8 |
9 | ```bash
10 | pnpm install
11 | ```
12 |
13 | 本地环境开发:
14 |
15 | ```bash
16 | pnpm dev
17 | ```
18 |
19 | ## 文章贡献
20 |
21 | 对于文章贡献,分两种情况:
22 |
23 | - 如果你是原创作者,请在 `author` 字段填写自己的 GitHub 账号名,会自动在文章末尾进行声明。
24 |
25 | - 如果你是修正某篇文章,请在 `contributors` 字段增加自己的 GitHub 账号名,也会有贡献者头像,并不会修改原作者信息。
26 |
27 | ```md
28 | ---
29 | author: Vincent Wang
30 | contributors: [HearLing]
31 | ---
32 | ```
33 |
34 | ## 代码格式
35 |
36 | 对于代码格式,本仓库使用 `prettier` 与 `git-hooks`,在你提交代码的时候会进行格式化以及修复一些问题。
37 |
38 | 也可以手动执行一下:
39 |
40 | ```bash
41 | pnpm prettier:fix
42 | ```
43 |
44 | 提交之前需要`build`检查有没有错误。
45 |
46 | ```bash
47 | pnpm run build && pnpm run serve
48 | ```
49 |
50 | 重建所有的`index.md`文件
51 |
52 | ```bash
53 | pnpm run build:index
54 | ```
55 |
56 | ## 贡献者列表
57 |
58 | 推荐大家自行填写相关信息,只需要在 `docs/index.md` 文件内添加自己的相关信息即可,无需修改 `contributors.json` 文件,该文件会自动生成。
59 |
60 | ## 文字排版
61 |
62 | 笔记内容按照 [中文文案排版指北](https://mazhuang.org/wiki/chinese-copywriting-guidelines/)进行排版,即尽量保证中英文之间的空格,也可以使用 VSCode 相关格式化工具。
63 |
64 | `md`的文档格使用`pritter`配合`vscode`的插件[`esbenp.prettier-vscode`](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
65 |
66 | ## 感谢参与
67 |
68 | 非常感谢你对于 [ChoDocs](https://github.com/chodocs/chodocs) 的参与贡献,我们会在首页 [chodocs.cn](https://chodocs.cn/) 展示各位贡献者的头像!
69 |
--------------------------------------------------------------------------------
/docs/contributors.json:
--------------------------------------------------------------------------------
1 | ["wwsheng009", "AbbetWang"]
2 |
--------------------------------------------------------------------------------
/docs/contributors.ts:
--------------------------------------------------------------------------------
1 | import contributors from './contributors.json';
2 |
3 | export interface Contributor {
4 | name: string;
5 | avatar: string;
6 | }
7 |
8 | export interface CoreTeam {
9 | avatar: string;
10 | name: string;
11 | github: string;
12 | twitter?: string;
13 | sponsors?: boolean;
14 | description: string;
15 | packages?: string[];
16 | functions?: string[];
17 | }
18 |
19 | const contributorsAvatars: Record = {};
20 |
21 | const getAvatarUrl = (name: string) => `https://github.com/${name}.png`;
22 |
23 | const contributorList = (contributors as string[]).reduce((acc, name) => {
24 | contributorsAvatars[name] = getAvatarUrl(name);
25 | acc.push({ name, avatar: contributorsAvatars[name] });
26 | return acc;
27 | }, [] as Contributor[]);
28 |
29 | export { contributorList as contributors };
30 |
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: home
3 |
4 | title: Yao
5 | titleTemplate: 学习笔记
6 |
7 | hero:
8 | name: 分享
9 | text: 努力学习,天天向上
10 | tagline: 学习,总结,分享,成长
11 | actions:
12 | - theme: brand
13 | text: 开始学习
14 | link: /%E5%85%A5%E9%97%A8%E6%8C%87%E5%8D%97/readme.md
15 | - theme: alt
16 | text: 源代码
17 | link: https://github.com/wwsheng009/yao-docs
18 |
19 | features:
20 | - icon: 📝
21 | title: 入门指南
22 | details: 新手如何快速上手使用Yao.
23 | link: /入门指南/
24 | linkText: '入门指南'
25 | - icon: ❤️
26 | title: 常用的项目模板
27 | details: 包含简单的,复杂的项目模板.
28 | link: /%E5%85%A5%E9%97%A8%E6%8C%87%E5%8D%97/readme.md
29 | linkText: '项目模板'
30 | - icon: 🔥
31 | title: Yao引擎源代码分析
32 | details: 使用drawio绘制了Yao引擎的结构与原理.
33 | link: /流程图/
34 | linkText: 流程图
35 | - icon: 🚀
36 | title: 好用的插件
37 | details: 使用Studio插件/Vscode插件提升开发效率.
38 | link: /Studio/
39 | linkText: 编辑器
40 | ---
41 |
42 |
43 |
--------------------------------------------------------------------------------
/docs/postcss.config.mjs:
--------------------------------------------------------------------------------
1 | export default {
2 | plugins: {
3 | 'postcss-nested': {}
4 | }
5 | };
6 |
--------------------------------------------------------------------------------
/docs/public/images/keep.git:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/public/images/keep.git
--------------------------------------------------------------------------------
/docs/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Allow: /
3 | Sitemap: https://wwsheng009.github.io/yao-docs/sitemap.xml
--------------------------------------------------------------------------------
/docs/socialIcons.ts:
--------------------------------------------------------------------------------
1 | export const icons = {
2 | bilibili: ``
8 | };
9 |
--------------------------------------------------------------------------------
/docs/template.txt:
--------------------------------------------------------------------------------
1 | # 文档编写指南
2 |
3 | ## 文档结构规范
4 |
5 | 为了使文档更易于AI模型理解和检索,请遵循以下格式规范:
6 |
7 | ### 1. 文档基本结构
8 |
9 | 每个文档应包含以下部分:
10 |
11 | ```markdown
12 | # 标题
13 |
14 | ## 概述
15 |
16 | [简要描述本文档的主要内容和目的,2-3句话]
17 |
18 | ## 目录
19 |
20 | [自动生成的目录,使用 [[toc]] 标记]
21 |
22 | ## 正文内容
23 |
24 | [按照逻辑层次组织内容]
25 |
26 | ## 示例
27 |
28 | [如果适用,提供具体的代码示例或使用场景]
29 |
30 | ## 相关链接
31 |
32 | [相关文档链接]
33 | ```
34 |
35 | ### 2. 内容编写指南
36 |
37 | - 使用清晰的标题层级(h1-h6)
38 | - 每个主要概念都应有简要解释
39 | - 使用列表和表格组织复杂信息
40 | - 代码示例应包含注释
41 | - 使用统一的术语表述
42 |
43 | ### 3. SEO优化建议
44 |
45 | - 在文档开头添加关键词标签
46 | - 使用语义化的标题结构
47 | - 添加适当的内部链接
48 | - 确保代码块使用正确的语言标记
49 |
50 | ### 4. AI友好建议
51 |
52 | - 使用简洁明了的语言
53 | - 避免使用模糊或歧义的表述
54 | - 保持逻辑结构的一致性
55 | - 适当使用元数据标记
56 |
57 | ## 示例模板
58 |
59 | ```markdown
60 | # 功能名称
61 |
62 | ## 概述
63 |
64 | 简要描述该功能的主要用途和特点。
65 |
66 | [[toc]]
67 |
68 | ## 功能特性
69 |
70 | - 特性1
71 | - 特性2
72 | - 特性3
73 |
74 | ## 使用方法
75 |
76 | ### 基本用法
77 |
78 | `代码示例`
79 |
80 | ### 进阶用法
81 |
82 | `代码示例`
83 |
84 | ## 最佳实践
85 |
86 | - 实践建议1
87 | - 实践建议2
88 |
89 | ## 相关链接
90 |
91 | - [相关文档1](链接)
92 | - [相关文档2](链接)
93 | ```
94 |
--------------------------------------------------------------------------------
/docs/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from 'node:path';
2 | import { defineConfig } from 'vite';
3 | import Icons from 'unplugin-icons/vite';
4 | import IconsResolver from 'unplugin-icons/resolver';
5 | import Components from 'unplugin-vue-components/vite';
6 | import { MarkdownTransform } from './.vitepress/plugins/markdownTransform';
7 |
8 | // 添加ESM动态导入配置
9 | export default defineConfig(async () => {
10 | const [UnoCSS, { default: pkgManagerDetector }] = await Promise.all([
11 | import('unocss/vite').then((m) => m.default),
12 | import('package-manager-detector') // 修复ESM模块导入问题
13 | ]);
14 |
15 | return {
16 | server: {
17 | hmr: {
18 | overlay: false
19 | },
20 | fs: {
21 | allow: [resolve(__dirname, '..')]
22 | }
23 | },
24 | plugins: [
25 | // custom
26 | MarkdownTransform(),
27 | // plugins
28 | Components({
29 | dirs: resolve(__dirname, '.vitepress/theme/components'),
30 | include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
31 | resolvers: [
32 | IconsResolver({
33 | componentPrefix: ''
34 | })
35 | ],
36 | dts: './.vitepress/components.d.ts',
37 | transformer: 'vue3'
38 | }),
39 | Icons({
40 | compiler: 'vue3',
41 | autoInstall: true,
42 | defaultStyle: 'display: inline-block',
43 | // 添加浏览器polyfill配置
44 | customCollections: {
45 | core: {
46 | async loader() {
47 | return await pkgManagerDetector();
48 | }
49 | }
50 | }
51 | }),
52 | UnoCSS()
53 | ],
54 | // 添加ESM构建配置
55 | build: {
56 | target: 'esnext'
57 | }
58 | };
59 | });
60 |
--------------------------------------------------------------------------------
/docs/入门指南/Yao学习路线图.md:
--------------------------------------------------------------------------------
1 | # Yao 学习路线图
2 |
3 | ## 入门与上手
4 |
5 | - 到官网上看看 Yao 的介绍,先了解 Yao 的定位与用途=>[官网入口](https://yaoapps.com/)。
6 |
7 | - 下载安装 Yao。
8 |
9 | - 使用 Yao-Init 初始化工具构建您的第一个 Yao 项目,让自己对 Yao 有一个感性的认识。[初始化项目入口](https://github.com/wwsheng009/yao-init)。
10 |
11 | - 创建您的第一个模型文件。在目录/models 下参考 pet.mod.json 创建你的模型,初始阶段模型定义尽可能的简单。如果你的电脑环境可以使用 ChatGPT,可以让参考这里:[使用`ChatGPT`开发`Yao`应用](../AI/使用AI开发YAO应用.md)
12 |
13 | - 完成上一步后,你得到系统自动创建的界面配置。你可以尝试手工编写,进行更复杂的界面功能配置。
14 |
15 | - 让数据从外部访问。创建您的第一个 api 配置文件。
16 |
17 | ## 进阶
18 |
19 | - 学习使用 Yao 命令。命令提供了很多有用的工具
20 |
21 | - Yao migrate 更新模型数据表结构
22 | - Yao start 启动服务
23 | - Yao run 运行处理器
24 |
25 | - 更新您的模型定义文件,增加更多的字段,或是调整字段类型,增加模型与模型之间的关系。创建了新的模型,同样可以使用工具生成界面配置。
26 |
27 | > 更新模型后,记得运行命令`yao migrate`更新数据库,sqlite 数据库请执行`yao migrate --reset`
28 |
29 | - 学习并编写 Yao 脚本文件,Yao 使用 js 进行功能扩展,使用 js 脚本可以实现更复杂的功能与逻辑处理。
30 |
31 | ## 学习资源
32 |
33 | - [官网文档](https://yaoapps.com/doc)
34 | - [官网仓库](https://github.com/YaoApp)
35 | - [本项目](https://wwsheng009.github.io/yao-docs/)
36 |
37 | ## Yao 项目
38 |
39 | 目前官方正式的版本是 0.10.3。可以在官网的 github 上下载并学习。
40 |
41 | - [yao-admin,零代码生成 yao 应用] (https://github.com/YaoApp/yao-admin)
42 | - [yao-wms,仓库管理系统] (https://github.com/YaoApp/yao-wms)
43 |
44 | 开发版本 0.10.3,以下非官方维护。
45 |
46 | - [yao-init](https://github.com/wwsheng009/yao-init),项目初始化模板
47 | - [yao-wms](https://github.com/wwsheng009/yao-wms),比较复杂的示例
48 | - [yao-chatgpt](https://github.com/wwsheng009/yao-chatgpt),简单的示例
49 | - [yao-admin](https://github.com/wwsheng009/yao-admin),增强版 yao-admin
50 |
51 | ## 工具
52 |
53 | - [YAO 应用 JSON-SCHEMA](https://github.com/wwsheng009/yao-app-ts-types)
54 |
--------------------------------------------------------------------------------
/docs/入门指南/Yao简单介绍.md:
--------------------------------------------------------------------------------
1 | # Yao 简单介绍
2 |
3 | ## 概述
4 |
5 | YAO 是一款开源应用引擎,使用 Golang 编写的命令行工具,适用于开发业务系统、API接口、管理后台和低代码平台。本文将介绍 YAO 的核心概念、开发理念和主要功能模块。
6 |
7 | [[toc]]
8 |
9 | ## 什么是 YAO?
10 |
11 | YAO 是一款开源应用引擎,使用 Golang 编写,仅一个命令行工具,下载即用。适合用于开发业务系统、网站/APP API 接口、管理后台、自建低代码平台等。
12 |
13 | ## 技术栈
14 |
15 | YAO 使用以下核心技术栈:
16 |
17 | - 后端:Golang
18 | - 前端:React
19 | - 脚本:JavaScript
20 |
21 | ## 开发理念
22 |
23 | ### 元数据编程
24 |
25 | 通过模型配置文件来驱动数据库配置与界面配置。
26 |
27 | ### AI 驱动开发
28 |
29 | 2023年人工智能大爆发,YAO 充分利用 AI 技术解析自然语言生成代码,让人人都能编程。
30 |
31 | ### 配置驱动UI
32 |
33 | - 平台提供前端框架
34 | - 界面配置在后端编写
35 | - 使用 JSON/JSONC 格式配置文件
36 |
37 | ### 零代码开发
38 |
39 | 定义好模型文件后,框架会生成一系列的默认配置,开箱即用。
40 |
41 | ### 灵活编程编排
42 |
43 | - 引擎平台将功能封装为独立处理器
44 | - 处理器之间无代码级耦合
45 | - 通过配置文件灵活组合功能
46 |
47 | ### 无限扩展
48 |
49 | 前端 Xgen 和后端 Yao 都提供完善的扩展机制,可通过插件实现个性化需求。
50 |
51 | ## 主要开发工作
52 |
53 | 1. 编写 DSL 配置文件
54 | 2. 开发 JS 脚本增强数据操作
55 | 3. 开发 GO 插件实现特殊需求
56 | 4. 使用 Studio 命令生成配置
57 | 5. 查阅文档和源码
58 |
59 | ## 技术优势
60 |
61 | - **高性能部署**:Golang 开发的程序部署方便,性能优异
62 | - **丰富的前端功能**:React 开发的前端满足大部分需求
63 | - **快速开发**:标准后台 CRUD 功能仅需少量配置
64 |
65 | ## 核心模块
66 |
67 | ### 后端模块
68 |
69 | 1. **Yao API 服务**
70 |
71 | - 提供 API 网关功能
72 | - 支持 REST API 和 WebSocket
73 | - 内置用户认证
74 | - 预置数据操作接口
75 | - 文件处理功能
76 | [GitHub 仓库](https://github.com/yaoapp/yao)
77 |
78 | 2. **Gou 引擎框架**
79 |
80 | - 流程编排处理器
81 | - JS V8 引擎集成
82 | [GitHub 仓库](https://github.com/yaoapp/gou)
83 |
84 | 3. **Xun ORM**
85 |
86 | - 数据库驱动
87 | [GitHub 仓库](https://github.com/yaoapp/xun)
88 |
89 | 4. **Kun 工具包**
90 | - 常用数据处理功能
91 | [GitHub 仓库](https://github.com/yaoapp/kun)
92 |
93 | ## 相关链接
94 |
95 | - [YAO GitHub](https://github.com/yaoapp/yao)
96 | - [开发文档](../index.md)
97 | - [入门教程](./index.md)
98 |
--------------------------------------------------------------------------------
/docs/入门指南/index.md:
--------------------------------------------------------------------------------
1 | # 入门指南
2 |
3 |
4 |
5 | - [readme](readme.md)
6 | - [Yao学习路线图](Yao学习路线图.md)
7 | - [Yao简单介绍](Yao简单介绍.md)
8 | - [基础](基础/index)
9 | - [进阶系列](进阶系列/index)
10 | - [上手系列](上手系列/index)
11 |
12 |
--------------------------------------------------------------------------------
/docs/入门指南/readme.md:
--------------------------------------------------------------------------------
1 | # `Yao`低代码引擎开发与技巧
2 |
3 | ## 此项目收集使用`Yao`低代码引擎开发应用的文档,希望对您有帮助。
4 |
5 | - [Yao 低代码引擎官网](https://yaoapps.com/)
6 | - [Yao Github 主页](https://github.com/YaoApp)
7 | - 文档已经布署到 Githhub Pages 上,欢迎访问:[Yao-docs](https://github.com/wwsheng009/yao-docs)
8 |
9 | ## 主要分类
10 |
11 | - [入门指南](../%E5%85%A5%E9%97%A8%E6%8C%87%E5%8D%97/index)
12 | - [AI](../AI/index)
13 | - [Xgen](../YaoDSL/Xgen/index)
14 | - [YaoDSL](../YaoDSL/index)
15 | - 一些与`Yao`工作机制的流程图[Yao 流程图](../流程图/index)
16 |
17 | ## 其它工具与项目
18 |
19 | - [Yao-Amis-Admin](https://github.com/wwsheng009/yao-amis-admin)
20 | - [VSCode 编辑器语法校验证配置](https://github.com/wwsheng009/yao-app-ts-types)
21 | - [Yao-Init](https://github.com/wwsheng009/yao-init)
22 | - [Yao-WMS](https://github.com/wwsheng009/yao-wms)
23 | - [Yao-ChatGPT](https://github.com/wwsheng009/yao-chatgpt)
24 |
25 | ## 站点主题
26 |
27 | 项目的`VitePress`主题使用的是:[ChoDocs](https://github.com/chodocs/chodocs)
28 |
29 | ## ⭐ 请点亮你的小星星
30 |
31 | 
32 |
33 | ## 🧱 Contribute
34 |
35 | 期待您的参与
36 |
37 | 参考 [**Contributing Guide**](https://wwsheng009.github.io/yao-docs/contributing.html).
38 |
39 | ## 🧑💻 Contributors|贡献者
40 |
41 | 感谢所有的贡献者!
42 |
43 |
44 |
45 |
46 |
47 | ## 📄 License
48 |
49 | LICENSE
50 | © 2023-PRESENT [Vincent Wang](https://github.com/wwsheng009)
51 |
--------------------------------------------------------------------------------
/docs/入门指南/上手系列/1 Yao下载与安装.md:
--------------------------------------------------------------------------------
1 | # yao 下载与安装
2 |
3 | 如何安装 Yao
4 |
5 | 这里说的 Yao 是指 Yao 引擎的执行程序。安装 Yao 只需要下载一个执行程序就可以了。
6 |
7 | ## yao 版本
8 |
9 | 需要注意的时,yao 的应用需要使用特定版本的 yao 的执行程序。
10 |
11 | 在升级 yao 执行程序之前,可以给执行程序加个后缀,比如加上版本编号。可以直接另命名 yao 应用程序,不用担心程序依赖问题。
12 |
13 | ```sh
14 | # yao程序版本管理
15 | mv /usr/local/bin/yao /usr/local/bin/yao-0.10.2
16 |
17 | # 使用特定版本的yao启动你的应用
18 | yao-0.10.2 start
19 | ```
20 |
21 | ## 下载 Yao 程序
22 |
23 | ### 官方发行版本
24 |
25 | 官方在重大功能更新后会发布新的版本。
26 |
27 | 访问地址:https://yaoapps.com/release
28 |
29 | 在发布页面可以看到各个版本的下载地址与相关的说明。
30 |
31 | 找到合适的版本后,点击下载按钮后,会自动一个没有后缀的二进制文件。只需要把这个文件放到目录`/usr/local/bin/`即可。
32 |
33 | 比如下载安装 0.10.3 版本程序:
34 |
35 | ```sh
36 |
37 | wget https://release-bj.yaoapps.com/archives/yao-0.10.3-linux-amd64
38 |
39 | # 移动程序到bin目录
40 | mv yao-0.10.3-linux-amd64 /usr/local/bin/yao
41 |
42 | # 加上程序执行权限
43 | chmod +x /usr/local/bin/yao
44 |
45 | # 版本检查
46 | yao version --all
47 | ```
48 |
49 | ### 开发版本
50 |
51 | 开发版本的会有最新的特性与功能。从 github 的 actions 中可以找到最新的开发版本。
52 |
53 | https://github.com/YaoApp/yao/actions
54 |
55 | 按照自己的操作系统类别找到对应的制品程序。
56 |
57 | - MacOS intel/m1/m2
58 | - Linux amd64/arm64
59 |
60 | 0.10.3 版本 Linux
61 |
62 | https://github.com/YaoApp/yao/actions/workflows/build-linux-dev.yml
63 |
64 | 这里无法使用命令下载,需要在浏览器中下载。
65 |
66 | 下载后是一个 zip 压缩包,里面包含了 arm64 与 amd64 版本的程序。
67 |
68 | ```sh
69 | # 移动程序到bin目录
70 | mv yao-0.10.3-linux-amd64 /usr/local/bin/yao
71 |
72 | # 加上程序执行权限
73 | chmod +x /usr/local/bin/yao
74 |
75 | # 版本检查
76 | yao version --all
77 | ```
78 |
79 | ## 总结
80 |
81 | Yao 执行程序就一个二进制的文件,可以直接移动或是删除。
82 |
83 | Yao 各个版本的差异比较大,需要仔细辨别。
84 |
--------------------------------------------------------------------------------
/docs/入门指南/上手系列/4 生成数据库表.md:
--------------------------------------------------------------------------------
1 | # 根据模型生成数据库表
2 |
3 | 比如你在 hello_world 目录下创建一个新的模型`book`。
4 |
5 | `models/book.mod.yao`
6 |
7 | ```jsonc
8 | {
9 | "name": "Book",
10 | "table": {
11 | "name": "book" //这个模型在数据库中关联的表名是`book`。
12 | },
13 | "columns": [
14 | {
15 | "name": "id",
16 | "label": "ID",
17 | "type": "ID"
18 | },
19 | {
20 | "name": "title",
21 | "label": "Title",
22 | "type": "string",
23 | "length": 256,
24 | "index": true,
25 | "nullable": true
26 | },
27 | {
28 | "name": "author",
29 | "label": "Author",
30 | "type": "string",
31 | "length": 256,
32 | "index": true,
33 | "nullable": true
34 | },
35 | {
36 | "name": "publisher",
37 | "label": "Publisher",
38 | "type": "string",
39 | "length": 256,
40 | "index": true,
41 | "nullable": true
42 | }
43 | ]
44 | }
45 | ```
46 |
47 | 模型保存后,需要执行一个 yao 命令,把模型转换成数据库中的表。打开控制台,执行以下的命令。
48 |
49 | ```sh
50 | # mysql
51 | yao migrate -n book
52 |
53 | # sqlite,需要加上--reset,
54 | yao migrate -n book --reset
55 | ```
56 |
57 | 提示:reset 的作用是删除整个数据库表后再重新创建,不要在生产环境执行,会导致数据丢失。
58 |
59 | 成功后控制台会输出以下的内容。
60 |
61 | ```sh
62 | 更新表结构 model: book (book) SUCCESS
63 | ```
64 |
65 | 上面命令的作用是把 Yao 模型定义转换成数据库表结构。如果模型对应的数据库表已经存在就更新,如果不存在创建新表。
66 |
67 | > 后面如果对模型文档有变更,也需要手动执行命令才会把模型更新到数据库。
68 |
69 | ## 总结
70 |
71 | Yao 命令也是 Yao 开发中的重要组成部分。
72 |
--------------------------------------------------------------------------------
/docs/入门指南/上手系列/5 配置表格.md:
--------------------------------------------------------------------------------
1 | # 配置模型对应的表格
2 |
3 | 创建模型文件并生成数据库表后。还需要配置表格配置文件,才能在 yao 管理后台界面上显示表内容。
4 |
5 | 表格配置目录`tables`。参考示配置文件创建一个新的配置文件`book.tab.yao`。
6 |
7 | ```sh
8 | └── tables
9 | ├── admin
10 | │ └── user.tab.yao
11 | └── demo
12 | └── pet.tab.yao
13 | ```
14 |
15 | 配置文件:`book.tab.yao`。
16 |
17 | ```jsonc
18 | {
19 | "name": "书籍",
20 | "action": {
21 | "bind": { "model": "book" }
22 | }
23 | }
24 | ```
25 |
26 | 创建并保存配置文件后,在浏览器里就能通过 url 地址:http://127.0.0.1:5099/admin/x/Table/book
27 | 访问到模型对应的表内容。
28 |
29 | 这时界面上可以查看列表,但是还不能添加数据。
30 |
31 | ## 总结
32 |
33 | 表格用于显示数据列表,你可以定义多个表格对应一个模型。
34 |
--------------------------------------------------------------------------------
/docs/入门指南/上手系列/6 配置表单.md:
--------------------------------------------------------------------------------
1 | # 配置模型对应的表单
2 |
3 | 当我们配置好数据表格后,在 Yao 管理后台能看到数据列表,但是还不能编辑数据。接下来需要配置模型对应的表单。
4 |
5 | 表单配置文件保存目录`forms`。参考示配置文件创建一个新的文件`book.form.yao`。
6 |
7 | ```sh
8 | ├── forms
9 | │ ├── admin
10 | │ │ └── user.form.yao
11 | │ └── demo
12 | │ └── pet.form.yao
13 | ```
14 |
15 | 配置文件:`book.form.yao`。
16 |
17 | ```jsonc
18 | {
19 | "name": "书籍",
20 | "action": {
21 | "bind": { "model": "book", "option": {} }
22 | }
23 | }
24 | ```
25 |
26 | 创建并保存文件后,需要更新模型对应的表格配置文件`book.tab.yao`,增加配置项`action.bind.option`。
27 |
28 | ```jsonc
29 | {
30 | "name": "书籍",
31 | "action": {
32 | "bind": {
33 | "model": "book",
34 | "option": { "form": "book" }
35 | }
36 | }
37 | }
38 | ```
39 |
40 | 在浏览器里刷新 url 地址http://127.0.0.1:5099/admin/x/Table/book
41 |
42 | 在页面的右上角会多出来一个"创建"按钮。
43 |
44 | - 点击按钮会弹出新的表单。
45 | - 在表单里填入数据并点击保存按钮。
46 | - 点击关闭按钮关闭表单输入界面。
47 |
48 | 在数据列表的右边,每条记录都会显示 3 个按钮,"查看","修改","删除"。
49 |
50 | ## 总结
51 |
52 | 到这里,一个基础的模型与相关的 CURD 界面已配置完成。模型与 CURD 操作只需要四步。
53 |
54 | - 定义模型文件
55 | - 生成数据库表
56 | - 配置表格
57 | - 配置表单
58 |
59 | 熟练后几分钟能就配置一个模型 CURD 界面。
60 |
--------------------------------------------------------------------------------
/docs/入门指南/上手系列/7 配置外部API.md:
--------------------------------------------------------------------------------
1 | # 配置外部 API
2 |
3 | ## API 配置
4 |
5 | 接下来,我们配置一个外部 api 来访问刚创建的 book 模型。
6 |
7 | > api 配置需要保存在目录`apis`下。
8 |
9 | 创建配置文件:`apis/book.http.yao`
10 |
11 | ```jsonc
12 | {
13 | "name": "BOOK 外部接口 ",
14 | "version": "1.0.0",
15 | "description": "BOOK 外部接口",
16 | "guard": "-",
17 | "group": "v1",
18 | "paths": [
19 | {
20 | "path": "book",
21 | "method": "GET",
22 | "guard": "-",
23 | "process": "models.book.get", //内置的模型处理器
24 | "in": [":params"],
25 | "out": { "status": 200, "type": "application/json" }
26 | }
27 | ]
28 | }
29 | ```
30 |
31 | 以上配置会向 yao 引擎注册一个外部访问的 api 接口。
32 |
33 | api 的路径的规则是`http(s)://host:port/api/group/path`,包含以下几部分:
34 |
35 | - 主机与接口。
36 | - 固定前缀`/api`。
37 | - api 中配置的 group,这里配置的是 v1,group 可以包含斜杠/,区分大小写。
38 | - api 中配置的 path,paths 节点中每一条记录都是一个访问端点,区分大小写。
39 |
40 | 最终生成的的 api 访问地址是http://127.0.0.1:5099/api/v1/book。
41 |
42 | 测试 api 接口,使用命令行工具或是浏览器浏览地址。
43 |
44 | ```sh
45 | curl http://127.0.0.1:5099/api/v1/book
46 |
47 | [{"author":"1212","id":1,"publisher":"1212","title":"1212"},{"author":"12","id":3,"publisher":"12","title":"12"}]
48 | ```
49 |
50 | ## 总结
51 |
52 | 在 API 定义中使用现成的处理器,快速开发 API 接口。
53 |
--------------------------------------------------------------------------------
/docs/入门指南/上手系列/8 处理器.md:
--------------------------------------------------------------------------------
1 | # 处理器
2 |
3 | 处理器(Process)是 Yao 框架中非常重要的一个概念,贯穿了整个 yao 的应用开发过程。
4 |
5 | 可以把处理器理解为编程语言中的函数,接收输入参数,输出结果值。可以使用 js 脚本编写处理器,也可以使用 golang 编写插件处理器。
6 |
7 | ## 处理器列表
8 |
9 | 在 yao 中使用处理器需要注意的是需要查询处理器的参数类型与数量,这个可以查询官方或是阅读源代码。
10 |
11 | ## 总结
12 |
13 | 处理器就是函数。
14 |
15 | Yao 引擎内置了大量的处理器,使用这些处理器能快速、方便的操作处理数据。
16 |
--------------------------------------------------------------------------------
/docs/入门指南/上手系列/9 数据增删改查.md:
--------------------------------------------------------------------------------
1 | # 数据增删改查
2 |
3 | 在 yao 中对数据的增删除改查十分方便。
4 |
5 | 当在 yao 中增加模型定义后,并执行命令`yao migrate`后。即是在完成步骤 3,步骤 4 后,yao 会自动的生成针对模型的处理器。
6 |
7 | 在 api 的配置文件中使用了内置的模型处理器`models.book.get`来读取模型数据。它的命名规则是`models.模型名称.模型方法`:
8 |
9 | - `models`,固定的处理前缀,代表这个处理器与模型相关。
10 | - 模型名称是模型的标识 ID,比如这里的书籍模型的标识是 book。
11 | - 模型方法,Yao 针对模型的读取,更新,创建都已经内置了对应的操作方法。
12 |
13 | 比如之前创建了 book 的模型,那么可以直接调用以下的处理器:
14 |
15 | - models.book.create,创建
16 | - models.book.delete,软删除
17 | - models.book.deletewhere,按条件软删除
18 | - models.book.destroy,真删除
19 | - models.book.destroywhere,按条件真删除
20 | - models.book.eachsave,批量保存
21 | - models.book.eachsaveafterdelete 在删除后再批量保存
22 | - models.book.find,按 id 查找
23 | - models.book.get,按条件查找列表
24 | - models.book.insert,插入记录
25 | - models.book.paginate,按条件查找并返回分页
26 | - models.book.save,保存单条信息
27 | - models.book.selectoption,返回表对应的 lable/value 列表
28 | - models.book.update,更新记录
29 | - models.book.updatewhere,按条件更新
30 |
31 | - models.book.load,加载模型定义到内存中,更新内存中的模型定义
32 | - models.book.migrate,更新模型到数据库表
33 |
34 | 以上的处理器可以在任何可以使用处理器的地方调用,比如 api 定义,js 脚本,flow 定义等。
35 |
36 | ## 总结
37 |
38 | 创建模型后可以直接调用模型相关的处理器进行数据的增删改查处理。
39 |
--------------------------------------------------------------------------------
/docs/入门指南/上手系列/index.md:
--------------------------------------------------------------------------------
1 | # 上手系列
2 |
3 |
4 |
5 | - [1 Yao下载与安装](1%20Yao下载与安装.md)
6 | - [2 创建第一个Yao应用](2%20创建第一个Yao应用.md)
7 | - [3 增加模型定义](3%20增加模型定义.md)
8 | - [4 生成数据库表](4%20生成数据库表.md)
9 | - [5 配置表格](5%20配置表格.md)
10 | - [6 配置表单](6%20配置表单.md)
11 | - [7 配置外部API](7%20配置外部API.md)
12 | - [8 处理器](8%20处理器.md)
13 | - [9 数据增删改查](9%20数据增删改查.md)
14 |
15 |
--------------------------------------------------------------------------------
/docs/入门指南/基础/assets/admin-menu-done.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/入门指南/基础/assets/admin-menu-done.jpg
--------------------------------------------------------------------------------
/docs/入门指南/基础/assets/admin-menu.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/入门指南/基础/assets/admin-menu.jpg
--------------------------------------------------------------------------------
/docs/入门指南/基础/assets/admin-stat-done.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/入门指南/基础/assets/admin-stat-done.jpg
--------------------------------------------------------------------------------
/docs/入门指南/基础/assets/yao-setup-tree.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/入门指南/基础/assets/yao-setup-tree.jpg
--------------------------------------------------------------------------------
/docs/入门指南/基础/index.md:
--------------------------------------------------------------------------------
1 | # 基础
2 |
3 |
4 |
5 | - [安装配置](安装配置.md)
6 | - [编写API接口](编写API接口.md)
7 | - [编写图表](编写图表.md)
8 | - [编写界面](编写界面.md)
9 | - [创建数据模型](创建数据模型.md)
10 | - [逻辑编排](逻辑编排.md)
11 | - [使用Widgets](使用Widgets.md)
12 | - [使用处理器](使用处理器.md)
13 | - [文件上传](文件上传.md)
14 | - [应用目录结构](应用目录结构.md)
15 | - [应用语言包](应用语言包.md)
16 | - [YAO命令](YAO命令.md)
17 | - [YAO编程基础](YAO编程基础.md)
18 |
19 |
--------------------------------------------------------------------------------
/docs/入门指南/基础/安装配置.md:
--------------------------------------------------------------------------------
1 | # 安装配置
2 |
3 | 服务启动时,如果未检测到应用配置信息,将启动应用安装服务,根据提示完成安装配置。
4 |
5 | ## 第一步: 创建应用目录
6 |
7 | 创建一个空的应用目录, 进入应用目录,运行 `yao start` 命令
8 |
9 | ```bash
10 | mkdir -p /data/app
11 | cd /data/app
12 | yao start
13 | ```
14 |
15 | ## 第二步: 安装配置
16 |
17 | 根据命令行提示,使用浏览器打开安装页面 `http://:/`, 根据页面提示完成安装配置。
18 |
19 | 如果网络结构较为复杂,命令行提示的 IP 地址无法访问,可根据实际网络结构,更换为相应 IP 地址。
20 |
21 | 安装程序会自动创建演示代码, 安装完毕后,应用目录代码结构:
22 |
23 | 
24 |
25 | ## 登录管理后台
26 |
27 | 配置完成后,自动转向管理员登录页面。
28 |
29 | 管理后台默认用户名: `xiang@iqka.com`, 密码: `A123456p+`
30 |
--------------------------------------------------------------------------------
/docs/入门指南/进阶系列/index.md:
--------------------------------------------------------------------------------
1 | # 进阶系列
2 |
3 |
4 |
5 | - [后台执行](后台执行.md)
6 | - [使用会话保存信息](使用会话保存信息.md)
7 | - [yao源代码安装](yao源代码安装.md)
8 |
9 |
--------------------------------------------------------------------------------
/docs/入门指南/进阶系列/yao源代码安装.md:
--------------------------------------------------------------------------------
1 | # 源代码安装与调试
2 |
3 | xgen 与 yao 前后端分离,可以单独进行单独的运行与调试
4 |
5 | ## 编译前端
6 |
7 | yao 前端 xgen 是一个独立的 react 项目。
8 |
9 | 安装前提,需要 nodejs 16+。
10 |
11 | ```sh
12 | git clone https://github.com/YaoApp/xgen
13 |
14 | cd xgen
15 | # 安装依赖
16 | pnpm install --no-frozen-lockfile
17 | # 开发
18 | pnpm run dev
19 | # 编译
20 | pnpm run build
21 | ```
22 |
23 | 另外 xgen 的调试需要配置 host 文件`/etc/hosts`。
24 |
25 | ```sh
26 | 127.0.0.1 _dev.com
27 | ```
28 |
29 | ## 编译后端
30 |
31 | 需要把以下的子项目都下载到同一个目录,yao 是主项目,其它的项目是依赖项。
32 |
33 | ```sh
34 | mkdir /your-project/root
35 | git clone https://github.com/yaoapp/yao
36 | git clone https://github.com/yaoapp/gou
37 | git clone https://github.com/yaoapp/xun
38 | git clone https://github.com/yaoapp/kun
39 | git clone https://github.com/yaoapp/v8go
40 |
41 | cd yao
42 |
43 | # 下载模块依赖
44 | go mod tidy
45 |
46 | # 调试,需要设置环境变量
47 | go run .
48 | go run . run xiang.sys.ping
49 | go run . start
50 |
51 | # 不集成 XGen 界面引擎
52 | make debug
53 |
54 | # macos制品
55 | make release
56 |
57 | # linux 制品 把前端项目也打包到yao执行程序里
58 | make linux-release
59 | ```
60 |
--------------------------------------------------------------------------------
/docs/入门指南/进阶系列/使用会话保存信息.md:
--------------------------------------------------------------------------------
1 | # 使用会话保存信息
2 |
3 | 创建一个 http api 配置,在配置文件中一定要设置`"guard": "bearer-jwt"`。
4 |
5 | ```json
6 | {
7 | "name": "excel data",
8 | "version": "1.0.0",
9 | "description": "excel data",
10 | "group": "",
11 | "guard": "bearer-jwt",
12 | "paths": [
13 | {
14 | "path": "/crud-menu.json",
15 | "method": "get",
16 | "process": "scripts.amis.menu.main",
17 | "in": [],
18 | "out": {
19 | "status": 200,
20 | "type": "application/json"
21 | }
22 | }
23 | }
24 | ```
25 |
26 | js 脚本中调用处理器`session.set`设置会话信息。
27 |
28 | ```js
29 | function main() {
30 | //在会话中写入信息
31 | Process('session.set', 'my_name', 'yao admin');
32 | }
33 | ```
34 |
35 | 调用处理器`session.get`读取会话信息。
36 |
37 | ```js
38 | function main() {
39 | //打印所有的会话信息
40 | const ses = Process('session.dump');
41 | console.log('session:', ses);
42 | //打印用户的会话信息
43 | const user = Process('session.get', 'user');
44 | console.log('user:', user);
45 | //读取自定义设置会话信息
46 | const myName = Process('session.get', 'my_name');
47 | console.log('myName:', myName);
48 | }
49 | ```
50 |
--------------------------------------------------------------------------------
/docs/入门指南/进阶系列/后台执行.md:
--------------------------------------------------------------------------------
1 | # 后台执行`Yao`应用
2 |
3 | `Linux`OS 操作
4 |
5 | ```sh
6 | cd /your-app/
7 |
8 | #后台作业运行
9 | nohup yao start &
10 |
11 | #save last pid
12 | echo (jobs -l | awk '{print $2}') > yao_pid.txt
13 | ```
14 |
15 | 查看作业与进程
16 |
17 | ```sh
18 | #list jobs
19 | jobs -l
20 |
21 | #list process
22 | ps aux | grep 'yao'
23 | ```
24 |
25 | 把后台进程提到前台
26 |
27 | ```sh
28 | fg %1
29 | ```
30 |
31 | 结束进程
32 |
33 | ```sh
34 | #kill by pid
35 | kill -9 (cat yao_pid.txt)
36 |
37 | #kill all
38 | kill -9 $(ps aux | grep 'yao' | awk '{print $2}')
39 | ```
40 |
--------------------------------------------------------------------------------
/docs/流程图/Yao 架构概览.md:
--------------------------------------------------------------------------------
1 | # YAO 架构概览
2 |
3 | - 数据库更新数据流程
4 | - 数据库读取过程
5 | - gRPC 插件执行逻辑
6 | - table hooks
7 | - api 请求过程
8 | - flow process
9 | - flow process2
10 | - 条件执行
11 | - charts
12 | - 参数查询
13 |
14 | [流程图在线查看](https://viewer.diagrams.net/?tags=%7B%7D&highlight=0000ff&edit=_blank&layers=1&nav=1&title=yao_app.drawio#Uhttps%3A%2F%2Fraw.githubusercontent.com%2Fwwsheng009%2Fyao-docs%2Fmain%2Fdocs%2F%25E6%25B5%2581%25E7%25A8%258B%25E5%259B%25BE%2Fdrawio%2Fyao_app.drawio)
15 |
--------------------------------------------------------------------------------
/docs/流程图/api请求过程.md:
--------------------------------------------------------------------------------
1 | # api 请求过程
2 |
3 | [流程图在线查看](https://viewer.diagrams.net/?tags=%7B%7D&highlight=0000ff&edit=_blank&layers=1&nav=1&title=yao_app.drawio#Uhttps%3A%2F%2Fraw.githubusercontent.com%2Fwwsheng009%2Fyao-docs%2Fmain%2Fdocs%2F%25E6%25B5%2581%25E7%25A8%258B%25E5%259B%25BE%2Fdrawio%2Fyao_app.drawio)
4 |
5 | 
6 |
7 | ## 处理流程说明
8 |
9 | Yao 的 API 请求处理流程包含以下几个主要步骤:
10 |
11 | 1. **API 入口**
12 |
13 | - 接收来自客户端的 HTTP 请求
14 | - 初始化请求上下文
15 |
16 | 2. **处理器**
17 |
18 | - 根据请求路径进行路由分发
19 | - 将请求分发到相应的处理模块(table、model 等)
20 |
21 | 3. **Table 处理**
22 |
23 | - 如果请求涉及表格操作,进入 table 处理流程
24 | - 触发 Before Hook 进行前置处理
25 | - 执行表格相关操作
26 | - 触发 After Hook 进行后置处理
27 |
28 | 4. **Model 处理**
29 |
30 | - 如果请求涉及数据模型,进入 model 处理流程
31 | - 执行数据模型相关操作
32 |
33 | 5. **参数处理**
34 |
35 | - 解析请求参数
36 | - 处理 URL 查询参数(query-param)
37 | - 转换参数格式
38 |
39 | 6. **请求执行**
40 |
41 | - 根据解析的参数执行具体业务逻辑
42 | - 调用相应的处理函数
43 |
44 | 7. **结果返回**
45 | - 处理执行结果
46 | - 格式化响应数据
47 | - 返回给客户端
48 |
49 | ## 关键组件说明
50 |
51 | - **gin 路由**: 负责 HTTP 请求的路由分发
52 | - **parsein**: 请求参数解析器
53 | - **URLToQueryParam**: 将 URL 参数转换为查询参数
54 | - **Xun 查询**: 执行数据库查询操作
55 | - **应用处理器**: 处理具体的业务逻辑
56 |
57 | ## 处理流程特点
58 |
59 | 1. 完整的前置和后置钩子支持,可以在处理前后执行自定义逻辑
60 | 2. 灵活的参数处理机制,支持多种参数格式
61 | 3. 统一的错误处理和响应格式
62 | 4. 模块化的设计,便于扩展和维护
63 |
--------------------------------------------------------------------------------
/docs/流程图/drawio/yao_connector.drawio:
--------------------------------------------------------------------------------
1 | 7Vjfk5owEP5reGxHiCK++qN3D+f0wc60PqawAp1gnLAI3F/fIIuB4fTam7uiM33R7LebkHzf7ka02CIpHhQ/RGsZgLCcUVBYbGk5jj1hY/1VIWWNzEasBkIVBxRkgE38DASOCM3iANJOIEopMD50QV/u9+BjB+NKybwbtpOi+9QDD6EHbHwu+uj3OMCoRj1navBHiMOoebLtzmpPwptgOkka8UDmLYitLLZQUmI9SooFiIq8hpd63pcL3vPGFOzxTyasv86f06dvO2+N+OgosfSmq0+0ypGLjA5MREpFu8ayoULJbB9AtZptsXkexQibA/crb67F11iEiSB3f3fNo0AhFC2IdvsAMgFUpQ4hr8uIOUod5pKdGyHsht2oJUITx0n78Ly0oUcPiKG/YGvS4wQCnS1kSoWRDOWei5VB54a1kbZMzJOUB+LqFyCWlPo8Q9llEooYf7TG22qpzxOylgWtfDJKMi6yn8pM+XDliA7VGFch4JU4Kuvq/Fe1VCA4xsduNb27ME23GEYZo8a25XlZGS2IKluTKnPb9plpJ6uZ52fqeK69j5fXvil5nV6XSuqLZuAO5XjdDmWPh+5Q7r10KFMHnSowRXGhDt6e+uwuU5/1Uj/VdzPcXOoPfzl7Q6T+29Ox+TH7WjpObyodZ//7yyu/iO5M0HGvvwSw45lAy3H1B5v/1C8CbliNbvfNYPh7d9qjcTkfnCZv/O9o0qZ5lT35Wn8IsNVv
--------------------------------------------------------------------------------
/docs/流程图/index.md:
--------------------------------------------------------------------------------
1 | # 流程图
2 |
3 |
4 |
5 | - [查询参数QueryParam](查询参数QueryParam.md)
6 | - [任务Task处理](任务Task处理.md)
7 | - [数据库schema](数据库schema.md)
8 | - [数据库xun架构](数据库xun架构.md)
9 | - [数据库更新流程](数据库更新流程.md)
10 | - [数据库读取流程](数据库读取流程.md)
11 | - [用户登录流程会话](用户登录流程会话.md)
12 | - [自定义widget](自定义widget.md)
13 | - [api请求过程](api请求过程.md)
14 | - [yao migrate](yao%20migrate.md)
15 | - [Yao 架构概览](Yao%20架构概览.md)
16 |
17 |
--------------------------------------------------------------------------------
/docs/流程图/png/yao_app_api请求过程.drawio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/流程图/png/yao_app_api请求过程.drawio.png
--------------------------------------------------------------------------------
/docs/流程图/png/yao_app_flow.process.drawio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/流程图/png/yao_app_flow.process.drawio.png
--------------------------------------------------------------------------------
/docs/流程图/png/yao_app_参数查询.drawio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/流程图/png/yao_app_参数查询.drawio.png
--------------------------------------------------------------------------------
/docs/流程图/png/yao_app_数据库更新流程.drawio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/流程图/png/yao_app_数据库更新流程.drawio.png
--------------------------------------------------------------------------------
/docs/流程图/png/yao_app_数据读取数据过程.drawio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/流程图/png/yao_app_数据读取数据过程.drawio.png
--------------------------------------------------------------------------------
/docs/流程图/png/yao_database_database_xun.drawio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/流程图/png/yao_database_database_xun.drawio.png
--------------------------------------------------------------------------------
/docs/流程图/png/yao_database_migrate.drawio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/流程图/png/yao_database_migrate.drawio.png
--------------------------------------------------------------------------------
/docs/流程图/png/yao_database_xun_schema.drawio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/流程图/png/yao_database_xun_schema.drawio.png
--------------------------------------------------------------------------------
/docs/流程图/png/yao_session_用户登录流程会话.drawio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/流程图/png/yao_session_用户登录流程会话.drawio.png
--------------------------------------------------------------------------------
/docs/流程图/png/yao_task.drawio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/流程图/png/yao_task.drawio.png
--------------------------------------------------------------------------------
/docs/流程图/png/yao_widget.drawio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wwsheng009/yao-docs/80fbfb722d9ccc0a5db41918f88f8be9a91ea663/docs/流程图/png/yao_widget.drawio.png
--------------------------------------------------------------------------------
/docs/流程图/yao migrate.md:
--------------------------------------------------------------------------------
1 | # yao migrate
2 |
3 | [流程图在线查看](https://viewer.diagrams.net/?tags=%7B%7D&highlight=0000ff&edit=_blank&layers=1&nav=1&page-id=2XGTXKiTmeM8RcKDhDW0&title=yao_database.drawio#Uhttps%3A%2F%2Fraw.githubusercontent.com%2Fwwsheng009%2Fyao-docs%2Fmain%2Fdocs%2F%25E6%25B5%2581%25E7%25A8%258B%25E5%259B%25BE%2Fdrawio%2Fyao_database.drawio)
4 |
5 | 
6 |
--------------------------------------------------------------------------------
/docs/流程图/任务Task处理.md:
--------------------------------------------------------------------------------
1 | # 任务 Task 处理
2 |
3 | ## 流程图说明
4 |
5 | 任务处理是 Yao 框架中的重要组成部分,包括并发任务、计划任务和异步任务的处理流程。您可以通过以下方式查看详细的流程图:
6 |
7 | - [在线查看流程图](https://viewer.diagrams.net/?tags=%7B%7D&highlight=0000ff&edit=_blank&layers=1&nav=1&title=yao_task.drawio#Uhttps%3A%2F%2Fraw.githubusercontent.com%2Fwwsheng009%2Fyao-docs%2Fmain%2Fdocs%2F%25E6%25B5%2581%25E7%25A8%258B%25E5%259B%25BE%2Fdrawio%2Fyao_task.drawio)
8 | - [本地流程图](./png/yao_task.drawio.png)
9 |
10 | 
11 |
--------------------------------------------------------------------------------
/docs/流程图/数据库schema.md:
--------------------------------------------------------------------------------
1 | # 数据库 schema
2 |
3 | [流程图在线查看](https://viewer.diagrams.net/?tags=%7B%7D&highlight=0000ff&edit=_blank&layers=1&nav=1&page-id=2XGTXKiTmeM8RcKDhDW0&title=yao_database.drawio#Uhttps%3A%2F%2Fraw.githubusercontent.com%2Fwwsheng009%2Fyao-docs%2Fmain%2Fdocs%2F%25E6%25B5%2581%25E7%25A8%258B%25E5%259B%25BE%2Fdrawio%2Fyao_database.drawio)
4 |
5 | 
6 |
--------------------------------------------------------------------------------
/docs/流程图/数据库xun架构.md:
--------------------------------------------------------------------------------
1 | # Yao xun
2 |
3 | xun 是一个轻量级别的 ORM。可以根据自己的需求增强 xun 数据库驱动。
4 |
5 | [流程图在线查看](https://viewer.diagrams.net/?tags=%7B%7D&highlight=0000ff&edit=_blank&layers=1&nav=1&page-id=2XGTXKiTmeM8RcKDhDW0&title=yao_database.drawio#Uhttps%3A%2F%2Fraw.githubusercontent.com%2Fwwsheng009%2Fyao-docs%2Fmain%2Fdocs%2F%25E6%25B5%2581%25E7%25A8%258B%25E5%259B%25BE%2Fdrawio%2Fyao_database.drawio)
6 |
7 | 
8 |
9 | [SAP HANA 数据库适配](https://github.com/wwsheng009/xun/tree/main/grammar/saphdb)
10 |
--------------------------------------------------------------------------------
/docs/流程图/数据库更新流程.md:
--------------------------------------------------------------------------------
1 | # 数据库更新流程
2 |
3 | [流程图在线查看](https://viewer.diagrams.net/?tags=%7B%7D&highlight=0000ff&edit=_blank&layers=1&nav=1&page-id=2XGTXKiTmeM8RcKDhDW0&title=yao_database.drawio#Uhttps%3A%2F%2Fraw.githubusercontent.com%2Fwwsheng009%2Fyao-docs%2Fmain%2Fdocs%2F%25E6%25B5%2581%25E7%25A8%258B%25E5%259B%25BE%2Fdrawio%2Fyao_database.drawio)
4 |
5 | 
6 |
--------------------------------------------------------------------------------
/docs/流程图/数据库读取流程.md:
--------------------------------------------------------------------------------
1 | # 数据库读取流程
2 |
3 | [流程图在线查看](https://viewer.diagrams.net/?tags=%7B%7D&highlight=0000ff&edit=_blank&layers=1&nav=1&page-id=2XGTXKiTmeM8RcKDhDW0&title=yao_database.drawio#Uhttps%3A%2F%2Fraw.githubusercontent.com%2Fwwsheng009%2Fyao-docs%2Fmain%2Fdocs%2F%25E6%25B5%2581%25E7%25A8%258B%25E5%259B%25BE%2Fdrawio%2Fyao_database.drawio)
4 |
5 | 
6 |
--------------------------------------------------------------------------------
/docs/流程图/查询参数QueryParam.md:
--------------------------------------------------------------------------------
1 | # 查询参数`QueryParam`
2 |
3 | [流程图在线查看](https://viewer.diagrams.net/?tags=%7B%7D&highlight=0000ff&edit=_blank&layers=1&nav=1&title=yao_app.drawio#Uhttps%3A%2F%2Fraw.githubusercontent.com%2Fwwsheng009%2Fyao-docs%2Fmain%2Fdocs%2F%25E6%25B5%2581%25E7%25A8%258B%25E5%259B%25BE%2Fdrawio%2Fyao_app.drawio)
4 |
5 | ## QueryParam 概述
6 |
7 | QueryParam 是 Yao 中用于构建数据查询条件的重要组件,它可以将结构化的查询参数转换为数据库可执行的查询语句。主要应用在以下场景:
8 |
9 | 1. URL 查询参数转换:将 API 请求 URL 中的查询字符串解析为标准的查询参数
10 | 2. 模型处理器参数:在调用数据模型处理器时,用于构建复杂的查询条件
11 |
12 | ## 查询参数处理流程
13 |
14 | ### 1. 参数输入
15 |
16 | 查询参数可以来自两个主要来源:
17 |
18 | - URL 查询字符串:通过 API 请求中的查询参数传入
19 | - 直接构造:在处理器中直接构造 QueryParam 对象
20 |
21 | ### 2. 参数解析
22 |
23 | 系统会对输入的参数进行解析和转换,主要包括:
24 |
25 | - parseIn:解析输入参数
26 | - 参数验证:确保参数格式正确
27 | - 转换成表查询参数:将解析后的参数转换为标准的 QueryParam 格式
28 |
29 | ### 3. 查询执行
30 |
31 | 转换后的 QueryParam 会被用于执行实际的数据库查询:
32 |
33 | 1. 根据 QueryParam 构建 SQL 查询语句
34 | 2. 执行查询操作
35 | 3. 返回查询结果
36 |
37 | ## QueryParam 支持的查询条件
38 |
39 | QueryParam 支持多种查询条件和操作:
40 |
41 | 1. 基础查询条件:
42 |
43 | - 等于(eq)
44 | - 不等于(neq)
45 | - 大于(gt)
46 | - 小于(lt)
47 | - 大于等于(gte)
48 | - 小于等于(lte)
49 |
50 | 2. 高级查询条件:
51 |
52 | - 模糊匹配(match)
53 | - 范围查询(between)
54 | - 空值查询(null)
55 | - 非空查询(notnull)
56 | - 包含查询(in)
57 | - 不包含查询(notin)
58 |
59 | 3. 查询参数配置:
60 | - 字段选择(select)
61 | - 关联查询(withs)
62 | - 排序(order)
63 | - 分页(page、pagesize)
64 |
65 | ## 使用示例
66 |
67 | 1. URL 查询示例:
68 |
69 | ```bash
70 | GET /api/user/paginate?withs=manu,mother,addresses&where.status.eq=enabled&select=id,name,mobile,status,extra&page=1&pagesize=2
71 | ```
72 |
73 | 2. 直接构造示例:
74 |
75 | ```json
76 | {
77 | "select": ["id", "name", "mobile", "status", "extra"],
78 | "withs": { "manu": {}, "mother": {}, "addresses": {} },
79 | "wheres": [{ "column": "status", "value": "enabled" }],
80 | "page": 1,
81 | "pagesize": 2
82 | }
83 | ```
84 |
85 | 通过这种方式,QueryParam 提供了一个灵活且强大的查询参数处理机制,使得数据查询既简单又高效。
86 |
--------------------------------------------------------------------------------
/docs/流程图/自定义widget.md:
--------------------------------------------------------------------------------
1 | # 自定义 Widget 开发
2 |
3 | [自定义 Widget](../YaoDSL/Widget/自定义Widget.md)
4 |
5 | [流程图在线查看](https://viewer.diagrams.net/?tags=%7B%7D&highlight=0000ff&edit=_blank&layers=1&nav=1&title=yao_widget.drawio#Uhttps%3A%2F%2Fraw.githubusercontent.com%2Fwwsheng009%2Fyao-docs%2Fmain%2Fdocs%2F%25E6%25B5%2581%25E7%25A8%258B%25E5%259B%25BE%2Fdrawio%2Fyao_widget.drawio)
6 |
7 | 
8 |
--------------------------------------------------------------------------------
/docs/源代码/Gou/Null值转换成Int类型值时panic.md:
--------------------------------------------------------------------------------
1 | # Null 值转换成 Int 类型值时 panic
2 |
3 | 当数据库表的字段值是 null,而类型是 float 时,会转换出错。
4 |
5 | 源代码:
6 | `/data/projects/yao/yao-app-sources/kun/any/any.go`
7 |
8 | ```go
9 | // CFloat64 converts and returns as float64
10 | func (v Any) CFloat64() float64 {
11 |
12 | if v.value == nil {
13 | return 0
14 | }
15 |
16 | value, ok := v.value.(float64)
17 | if ok {
18 | return value
19 | }
20 |
21 | if v.IsString() && v.String() == "" {
22 | return 0
23 | }
24 |
25 | value, err := strconv.ParseFloat(fmt.Sprintf("%v", v.value), 64)
26 | if err != nil {
27 | panic(err.Error()) //panic
28 | }
29 | return value
30 | }
31 |
32 | ```
33 |
34 | 修正:
35 |
36 | - `https://github.com/wwsheng009/kun/commit/631074294b798b2039f207884162c019ddac5daa`
37 |
38 | - `https://github.com/wwsheng009/gou/commit/745392660f9689f32044b9974fb34febca452db4`
39 |
--------------------------------------------------------------------------------
/docs/源代码/Gou/index.md:
--------------------------------------------------------------------------------
1 | # Gou
2 |
3 |
4 |
5 | - [加密处理器调用错误](加密处理器调用错误.md)
6 | - [两个HasMany问题](两个HasMany问题.md)
7 | - [数据库Schema默认值转换异常](数据库Schema默认值转换异常.md)
8 | - [jsapi中的undefined转换](jsapi中的undefined转换.md)
9 | - [Null值转换成Int类型值时panic](Null值转换成Int类型值时panic.md)
10 |
11 |
--------------------------------------------------------------------------------
/docs/源代码/Gou/jsapi中的undefined转换.md:
--------------------------------------------------------------------------------
1 | # jsapi 中的 undefined 转换问题
2 |
3 | 在 jsapi 中,在使用 console.log 打印数据时,如果数据中包含 undefined 值,不会直接打印出 undefined,而是转换成了 0x0。
4 |
5 | ```js
6 | function test() {
7 | let model = {};
8 | // 经过go转换的undefined会变成0。
9 | // 不要使用==null的判断,而且是使用===null and === undefined
10 | console.log('model is undefined', model.xxxx === undefined);
11 | console.log('model is null', model.xxxx === null);
12 | console.log('model is 0', model.xxxx === 0);
13 | console.log('model.xxxx', model.xxx); //总是输出0
14 | return;
15 | }
16 | ```
17 |
18 | 也是说,在 js 中的 undefined 在 golang 中被转换成了 0。
19 |
20 | 如果在 js 使用`==null`或是`!=null`会无法正确判断 undefined 值。
21 |
22 | ```go
23 | // Undefined jsValue Undefined
24 | var Undefined UndefinedT = 0x00
25 |
26 |
27 | func GoValue(value *v8go.Value, ctx *v8go.Context) (interface{}, error) {
28 |
29 | if value.IsNull() {
30 | return nil, nil
31 | }
32 |
33 | if value.IsUndefined() {
34 | return Undefined, nil
35 | }
36 | }
37 | ```
38 |
39 | ## 总结
40 |
41 | 此问题已修复!
42 |
--------------------------------------------------------------------------------
/docs/源代码/Gou/加密处理器调用错误.md:
--------------------------------------------------------------------------------
1 | # 加密处理器调用错误
2 |
3 | 在 scripts js 脚本里面通过 Process 调用加密解密相关的处理器,为何会一直报 失败: Process:crypto.Hash format error 错误呢?
4 | let pwd = Process('crypto.Hash', 'SHA512', '123456')
5 |
6 | 这应该也是一个 bug。非白名单中的处理器名不能少于 3 个字段。
7 |
8 | 处理方法:
9 |
10 | - 使用 yao.crypto.Hash,而不是 crypto.Hash。
11 | - 使用 crypto.Hmac,而不是 crypto.Hmac
12 |
13 | ```go
14 | // yao-app-sources/gou/process.go
15 | var whitelist = map[string]bool{
16 | "flows": true,
17 | "session": true,
18 | "ssl": true,
19 | "websocket": true,
20 | "http": true,
21 | "widget": true,
22 | }
23 |
24 | func (process *Process) extraProcess() {
25 |
26 | namer := strings.Split(process.Name, ".")
27 | last := len(namer) - 1
28 |
29 | //这里报错
30 | if _, has := whitelist[namer[0]]; last < 2 && !has {
31 | exception.New("Process:%s format error", 400, process.Name).Throw()
32 | }
33 | }
34 |
35 | ```
36 |
--------------------------------------------------------------------------------
/docs/源代码/Gou/数据库Schema默认值转换异常.md:
--------------------------------------------------------------------------------
1 | # 数据库读取 Schema 转换成 Model 时默认值转换异常。
2 |
3 | `gou`与`xun`的处理逻辑存在不一致。
4 |
5 | 在`gou`开发库中缺少针对数据库类型默认值的转换处理。
6 |
7 | 源代码:
8 | `/data/projects/yao/yao-app-sources/gou/schema/xun/blueprint.go`
9 |
10 | ```go
11 | func parseColumnType(col *schema.Column, column *types.Column) {
12 | 。。。
13 |
14 | case "timestamp", "datetime"://这里的datetime是错误的。
15 | }
16 |
17 | ```
18 |
19 | 修正:
20 |
21 | `https://github.com/wwsheng009/gou/commits/saphana`
22 |
--------------------------------------------------------------------------------
/docs/源代码/Kun/console_log无法输出正确格式.md:
--------------------------------------------------------------------------------
1 | # console.log 无法正确输出
2 |
3 | 当在脚本中使用`console.log`打印`html`字符时,输出的是`unicode`编码而不是`utf8`编码。这与浏览器的输出差异比较大。
4 |
5 | `Yao Js`
6 |
7 | ```js
8 | function excute() {
9 | console.log('<');
10 | console.log('\u003C');
11 | }
12 |
13 | // 都是输出
14 | // "\u003c"
15 | ```
16 |
17 | `ES6 js`
18 |
19 | ```js
20 | function excute() {
21 | console.log('<');
22 | console.log('\u003C');
23 | }
24 |
25 | // 都是输出
26 | // <
27 | ```
28 |
29 | 原因,脚本中的`console.log`是`golang`函数的代理,在`golang`中使用`json.Marshal`方法处理对象时,把数据转换成了`unicode`编码
30 |
31 | 源代码位置:`/yao-app-sources/kun/utils/utils.go`
32 |
33 | ```go
34 |
35 | // Dump The Dump function dumps the given variables:
36 | func Dump(values ...interface{}) {
37 | f := colorjson.NewFormatter()
38 | f.Indent = 4
39 | for _, v := range values {
40 |
41 | jsoniter.Unmarshal(txt, &res)
42 | s, _ := f.Marshal(res) //uncode编码
43 | fmt.Printf("%s\n", s)
44 | }
45 | }
46 | ```
47 |
48 | 尝试修复如下,设置`html`符号不转义:
49 |
50 | https://github.com/wwsheng009/kun/commit/8ed8e7237d35e829050dff98ae0e5dd500380a14
51 |
52 | ```go
53 | // Dump The Dump function dumps the given variables:
54 | func Dump(values ...interface{}) {
55 | f := colorjson.NewFormatter()
56 | f.Indent = 4
57 | for _, v := range values {
58 |
59 | jsoniter.Unmarshal(txt, &res)
60 | // s, _ := f.Marshal(res)
61 | // fmt.Printf("%s\n", s)
62 | s, _ := UnescapeJsonMarshal(res)
63 | fmt.Printf("%s", s) //返回值已带有\n
64 | }
65 | }
66 |
67 | // https://blog.csdn.net/zhuhanzi/article/details/106156174
68 | // 修正console.log输出html符号异常
69 | func UnescapeJsonMarshal(jsonRaw interface{}) ([]byte, error) {
70 | buffer := &bytes.Buffer{}
71 | encoder := json.NewEncoder(buffer)
72 | encoder.SetEscapeHTML(false)
73 | //带有缩进的格式化
74 | encoder.SetIndent("", " ")
75 | err := encoder.Encode(jsonRaw)
76 | return buffer.Bytes(), err
77 | }
78 |
79 | ```
80 |
--------------------------------------------------------------------------------
/docs/源代码/Kun/index.md:
--------------------------------------------------------------------------------
1 | # Kun
2 |
3 |
4 |
5 | - [console_log无法输出正确格式](console_log无法输出正确格式.md)
6 |
7 |
--------------------------------------------------------------------------------
/docs/源代码/Xgen/index.md:
--------------------------------------------------------------------------------
1 | # Xgen
2 |
3 |
4 |
5 | - [xgen List控件保存数据时数据被清空](xgen%20List控件保存数据时数据被清空.md)
6 | - [xgen remoteSearch](xgen%20remoteSearch.md)
7 | - [xgen 批量上传功能](xgen%20批量上传功能.md)
8 |
9 |
--------------------------------------------------------------------------------
/docs/源代码/Xgen/xgen List控件保存数据时数据被清空.md:
--------------------------------------------------------------------------------
1 | # List 删除项目后,列表被清空
2 |
3 | 0.10.3/yao-wms/forms/plan.form.json 这个 form 里使用了 List 控件作为子表保存数据,
4 | 当用户删除已有的项目时,会清空整个列表。
5 |
6 | 为什么会出现这个问题?
7 |
8 | 因为这个控件的处理新增数据与修改数据时的数据结构是不一样的。
9 |
10 | 当你新增数据,没有删除数据时,这个控件对应的数据结构是数组,数组里保存了控件里的行数据。
11 |
12 | 而当我们有了删除操作后,这个控件对应的数据结构发生了变化。它会变成一个对象。对象里包含一个 data 对象和一个 delete 对象。
13 |
14 | - 在 data 对象里包含未被删除的对象列表,
15 | - 在 delete 包含删除对象列表。
16 |
17 | 没有删除操作时
18 |
19 | ```json
20 | [
21 | {
22 | "item1": 1
23 | },
24 | {
25 | "item2": 1
26 | }
27 | ]
28 | ```
29 |
30 | 有删除操作后
31 |
32 | ```json
33 | {
34 | "data": [{ "item1": 1 }],
35 | "delete": [{ "item2": 1 }]
36 | }
37 | ```
38 |
39 | 在赋值时,加个判断即可。
40 |
41 | 尝试修复如下:
42 | https://github.com/wwsheng009/xgen/commit/c2534e88404166749c66b965aed2bbd99f785333
43 |
--------------------------------------------------------------------------------
/docs/源代码/Xgen/xgen remoteSearch.md:
--------------------------------------------------------------------------------
1 | # `Select控件/Mention控件`远程`searchOptions`的 bug。
2 |
3 | 按后端的返回值来看,远程控件只有两个属性`api`与`params`,不会存在`key`。所以搜索条件的字段名会变成`undefined`。
4 |
5 | 请求示例如下:
6 | http://192.168.126.141:5099/api/__yao/table/material.category/component/fields.table.%E4%B8%8A%E7%BA%A7%E7%B1%BB%E7%9B%AE.edit.props.xProps/search?id=1&key=id&undefined=12
7 |
8 | 源代码:`/yao-app-sources/xgen-v1.0/packages/xgen/models/remote.ts`
9 |
10 | 尝试修复如下,使用参数中的一个`key`参数作为搜索字段
11 |
12 | https://github.com/wwsheng009/xgen/commit/641745d5b8f544388831f7973619baf53b2c8551
13 |
14 | ```js
15 | async searchOptions(v: string) {
16 | const search = this.raw_props.xProps.search
17 |
18 | if (!search) return
19 |
20 | const params = {
21 | ...search.params,
22 | // [search.key]: v
23 | [search.params?.key]: v
24 | }
25 | }
26 | ```
27 |
--------------------------------------------------------------------------------
/docs/源代码/Xgen/xgen 批量上传功能.md:
--------------------------------------------------------------------------------
1 | # Xgen 批量上传功能
2 |
3 | xgen 本身有批量上传功能,但是上传控件少了一个参数`api`。
4 |
5 | 这里通过硬改代码的方式处理。
6 |
7 | xgen 源代码尝试修复如下:
8 | https://github.com/wwsheng009/xgen/commit/8bac8871c9986efc13d0e8e7762e5b74bbf4fb85
9 |
10 | gou 代码修复 fs.system.Upload 类型报错:
11 | https://github.com/wwsheng009/gou/commit/7fafef2100057343024e6fbe7728fd7d58cb28c9
12 |
--------------------------------------------------------------------------------
/docs/源代码/Xun/index.md:
--------------------------------------------------------------------------------
1 | # Xun
2 |
3 |
4 |
5 | - [使用postgresql保存Embedding](使用postgresql保存Embedding.md)
6 | - [数据库连接配置](数据库连接配置.md)
7 | - [Mysql数据库事务](Mysql数据库事务.md)
8 | - [PG数据库增加自定义类型](PG数据库增加自定义类型.md)
9 | - [sqlite数据库bug](sqlite数据库bug.md)
10 |
11 |
--------------------------------------------------------------------------------
/docs/源代码/Xun/sqlite数据库bug.md:
--------------------------------------------------------------------------------
1 | # Sqlite 数据库表中的字段名不能与表名一样。
2 |
3 | 处理器:`schemas.default.TableGet`,无法读取表的字段定义,提示`schemas.default.TableGet the column %s does not exists`,
4 |
5 | 从代码上看,如果字段名与表名一样,会被排除掉。
6 |
7 | 尝试修复如下:
8 |
9 | https://github.com/wwsheng009/xun/commit/7127b0945f1b5c9c279fc2005e17836ffcc65c7d
10 |
11 | ```go
12 | selectColumns := []string{
13 | "m.name AS `table_name`",
14 | "p.name AS `name`",
15 | "p.cid AS `position`",
16 | "p.dflt_value AS `default`",
17 | "UPPER(p.type) as `type`",
18 | `CASE
19 | WHEN ` + "p.`notnull`" + ` == 0 THEN 1
20 | ELSE 0
21 | END AS ` + "`nullable`",
22 | `CASE
23 | WHEN INSTR(` + "p.`type`" + `, 'UNSIGNED' ) THEN 1
24 | WHEN p.pk = 1 and ` + "p.`type`" + ` = 'INTEGER' THEN 1
25 | ELSE 0
26 | END AS` + "`unsigned`",
27 | `CASE
28 | WHEN p.pk = 1 THEN 1
29 | ELSE 0
30 | END AS ` + "`primary`",
31 | `CASE
32 | WHEN p.pk = 1 and INSTR(m.sql, 'AUTOINCREMENT' ) THEN "AutoIncrement"
33 | ELSE ""
34 | END AS ` + "`extra`",
35 | }
36 | sql := fmt.Sprintf(`
37 | SELECT %s
38 | FROM sqlite_master m
39 | LEFT OUTER JOIN pragma_table_info((m.name)) p ON m.name <> p.name
40 | WHERE m.type = 'table' and table_name=%s
41 | `,
42 | strings.Join(selectColumns, ","),
43 | grammarSQL.VAL(tableName),
44 | )
45 |
46 |
47 | ```
48 |
49 | 出错的地方:
50 |
51 | ```go
52 | sql := fmt.Sprintf(`
53 | SELECT %s
54 | FROM sqlite_master m
55 | LEFT OUTER JOIN pragma_table_info((m.name)) p ON m.name <> p.name
56 | WHERE m.type = 'table' and table_name=%s
57 | `,
58 | strings.Join(selectColumns, ","),
59 | ```
60 |
61 | 从上面修改成下面的:
62 |
63 | ```go
64 | sql := fmt.Sprintf(`
65 | SELECT %s
66 | FROM sqlite_master m,
67 | pragma_table_info((m.name)) p
68 | WHERE m.type = 'table' and table_name=%s
69 | `,
70 | strings.Join(selectColumns, ","),
71 | ```
72 |
--------------------------------------------------------------------------------
/docs/源代码/Xun/数据库连接配置.md:
--------------------------------------------------------------------------------
1 | # 不同数据库连接配置
2 |
3 | ## bug 修复
4 |
5 | 修复由于只配置了`primary host`导致无法在`js query`中使用 Get 方法。
6 |
7 | https://github.com/wwsheng009/gou/commit/c21e8a8c9a2ee131d90006d8d8840134856019f4
8 |
--------------------------------------------------------------------------------
/docs/源代码/Yao/Compute 处理器无法处理关联表.md:
--------------------------------------------------------------------------------
1 | # Compute 无法处理关联表
2 |
3 | 如果 Compute 处理的对象是关联表,处理器无法起作用。
4 |
5 | 尝试修复如下:
6 | https://github.com/wwsheng009/yao/commit/d9e0b6ef1ea2175d24f2c57c0385a2e40546633a
7 |
--------------------------------------------------------------------------------
/docs/源代码/Yao/index.md:
--------------------------------------------------------------------------------
1 | # Yao
2 |
3 |
4 |
5 | - [处理器yao.component.selectoptions修正](处理器yao.component.selectoptions修正.md)
6 | - [Compute 处理器无法处理关联表](Compute%20处理器无法处理关联表.md)
7 | - [yao 应用打包功能pack](yao%20应用打包功能pack.md)
8 |
9 |
--------------------------------------------------------------------------------
/docs/源代码/Yao/yao 应用打包功能pack.md:
--------------------------------------------------------------------------------
1 | # yao 应用打包功能 pack
2 |
3 | 0.10.3 版本提供了一个程序应用打包的功能。操作命令是:
4 |
5 | 打包后的文件默认情况是保存在目录 dist/app.yaz
6 |
7 | ```sh
8 | # 不加密打包
9 | yao pack
10 |
11 | # 加密打包
12 | yao pack -l xxxx
13 |
14 | ```
15 |
16 | 指定程序包,使用参数-f 指定 yaz 或是使用环境变量指定应用包的路径 YAO_APP_SOURCE=app.yaz
17 |
18 | 使用程序包,解密使用-k
19 |
20 | ```sh
21 | # -f 指定yaz或是使用环境变量YAO_APP_SOURCE=app.yaz
22 | yao start -f app.yaz -k xxxx
23 |
24 | ```
25 |
--------------------------------------------------------------------------------
/docs/源代码/index.md:
--------------------------------------------------------------------------------
1 | # 源代码
2 |
3 | 针对于 Yao 的一些源代码分析与研究。
4 |
5 |
6 |
7 | - [Github Commit List](Github%20Commit%20List.md)
8 | - [源码编译](源码编译/index)
9 | - [Gou](Gou/index)
10 | - [Kun](Kun/index)
11 | - [Xgen](Xgen/index)
12 | - [Xun](Xun/index)
13 | - [Yao](Yao/index)
14 |
15 |
--------------------------------------------------------------------------------
/docs/源代码/源码编译/0.10.3-pre To 0.10.3-dev.md:
--------------------------------------------------------------------------------
1 | # 0.10.3-pre To 0.10.3
2 |
3 | new features:
4 |
5 | - config file support '.json','.yao','jsonc'
6 |
7 | ## gou 0.10.3-pre =>0.10.3
8 |
9 | ```sh
10 | git checkout saphana
11 |
12 | git checkout -b v0.10.3
13 |
14 | git fetch upstream
15 |
16 | git merge upstream/main
17 |
18 | ```
19 |
20 | handle the conflict files
21 |
22 | ## Yao 0.10.3-pre =>0.10.3
23 |
24 | ```sh
25 |
26 | git checkout main
27 |
28 | git git checkout -b v0.10.3
29 |
30 | git fetch upstream
31 |
32 | git merge upstream/v0.10.3
33 | ```
34 |
35 | handle the conflict files
36 |
37 | ## fallback to 0.10.3-pre
38 |
39 | ```sh
40 | cd yao
41 | git checkout main
42 |
43 | cd gou
44 | git checkout saphana
45 |
46 | ```
47 |
48 | ## switch to 0.10.3
49 |
50 | ```sh
51 | cd yao
52 | git checkout v0.10.3
53 |
54 | cd gou
55 | git checkout v0.10.3
56 | ```
57 |
58 | ## main change in 0.10.3
59 |
60 | - studio function not working yet
61 | - 读写文件的超级权限的变化
62 |
63 | ```js
64 | // WriteFile SU root
65 | // 0.10.2
66 | __YAO_SU_ROOT = true;
67 |
68 | //0.10.3
69 | __yao_data = { ROOT: true };
70 | ```
71 |
72 | 获取全局变量与权限
73 |
74 | ```js
75 | const test = () => {
76 | const result = Studio('unit.test.process', 'foo', 99, 0.618);
77 | return {
78 | ...result,
79 | __yao_global: __yao_data['DATA'], //全局数据,等于res["Global"]
80 | __yao_sid: __yao_data['SID'], //等于res["Sid"]
81 | __YAO_SU_ROOT: __yao_data['ROOT'] //是否超级权限
82 | };
83 | };
84 | test();
85 | ```
86 |
--------------------------------------------------------------------------------
/docs/源代码/源码编译/index.md:
--------------------------------------------------------------------------------
1 | # 源码编译
2 |
3 |
4 |
5 | - [0.10.3-pre To 0.10.3-dev](0.10.3-pre%20To%200.10.3-dev.md)
6 | - [编译yao源代码](编译yao源代码.md)
7 | - [windows版本适配](windows版本适配/index)
8 |
9 |
--------------------------------------------------------------------------------
/docs/源代码/源码编译/windows版本适配/index.md:
--------------------------------------------------------------------------------
1 | # windows 版本适配
2 |
3 |
4 |
5 | - [编译yao windows修改版本](编译yao%20windows修改版本.md)
6 | - [windows pack功能适配](windows%20pack功能适配.md)
7 |
8 |
--------------------------------------------------------------------------------
/docs/源代码/源码编译/windows版本适配/windows pack功能适配.md:
--------------------------------------------------------------------------------
1 | # 适用于 windows 的 pack 功能适配
2 |
3 | 0.10.3 版本提供了一个程序应用打包的功能。操作命令是:
4 |
5 | 打包后的文件默认情况是保存在目录 dist/app.yaz
6 |
7 | ```sh
8 | # 不加密打包
9 | yao pack
10 |
11 | # 加密打包
12 | yao pack -l xxxx
13 |
14 | ```
15 |
16 | 指定程序包,使用参数-f 指定 yaz 或是使用环境变量指定应用包的路径 YAO_APP_SOURCE=app.yaz
17 |
18 | 使用程序包,解密使用-k
19 |
20 | ```sh
21 | # -f 指定yaz或是使用环境变量YAO_APP_SOURCE=app.yaz
22 | yao start -f app.yaz -k xxxx
23 |
24 | ```
25 |
26 | 官方目前只测试了 linux 版本,不支持 windows 版,需要手工处理。
27 |
28 | 0.10.3 版本的 pack 功能 windows 平台适配
29 |
30 | https://github.com/wwsheng009/gou/commit/773b81ea80b289055ee26a303a625eec101556cd
31 |
32 | ## zip 打包文件路径只能使用 linux 风格的路径分隔符
33 |
34 | ```go
35 | relPath = strings.ReplaceAll(relPath, "\\", "/")
36 | ```
37 |
38 | ## 移除临时文件的处理
39 |
40 | windows 删除文件会判断当前文件是否在使用。需要把删除文件的操作放在最后面。
41 |
42 | ```go
43 | defer os.Remove(encryptFile)//移除文件要在最后操作
44 | defer encryptWriter.Close()
45 | ```
46 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # 记录Yao应用开发过程中的一些问题与经验
2 |
3 | 收集的一些与 Yao 开发相关的文档,文档使用`vitepress`制作,并自动发布到`github page`上。直接访问地址:
4 |
5 | [https://wwsheng009.github.io/yao-docs](https://wwsheng009.github.io/yao-docs)
6 |
7 | cf pages 地址:
8 | [https://yao-docs.wwsheng.cloud](https://yao-docs.wwsheng.cloud/)
9 |
10 | ## 文档编写与构建
11 |
12 | 文档使用`markdown`格式编写,新建的文档存放在目录`/docs`。
13 |
14 | 在文档发布之前先本地构建一次检查有没有错误。
15 |
16 | ```sh
17 | pnpm run build
18 | ```
19 |
20 | ## `vitepress`配置文件自动生成
21 |
22 | `vitepress`以下配置文件使用脚本生成
23 |
24 | - `/docs/.vitepress/sidebar.ts`使用脚本`script/generate_config.ts`根据目录结构自动生成。
25 | - `/docs/.vitepress/nav.ts`使用脚本`script/generate_config.ts`根据目录结构自动生成。
26 |
27 | 监听文件变更,自动生成`vitepress`配置文件
28 |
29 | ```sh
30 | node script/watch.ts
31 | ```
32 |
33 | ## `index.md`文件的更新
34 |
35 | 当一个目录中新增/修改/删除文件后,索引文件`index.md`并不会自动的更新。
36 |
37 | 重建所有的`index.md`文件
38 |
39 | ```bash
40 | pnpm run build:index
41 | ```
42 |
--------------------------------------------------------------------------------
/scripts/cleanup.ts:
--------------------------------------------------------------------------------
1 | import fs from 'node:fs';
2 | import path from 'node:path';
3 | import { BaseDocPath } from './generate_config';
4 |
5 | function CleanUp(suffix: string) {
6 | deleteFilesWithBakSuffix(BaseDocPath, suffix);
7 | }
8 |
9 | // 检查目录及其子目录是否包含 .md 文件
10 | function hasMarkdownFiles(dirPath: string): boolean {
11 | const files = fs.readdirSync(dirPath);
12 |
13 | for (const file of files) {
14 | const filePath = path.join(dirPath, file);
15 | const stat = fs.statSync(filePath);
16 |
17 | if (stat.isDirectory()) {
18 | if (hasMarkdownFiles(filePath)) {
19 | return true;
20 | }
21 | } else if (file.endsWith('.md') && file !== 'index.md') {
22 | return true;
23 | }
24 | }
25 |
26 | return false;
27 | }
28 |
29 | // 定义删除函数
30 | function deleteFilesWithBakSuffix(dirPath: string, suffix: string) {
31 | if (dirPath.startsWith('.vitepress')) {
32 | return;
33 | }
34 |
35 | const match = suffix || '.bak';
36 | const files = fs.readdirSync(dirPath);
37 |
38 | // 检查目录是否只包含 index.md
39 | const hasOnlyIndexMd = files.length === 1 && files[0] === 'index.md';
40 | const indexMdPath = path.join(dirPath, 'index.md');
41 |
42 | // 遍历处理文件和目录
43 | files.forEach((file) => {
44 | const filePath = path.join(dirPath, file);
45 | const stat = fs.statSync(filePath);
46 |
47 | if (stat.isDirectory()) {
48 | // 递归处理子目录
49 | deleteFilesWithBakSuffix(filePath, suffix);
50 |
51 | // 检查子目录是否为空
52 | const subFiles = fs.readdirSync(filePath);
53 | if (subFiles.length === 0) {
54 | fs.rmdirSync(filePath);
55 | }
56 | }
57 | });
58 |
59 | // 如果目录中只有 index.md,且匹配删除条件,则删除它
60 | // 或者如果目录及其子目录中没有其他 .md 文件,也删除 index.md
61 | if (
62 | (hasOnlyIndexMd && match === 'index.md') ||
63 | (match === 'index.md' &&
64 | !hasMarkdownFiles(dirPath) &&
65 | fs.existsSync(indexMdPath))
66 | ) {
67 | fs.unlinkSync(indexMdPath);
68 | }
69 | }
70 |
71 | // CleanUp();
72 | CleanUp('index.md');
73 |
--------------------------------------------------------------------------------
/scripts/generate.ts:
--------------------------------------------------------------------------------
1 | import { CreateVitePressConfig } from './generate_config';
2 |
3 | // 生成站起index.md
4 | CreateVitePressConfig();
5 |
--------------------------------------------------------------------------------
/scripts/postbuild.ts:
--------------------------------------------------------------------------------
1 | import { copyFile } from 'node:fs/promises';
2 |
3 | // Path to the source file
4 | const source = './dist/yao-docs/index.html';
5 |
6 | // Path to the destination where file will be copied
7 | const destination = './dist/index.html';
8 |
9 | // Copying the file
10 | try {
11 | await copyFile(source, destination);
12 | console.log('File was copied successfully');
13 | } catch (err) {
14 | console.error('Error occurred while copying the file:', err);
15 | }
16 |
--------------------------------------------------------------------------------
/scripts/release.ts:
--------------------------------------------------------------------------------
1 | import { execSync } from 'node:child_process';
2 | import { readJSONSync } from 'fs-extra';
3 | import { updateContributors } from './utils';
4 |
5 | const { version: oldVersion } = readJSONSync('package.json');
6 |
7 | execSync('bumpp --no-commit --no-tag --no-push', { stdio: 'inherit' });
8 |
9 | const { version } = readJSONSync('package.json');
10 |
11 | if (oldVersion === version) {
12 | console.log('canceled');
13 | process.exit();
14 | }
15 |
16 | updateContributors();
17 |
18 | execSync('git add .', { stdio: 'inherit' });
19 |
20 | execSync(`git commit -m "chore: release v${version}"`, { stdio: 'inherit' });
21 | execSync(`git tag -a v${version} -m "v${version}"`, { stdio: 'inherit' });
22 |
--------------------------------------------------------------------------------
/scripts/update.ts:
--------------------------------------------------------------------------------
1 | import { updateContributors } from './utils';
2 |
3 | updateContributors();
4 |
--------------------------------------------------------------------------------
/scripts/watch.ts:
--------------------------------------------------------------------------------
1 | import fs from 'node:fs';
2 | import path from 'node:path';
3 | import { CreateVitePressConfig } from './generate_config';
4 | // Define the folder to watch
5 | const docsPath = path.resolve('./docs');
6 |
7 | // Define the callback function to execute when a file changes
8 | const callback = (eventType, filename) => {
9 | if (filename.startsWith('.vitepress')) {
10 | return;
11 | }
12 |
13 | console.log(`File ${filename} has been ${eventType}`);
14 |
15 | CreateVitePressConfig();
16 | };
17 |
18 | // Watch the folder for file changes
19 | fs.watch(docsPath, { recursive: true }, callback);
20 |
--------------------------------------------------------------------------------
/shims.d.ts:
--------------------------------------------------------------------------------
1 | declare module '*.vue' {
2 | import { ComponentOptions } from 'vue';
3 | const componentOptions: ComponentOptions;
4 | export default componentOptions;
5 | }
6 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "NodeNext",
4 | "moduleResolution": "NodeNext",
5 | "target": "esnext",
6 | "esModuleInterop": true,
7 | "strict": true,
8 | "skipLibCheck": true,
9 | "noUnusedLocals": true,
10 | "resolveJsonModule": true,
11 | "isolatedModules": true,
12 | "jsx": "preserve",
13 | "lib": ["ESNext", "dom", "ES2021.String"]
14 | },
15 | "include": [
16 | "docs",
17 | "docs/.vitepress/components/*.vue",
18 | "docs/.vitepress/*.ts",
19 | "docs/.vitepress/config.ts"
20 | ],
21 | "exclude": ["**/node_modules/**", "**/dist/**"]
22 | }
23 |
--------------------------------------------------------------------------------
/unocss.config.ts:
--------------------------------------------------------------------------------
1 | import {
2 | defineConfig,
3 | presetAttributify,
4 | presetIcons,
5 | presetUno,
6 | transformerDirectives,
7 | transformerVariantGroup
8 | } from 'unocss';
9 |
10 | export default defineConfig({
11 | shortcuts: {
12 | 'border-main': 'border-gray-400 border-opacity-30',
13 | 'bg-main': 'bg-gray-400',
14 | 'bg-base': 'bg-white dark:bg-hex-1a1a1a'
15 | },
16 | presets: [
17 | presetUno(),
18 | presetAttributify(),
19 | presetIcons({
20 | scale: 1.2,
21 | warn: true
22 | })
23 | ],
24 | theme: {
25 | colors: {
26 | primary: '#3eaf7c'
27 | },
28 | fontFamily: {
29 | mono: 'var(--vt-font-family-mono)'
30 | }
31 | },
32 | transformers: [transformerDirectives(), transformerVariantGroup()]
33 | });
34 |
--------------------------------------------------------------------------------