From 0aeeb946cc503380921e2760f3716a00e3736690 Mon Sep 17 00:00:00 2001 From: fancl Date: Fri, 13 Dec 2024 13:32:47 +0800 Subject: [PATCH] add document --- README.md | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/README.md b/README.md index 89d136d..2912150 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,130 @@ # 模版 +## 基础框架 + +### 程序配置 + +核心配置为数据库配置: + +```yaml +database: + address: "192.168.9.199:3306" + username: "root" + password: "root" + database: "test2" + +adminUsers: + - "1000" + +system: + settings: + productName: "测试网址" + copyright: "xxx" +``` + +**数据库配置** + +| 配置节点 | 配置说明 | +|----------|---------| +| address | 数据库连接地址 | +| username | 数据库用户名 | +| password | 数据库密码 | +| database | 使用的数据库 | + +**系统配置** + +系统配置为键值对的格式,结合界面进行配置的 + +| 配置节点 | 配置说明 | +|-------------|-----------------| +| productName | 产品名称,对应界面的title | +| copyright | 版权信息 | +| logo | logo的Url地址 | + +### 程序启动 + +如果设置了`VOX_DEBUG`环境变量会以`DEBUG`模式进行启动,常规启动方式为 + +```shell +moto --config=/path/to/config.yaml +``` + +## 开始开发 + +框架主要适用于多使用增删改查的操作逻辑,开发流程为定义模型,定义菜单,定制界面。 + +### 模型定义 + + +```go +package models + +type Login struct { + ID string `json:"id" gorm:"primaryKey;size:20" comment:"ID" scenarios:"view;export"` + CreatedAt int64 `json:"created_at" gorm:"autoCreateTime" comment:"登录时间" scenarios:"list;search;view;export" position:"2"` + Domain string `json:"domain" gorm:"index;size:60;not null;default:'default'" comment:"域" scenarios:"export"` + UID string `json:"uid" gorm:"column:uid;index;size:20;not null;default:''" props:"match:exactly" comment:"座席" format:"user" scenarios:"search;list;export" position:"1"` + IP string `json:"ip" gorm:"size:20;not null;default:''" comment:"IP" scenarios:"search;list;export"` + Browser string `json:"browser" gorm:"size:200;not null;default:''" comment:"浏览器" scenarios:"search;list;export"` + Os string `json:"os" gorm:"size:200;not null;default:''" comment:"操作系统" scenarios:"search;list;export"` + Platform string `json:"platform" gorm:"size:200;not null;default:''" comment:"平台" scenarios:"search;list;export"` + AccessToken string `json:"access_token" gorm:"size:200;not null;default:''" comment:"访问令牌" scenarios:"export"` + UserAgent string `json:"user_agent" gorm:"size:1024;not null;default:''" comment:"UserAgent" scenarios:"export"` +} + +func (model *Login) TableName() string { + return "user_logins" +} +``` + +## 菜单定义 + +```js +let menu = { + label: "部门管理", + route: "/organize/departments", + permissions: [ + { + label: '新建', + value: 'create' + }, + { + label: '更新', + value: 'update' + }, + { + label: '删除', + value: 'delete' + } + ] +} +``` + +## 视图定义 + +```vue + + + +```