Skip to content

Commit

Permalink
Merge branch 'remaxToNanachi'
Browse files Browse the repository at this point in the history
  • Loading branch information
peacejj committed Jan 4, 2024
2 parents 74b4cfb + c3209f8 commit 7c23158
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nanachi-cli",
"version": "1.8.28",
"version": "1.8.29",
"description": "cli tool for nanachi",
"bin": {
"nanachi": "./bin/index.js"
Expand Down
7 changes: 7 additions & 0 deletions packages/cli/packages/babelPlugins/miniappVisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ const visitor = {
modules.className = name;
helpers.render.exit(astPath, '无状态组件', name, modules);
if (modules.componentType === 'Page') {
modules.classUid = 'c' + utils_1.default.createUUID(astPath);
modules.registerStatement = utils_1.default.createRegisterStatement(name, modules.current
.replace(/.+pages/, 'pages')
.replace(/\.js$/, ''), true);
Expand Down Expand Up @@ -276,6 +277,12 @@ const visitor = {
FUN_DATA: 'FUN_DATA'
}));
}
if (modules.componentType === 'Page') {
const left = t.memberExpression(t.thisExpression(), t.identifier('classUid'));
const right = t.stringLiteral(modules.classUid);
body.unshift(t.expressionStatement(t.assignmentExpression('=', left, right)));
}
;
body.unshift(template_1.default(utils_1.default.shortcutOfCreateElement())());
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/cli/packages/babelPlugins/miniappVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ const visitor: babel.Visitor = {

helpers.render.exit(astPath, '无状态组件', name, modules);
if (modules.componentType === 'Page') {
modules.classUid = 'c' + utils.createUUID(astPath);
modules.registerStatement = utils.createRegisterStatement(
name,
modules.current
Expand Down Expand Up @@ -369,6 +370,15 @@ const visitor: babel.Visitor = {
}) as any)
}

// 只给页面加classUid
if(modules.componentType === 'Page'){
const left = t.memberExpression(t.thisExpression(), t.identifier('classUid'));
const right = t.stringLiteral(modules.classUid);
body.unshift(
t.expressionStatement(t.assignmentExpression('=', left, right))
);
};

body.unshift(
template(utils.shortcutOfCreateElement())() as any
);
Expand Down

0 comments on commit 7c23158

Please sign in to comment.