Skip to content

Commit 423b642

Browse files
committed
fix: 修复自定义组件taro无样式问题
1 parent b7a7990 commit 423b642

File tree

2 files changed

+76
-3
lines changed

2 files changed

+76
-3
lines changed

index.js

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,72 @@ switch (platform) {
224224
}
225225
break
226226
case 'arm':
227+
if (isMusl()) {
228+
localFileExisted = existsSync(
229+
join(__dirname, 'parse-css-to-stylesheet.linux-arm-musleabihf.node')
230+
)
231+
try {
232+
if (localFileExisted) {
233+
nativeBinding = require('./parse-css-to-stylesheet.linux-arm-musleabihf.node')
234+
} else {
235+
nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-arm-musleabihf')
236+
}
237+
} catch (e) {
238+
loadError = e
239+
}
240+
} else {
241+
localFileExisted = existsSync(
242+
join(__dirname, 'parse-css-to-stylesheet.linux-arm-gnueabihf.node')
243+
)
244+
try {
245+
if (localFileExisted) {
246+
nativeBinding = require('./parse-css-to-stylesheet.linux-arm-gnueabihf.node')
247+
} else {
248+
nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-arm-gnueabihf')
249+
}
250+
} catch (e) {
251+
loadError = e
252+
}
253+
}
254+
break
255+
case 'riscv64':
256+
if (isMusl()) {
257+
localFileExisted = existsSync(
258+
join(__dirname, 'parse-css-to-stylesheet.linux-riscv64-musl.node')
259+
)
260+
try {
261+
if (localFileExisted) {
262+
nativeBinding = require('./parse-css-to-stylesheet.linux-riscv64-musl.node')
263+
} else {
264+
nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-riscv64-musl')
265+
}
266+
} catch (e) {
267+
loadError = e
268+
}
269+
} else {
270+
localFileExisted = existsSync(
271+
join(__dirname, 'parse-css-to-stylesheet.linux-riscv64-gnu.node')
272+
)
273+
try {
274+
if (localFileExisted) {
275+
nativeBinding = require('./parse-css-to-stylesheet.linux-riscv64-gnu.node')
276+
} else {
277+
nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-riscv64-gnu')
278+
}
279+
} catch (e) {
280+
loadError = e
281+
}
282+
}
283+
break
284+
case 's390x':
227285
localFileExisted = existsSync(
228-
join(__dirname, 'parse-css-to-stylesheet.linux-arm-gnueabihf.node')
286+
join(__dirname, 'parse-css-to-stylesheet.linux-s390x-gnu.node')
229287
)
230288
try {
231289
if (localFileExisted) {
232-
nativeBinding = require('./parse-css-to-stylesheet.linux-arm-gnueabihf.node')
290+
nativeBinding = require('./parse-css-to-stylesheet.linux-s390x-gnu.node')
233291
} else {
234-
nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-arm-gnueabihf')
292+
nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-s390x-gnu')
235293
}
236294
} catch (e) {
237295
loadError = e

src/visitor.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,13 @@ impl VisitMut for ObjectFinder {
12951295
],
12961296
})),
12971297
}))
1298+
));
1299+
props.insert(
1300+
0,
1301+
PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
1302+
key: PropName::Ident(Ident::new("__hmStyle".into(), DUMMY_SP)),
1303+
value: Box::new(ObjectFinder::get_fun_call_expr(class_attr_value.clone())),
1304+
}))
12981305
))
12991306
}
13001307
}
@@ -1457,6 +1464,14 @@ impl<'i> VisitMut for JSXMutVisitor<'i> {
14571464
}))),
14581465
})),
14591466
}));
1467+
n.opening.attrs.push(JSXAttrOrSpread::JSXAttr(JSXAttr {
1468+
span: DUMMY_SP,
1469+
name: JSXAttrName::Ident(Ident::new("__hmStyle".into(), DUMMY_SP)),
1470+
value: Some(JSXAttrValue::JSXExprContainer(JSXExprContainer {
1471+
span: DUMMY_SP,
1472+
expr: JSXExpr::Expr(Box::new(get_fun_call_expr(class_attr_value.clone()))),
1473+
})),
1474+
}));
14601475
},
14611476
None => {},
14621477
}

0 commit comments

Comments
 (0)