refactor: 项目架构重构 - 目录标准化 + 清理冗余

- 目录重命名: backend/wdkj-server/ → server/, frontend/ai-dimension/ → client/
- 删除 20+ 冗余文件(WDKJ 旧脚本、Windows 脚本、过时文档、设计稿)
- 更新 package.json 元数据(移除 wdkj 命名)
- 完善三级 .gitignore(根 + server + client)
- 重写 README.md 和 CHANGELOG.md
- 工具脚本移至 scripts/
This commit is contained in:
Yuzhiran Dev
2026-07-11 12:45:37 +08:00
parent 66ac576082
commit c1d6dd3b29
106 changed files with 17436 additions and 2311 deletions
+42
View File
@@ -0,0 +1,42 @@
const mongoose = require('mongoose')
/**
* 数据库连接配置
*/
const connectDB = async () => {
try {
const mongoURI = process.env.MONGODB_URI ||
`mongodb://${process.env.MONGODB_USER}:${process.env.MONGODB_PASSWORD}@${process.env.MONGODB_HOST}:${process.env.MONGODB_PORT}/${process.env.MONGODB_DB}?authSource=${process.env.MONGODB_DB}`
const conn = await mongoose.connect(mongoURI, {
// Mongoose 6+ 不再需要这些选项,但保留以兼容旧版本
// useNewUrlParser: true,
// useUnifiedTopology: true,
})
console.log(`✅ MongoDB 连接成功: ${conn.connection.host}:${conn.connection.port}/${conn.connection.name}`)
// 连接事件监听
mongoose.connection.on('error', (err) => {
console.error('❌ MongoDB 连接错误:', err)
})
mongoose.connection.on('disconnected', () => {
console.warn('⚠️ MongoDB 连接断开')
})
// 优雅关闭
process.on('SIGINT', async () => {
await mongoose.connection.close()
console.log('🔌 MongoDB 连接已关闭')
process.exit(0)
})
return conn
} catch (error) {
console.error('❌ MongoDB 连接失败:', error.message)
process.exit(1)
}
}
module.exports = connectDB