Commit df48e092 authored by 郭志伟's avatar 郭志伟

fix(pagedata): 提示优化

parent 6240e63b
......@@ -14,9 +14,13 @@ export default class EditorController extends Controller {
public async save(ctx: Context) {
const pageInfo = ctx.request.body;
const result = await ctx.model.PageInfo.create({ ...pageInfo, uuid: uuidv1().replace(/-/g, ''), tenantId: ctx.headers['qg-tenant-id']});
await ctx.service.redis.set(`pageInfo:${result.dataValues.uuid}`, result.dataValues);
ctx.body = ctx.helper.ok(result);
try {
const result = await ctx.model.PageInfo.create({ ...pageInfo, uuid: uuidv1().replace(/-/g, ''), tenantId: ctx.headers['qg-tenant-id']});
ctx.body = ctx.helper.ok(result);
await ctx.service.redis.set(`pageInfo:${result.dataValues.uuid}`, result.dataValues);
} catch (error) {
ctx.body = ctx.helper.fail(error);
}
}
public async update(ctx: Context) {
......@@ -27,10 +31,15 @@ export default class EditorController extends Controller {
if (ctx.headers['qg-tenant-id']) {
pageInfo.tenantId = +ctx.headers['qg-tenant-id'];
}
const result = await ctx.model.PageInfo.update(pageInfo, {where: { uuid: pageInfo.uuid, tenantId: ctx.headers['qg-tenant-id'] }});
await ctx.service.redis.set(`pageInfo:${pageInfo.uuid}`, pageInfo);
await ctx.service.redis.del(`page:${pageInfo.uuid}`);
try {
const result = await ctx.model.PageInfo.update(pageInfo, {where: { uuid: pageInfo.uuid, tenantId: ctx.headers['qg-tenant-id'] }});
await ctx.service.redis.set(`pageInfo:${pageInfo.uuid}`, pageInfo);
await ctx.service.redis.del(`page:${pageInfo.uuid}`);
ctx.body = ctx.helper.ok(result);
} catch (error) {
error.message = error.message.indexOf('Data too long') > -1 && error.message.indexOf('page_data') > -1 ? '配置组件过多,请对组件进行删减' : '';
ctx.body = ctx.helper.fail(error);
}
}
// todo 编辑器获取跳过redis,但需要注意
public async get(ctx: Context) {
......
......@@ -66,6 +66,16 @@ export default class EditorModule implements Module<EditorState, RootState> {
const goodsTabs = {};
(pageObj as Page).elements.forEach((element, idx) => {
if (element.schame) {
delete element.schame;
}
if (element?.child?.length) {
element.child.forEach(childEle => {
if (childEle.schame) {
delete childEle.schame;
}
});
}
if (element.name === 'cs-goods-tabs' && element?.child?.length) {
goodsTabs[idx] = cloneDeep(element.child);
// 逆向循环
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment