refactor(文件管理): 重构图片存储及模型字段命名

- 删除根目录图片文件,迁移至uploads/images目录
- 添加.gitkeep文件保持目录结构
- 在app.js中添加静态资源服务配置
- 将Product模型中的image_url字段改为camelCase命名规范imageUrl
master
Lmx 2 weeks ago
parent f2eee72513
commit 3ab42b00a3

@ -19,6 +19,8 @@ app.use(cors({
origin: process.env.CORS_ORIGIN,
credentials: true // 允许携带Cookie后续若需记住登录状态可用
}));
// 配置静态资源服务
app.use('/uploads', express.static('uploads'));
// 2. 测试数据库连接(启动时自动验证)
testDbConnection();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 KiB

@ -33,7 +33,7 @@ const Product = sequelize.define('Product', {
allowNull: true,
comment: '商品分类'
},
image_url: {
imageUrl: {
type: DataTypes.STRING(255),
allowNull: true,
comment: '商品图片URL'
@ -61,7 +61,7 @@ const Product = sequelize.define('Product', {
charset: 'utf8mb4',
collate: 'utf8mb4_unicode_ci',
freezeTableName: true,
syncOnAssociation: false
syncOnAssociation: false,
});
module.exports = Product;

@ -0,0 +1 @@
# This file keeps the images folder in git

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Loading…
Cancel
Save