From 8ce041dd6dc822e83a8a408da896ad14679b1703 Mon Sep 17 00:00:00 2001 From: ykforerlang <1527997464@qq.com> Date: Tue, 28 Apr 2020 18:27:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(alita-core):=20=E4=BF=AE=E5=A4=8D=E5=BA=8F?= =?UTF-8?q?=E5=8F=B7=E9=87=8D=E5=A4=8D=EF=BC=8C=E5=BC=95=E8=B5=B7=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit affects: @areslabs/alita-core --- packages/alita-core/src/constants.ts | 1 + packages/alita-core/src/entrytran/handleEntry.ts | 2 +- packages/alita-core/src/tran/addTempName.js | 2 +- packages/alita-core/src/tran/cptCompHandler.js | 2 +- packages/alita-core/src/tran/geneAllTemplate.js | 4 ++-- packages/alita-core/src/util/util.ts | 5 +++-- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/alita-core/src/constants.ts b/packages/alita-core/src/constants.ts index 8439aca..2ec8d50 100644 --- a/packages/alita-core/src/constants.ts +++ b/packages/alita-core/src/constants.ts @@ -16,6 +16,7 @@ export { touchableWithoutFeedbackOrigin, touchableOpacityOrigin, touchableHighlightOrigin, + errorViewOrigin, } from '@shared/constants' diff --git a/packages/alita-core/src/entrytran/handleEntry.ts b/packages/alita-core/src/entrytran/handleEntry.ts index 47dd56d..5066a19 100644 --- a/packages/alita-core/src/entrytran/handleEntry.ts +++ b/packages/alita-core/src/entrytran/handleEntry.ts @@ -41,7 +41,7 @@ export default function (ast, filepath, webpackContext) { const tabInfos = [] - const go = geneOrder() + const go = geneOrder('_') errorLogTraverse(ast, { enter: path => { if (path.type === 'StringLiteral' diff --git a/packages/alita-core/src/tran/addTempName.js b/packages/alita-core/src/tran/addTempName.js index c02fce6..cdec6ec 100644 --- a/packages/alita-core/src/tran/addTempName.js +++ b/packages/alita-core/src/tran/addTempName.js @@ -14,7 +14,7 @@ import {geneOrder} from '../util/util' export default function addTempName (ast, info) { let tempNameCount = geneOrder() - let diuuCount = geneOrder() + let diuuCount = geneOrder('_') // _的传递,是 diuu加属性 和 diuu自增重复 let datakeyCount = geneOrder() errorLogTraverse(ast, { diff --git a/packages/alita-core/src/tran/cptCompHandler.js b/packages/alita-core/src/tran/cptCompHandler.js index faebd3b..e680da0 100644 --- a/packages/alita-core/src/tran/cptCompHandler.js +++ b/packages/alita-core/src/tran/cptCompHandler.js @@ -16,7 +16,7 @@ import {jsxPropsMap} from '../util/getAndStorecompInfos' export default function cptCompHandler (ast, info) { const ALLCPTCOMPMAP = jsxPropsMap - const go = geneOrder() + const go = geneOrder('$') // $的传递,是防止生成文件和用户文件重名 errorLogTraverse(ast, { enter: path => { // 处理直接是{this.props.children} 这种情况 diff --git a/packages/alita-core/src/tran/geneAllTemplate.js b/packages/alita-core/src/tran/geneAllTemplate.js index 4445f64..35ef4ae 100644 --- a/packages/alita-core/src/tran/geneAllTemplate.js +++ b/packages/alita-core/src/tran/geneAllTemplate.js @@ -11,7 +11,7 @@ import errorLogTraverse from '../util/ErrorLogTraverse' import * as t from '@babel/types' import {decTemlate, isJSXChild, isChildCompChild, isChildComp, isRenderReturn, elementAddClass} from '../util/uast'; import { isEventProp } from '../util/util'; -import {wxBaseComp, originElementAttrName} from "../constants"; +import {wxBaseComp, originElementAttrName, errorViewOrigin} from "../constants"; import {allBaseComp} from "../util/getAndStorecompInfos"; import configure from '../configure' @@ -61,7 +61,7 @@ export default function(ast, info) { return } - if (originAttr.value.value === 'ErrorView') { + if (originAttr.value.value === errorViewOrigin) { path.node.attributes = [ t.jsxAttribute( t.jsxIdentifier('style'), diff --git a/packages/alita-core/src/util/util.ts b/packages/alita-core/src/util/util.ts index 5732e0f..dc6d45d 100644 --- a/packages/alita-core/src/util/util.ts +++ b/packages/alita-core/src/util/util.ts @@ -19,7 +19,7 @@ const allChars = (low + low.toUpperCase()).split('') * * @returns {any} */ -export function geneOrder() { +export function geneOrder(suffix = '') { let v = ['a'] return { get next() { @@ -33,7 +33,8 @@ export function geneOrder() { } } - return v.join('') + // $ 保证不会和用户数据重复 + return v.join('') + suffix }, } }