UNPKG

youzanyun-devtool-worker

Version:

- web - ws - proxy

222 lines (221 loc) 9.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const path_1 = tslib_1.__importDefault(require("path")); 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; await this.h5ExtensionService.updateH5Project(projectId); return true; } async getPageCustomList(ctx, next) { const params = ctx.query; const result = await this.h5ExtensionService.getPageCustomList(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({ customType: 'h5-extension', 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({ customType: 'h5-extension', 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({ customType: 'h5-extension', 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({ customType: 'h5-extension', projectId, nodeCode, pageName }); await handler.removeComponent(removeInfo); return true; } async broadcastPreviewComps(ctx, next) { const { projectId, workbenchId, previewComps } = ctx.request.body; await this.h5ExtensionService.broadcastPreviewComps(projectId, workbenchId, previewComps); return true; } async updatePreviewComps(ctx, next) { const { projectId, url, previewComps } = ctx.request.body; await this.h5ExtensionService.updatePreviewComps(projectId, url, previewComps); return true; } async getPreviewComps(ctx, next) { const { projectId, url } = ctx.query; const result = await this.h5ExtensionService.getPreviewComps(projectId, url); return result; } async savePageReplaceCustom(ctx, next) { const { projectId, nodeCode, pageName } = ctx.request.body; const handler = await this.h5ExtensionService.getPageHandler({ customType: 'h5-script-replace', projectId, nodeCode, pageName }); await handler.savePageReplaceCustom(); return true; } async removePageReplaceCustom(ctx, next) { const { projectId, nodeCode, pageName } = ctx.request.body; const handler = await this.h5ExtensionService.getPageHandler({ customType: 'h5-script-replace', projectId, nodeCode, pageName }); await handler.removePageReplaceCustom(); return true; } async addReplacePage(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({ customType: 'h5-script-replace', projectId, nodeCode, pageName }); try { await handler.addReplacePage(addInfo); return true; } catch (err) { ctx.body = { code: -1, message: err.message || '保存失败' }; return; } } async removeReplacePage(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({ customType: 'h5-script-replace', projectId, nodeCode, pageName }); await handler.removeReplacePage(removeInfo); return true; } async getTouchJsPath(ctx, next) { const touchJsPath = path_1.default.resolve(this.configService.getWorkerDir(), 'assets/utils/touch-emulator.js'); return touchJsPath; } async uploadInfo(ctx, next) { const { projectId } = ctx.request.body; const result = await this.h5ExtensionService.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.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("getPageCustomList", spring4js_nodejs_1.HttpMethod.GET) ], H5ExtensionController.prototype, "getPageCustomList", 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("updatePreviewComps", spring4js_nodejs_1.HttpMethod.POST) ], H5ExtensionController.prototype, "updatePreviewComps", 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("savePageReplaceCustom", spring4js_nodejs_1.HttpMethod.POST) ], H5ExtensionController.prototype, "savePageReplaceCustom", null); tslib_1.__decorate([ spring4js_nodejs_1.Path("removePageReplaceCustom", spring4js_nodejs_1.HttpMethod.POST) ], H5ExtensionController.prototype, "removePageReplaceCustom", null); tslib_1.__decorate([ spring4js_nodejs_1.Path("addReplacePage", spring4js_nodejs_1.HttpMethod.POST) ], H5ExtensionController.prototype, "addReplacePage", null); tslib_1.__decorate([ spring4js_nodejs_1.Path("removeReplacePage", spring4js_nodejs_1.HttpMethod.POST) ], H5ExtensionController.prototype, "removeReplacePage", null); tslib_1.__decorate([ spring4js_nodejs_1.Path("getTouchJsPath", spring4js_nodejs_1.HttpMethod.POST) ], H5ExtensionController.prototype, "getTouchJsPath", 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;