2024-12-12 11:45:03 +08:00
|
|
|
|
# 模版
|
|
|
|
|
|
2024-12-13 13:32:47 +08:00
|
|
|
|
## 基础框架
|
|
|
|
|
|
|
|
|
|
### 程序配置
|
|
|
|
|
|
|
|
|
|
核心配置为数据库配置:
|
|
|
|
|
|
|
|
|
|
```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
|
|
|
|
|
<template>
|
|
|
|
|
<viewer :title="title" :module-name="moduleName" :table-name="tableName" :disable-toolbar="false"
|
|
|
|
|
defaultSortable="id"></viewer>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import Viewer from '@/components/fragment/Viewer.vue';
|
|
|
|
|
import { computed } from 'vue';
|
|
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
title: {
|
|
|
|
|
type: String,
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const moduleName = computed(() => {
|
|
|
|
|
return ''
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const tableName = computed(() => {
|
|
|
|
|
return 'departments'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
```
|