youzanyun-devtool-worker
Version:
- web - ws - proxy
191 lines (190 loc) • 8.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const spring4js_nodejs_1 = require("spring4js-nodejs");
const BaseController_1 = tslib_1.__importDefault(require("../BaseController"));
let H5ExtensionController = class H5ExtensionController extends BaseController_1.default {
async initPageDemo(ctx, next) {
const { projectId } = ctx.query;
const versionInfo = await this.h5ExtensionService.initPageDemo(projectId);
return versionInfo;
}
async updateH5Project(ctx, next) {
const { projectId } = ctx.request.body;
const versionInfo = await this.h5ExtensionService.updateH5Project(projectId);
return versionInfo;
}
async getAllPageCustomList(ctx, next) {
const params = ctx.query;
const result = await this.h5ExtensionService.getAllPageCustomList(params);
return result;
}
async getPageComponentList(ctx, next) {
const params = ctx.query;
const result = await this.h5ExtensionService.getPageComponentList(params);
return result;
}
async getPageCustomListByNodeId(ctx, next) {
const params = ctx.query;
const result = await this.h5ExtensionService.getPageCustomListByNodeId(params);
return result;
}
async savePageCompCustom(ctx, next) {
const { projectId, nodeCode, pageName } = ctx.request.body;
const handler = await this.h5ExtensionService.getPageHandler({
projectId,
nodeCode,
pageName
});
await handler.savePageCompCustom();
return true;
}
async removePageCompCustom(ctx, next) {
const { projectId, nodeCode, pageName } = ctx.request.body;
const handler = await this.h5ExtensionService.getPageHandler({
projectId,
nodeCode,
pageName
});
await handler.removePageCompCustom();
return true;
}
async addComponent(ctx, next) {
const _a = ctx.request.body, { projectId, nodeCode, pageName } = _a, addInfo = tslib_1.__rest(_a, ["projectId", "nodeCode", "pageName"]);
const handler = await this.h5ExtensionService.getPageHandler({
projectId,
nodeCode,
pageName
});
try {
await handler.addComponent(addInfo);
return true;
}
catch (err) {
ctx.body = {
code: -1,
message: err.message || '保存失败'
};
return;
}
}
async removeComponent(ctx, next) {
const _a = ctx.request.body, { projectId, nodeCode, pageName } = _a, removeInfo = tslib_1.__rest(_a, ["projectId", "nodeCode", "pageName"]);
const handler = await this.h5ExtensionService.getPageHandler({
projectId,
nodeCode,
pageName
});
await handler.removeComponent(removeInfo);
return true;
}
async broadcastPreviewComps(ctx, next) {
const { projectId, workbenchId, previewComps } = ctx.request.body;
await this.h5ExtensionPreviewService.broadcastPreviewComps(projectId, workbenchId, previewComps);
return true;
}
async getPreviewComps(ctx, next) {
const { projectId, nodeCode, pageName } = ctx.query;
const result = {
localComps: [],
localPageFile: ''
};
const cacheComps = await this.h5ExtensionPreviewService.getPreviewComps(projectId, nodeCode, pageName);
const pageHandler = await this.h5ExtensionService.getPageHandler({
projectId,
nodeCode,
pageName
});
if (cacheComps) {
result.localComps = cacheComps;
}
else {
const localComps = await pageHandler.getComponents();
result.localComps = localComps;
}
const localPageFile = await pageHandler.getExactDistPageFile();
result.localPageFile = localPageFile;
return result;
}
async getImplPreviewComps(ctx, next) {
const { projectId, implId } = ctx.query;
const result = await this.h5ExtensionPreviewEditorService.getPreviewComps(projectId, implId);
return result;
}
async getLocalPageFile(ctx, next) {
const { projectId, nodeCode, pageName } = ctx.query;
const pageHandler = await this.h5ExtensionService.getPageHandler({
projectId,
nodeCode,
pageName
});
const { localPageFile } = await pageHandler.getDistPageComponents();
return localPageFile;
}
async uploadInfo(ctx, next) {
const { projectId } = ctx.request.body;
const result = await this.h5ExtensionUploadService.uploadInfo(projectId);
return result;
}
};
tslib_1.__decorate([
spring4js_nodejs_1.Resource()
], H5ExtensionController.prototype, "configService", void 0);
tslib_1.__decorate([
spring4js_nodejs_1.Resource()
], H5ExtensionController.prototype, "h5ExtensionService", void 0);
tslib_1.__decorate([
spring4js_nodejs_1.Resource()
], H5ExtensionController.prototype, "h5ExtensionUploadService", void 0);
tslib_1.__decorate([
spring4js_nodejs_1.Resource()
], H5ExtensionController.prototype, "h5ExtensionPreviewService", void 0);
tslib_1.__decorate([
spring4js_nodejs_1.Resource()
], H5ExtensionController.prototype, "h5ExtensionPreviewEditorService", void 0);
tslib_1.__decorate([
spring4js_nodejs_1.Path("initPageDemo", spring4js_nodejs_1.HttpMethod.GET)
], H5ExtensionController.prototype, "initPageDemo", null);
tslib_1.__decorate([
spring4js_nodejs_1.Path("updateH5Project", spring4js_nodejs_1.HttpMethod.POST)
], H5ExtensionController.prototype, "updateH5Project", null);
tslib_1.__decorate([
spring4js_nodejs_1.Path("getAllPageCustomList", spring4js_nodejs_1.HttpMethod.GET)
], H5ExtensionController.prototype, "getAllPageCustomList", null);
tslib_1.__decorate([
spring4js_nodejs_1.Path("getPageComponentList", spring4js_nodejs_1.HttpMethod.GET)
], H5ExtensionController.prototype, "getPageComponentList", null);
tslib_1.__decorate([
spring4js_nodejs_1.Path("getPageCustomListByNodeId", spring4js_nodejs_1.HttpMethod.GET)
], H5ExtensionController.prototype, "getPageCustomListByNodeId", null);
tslib_1.__decorate([
spring4js_nodejs_1.Path("savePageCompCustom", spring4js_nodejs_1.HttpMethod.POST)
], H5ExtensionController.prototype, "savePageCompCustom", null);
tslib_1.__decorate([
spring4js_nodejs_1.Path("removePageCompCustom", spring4js_nodejs_1.HttpMethod.POST)
], H5ExtensionController.prototype, "removePageCompCustom", null);
tslib_1.__decorate([
spring4js_nodejs_1.Path("addComponent", spring4js_nodejs_1.HttpMethod.POST)
], H5ExtensionController.prototype, "addComponent", null);
tslib_1.__decorate([
spring4js_nodejs_1.Path("removeComponent", spring4js_nodejs_1.HttpMethod.POST)
], H5ExtensionController.prototype, "removeComponent", null);
tslib_1.__decorate([
spring4js_nodejs_1.Path("previewComps/broadcast", spring4js_nodejs_1.HttpMethod.POST)
], H5ExtensionController.prototype, "broadcastPreviewComps", null);
tslib_1.__decorate([
spring4js_nodejs_1.Path("getPreviewComps", spring4js_nodejs_1.HttpMethod.GET)
], H5ExtensionController.prototype, "getPreviewComps", null);
tslib_1.__decorate([
spring4js_nodejs_1.Path("getImplPreviewComps", spring4js_nodejs_1.HttpMethod.GET)
], H5ExtensionController.prototype, "getImplPreviewComps", null);
tslib_1.__decorate([
spring4js_nodejs_1.Path("getLocalPageFile", spring4js_nodejs_1.HttpMethod.GET)
], H5ExtensionController.prototype, "getLocalPageFile", null);
tslib_1.__decorate([
spring4js_nodejs_1.Path("uploadInfo", spring4js_nodejs_1.HttpMethod.POST)
], H5ExtensionController.prototype, "uploadInfo", null);
H5ExtensionController = tslib_1.__decorate([
spring4js_nodejs_1.Controller("/api/h5-extension")
], H5ExtensionController);
exports.default = H5ExtensionController;