feat: save single html and update redis

This commit is contained in:
2024-10-27 17:46:59 +08:00
parent c6539439e9
commit e032c092d9
5 changed files with 97 additions and 23 deletions

View File

@@ -46,28 +46,28 @@ const add = app.route({
add.run = async (ctx) => {
const tokenUser = ctx.state.tokenUser;
const data = ctx.query.data;
const _data: Container = {
title: '',
description: '',
code: '',
type: '',
};
const container = {
..._data,
...data,
};
let containerModel: any = null;
if (container.id) {
containerModel = await ContainerModel.findByPk(container.id);
if (containerModel) {
containerModel.update(container);
await containerModel.save();
ctx.emit?.('pageEdit', {
source: 'container',
data: containerModel.toJSON(),
operation: 'edit',
containerModel.update({
...container,
publish: {
...containerModel.publish,
...container.publish,
},
});
await containerModel.save();
if (containerModel.code || containerModel.source || containerModel.sourceType) {
ctx.emit?.('pageEdit', {
source: 'container',
data: containerModel.toJSON(),
operation: 'edit',
});
}
}
} else {
try {
@@ -123,7 +123,7 @@ app
}
container.publish = publish;
await container.save();
const { title, description, key, version, fileName } = publish;
const { title, description, key, version, fileName, saveHTML } = publish;
ctx.body = container;
if (!key || !version || !fileName) {
return;
@@ -134,6 +134,7 @@ app
version: version,
code: container.code,
filePath: fileName,
saveHTML
});
await ctx.call({
path: 'app',
@@ -143,7 +144,7 @@ app
data: {
appKey: key,
version,
files: [uploadResult],
files: uploadResult,
},
},
});