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