feat: update auto render

This commit is contained in:
2025-08-07 20:03:53 +08:00
parent fd67864247
commit d7e8ca38f8
39 changed files with 5684 additions and 130 deletions

View File

@@ -1,147 +1,215 @@
# Database Render Application Configuration
# Copy this file to config.yaml and modify as needed
# 数据库动态渲染系统 - 配置文件示例
# 支持数据库类型: sqlite, mysql, postgres
app:
name: "Database Render"
port: 8080
debug: false
database:
# Database type: sqlite, mysql, postgres
type: "sqlite"
# SQLite configuration (used when type is sqlite)
path: "data/app.db"
# MySQL configuration (used when type is mysql)
# host: "localhost"
type: sqlite # 数据库类型: sqlite, mysql, postgres
path: ./data/app.db # SQLite数据库文件路径
# MySQL配置示例
# type: mysql
# host: localhost
# port: 3306
# user: "root"
# password: "password"
# db_name: "database_render"
# PostgreSQL configuration (used when type is postgres)
# host: "localhost"
# user: root
# password: password
# dbname: testdb
# PostgreSQL配置示例
# type: postgres
# host: localhost
# port: 5432
# user: "postgres"
# password: "password"
# db_name: "database_render"
# dsn: "host=localhost port=5432 user=postgres password=password dbname=database_render sslmode=disable"
# user: postgres
# password: password
# dbname: testdb
# Table configurations
# 模板系统配置
templates:
custom_path: "./web/templates/custom" # 自定义模板目录
cache_enabled: true # 启用模板缓存
hot_reload: false # 开发环境下启用热重载
builtin_path: "./web/templates/builtin" # 内置模板目录
# 模板定义配置
templates:
articles:
name: "文章列表"
type: "list"
description: "技术文章列表视图"
fields:
title: "string"
content: "markdown"
category: "category"
tags: "tag"
created_at: "time"
config:
page_size: 15
show_pagination: true
logs:
name: "系统日志"
type: "table"
description: "系统日志表格视图"
fields:
level: "tag"
message: "string"
timestamp: "time"
config:
page_size: 50
show_filter: true
users:
name: "用户管理"
type: "card"
description: "用户卡片视图"
fields:
username: "string"
email: "string"
role: "tag"
created_at: "time"
config:
page_size: 12
show_avatar: true
# 模板类型配置
template_types:
list:
layout: "table"
fields:
default: "raw"
time: "time"
markdown: "markdown"
tag: "tag"
category: "category"
options:
striped: true
hover: true
border: true
card:
layout: "grid"
fields:
default: "raw"
time: "relative"
markdown: "excerpt"
tag: "badge"
category: "chip"
options:
columns: "3"
spacing: "md"
timeline:
layout: "timeline"
fields:
default: "raw"
time: "relative"
markdown: "summary"
tag: "status"
category: "timeline"
options:
direction: "vertical"
alignment: "left"
# 数据表配置
tables:
- name: "posts"
alias: "文章管理"
description: "博客文章管理"
default: true
layout: "cards" # cards or list
articles:
alias: "技术文章"
layout: "card" # 默认布局: card, list, timeline
page_size: 15
template: "card" # 默认模板类型
custom_templates: # 自定义模板映射
list: "custom/articles/list.html"
card: "custom/articles/card.html"
field_renderers: # 字段渲染器映射
content: "custom/articles/field/markdown.html"
tags: "custom/articles/field/tag.html"
columns:
- name: "id"
alias: "ID"
type: "int"
primary: true
hidden: true
hidden: false
- name: "title"
alias: "标题"
type: "string"
searchable: true
max_length: 50
- name: "content"
alias: "内容"
type: "text"
render_type: "markdown"
searchable: true
hidden: true # 不在列表中显示,详情页显示
- name: "category"
alias: "分类"
type: "string"
searchable: true
render_type: "tag"
values:
technology:
label: "技术"
color: "#3b82f6"
life:
label: "生活"
color: "#10b981"
work:
label: "工作"
color: "#f59e0b"
render_type: "category"
- name: "tags"
alias: "标签"
type: "string"
searchable: true
render_type: "tag"
values:
1:
label: "Go"
color: "#00ADD8"
2:
label: "JavaScript"
color: "#f7df1e"
3:
label: "Python"
color: "#3776ab"
- name: "created_at"
alias: "创建时间"
alias: "发布时间"
type: "datetime"
render_type: "time"
- name: "updated_at"
alias: "更新时间"
type: "datetime"
render_type: "time"
- name: "users"
alias: "用户管理"
description: "系统用户管理"
format: "2006-01-02 15:04:05"
logs:
alias: "系统日志"
layout: "list"
page_size: 50
columns:
- name: "id"
alias: "ID"
type: "int"
primary: true
hidden: true
- name: "username"
alias: "用户名"
type: "string"
searchable: true
- name: "email"
alias: "邮箱"
type: "string"
searchable: true
- name: "full_name"
alias: "姓名"
type: "string"
searchable: true
- name: "status"
alias: "状态"
type: "string"
hidden: false
- name: "level"
alias: "级别"
type: "int"
render_type: "tag"
values:
active:
label: "激活"
color: "#10b981"
inactive:
label: "未激活"
color: "#ef4444"
pending:
label: "待审核"
color: "#f59e0b"
- name: "created_at"
alias: "创建时间"
1:
label: "INFO"
color: "#52c41a"
2:
label: "WARN"
color: "#faad14"
3:
label: "ERROR"
color: "#f5222d"
- name: "message"
alias: "日志信息"
type: "text"
max_length: 100
- name: "timestamp"
alias: "时间"
type: "datetime"
render_type: "time"
format: "2006-01-02 15:04:05"
# Logging configuration
app:
name: "数据库动态渲染系统"
theme: "modern"
language: "zh-CN"
port: 8080
# 日志配置
logging:
level: "info" # debug, info, warn, error
format: "json" # json, text
output: "stdout" # stdout, stderr, file
file: "logs/app.log" # Only used when output is file
# Server configuration
# 服务器配置
server:
read_timeout: 30s
write_timeout: 30s
idle_timeout: 60s
# Security configuration
security:
cors:
enabled: true
allow_origins: ["*"]
allow_methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"]
allow_headers: ["Origin", "Content-Type", "Accept", "Authorization"]
# Cache configuration
cache:
enabled: false
ttl: 5m
max_size: 100
idle_timeout: 60s

215
config/templates.yaml Normal file
View File

@@ -0,0 +1,215 @@
# 模板配置文件
# 支持自定义模板类型和字段渲染器配置
# 模板定义配置
templates:
articles:
name: "文章列表"
type: "list"
description: "技术文章列表视图"
fields:
id: "number"
title: "string"
content: "markdown"
category: "category"
tags: "tag"
created_at: "time"
config:
page_size: 15
show_pagination: true
show_search: true
show_sort: true
logs:
name: "系统日志"
type: "table"
description: "系统日志表格视图"
fields:
id: "number"
level: "tag"
message: "string"
timestamp: "time"
config:
page_size: 50
show_filter: true
show_export: true
users:
name: "用户管理"
type: "card"
description: "用户卡片视图"
fields:
id: "number"
username: "string"
email: "email"
role: "tag"
avatar: "image"
created_at: "time"
config:
page_size: 12
show_avatar: true
show_actions: true
projects:
name: "项目管理"
type: "timeline"
description: "项目进度时间轴视图"
fields:
id: "number"
name: "string"
description: "markdown"
status: "tag"
progress: "progress"
start_date: "time"
end_date: "time"
config:
page_size: 20
show_progress: true
# 模板类型配置
template_types:
list:
layout: "table"
fields:
default: "raw"
time: "time"
markdown: "markdown"
tag: "tag"
category: "category"
email: "email"
image: "image"
progress: "progress"
options:
striped: true
hover: true
border: true
responsive: true
card:
layout: "grid"
fields:
default: "raw"
time: "relative"
markdown: "excerpt"
tag: "badge"
category: "chip"
email: "email"
image: "avatar"
progress: "circle"
options:
columns: "3"
spacing: "lg"
shadow: "md"
timeline:
layout: "timeline"
fields:
default: "raw"
time: "relative"
markdown: "summary"
tag: "status"
category: "timeline"
email: "link"
image: "thumbnail"
progress: "bar"
options:
direction: "vertical"
alignment: "left"
alternating: false
table:
layout: "table"
fields:
default: "raw"
time: "time"
markdown: "preview"
tag: "tag"
category: "category"
email: "link"
image: "thumbnail"
progress: "bar"
options:
striped: true
hover: true
border: true
pagination: true
export: true
# 字段类型配置
field_types:
string:
type: "text"
renderer: "text"
options:
max_length: 100
ellipsis: true
validation:
required: false
number:
type: "number"
renderer: "number"
options:
thousand_separator: true
validation:
min: 0
time:
type: "datetime"
renderer: "time"
options:
format: "2006-01-02 15:04:05"
relative: true
formatting:
locale: "zh-CN"
markdown:
type: "text"
renderer: "markdown"
options:
max_length: 500
excerpt: true
validation:
sanitize: true
tag:
type: "enum"
renderer: "badge"
options:
style: "rounded"
size: "sm"
validation:
allowed_values: []
category:
type: "string"
renderer: "chip"
options:
style: "outlined"
size: "md"
email:
type: "email"
renderer: "link"
options:
mailto: true
validation:
email: true
image:
type: "url"
renderer: "image"
options:
width: 50
height: 50
fit: "cover"
progress:
type: "number"
renderer: "progress"
options:
show_percentage: true
color: "primary"
formatting:
unit: "%"
max: 100