Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lcap/asl

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lcap/asl - npm Package Compare versions

Comparing version 0.1.15 to 0.1.16

out/service/assets/asset.d.ts

2

out/service/common/preprocess.js

@@ -23,3 +23,3 @@ "use strict";

exports.preParentAttr = exports.prePosIndex = exports.postServiceType = exports.createPreServiceType = void 0;
const utils = __importStar(require("../../types/common/utils"));
const utils = __importStar(require("../../types/utils"));
const ServiceType = {

@@ -26,0 +26,0 @@ web: 'WEB',

export interface TemplateItem {
text: string;
value: string;
content: string;
}

@@ -6,0 +5,0 @@ /**

@@ -10,397 +10,11 @@ "use strict";

exports.TEMPLATE_LIST = [
{ text: '仪表盘布局', value: 'dashboard', content: `<template>
<l-dashboard>
<template #head>
<u-navbar>
<template #left>
<s-logo>演示</s-logo>
</template>
<template #default>
<u-navbar-item>Item 1</u-navbar-item>
<u-navbar-item>Item 2</u-navbar-item>
</template>
<template #right>
<!-- <div :class="$style.item">
<u-badge corner dot :value="noticeCount">
<u-link :class="$style.link"
:active="noticeActive"
to="/notice"
title="通知">
<i-icon name="notice" style="display: inline-block; vertical-align: top; font-size: 16px;"></i-icon>
</u-link>
</u-badge>
</div> -->
<u-navbar-dropdown style="margin-right: 10px;" v-if="userInfo">
<template #title>
<u-avatar shape="circle"></u-avatar>
<span style="display: inline-block; vertical-align: top; margin-left: 10px; margin-right: 10px; color: white;">{{ userInfo.UserName }}</span>
</template>
<template #default>
<u-navbar-menu>
<u-navbar-menu-item to="/account/center">个人中心</u-navbar-menu-item>
<u-navbar-menu-item @click="logout">安全退出</u-navbar-menu-item>
</u-navbar-menu>
</template>
</u-navbar-dropdown>
<template v-else>
<u-navbar>
<u-navbar-item href="/login">登录</u-navbar-item>
</u-navbar>
</template>
</template>
</u-navbar>
</template>
<template #side>
<u-sidebar>
<u-sidebar-item to="/overview">总览</u-sidebar-item>
<u-sidebar-item>Item 2</u-sidebar-item>
</u-sidebar>
</template>
<template #default>
<u-linear-layout direction="vertical" :class="$style.main">
<u-crumb auto></u-crumb>
<slot><router-view></router-view></slot>
</u-linear-layout>
</template>
</l-dashboard>
</template>
<script>
export default {
data() {
return {
userInfo: {},
noticeCount: 0,
noticeActive: false,
};
},
watch: {
$route: {
immediate: true,
handler($route) {
this.noticeActive = $route.path.startsWith('/notice');
},
},
},
created() {
this.$auth && this.$auth.getUserInfo().then((userInfo) => this.userInfo = userInfo);
},
methods: {
logout() {
/* eslint-disable new-cap */
this.$confirm(\`确定退出登录吗?\`, '提示')
.then(() => this.$services.auth.Logout())
.then(() => location.reload());
},
},
};
</script>
` },
{ text: '通用页面布局', value: 'page', content: `<template>
<l-page>
<template #head>
<u-navbar>
<template #left>
<s-logo>演示</s-logo>
</template>
<template #default>
<u-navbar-item>Item 1</u-navbar-item>
<u-navbar-item>Item 2</u-navbar-item>
</template>
<template #right>
<!-- <div :class="$style.item">
<u-badge corner dot :value="noticeCount">
<u-link :class="$style.link"
:active="noticeActive"
to="/notice"
title="通知">
<i-icon name="notice" :class="$style.icon"></i-icon>
</u-link>
</u-badge>
</div> -->
<u-navbar-dropdown style="margin-right: 10px;" v-if="userInfo">
<template #title>
<u-avatar shape="circle"></u-avatar>
<span style="display: inline-block; vertical-align: top; margin-left: 10px; margin-right: 10px; color: white;">{{ userInfo.username }}</span>
</template>
<template #default>
<u-navbar-menu>
<u-navbar-menu-item to="/account/center">个人中心</u-navbar-menu-item>
<u-navbar-menu-item @click="logout">安全退出</u-navbar-menu-item>
</u-navbar-menu>
</template>
</u-navbar-dropdown>
<template v-else>
<u-navbar>
<u-navbar-item href="/login">登录</u-navbar-item>
</u-navbar>
</template>
</template>
</u-navbar>
</template>
<template #default>
<u-linear-layout direction="vertical" :class="$style.main">
<slot><router-view></router-view></slot>
</u-linear-layout>
</template>
</l-page>
</template>
<script>
export default {
data() {
return {
userInfo: {
username: 'User',
},
noticeCount: 0,
noticeActive: false,
};
},
watch: {
$route: {
immediate: true,
handler($route) {
this.noticeActive = $route.path.startsWith('/notice');
},
},
},
methods: {
logout() {
this.$confirm(\`确定退出登录吗?\`, '提示').then(() => {
location.reload();
});
},
},
};
</script>
` },
{ text: '空白页', value: 'wrapper', content: `<template>
<u-linear-layout direction="vertical">
<router-view></router-view>
</u-linear-layout>
</template>
` },
{ text: '首页', value: 'index-page', content: `<template>
<div style="min-width: 1200px">
<div style="background:#343e4f">
<u-navbar style="width: 100%;">
<template #left>
<u-navbar-item href="/" style="margin-left: 20px">轻舟低代码</u-navbar-item>
</template>
<u-navbar-item href="/">产品</u-navbar-item>
<u-navbar-item href="/">关于我们</u-navbar-item>
<template #right>
<u-navbar-item href="/dashboard" style="margin-right: 20px">控制台</u-navbar-item>
</template>
</u-navbar>
</div>
<div style="background: #1c2138;">
<u-carousel style="width: 100%; margin: 0 auto; height: 420px; text-align: center;">
<u-carousel-item>
<u-link>
<u-image style="width:100%;height:100%" src="https://raw.githubusercontent.com/vusion/cloud-ui/master/src/assets/images/1.jpg"></u-image>
</u-link>
</u-carousel-item>
<u-carousel-item>
<u-link>
<u-image style="width:100%;height:100%" src="https://raw.githubusercontent.com/vusion/cloud-ui/master/src/assets/images/3.jpg"></u-image>
</u-link>
</u-carousel-item>
</u-carousel>
</div>
<u-linear-layout style="width: 1200px; margin: 0 auto;">
<u-linear-layout style="position: relative; height: 840px; margin: 0 auto">
<div style="position: absolute; top:80px;left:0;right:0; margin:0 auto;text-align:center;">
<div style="color:#333;font-size:32px;line-height:45px;margin-bottom:12px;font-weight:500">让软件驱动生产力</div>
<div style="color:#687492;font-size:16px;line-height:22px;">
打造更敏捷、更高效的软件生产力平台
</div>
</div>
<div style="position: absolute;top:285px;left:75px;width:288px">
<div style="color:#333;font-size:24px;line-height:34px;margin-bottom:16px;font-weight:500">让软件驱动生产力</div>
<div style="color:#687492;font-size:16px;line-height:32px;">
<span style="color:#333">服务化:</span>重塑企业面向数字化的服务能力
<br><span style="color:#333">敏 捷:</span>敏捷迭代提升研发和运维效率
<br><span style="color:#333">高 效:</span>软件生命周期自动化与协作水平
<br><span style="color:#333">开 放:</span>打造开放的技术体系和软件架构
</div>
<u-link style="margin-top:16px;font-size:16px;line-height:32px;display: block;">查看详情 ></u-link>
<u-button color="primary" style="margin-top:40px;height:42px;line-height:42px" href="/">免费试用</u-button>
</div>
<u-image src="https://static-vusion.nos-eastchina1.126.net/assets/%E5%8F%B3%E5%9B%BE%402x.png" style="position: absolute;top:240px;left:455px;width:672px;height: 400px">
</u-image>
</u-linear-layout>
</u-linear-layout>
<div style="height:320px;background: #242A38;">
<div style="width: 1200px;margin: 0 auto;">
<div style="position: relative;height:174px;margin:0 auto ;left:30px;right:0">
<div style="position: absolute;top:30px;left:0">
<div style="display:block;font-size: 16px;line-height: 22px;color:#fff;margin-top:10px">产品和服务</div>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">轻舟微服务</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">轻舟混合云</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">轻舟低代码</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">轻舟中间件</a>
</div>
<div style="position: absolute;top:30px;left:217px;">
<div style="display:block;font-size: 16px;line-height: 22px;color:#fff;margin-top:10px">关于我们</div>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">公司简介</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">媒体报道</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">荣誉与认证</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">友情链接</a>
</div>
<div style="position: absolute;top:30px;left:424px;">
<div style="display:block;font-size: 16px;line-height: 22px;color:#fff;margin-top:10px">资源与文档</div>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">新手帮助</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">产品文档</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">开发者资源</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">备案帮助</a>
</div>
<div style="position: absolute;top:30px;left:641px;">
<div style="display:block;font-size: 16px;line-height: 22px;color:#fff;margin-top:10px">诚邀合作</div>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">渠道合作</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">社区合作</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">教育合作</a>
</div>
<div style="position: absolute;top:30px;left:842px;">
<div style="display:block;font-size: 16px;line-height: 22px;color:#fff;margin-top:10px">管理与支持</div>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">控制台</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">联系我们</a>
</div>
<div style="position: absolute;left:1049px;top:30px">
<a style=" position: relative;
display: inline-block;
width: 24px;
height: 24px;
background-size: 24px auto;
background-position: 0 -48px;
background-image: url(https://static-vusion.nos-eastchina1.126.net/assets/footer-icon-sns.png);" @mouseenter="linkCode = 'weixin'" v-show="linkCode !== 'weixin'" weixin>
</a>
<a style=" position: relative;
display: inline-block;
width: 24px;
height: 24px;
background-size: 24px auto;
background-position: 0 -72px;
background-image: url(https://static-vusion.nos-eastchina1.126.net/assets/footer-icon-sns.png);" @mouseenter="linkCode = 'weixin'" v-show="linkCode === 'weixin'" weixin>
<u-image style=" position: absolute;width: 120px;height: 120px;max-width: none;top: 30px;right: -30px;" src="https://static-vusion.nos-eastchina1.126.net/assets/weixin%402x.png" fit="full"></u-image>
</a>
<a href="/" weibo style=" position: relative;
display: inline-block;
width: 24px;
height: 24px;
background-size: 24px auto;
background-position: 0 -24px;
margin-left:20px;
background-image: url(https://static-vusion.nos-eastchina1.126.net/assets/footer-icon-sns.png);" @mouseenter="linkCode = 'weibo'" v-show="linkCode === 'weibo'">
<u-image style=" position: absolute;width: 120px;height: 120px;max-width: none;top: 30px;right: -30px;" src="https://static-vusion.nos-eastchina1.126.net/assets/weibo%402x.png" fit="full"></u-image>
</a>
<a href="/" weibo style=" position: relative;
display: inline-block;
width: 24px;
height: 24px;
margin-left:20px;
background-size: 24px auto;
background-position: 0 0;
background-image: url(https://static-vusion.nos-eastchina1.126.net/assets/footer-icon-sns.png);" @mouseenter="linkCode = 'weibo'" v-show="linkCode !== 'weibo'">
</a>
</div>
</div>
<div style="margin-top: 70px;font-size: 14px;line-height: 20px;color:#999;text-align:center">
<div>XX 公司版权所有 © 1997-2020 </div>
<div style="margin-top:10px">备案号</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
linkCode: 'weixin',
};
},
};
</script>
` },
{ text: '登录页', value: 'login-page', content: `<template>
<u-linear-layout type="flex" justify="center" alignment="center" style="background: url('https://static-vusion.163yun.com/assets/login-bg-1.jpg') no-repeat; background-size: cover; height: 100vh;">
<u-linear-layout direction="vertical" justify="center">
<h1>登录</h1>
<lcap-login :src="\`http://\${tenant}.\${nuimsDomain}\`" :domain-name="domainName" @success="onSuccess"></lcap-login>
</u-linear-layout>
</u-linear-layout>
</template>
<script>
export default {
data() {
return {
// window 等变量暂时不支持变成 ASL
tenant: window.appInfo.tenant,
domainName: window.appInfo.domainName,
nuimsDomain: window.appInfo.tenant === 'lcp' ? 'user.vusion.top' : window.appInfo.nuimsDomain || 'user.lcap.163yun.com',
};
},
methods: {
onSuccess() {
location.href = '/dashboard';
},
},
};
</script>
` },
{ text: '404 页面', value: '404-page', content: `<template>
<u-linear-layout style="height: 100vh;" type="flex" justify="center" alignment="center">
<u-linear-layout direction="vertical" justify="center">
<img src="https://static-vusion.163yun.com/assets/error-code.svg" width="240">
<h1 style="margin: 0; margin-top: -15px; padding-bottom: 20px; font-family: Geneva, 'Arial Black', Verdana, Tahoma, sans-serif; font-size: 64px;">404</h1>
<h2 style="color: var(--color-light);">抱歉,你访问的页面不存在</h2>
<u-button color="primary" shape="round" href="/">返回首页</u-button>
</u-linear-layout>
</u-linear-layout>
</template>
` },
{ text: '无权限页面', value: '401-page', content: `<template>
<u-linear-layout style="height: 100vh;" type="flex" justify="center" alignment="center">
<u-linear-layout direction="vertical" justify="center">
<img src="https://static-vusion.163yun.com/assets/error-code.svg" width="240">
<h1 style="margin: 0; margin-top: -15px; padding-bottom: 20px; font-family: Geneva, 'Arial Black', Verdana, Tahoma, sans-serif; font-size: 64px;">401</h1>
<h2 style="color: var(--color-light);">你没有访问该页面的权限</h2>
<u-linear-layout>
<u-button color="primary" shape="round" href="/login">重新登录</u-button>
<u-button shape="round" href="/">返回首页</u-button>
</u-linear-layout>
</u-linear-layout>
</u-linear-layout>
</template>
` },
{ text: '禁止访问页面', value: '403-page', content: `<template>
<u-linear-layout style="height: 100vh;" type="flex" justify="center" alignment="center">
<u-linear-layout direction="vertical" justify="center">
<img src="https://static-vusion.163yun.com/assets/error-code.svg" width="240">
<h1 style="margin: 0; margin-top: -15px; padding-bottom: 20px; font-family: Geneva, 'Arial Black', Verdana, Tahoma, sans-serif; font-size: 64px;">403</h1>
<h2 style="color: var(--color-light);">禁止访问该页面</h2>
<u-button color="primary" shape="round" href="/">返回首页</u-button>
</u-linear-layout>
</u-linear-layout>
</template>
` },
{ text: '服务器错误页面', value: '500-page', content: `<template>
<u-linear-layout style="height: 100vh;" type="flex" justify="center" alignment="center">
<u-linear-layout direction="vertical" justify="center">
<img src="https://static-vusion.163yun.com/assets/error-code.svg" width="240">
<h1 style="margin: 0; margin-top: -15px; padding-bottom: 20px; font-family: Geneva, 'Arial Black', Verdana, Tahoma, sans-serif; font-size: 64px;">500</h1>
<h2 style="color: var(--color-light);">抱歉,服务器出现错误</h2>
<u-button color="primary" shape="round" href="/">返回首页</u-button>
</u-linear-layout>
</u-linear-layout>
</template>
` },
{ text: '仪表盘布局', value: 'dashboard' },
{ text: '通用页面布局', value: 'page' },
{ text: '空白页', value: 'wrapper' },
{ text: '首页', value: 'index-page' },
{ text: '登录页', value: 'login-page' },
{ text: '404 页面', value: '404-page' },
{ text: '无权限页面', value: '401-page' },
{ text: '禁止访问页面', value: '403-page' },
{ text: '服务器错误页面', value: '500-page' },
];

@@ -407,0 +21,0 @@ exports.TEMPLATE_MAP = {};

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEntityInterfaces = exports.getEntityPropertyParams = exports.getEntityGetAllQueryParams = exports.getEntityStructures = exports.getEntityStructureNames = exports.ENTITY_INTERFACE_PREFIX = exports.ENTITY_STRUCTURE_PREFIX = void 0;
const utils_1 = require("../common/utils");
const utils_1 = require("../utils");
const pluralize = require("pluralize");

@@ -6,0 +6,0 @@ const lodash_1 = require("lodash");

@@ -37,3 +37,3 @@ export { EventEmitter } from './common/EventEmitter';

export { default as history } from './history';
export * as utils from './common/utils';
export * as utils from './utils';
export * as generator from './generator';

@@ -40,0 +40,0 @@ /**

@@ -101,3 +101,3 @@ "use strict";

Object.defineProperty(exports, "history", { enumerable: true, get: function () { return __importDefault(history_1).default; } });
exports.utils = __importStar(require("./common/utils"));
exports.utils = __importStar(require("./utils"));
exports.generator = __importStar(require("./generator"));

@@ -104,0 +104,0 @@ /**

@@ -13,3 +13,3 @@ "use strict";

const logic_1 = require("../../service/logic");
const utils_1 = require("../common/utils");
const utils_1 = require("../utils");
var LOGIC_TYPE;

@@ -16,0 +16,0 @@ (function (LOGIC_TYPE) {

@@ -154,3 +154,3 @@ "use strict";

node.name = node.code || node.name;
if (!((parent && parent.type === 'MemberExpression' && node === parent.property) || node.name.startsWith('this.')))
if (!((parent && parent.type === 'MemberExpression' && node === parent.property) || (node.name && node.name.startsWith('this.'))))
checkThis(node);

@@ -157,0 +157,0 @@ }

@@ -14,3 +14,3 @@ "use strict";

const LogicItem_1 = require("../logic/LogicItem");
const utils_1 = require("../common/utils");
const utils_1 = require("../utils");
function generateBody(body) {

@@ -17,0 +17,0 @@ if (body.expression) {

@@ -15,3 +15,3 @@ "use strict";

const LogicItem_1 = require("../logic/LogicItem");
const utils_1 = require("../common/utils");
const utils_1 = require("../utils");
function generateBody(body) {

@@ -18,0 +18,0 @@ if (body.expression) {

@@ -147,2 +147,12 @@ "use strict";

this.deepPick(result, ['id', 'parentId']);
// attr,directive,event的id,exprssion需要合并
this.attrList.forEach((attr, index) => {
attr.deepPick(result.attrList[index], ['id', 'expression']);
});
this.directiveList.forEach((directive, index) => {
directive.deepPick(result.directiveList[index], ['id', 'expression']);
});
this.eventList.forEach((event, index) => {
event.deepPick(result.eventList[index], ['id']);
});
this.view && this.view.emit('change');

@@ -189,2 +199,27 @@ __1.history.push(`添加元素"${this.tag}"`);

const newNode = Element.fromHTML(code, this.parent, this.view);
const mergeExpression = (originList, newList) => {
newList.forEach((item) => {
const originItem = originList.find((originItem) => originItem.name === item.name);
if (originItem && originItem.expression) {
// item.expression可能为空
const expression = Object.assign({}, originItem.expression);
Object.assign(item, { expression, value: '' });
Object.assign(item.expression, { id: '' });
__1.utils.traverse((current) => {
delete current.node.editable;
delete current.node.index;
}, { node: item.expression }, { mode: 'anyObject' });
}
});
};
mergeExpression(this.attrList, newNode.attrList);
mergeExpression(this.directiveList, newNode.directiveList);
newNode.eventList.forEach((event) => {
const originEvent = this.eventList.find((eventTemp) => eventTemp.name === event.name);
if (originEvent) {
Object.assign(event, {
logicId: originEvent.logicId,
});
}
});
~index && this.parent.children.splice(index + 1, 0, newNode);

@@ -484,2 +519,5 @@ await newNode.create();

}, element);
if (astNode.attrsMap[`:${attr.name}.sync`]) {
attr.assign({ sync: true });
}
}

@@ -682,3 +720,2 @@ }

}, { node: ast }, { mode: 'anyObject' });
console.log('ast', ast);
return __1.LogicItem.from(ast, null, null);

@@ -685,0 +722,0 @@ }

@@ -44,11 +44,13 @@ "use strict";

value = __1.genFinalCode(value, finalCode);
const params = ['$event'];
let tempElement = element;
while (tempElement) {
if (tempElement.slotScope) {
params.push(tempElement.slotScope);
if (!value.includes('(')) {
const params = ['$event'];
let tempElement = element;
while (tempElement) {
if (tempElement.slotScope) {
params.push(tempElement.slotScope);
}
tempElement = tempElement.parent;
}
tempElement = tempElement.parent;
value = `${value}(${params.join(',')})`;
}
value = `${value}(${params.join(',')})`;
}

@@ -55,0 +57,0 @@ }

@@ -16,3 +16,3 @@ "use strict";

const page_1 = __importDefault(require("../../service/page"));
const utils_1 = require("../common/utils");
const utils_1 = require("../utils");
/**

@@ -19,0 +19,0 @@ * 页面(入口页)类,后端路由控制

@@ -185,4 +185,4 @@ import { LEVEL_ENUM, Page, Element } from '..';

*/
static fromTemplate(templateName: string, source: any, parent: View, page: Page): View;
static fromTemplate(templateName: string, source: any, parent: View, page: Page): Promise<View>;
}
export default View;

@@ -19,5 +19,6 @@ "use strict";

const logic_1 = require("../../service/logic");
const templates_1 = require("../../service/page/templates");
const assets_1 = require("../../service/assets");
const translator_1 = __importDefault(require("../logic/translator"));
const lodash_1 = require("lodash");
const utils_1 = require("../utils");
/**

@@ -334,3 +335,3 @@ * 子页面类,前端路由控制

if (this.script)
result += `<script>\n${this.script}\n</script>\n`;
result += `<script>\n${this.toScript(options)}\n</script>\n`;
if (this.$def)

@@ -368,4 +369,34 @@ result += ''; // `<script>\n${this.$html.toVue()}\n</script>\n`;

async mergeCode(code, nodePath) {
/**
* 本来的 Name 相关的集合
*/
const thisNameSets = {
viewVariables: new Set(),
logics: new Set(),
elements: new Set(),
};
/**
* 需要替换的 Map
*/
const replacements = {
viewVariables: {},
logics: {},
elements: {},
};
this.$def.params.forEach((param) => thisNameSets.viewVariables.add(param.name));
this.$def.variables.forEach((param) => thisNameSets.viewVariables.add(param.name));
this.$def.logics.forEach((logic) => thisNameSets.logics.add(logic.name));
__1.utils.traverse((current) => {
if (current.node.level === 'element' && current.node.name)
thisNameSets.elements.add(current.node.name);
}, { node: this.$html });
console.log(thisNameSets.elements);
const setNewNameIfNotUnique = (obj, key, type) => {
// name 去重
const newName = __1.utils.unique(obj[key], thisNameSets[type]);
if (newName !== obj[key])
obj[key] = replacements[type][obj[key]] = newName;
};
const body = {};
const template = __1.utils.sliceTagContent(code, 'template');
const body = {};
const parentNode = this.findElementByNodePath(nodePath);

@@ -377,10 +408,14 @@ const viewId = parentNode.view.id;

const $def = JSON.parse(definition);
const { logics = [], params = [], variables = [], lifecycles = [] } = $def;
logics.forEach((logic) => {
[].concat($def.params || [], $def.variables || []).forEach((param) => {
param.viewId = viewId;
setNewNameIfNotUnique(param, 'name', 'viewVariables');
});
($def.lifecycles || []).forEach((lifecycle) => {
lifecycle.viewId = viewId;
});
($def.logics || []).forEach((logic) => {
logic.moduleType = 'view';
logic.moduleId = viewId;
setNewNameIfNotUnique(logic, 'name', 'logics');
});
[...params, ...variables, ...lifecycles].forEach((item) => {
item.viewId = viewId;
});
body.$def = $def;

@@ -394,4 +429,41 @@ }

});
body.$html = newNode;
body.$html = newNode.toJSON();
utils_1.traverse((current) => {
if (current.node.level === 'element' && current.node.name)
setNewNameIfNotUnique(current.node, 'name', 'elements');
}, { node: body.$html });
}
console.log(replacements.elements);
const hasKeyThenReplace = (obj, key, test, replacement) => {
if (obj[key] === undefined || !Object.keys(replacement).length)
return;
if (!test)
test = /^(\w+)$/;
const cap = obj[key].match(test);
if (!cap)
return;
const oldName = cap[1];
const newName = replacement[oldName];
if (newName)
obj[key] = obj[key].replace(test, () => test.toString().replace(/[\^\\/]/g, '').replace(/\$$/, '').replace(/\(w\+\)/, newName));
};
utils_1.traverse((current) => {
if (current.node.level === 'lifecycle' || current.node.level === 'event') {
hasKeyThenReplace(current.node, 'logicId', null, replacements.logics);
hasKeyThenReplace(current.node, 'value', null, replacements.logics);
hasKeyThenReplace(current.node, 'value', /^\$refs\.(\w+)\./, replacements.elements);
}
else if (current.node.level === 'logicNode' && current.node.type === 'CallLogic') {
hasKeyThenReplace(current.node, 'callee', null, replacements.logics);
hasKeyThenReplace(current.node, 'calleeCode', null, replacements.logics);
hasKeyThenReplace(current.node, 'calleeCode', /^\$refs\.(\w+)\./, replacements.elements);
}
else if (current.node.level === 'expressionNode' && current.node.type === 'Identifier') {
if (current.parent && (current.parent.type !== 'MemberExpression' || current.node.parentAttr === 'object')) {
hasKeyThenReplace(current.node, 'code', null, replacements.viewVariables);
hasKeyThenReplace(current.node, 'name', null, replacements.viewVariables);
hasKeyThenReplace(current.node, 'name', null, replacements.logics); // 处理表格 data-source 的问题
}
} // else if (current.node.level === 'expressionNode')
}, { node: body }, { mode: 'anyObject' });
const res = await page_1.viewService.mergeBlock({

@@ -432,6 +504,15 @@ body,

*/
static fromTemplate(templateName, source, parent, page) {
const template = templates_1.TEMPLATE_MAP[templateName];
const html = __1.utils.sliceTagContent(template.content, 'template');
const script = __1.utils.sliceTagContent(template.content, 'script');
static async fromTemplate(templateName, source, parent, page) {
// const template = TEMPLATE_MAP[templateName];
// @TODO: 后面改到资产中心
const { rows } = await assets_1.blockService.loadList({
query: {
keyword: `@cloud-ui/s-${templateName}.vue`,
},
});
if (!rows[0])
throw new Error('Cannot find block ' + templateName);
const content = rows[0].content;
const html = __1.utils.sliceTagContent(content, 'template');
const script = __1.utils.sliceTagContent(content, 'script');
const view = this.from(source, parent, page);

@@ -438,0 +519,0 @@ view.assign({

{
"name": "@lcap/asl",
"description": "Lowcode Application Specific Language",
"version": "0.1.15",
"version": "0.1.16",
"author": "Forrest <rainforest92@126.com>",

@@ -6,0 +6,0 @@ "scripts": {

@@ -1,2 +0,2 @@

import * as utils from '../../types/common/utils';
import * as utils from '../../types/utils';

@@ -3,0 +3,0 @@ const ServiceType = {

export interface TemplateItem {
text: string;
value: string;
content: string;
}

@@ -13,397 +12,11 @@

export const TEMPLATE_LIST: Array<TemplateItem> = [
{ text: '仪表盘布局', value: 'dashboard', content: `<template>
<l-dashboard>
<template #head>
<u-navbar>
<template #left>
<s-logo>演示</s-logo>
</template>
<template #default>
<u-navbar-item>Item 1</u-navbar-item>
<u-navbar-item>Item 2</u-navbar-item>
</template>
<template #right>
<!-- <div :class="$style.item">
<u-badge corner dot :value="noticeCount">
<u-link :class="$style.link"
:active="noticeActive"
to="/notice"
title="通知">
<i-icon name="notice" style="display: inline-block; vertical-align: top; font-size: 16px;"></i-icon>
</u-link>
</u-badge>
</div> -->
<u-navbar-dropdown style="margin-right: 10px;" v-if="userInfo">
<template #title>
<u-avatar shape="circle"></u-avatar>
<span style="display: inline-block; vertical-align: top; margin-left: 10px; margin-right: 10px; color: white;">{{ userInfo.UserName }}</span>
</template>
<template #default>
<u-navbar-menu>
<u-navbar-menu-item to="/account/center">个人中心</u-navbar-menu-item>
<u-navbar-menu-item @click="logout">安全退出</u-navbar-menu-item>
</u-navbar-menu>
</template>
</u-navbar-dropdown>
<template v-else>
<u-navbar>
<u-navbar-item href="/login">登录</u-navbar-item>
</u-navbar>
</template>
</template>
</u-navbar>
</template>
<template #side>
<u-sidebar>
<u-sidebar-item to="/overview">总览</u-sidebar-item>
<u-sidebar-item>Item 2</u-sidebar-item>
</u-sidebar>
</template>
<template #default>
<u-linear-layout direction="vertical" :class="$style.main">
<u-crumb auto></u-crumb>
<slot><router-view></router-view></slot>
</u-linear-layout>
</template>
</l-dashboard>
</template>
<script>
export default {
data() {
return {
userInfo: {},
noticeCount: 0,
noticeActive: false,
};
},
watch: {
$route: {
immediate: true,
handler($route) {
this.noticeActive = $route.path.startsWith('/notice');
},
},
},
created() {
this.$auth && this.$auth.getUserInfo().then((userInfo) => this.userInfo = userInfo);
},
methods: {
logout() {
/* eslint-disable new-cap */
this.$confirm(\`确定退出登录吗?\`, '提示')
.then(() => this.$services.auth.Logout())
.then(() => location.reload());
},
},
};
</script>
` },
{ text: '通用页面布局', value: 'page', content: `<template>
<l-page>
<template #head>
<u-navbar>
<template #left>
<s-logo>演示</s-logo>
</template>
<template #default>
<u-navbar-item>Item 1</u-navbar-item>
<u-navbar-item>Item 2</u-navbar-item>
</template>
<template #right>
<!-- <div :class="$style.item">
<u-badge corner dot :value="noticeCount">
<u-link :class="$style.link"
:active="noticeActive"
to="/notice"
title="通知">
<i-icon name="notice" :class="$style.icon"></i-icon>
</u-link>
</u-badge>
</div> -->
<u-navbar-dropdown style="margin-right: 10px;" v-if="userInfo">
<template #title>
<u-avatar shape="circle"></u-avatar>
<span style="display: inline-block; vertical-align: top; margin-left: 10px; margin-right: 10px; color: white;">{{ userInfo.username }}</span>
</template>
<template #default>
<u-navbar-menu>
<u-navbar-menu-item to="/account/center">个人中心</u-navbar-menu-item>
<u-navbar-menu-item @click="logout">安全退出</u-navbar-menu-item>
</u-navbar-menu>
</template>
</u-navbar-dropdown>
<template v-else>
<u-navbar>
<u-navbar-item href="/login">登录</u-navbar-item>
</u-navbar>
</template>
</template>
</u-navbar>
</template>
<template #default>
<u-linear-layout direction="vertical" :class="$style.main">
<slot><router-view></router-view></slot>
</u-linear-layout>
</template>
</l-page>
</template>
<script>
export default {
data() {
return {
userInfo: {
username: 'User',
},
noticeCount: 0,
noticeActive: false,
};
},
watch: {
$route: {
immediate: true,
handler($route) {
this.noticeActive = $route.path.startsWith('/notice');
},
},
},
methods: {
logout() {
this.$confirm(\`确定退出登录吗?\`, '提示').then(() => {
location.reload();
});
},
},
};
</script>
` },
{ text: '空白页', value: 'wrapper', content: `<template>
<u-linear-layout direction="vertical">
<router-view></router-view>
</u-linear-layout>
</template>
` },
{ text: '首页', value: 'index-page', content: `<template>
<div style="min-width: 1200px">
<div style="background:#343e4f">
<u-navbar style="width: 100%;">
<template #left>
<u-navbar-item href="/" style="margin-left: 20px">轻舟低代码</u-navbar-item>
</template>
<u-navbar-item href="/">产品</u-navbar-item>
<u-navbar-item href="/">关于我们</u-navbar-item>
<template #right>
<u-navbar-item href="/dashboard" style="margin-right: 20px">控制台</u-navbar-item>
</template>
</u-navbar>
</div>
<div style="background: #1c2138;">
<u-carousel style="width: 100%; margin: 0 auto; height: 420px; text-align: center;">
<u-carousel-item>
<u-link>
<u-image style="width:100%;height:100%" src="https://raw.githubusercontent.com/vusion/cloud-ui/master/src/assets/images/1.jpg"></u-image>
</u-link>
</u-carousel-item>
<u-carousel-item>
<u-link>
<u-image style="width:100%;height:100%" src="https://raw.githubusercontent.com/vusion/cloud-ui/master/src/assets/images/3.jpg"></u-image>
</u-link>
</u-carousel-item>
</u-carousel>
</div>
<u-linear-layout style="width: 1200px; margin: 0 auto;">
<u-linear-layout style="position: relative; height: 840px; margin: 0 auto">
<div style="position: absolute; top:80px;left:0;right:0; margin:0 auto;text-align:center;">
<div style="color:#333;font-size:32px;line-height:45px;margin-bottom:12px;font-weight:500">让软件驱动生产力</div>
<div style="color:#687492;font-size:16px;line-height:22px;">
打造更敏捷、更高效的软件生产力平台
</div>
</div>
<div style="position: absolute;top:285px;left:75px;width:288px">
<div style="color:#333;font-size:24px;line-height:34px;margin-bottom:16px;font-weight:500">让软件驱动生产力</div>
<div style="color:#687492;font-size:16px;line-height:32px;">
<span style="color:#333">服务化:</span>重塑企业面向数字化的服务能力
<br><span style="color:#333">敏 捷:</span>敏捷迭代提升研发和运维效率
<br><span style="color:#333">高 效:</span>软件生命周期自动化与协作水平
<br><span style="color:#333">开 放:</span>打造开放的技术体系和软件架构
</div>
<u-link style="margin-top:16px;font-size:16px;line-height:32px;display: block;">查看详情 ></u-link>
<u-button color="primary" style="margin-top:40px;height:42px;line-height:42px" href="/">免费试用</u-button>
</div>
<u-image src="https://static-vusion.nos-eastchina1.126.net/assets/%E5%8F%B3%E5%9B%BE%402x.png" style="position: absolute;top:240px;left:455px;width:672px;height: 400px">
</u-image>
</u-linear-layout>
</u-linear-layout>
<div style="height:320px;background: #242A38;">
<div style="width: 1200px;margin: 0 auto;">
<div style="position: relative;height:174px;margin:0 auto ;left:30px;right:0">
<div style="position: absolute;top:30px;left:0">
<div style="display:block;font-size: 16px;line-height: 22px;color:#fff;margin-top:10px">产品和服务</div>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">轻舟微服务</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">轻舟混合云</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">轻舟低代码</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">轻舟中间件</a>
</div>
<div style="position: absolute;top:30px;left:217px;">
<div style="display:block;font-size: 16px;line-height: 22px;color:#fff;margin-top:10px">关于我们</div>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">公司简介</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">媒体报道</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">荣誉与认证</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">友情链接</a>
</div>
<div style="position: absolute;top:30px;left:424px;">
<div style="display:block;font-size: 16px;line-height: 22px;color:#fff;margin-top:10px">资源与文档</div>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">新手帮助</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">产品文档</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">开发者资源</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">备案帮助</a>
</div>
<div style="position: absolute;top:30px;left:641px;">
<div style="display:block;font-size: 16px;line-height: 22px;color:#fff;margin-top:10px">诚邀合作</div>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">渠道合作</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">社区合作</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">教育合作</a>
</div>
<div style="position: absolute;top:30px;left:842px;">
<div style="display:block;font-size: 16px;line-height: 22px;color:#fff;margin-top:10px">管理与支持</div>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">控制台</a>
<a style="display:block;font-size: 14px;line-height: 20px;color:#999;margin-top:8px">联系我们</a>
</div>
<div style="position: absolute;left:1049px;top:30px">
<a style=" position: relative;
display: inline-block;
width: 24px;
height: 24px;
background-size: 24px auto;
background-position: 0 -48px;
background-image: url(https://static-vusion.nos-eastchina1.126.net/assets/footer-icon-sns.png);" @mouseenter="linkCode = 'weixin'" v-show="linkCode !== 'weixin'" weixin>
</a>
<a style=" position: relative;
display: inline-block;
width: 24px;
height: 24px;
background-size: 24px auto;
background-position: 0 -72px;
background-image: url(https://static-vusion.nos-eastchina1.126.net/assets/footer-icon-sns.png);" @mouseenter="linkCode = 'weixin'" v-show="linkCode === 'weixin'" weixin>
<u-image style=" position: absolute;width: 120px;height: 120px;max-width: none;top: 30px;right: -30px;" src="https://static-vusion.nos-eastchina1.126.net/assets/weixin%402x.png" fit="full"></u-image>
</a>
<a href="/" weibo style=" position: relative;
display: inline-block;
width: 24px;
height: 24px;
background-size: 24px auto;
background-position: 0 -24px;
margin-left:20px;
background-image: url(https://static-vusion.nos-eastchina1.126.net/assets/footer-icon-sns.png);" @mouseenter="linkCode = 'weibo'" v-show="linkCode === 'weibo'">
<u-image style=" position: absolute;width: 120px;height: 120px;max-width: none;top: 30px;right: -30px;" src="https://static-vusion.nos-eastchina1.126.net/assets/weibo%402x.png" fit="full"></u-image>
</a>
<a href="/" weibo style=" position: relative;
display: inline-block;
width: 24px;
height: 24px;
margin-left:20px;
background-size: 24px auto;
background-position: 0 0;
background-image: url(https://static-vusion.nos-eastchina1.126.net/assets/footer-icon-sns.png);" @mouseenter="linkCode = 'weibo'" v-show="linkCode !== 'weibo'">
</a>
</div>
</div>
<div style="margin-top: 70px;font-size: 14px;line-height: 20px;color:#999;text-align:center">
<div>XX 公司版权所有 © 1997-2020 </div>
<div style="margin-top:10px">备案号</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
linkCode: 'weixin',
};
},
};
</script>
` },
{ text: '登录页', value: 'login-page', content: `<template>
<u-linear-layout type="flex" justify="center" alignment="center" style="background: url('https://static-vusion.163yun.com/assets/login-bg-1.jpg') no-repeat; background-size: cover; height: 100vh;">
<u-linear-layout direction="vertical" justify="center">
<h1>登录</h1>
<lcap-login :src="\`http://\${tenant}.\${nuimsDomain}\`" :domain-name="domainName" @success="onSuccess"></lcap-login>
</u-linear-layout>
</u-linear-layout>
</template>
<script>
export default {
data() {
return {
// window 等变量暂时不支持变成 ASL
tenant: window.appInfo.tenant,
domainName: window.appInfo.domainName,
nuimsDomain: window.appInfo.tenant === 'lcp' ? 'user.vusion.top' : window.appInfo.nuimsDomain || 'user.lcap.163yun.com',
};
},
methods: {
onSuccess() {
location.href = '/dashboard';
},
},
};
</script>
` },
{ text: '404 页面', value: '404-page', content: `<template>
<u-linear-layout style="height: 100vh;" type="flex" justify="center" alignment="center">
<u-linear-layout direction="vertical" justify="center">
<img src="https://static-vusion.163yun.com/assets/error-code.svg" width="240">
<h1 style="margin: 0; margin-top: -15px; padding-bottom: 20px; font-family: Geneva, 'Arial Black', Verdana, Tahoma, sans-serif; font-size: 64px;">404</h1>
<h2 style="color: var(--color-light);">抱歉,你访问的页面不存在</h2>
<u-button color="primary" shape="round" href="/">返回首页</u-button>
</u-linear-layout>
</u-linear-layout>
</template>
` },
{ text: '无权限页面', value: '401-page', content: `<template>
<u-linear-layout style="height: 100vh;" type="flex" justify="center" alignment="center">
<u-linear-layout direction="vertical" justify="center">
<img src="https://static-vusion.163yun.com/assets/error-code.svg" width="240">
<h1 style="margin: 0; margin-top: -15px; padding-bottom: 20px; font-family: Geneva, 'Arial Black', Verdana, Tahoma, sans-serif; font-size: 64px;">401</h1>
<h2 style="color: var(--color-light);">你没有访问该页面的权限</h2>
<u-linear-layout>
<u-button color="primary" shape="round" href="/login">重新登录</u-button>
<u-button shape="round" href="/">返回首页</u-button>
</u-linear-layout>
</u-linear-layout>
</u-linear-layout>
</template>
` },
{ text: '禁止访问页面', value: '403-page', content: `<template>
<u-linear-layout style="height: 100vh;" type="flex" justify="center" alignment="center">
<u-linear-layout direction="vertical" justify="center">
<img src="https://static-vusion.163yun.com/assets/error-code.svg" width="240">
<h1 style="margin: 0; margin-top: -15px; padding-bottom: 20px; font-family: Geneva, 'Arial Black', Verdana, Tahoma, sans-serif; font-size: 64px;">403</h1>
<h2 style="color: var(--color-light);">禁止访问该页面</h2>
<u-button color="primary" shape="round" href="/">返回首页</u-button>
</u-linear-layout>
</u-linear-layout>
</template>
` },
{ text: '服务器错误页面', value: '500-page', content: `<template>
<u-linear-layout style="height: 100vh;" type="flex" justify="center" alignment="center">
<u-linear-layout direction="vertical" justify="center">
<img src="https://static-vusion.163yun.com/assets/error-code.svg" width="240">
<h1 style="margin: 0; margin-top: -15px; padding-bottom: 20px; font-family: Geneva, 'Arial Black', Verdana, Tahoma, sans-serif; font-size: 64px;">500</h1>
<h2 style="color: var(--color-light);">抱歉,服务器出现错误</h2>
<u-button color="primary" shape="round" href="/">返回首页</u-button>
</u-linear-layout>
</u-linear-layout>
</template>
` },
{ text: '仪表盘布局', value: 'dashboard' },
{ text: '通用页面布局', value: 'page' },
{ text: '空白页', value: 'wrapper' },
{ text: '首页', value: 'index-page' },
{ text: '登录页', value: 'login-page' },
{ text: '404 页面', value: '404-page' },
{ text: '无权限页面', value: '401-page' },
{ text: '禁止访问页面', value: '403-page' },
{ text: '服务器错误页面', value: '500-page' },
];

@@ -410,0 +23,0 @@

@@ -1,2 +0,2 @@

import { firstUpperCase } from '../common/utils';
import { firstUpperCase } from '../utils';
import pluralize = require('pluralize');

@@ -3,0 +3,0 @@ import { kebabCase } from 'lodash';

@@ -41,3 +41,3 @@ export { EventEmitter } from './common/EventEmitter';

export { default as history } from './history';
export * as utils from './common/utils';
export * as utils from './utils';
export * as generator from './generator';

@@ -44,0 +44,0 @@

@@ -5,3 +5,3 @@ import { immutable, excludedInJSON, circular, action } from '../decorators';

import { assert } from 'console';
import { traverse } from '../common/utils';
import { traverse } from '../utils';
import { vertexsMap } from '../cacheData';

@@ -8,0 +8,0 @@

@@ -105,10 +105,10 @@ import generate from '@babel/generator';

memberExpression = JSON.parse(JSON.stringify(memberExpression));
if(memberExpression.type === 'MemberExpression') {
const { object, property } = memberExpression;
if(object.code)
if (memberExpression.type === 'MemberExpression') {
const { object, property } = memberExpression;
if (object.code)
object.name = object.code;
if(property.code)
if (property.code)
property.name = property.code;
if(object.type === 'MemberExpression')
if (object.type === 'MemberExpression')
memberExpression.object = nameToCodeForMeberExpression(object);

@@ -146,3 +146,3 @@ }

node.name = node.code || node.name;
if (!((parent && parent.type === 'MemberExpression' && node === parent.property) || node.name.startsWith('this.')))
if (!((parent && parent.type === 'MemberExpression' && node === parent.property) || (node.name && node.name.startsWith('this.'))))
checkThis(node);

@@ -270,3 +270,3 @@ } else if (node.type === 'AssignmentExpression') {

// const queryParams = data.filter((param) => {
// param.in === 'query';

@@ -273,0 +273,0 @@ // });

@@ -5,3 +5,3 @@ import { action, circular, excludedInJSON, immutable } from '../decorators';

import { LogicItem, evaluate } from '../logic/LogicItem';
import { traverse } from '../common/utils';
import { traverse } from '../utils';

@@ -8,0 +8,0 @@ function generateBody(body: Attr) {

@@ -6,3 +6,3 @@ // import stringify = require('json-stringify-safe');

import { LogicItem, evaluate } from '../logic/LogicItem';
import { traverse } from '../common/utils';
import { traverse } from '../utils';

@@ -9,0 +9,0 @@ function generateBody(body: Directive) {

@@ -10,2 +10,3 @@ // import stringify = require('json-stringify-safe');

import * as babelParser from '@babel/parser';
import { traverse } from '../utils';

@@ -153,2 +154,12 @@ export interface ElementToVueOptions {

this.deepPick(result, ['id', 'parentId']);
// attr,directive,event的id,exprssion需要合并
this.attrList.forEach((attr, index)=>{
attr.deepPick(result.attrList[index], ['id', 'expression']);
});
this.directiveList.forEach((directive, index)=>{
directive.deepPick(result.directiveList[index], ['id', 'expression']);
});
this.eventList.forEach((event, index)=>{
event.deepPick(result.eventList[index], ['id']);
});

@@ -203,2 +214,28 @@ this.view && this.view.emit('change');

const newNode = Element.fromHTML(code, this.parent, this.view);
const mergeExpression = (originList: Array<Attr|Directive>, newList: Array<Attr|Directive>)=>{
newList.forEach((item)=>{
const originItem = originList.find((originItem)=>originItem.name === item.name);
if(originItem && originItem.expression){
// item.expression可能为空
const expression = Object.assign({}, originItem.expression);
Object.assign(item, { expression, value: '' });
Object.assign(item.expression, {id: ''});
utils.traverse((current) => {
delete current.node.editable;
delete current.node.index;
}, { node: item.expression as any }, { mode: 'anyObject' });
}
});
};
mergeExpression(this.attrList, newNode.attrList);
mergeExpression(this.directiveList, newNode.directiveList);
newNode.eventList.forEach((event)=>{
const originEvent = this.eventList.find((eventTemp)=>eventTemp.name === event.name);
if(originEvent){
Object.assign(event, {
logicId: originEvent.logicId,
});
}
});
~index && this.parent.children.splice(index + 1, 0, newNode);

@@ -525,2 +562,5 @@ await newNode.create();

}, element);
if(astNode.attrsMap[`:${attr.name}.sync`]){
attr.assign({sync: true});
}
}

@@ -735,4 +775,2 @@ }

}, { node: ast }, { mode: 'anyObject' });
console.log('ast', ast);

@@ -739,0 +777,0 @@ return LogicItem.from(ast, null, null);

@@ -9,3 +9,3 @@ // import stringify = require('json-stringify-safe');

import { LogicItem, evaluate } from '../logic/LogicItem';
import { traverse } from '../common/utils';
import { traverse } from '../utils';
import generate from '@babel/generator';

@@ -77,11 +77,13 @@ import { vertexsMap } from '../cacheData';

value = genFinalCode(value, finalCode);
const params = ['$event'];
let tempElement = element;
while(tempElement){
if(tempElement.slotScope){
params.push(tempElement.slotScope);
if (!value.includes('(')) {
const params = ['$event'];
let tempElement = element;
while(tempElement){
if(tempElement.slotScope) {
params.push(tempElement.slotScope);
}
tempElement = tempElement.parent;
}
tempElement = tempElement.parent;
value = `${value}(${params.join(',')})`;
}
value = `${value}(${params.join(',')})`;
}

@@ -88,0 +90,0 @@ }

import { immutable, circular, action, excludedInJSON } from '../decorators';
import { config, history, LEVEL_ENUM, Vertex, PackageJSON, App, WebService, View, utils, generator } from '..';
import pageService from '../../service/page';
import { traverse } from '../common/utils';
import { traverse } from '../utils';

@@ -6,0 +6,0 @@ /**

@@ -8,7 +8,8 @@ import { immutable, circular, action } from '../decorators';

import { logicService } from '../../service/logic';
import { blockService } from '../../service/assets';
import { TEMPLATE_MAP } from '../../service/page/templates';
import { ElementToVueOptions } from './Element';
import { traverse } from '../common/utils';
import translator from '../logic/translator';
import { throttle } from 'lodash';
import { traverse } from '../utils';

@@ -356,3 +357,3 @@ /**

*/
toScript(options ?: ElementToVueOptions) {
toScript(options?: ElementToVueOptions) {
let componentOptions = 'const componentOptions = {};';

@@ -380,3 +381,3 @@ if (this.script)

if (this.script)
result += `<script>\n${this.script}\n</script>\n`;
result += `<script>\n${this.toScript(options)}\n</script>\n`;
if (this.$def)

@@ -415,4 +416,46 @@ result += ''; // `<script>\n${this.$html.toVue()}\n</script>\n`;

async mergeCode(code: string, nodePath: string) {
type Replacement = { [name: string]: string };
/**
* 本来的 Name 相关的集合
*/
const thisNameSets: {
viewVariables: Set<string>,
logics: Set<string>,
elements: Set<string>,
} = {
viewVariables: new Set(),
logics: new Set(),
elements: new Set(),
}
/**
* 需要替换的 Map
*/
const replacements: {
viewVariables: Replacement,
logics: Replacement,
elements: Replacement,
} = {
viewVariables: {},
logics: {},
elements: {},
};
this.$def.params.forEach((param) => thisNameSets.viewVariables.add(param.name));
this.$def.variables.forEach((param) => thisNameSets.viewVariables.add(param.name));
this.$def.logics.forEach((logic) => thisNameSets.logics.add(logic.name));
utils.traverse((current) => {
if (current.node.level === 'element' && current.node.name)
thisNameSets.elements.add(current.node.name);
}, { node: this.$html });
console.log(thisNameSets.elements);
const setNewNameIfNotUnique = (obj: any, key: string, type: 'viewVariables' | 'logics' | 'elements') => {
// name 去重
const newName = utils.unique(obj[key], thisNameSets[type]);
if (newName !== obj[key])
obj[key] = replacements[type][obj[key]] = newName;
}
const body: any = {};
const template = utils.sliceTagContent(code, 'template');
const body: any = {};
const parentNode = this.findElementByNodePath(nodePath);

@@ -425,10 +468,17 @@ const viewId = parentNode.view.id;

const $def: any = JSON.parse(definition);
const { logics = [], params = [], variables = [], lifecycles = []} = $def;
logics.forEach((logic: any) => {
[].concat($def.params || [], $def.variables || []).forEach((param: any) => {
param.viewId = viewId;
setNewNameIfNotUnique(param, 'name', 'viewVariables');
});
($def.lifecycles || []).forEach((lifecycle: any) => {
lifecycle.viewId = viewId;
});
($def.logics || []).forEach((logic: any) => {
logic.moduleType = 'view';
logic.moduleId = viewId;
setNewNameIfNotUnique(logic, 'name', 'logics');
});
[...params, ...variables, ...lifecycles].forEach((item) => {
item.viewId = viewId;
});

@@ -444,5 +494,44 @@ body.$def = $def;

})
body.$html = newNode;
body.$html = newNode.toJSON();
traverse((current) => {
if (current.node.level === 'element' && current.node.name)
setNewNameIfNotUnique(current.node, 'name', 'elements');
}, { node: body.$html });
}
console.log(replacements.elements);
const hasKeyThenReplace = (obj: any, key: string, test: RegExp, replacement: Replacement) => {
if (obj[key] === undefined || !Object.keys(replacement).length)
return;
if (!test)
test = /^(\w+)$/;
const cap = obj[key].match(test);
if (!cap)
return;
const oldName = cap[1];
const newName = replacement[oldName];
if (newName)
obj[key] = obj[key].replace(test, () => test.toString().replace(/[\^\\/]/g, '').replace(/\$$/, '').replace(/\(w\+\)/, newName));
}
traverse((current) => {
if (current.node.level === 'lifecycle' || current.node.level === 'event') {
hasKeyThenReplace(current.node, 'logicId', null, replacements.logics);
hasKeyThenReplace(current.node, 'value', null, replacements.logics);
hasKeyThenReplace(current.node, 'value', /^\$refs\.(\w+)\./, replacements.elements);
} else if (current.node.level === 'logicNode' && current.node.type === 'CallLogic') {
hasKeyThenReplace(current.node, 'callee', null, replacements.logics);
hasKeyThenReplace(current.node, 'calleeCode', null, replacements.logics);
hasKeyThenReplace(current.node, 'calleeCode', /^\$refs\.(\w+)\./, replacements.elements);
} else if (current.node.level === 'expressionNode' && current.node.type === 'Identifier') {
if (current.parent && (current.parent.type !== 'MemberExpression' || current.node.parentAttr === 'object')) {
hasKeyThenReplace(current.node, 'code', null, replacements.viewVariables);
hasKeyThenReplace(current.node, 'name', null, replacements.viewVariables);
hasKeyThenReplace(current.node, 'name', null, replacements.logics); // 处理表格 data-source 的问题
}
} // else if (current.node.level === 'expressionNode')
}, { node: body }, { mode: 'anyObject' });
const res = await viewService.mergeBlock({

@@ -487,7 +576,18 @@ body,

*/
public static fromTemplate(templateName: string, source: any, parent: View, page: Page) {
const template = TEMPLATE_MAP[templateName];
const html = utils.sliceTagContent(template.content, 'template');
const script = utils.sliceTagContent(template.content, 'script');
public static async fromTemplate(templateName: string, source: any, parent: View, page: Page) {
// const template = TEMPLATE_MAP[templateName];
// @TODO: 后面改到资产中心
const { rows } = await blockService.loadList({
query: {
keyword: `@cloud-ui/s-${templateName}.vue`,
},
});
if (!rows[0])
throw new Error('Cannot find block ' + templateName);
const content = rows[0].content;
const html = utils.sliceTagContent(content, 'template');
const script = utils.sliceTagContent(content, 'script');
const view = this.from(source, parent, page);

@@ -494,0 +594,0 @@ view.assign({

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc