UNPKG

@lcap/asl

Version:

NetEase Application Specific Language

73 lines 2.35 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Destination = void 0; const decorators_1 = require("../../decorators"); const LogicItem_1 = require("../LogicItem"); /** * 跳转页面 * @TODO: 当前类目前主要用于生成文档 */ class Destination extends LogicItem_1.ExpressionNode { constructor() { super(...arguments); /** * 逻辑节点类型 */ this.type = LogicItem_1.LOGIC_TYPE.Destination; /** * 页面路径 */ this.page = undefined; /** * URL */ this.url = undefined; /** * Code */ this.code = undefined; /** * 跳转页面参数 */ this.params = []; } /** * 生成 JS 脚本 */ toScript() { const params = this.params .filter((param) => param.pageParamKey && param.pageParamKeyValue) .map((param) => param.toScript()); let result = this.code; if (params.length) { result = '`' + `${this.code}?${params.join('&')}` + '`'; } else { result = '`' + `${result}` + '`'; } return result.replace(/"/g, "'"); } } __decorate([ decorators_1.immutable() ], Destination.prototype, "type", void 0); __decorate([ decorators_1.immutable() ], Destination.prototype, "page", void 0); __decorate([ decorators_1.immutable() ], Destination.prototype, "url", void 0); __decorate([ decorators_1.immutable() ], Destination.prototype, "code", void 0); __decorate([ decorators_1.immutable() ], Destination.prototype, "params", void 0); exports.Destination = Destination; //# sourceMappingURL=Destination.js.map