asd123a20 2 роки тому
батько
коміт
5a8da88b9a
2 змінених файлів з 20 додано та 19 видалено
  1. 3 2
      app/service/content.js
  2. 17 17
      config/config.default.js

+ 3 - 2
app/service/content.js

@@ -6,12 +6,13 @@ const moment = require('moment');
 class ContentService extends Service {
   async create({ title, thumbnail, annex, content, istop, menus, date, annexname, term, sort }) {
     assert(title, '标题不存在');
-    assert(thumbnail, '缩略图不存在');
+    // assert(thumbnail, '缩略图不存在');
     assert(content, '内容不存在');
     const { Content: model } = this.ctx.model;
     const createAt = moment().format('x');
     let text = content.replace(new RegExp('</?[^>]+>', 'gm'), '');
-    text = text.replace('\\s*|\t|\r|\n', '');
+    text = text.replace(/\s*|\t|\r|\n/g, '');
+    text = text.replace(/&nbsp;/ig, '');
     const slug = text.substring(0, 200);
     try {
       const year = date.slice(0, 4) + '年';

+ 17 - 17
config/config.default.js

@@ -50,28 +50,28 @@ module.exports = appInfo => {
   config.userSecret = '123456';
   config.filespath = '/var/www/jjzh';
   // 数据库配置
+  // config.mongoose = {
+  //   url: 'mongodb://127.0.0.1:27017/cms',
+  //   options: {
+  //     user: 'root',
+  //     pass: 'cms@cc-lotus',
+  //     authSource: 'admin',
+  //     useNewUrlParser: true,
+  //     useCreateIndex: true,
+  //     useUnifiedTopology: true,
+  //   },
+  // };
   config.mongoose = {
     url: 'mongodb://127.0.0.1:27017/cms',
     options: {
-      user: 'root',
-      pass: 'cms@cc-lotus',
-      authSource: 'admin',
-      useNewUrlParser: true,
-      useCreateIndex: true,
-      useUnifiedTopology: true,
+      // user: 'root',
+      // pass: 'cms@cc-lotus',
+      // authSource: 'admin',
+      // useNewUrlParser: true,
+      // useCreateIndex: true,
+      // useUnifiedTopology: true,
     },
   };
-  // config.mongoose = {
-  //   url: 'mongodb://127.0.0.1:27017/example',
-  //   options: {
-  //     // user: 'root',
-  //     // pass: 'cms@cc-lotus',
-  //     // authSource: 'admin',
-  //     // useNewUrlParser: true,
-  //     // useCreateIndex: true,
-  //     // useUnifiedTopology: true,
-  //   },
-  // };
   // 异常捕获 路由拦截
   config.middleware = [ 'errorHandler' ];
   config.errorHandler = {