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

fix: 修改问题

parent c2a0f20b
......@@ -3,7 +3,6 @@ import * as path from 'path';
export default class ActivityController extends Controller {
public async home(ctx: Context) {
const { api, qiniu } = await import(path.resolve('./config/apollo.json'));
const redisKey = `quantum-blocks:page:${ctx.params.id}`;
let body = await ctx.service.redis.get(redisKey);
if (body) {
......@@ -14,9 +13,11 @@ export default class ActivityController extends Controller {
await ctx.service.redis.set(redisKey, body);
}
if (process.env.NODE_ENV === 'production') {
const firstScriptTagIndex = body.indexOf('<script');
const { api, qiniu } = await import(path.resolve('./config/apollo.json'));
const firstScriptTagIndex = body.indexOf('<script');
body = `${body.slice(0, firstScriptTagIndex)}<script>var apollo = ${JSON.stringify({...api, ...qiniu} )};</script>${body.slice(firstScriptTagIndex, body.length - 1)}`;
}
ctx.logger.info('body: %j', body);
ctx.body = body;
}
}
\ No newline at end of file
......@@ -31,23 +31,29 @@ export default class EditorModule implements Module<EditorState, RootState> {
state.pageInfo = data;
},
[UPDATE_PAGE_INFO](state, { containerIndex, childIndex, data }) {
const page = (state.pageInfo.page as Page).elements;
if (childIndex || childIndex === 0) {
page[containerIndex].child.splice(childIndex, 1, data);
} else {
page.splice(containerIndex, 1, data);
if (state.pageInfo && state.pageInfo.page) {
const page = (state.pageInfo.page as Page).elements;
if (childIndex || childIndex === 0) {
page[containerIndex].child.splice(childIndex, 1, data);
} else {
page.splice(containerIndex, 1, data);
}
}
},
[SET_PAGE_DATA](state, data) {
state.pageInfo.page = data;
},
[SET_PAGE_ELEMENTS](state, data) {
if (data) { (state.pageInfo.page as Page).elements = data; }
if (state.pageInfo && state.pageInfo.page) {
if (data) { (state.pageInfo.page as Page).elements = data; }
}
},
[SET_ELEMENT_POINT](state, { id, data }) {
const elements = (state.pageInfo.page as Page).elements;
const element = elements.find(ele => ele.id === id);
if (element && data) { element.point = data; }
if (state.pageInfo && state.pageInfo.page) {
const elements = (state.pageInfo.page as Page).elements;
const element = elements.find(ele => ele.id === id);
if (element && data) { element.point = data; }
}
},
};
......
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