feat: 系统配置 + 用户签名
- 新增 sys_config 表,存储应用版本号、标语、描述 - 关于小菜弹窗版本号改为从数据库动态获取 - 用户表新增 slogan 字段(个性签名) - 编辑资料页面支持修改签名 - 管理后台新增系统配置管理页面 - 更新 CLAUDE.md 文档
This commit is contained in:
@@ -165,6 +165,56 @@ async function runMigrations(conn: mysql.Connection) {
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
|
||||
`)
|
||||
}
|
||||
|
||||
// users 表添加 slogan(个性签名)
|
||||
const hasSlogan = await columnExists(conn, 'users', 'slogan')
|
||||
if (!hasSlogan) {
|
||||
console.log('[DB] Migrating: adding slogan to users')
|
||||
await conn.query("ALTER TABLE users ADD COLUMN slogan VARCHAR(100) DEFAULT '记账小能手' COMMENT '个性签名' AFTER avatar_url")
|
||||
}
|
||||
|
||||
// 系统配置表
|
||||
const hasSysConfig = await tableExists(conn, 'sys_config')
|
||||
if (!hasSysConfig) {
|
||||
console.log('[DB] Migrating: creating sys_config table')
|
||||
await conn.query(`
|
||||
CREATE TABLE IF NOT EXISTS sys_config (
|
||||
config_key VARCHAR(50) PRIMARY KEY COMMENT '配置键',
|
||||
config_value TEXT NOT NULL COMMENT '配置值',
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
|
||||
`)
|
||||
// 插入默认配置
|
||||
await conn.query(`
|
||||
INSERT IGNORE INTO sys_config (config_key, config_value) VALUES
|
||||
('app_version', '1.0.0'),
|
||||
('app_slogan', '温暖 x 轻松的个人记账小程序'),
|
||||
('app_description', '让记账从负担变成享受')
|
||||
`)
|
||||
}
|
||||
|
||||
// 反馈表
|
||||
const hasFeedbacks = await tableExists(conn, 'feedbacks')
|
||||
if (!hasFeedbacks) {
|
||||
console.log('[DB] Migrating: creating feedbacks table')
|
||||
await conn.query(`
|
||||
CREATE TABLE IF NOT EXISTS feedbacks (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT NOT NULL,
|
||||
type ENUM('bug', 'feature', 'ux', 'other') NOT NULL DEFAULT 'other' COMMENT '反馈类型',
|
||||
content TEXT NOT NULL COMMENT '反馈内容',
|
||||
contact VARCHAR(100) DEFAULT '' COMMENT '联系方式',
|
||||
status ENUM('pending', 'processed', 'ignored') DEFAULT 'pending' COMMENT '处理状态',
|
||||
admin_reply TEXT DEFAULT '' COMMENT '管理员回复',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
INDEX idx_user (user_id),
|
||||
INDEX idx_status (status),
|
||||
INDEX idx_created (created_at),
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
|
||||
`)
|
||||
}
|
||||
}
|
||||
|
||||
export async function initDatabase() {
|
||||
|
||||
Reference in New Issue
Block a user