Skip to content

Commit

Permalink
fix(alita-core): 修复序号重复,引起的bug
Browse files Browse the repository at this point in the history
affects: @areslabs/alita-core
  • Loading branch information
ykforerlang committed Apr 28, 2020
1 parent 6b4c6f1 commit 8ce041d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/alita-core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export {
touchableWithoutFeedbackOrigin,
touchableOpacityOrigin,
touchableHighlightOrigin,
errorViewOrigin,
} from '@shared/constants'


Expand Down
2 changes: 1 addition & 1 deletion packages/alita-core/src/entrytran/handleEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/alita-core/src/tran/addTempName.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
2 changes: 1 addition & 1 deletion packages/alita-core/src/tran/cptCompHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
// 处理直接是<V>{this.props.children}</V> 这种情况
Expand Down
4 changes: 2 additions & 2 deletions packages/alita-core/src/tran/geneAllTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'),
Expand Down
5 changes: 3 additions & 2 deletions packages/alita-core/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -33,7 +33,8 @@ export function geneOrder() {
}
}

return v.join('')
// $ 保证不会和用户数据重复
return v.join('') + suffix
},
}
}
Expand Down

0 comments on commit 8ce041d

Please sign in to comment.