Quellcode durchsuchen

feat:修改添加文章改成富文本

wangsisi vor 19 Stunden
Ursprung
Commit
4fb3e39c4a
2 geänderte Dateien mit 56 neuen und 2 gelöschten Zeilen
  1. 3 2
      app.js
  2. 53 0
      migrations/20250914031648-add-missing-fields-to-articles.js

+ 3 - 2
app.js

@@ -25,8 +25,9 @@ const corsOptions = {
 app.use(cors());
 
 app.use(logger('dev'));
-app.use(express.json());
-app.use(express.urlencoded({ extended: false }));
+// 增加请求体大小限制以支持富文本内容
+app.use(express.json({ limit: '50mb' }));
+app.use(express.urlencoded({ extended: false, limit: '50mb' }));
 app.use(cookieParser());
 app.use(express.static(path.join(__dirname, 'public')));
 

+ 53 - 0
migrations/20250914031648-add-missing-fields-to-articles.js

@@ -0,0 +1,53 @@
+'use strict';
+
+/** @type {import('sequelize-cli').Migration} */
+module.exports = {
+  async up (queryInterface, Sequelize) {
+    // 检查并添加缺失的字段到Articles表
+    const tableDescription = await queryInterface.describeTable('Articles');
+    
+    if (!tableDescription.author) {
+      await queryInterface.addColumn('Articles', 'author', {
+        type: Sequelize.TEXT,
+        allowNull: true,
+      });
+    }
+
+    if (!tableDescription.category) {
+      await queryInterface.addColumn('Articles', 'category', {
+        type: Sequelize.INTEGER,
+        allowNull: true,
+      });
+    }
+
+    if (!tableDescription.crop) {
+      await queryInterface.addColumn('Articles', 'crop', {
+        type: Sequelize.INTEGER,
+        allowNull: true,
+      });
+    }
+
+    if (!tableDescription.seoKeyword) {
+      await queryInterface.addColumn('Articles', 'seoKeyword', {
+        type: Sequelize.TEXT,
+        allowNull: true,
+      });
+    }
+
+    if (!tableDescription.seoDescription) {
+      await queryInterface.addColumn('Articles', 'seoDescription', {
+        type: Sequelize.TEXT,
+        allowNull: true,
+      });
+    }
+  },
+
+  async down (queryInterface, Sequelize) {
+    // 删除添加的字段
+    await queryInterface.removeColumn('Articles', 'author');
+    await queryInterface.removeColumn('Articles', 'category');
+    await queryInterface.removeColumn('Articles', 'crop');
+    await queryInterface.removeColumn('Articles', 'seoKeyword');
+    await queryInterface.removeColumn('Articles', 'seoDescription');
+  }
+};