We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5095f15 commit bbc5539Copy full SHA for bbc5539
index.d.ts
@@ -10,6 +10,7 @@ export interface ParseOptions {
10
platformString: string
11
designWidth?: number
12
output?: OutputOptions
13
+ allowInherit?: boolean
14
}
15
export interface ParseResult {
16
code?: string
src/style_propetries/macros.rs
@@ -72,7 +72,23 @@ macro_rules! generate_expr_lit_color {
72
macro_rules! generate_expr_lit_calc {
73
($var:expr, $platform:expr) => {{
74
use $crate::generate_expr_lit_str;
75
- generate_expr_lit_str!($var.clone())
+ // 扫描 $var 中是存在px单位,如果存在,替换为lpx
76
+ let re = regex::Regex::new(r#"(\d+(?:px|vw|vh))"#).unwrap();
77
+ let result = re.replace_all($var.as_str(), |caps: ®ex::Captures| {
78
+ let value = &caps[1];
79
+ let unit = &value[value.len() - 2..];
80
+ let parsed_value: i32 = value[..value.len() - 2].parse().unwrap();
81
+ if $platform == Platform::Harmony {
82
+ if unit == "px" {
83
+ format!("{}lpx", parsed_value)
84
+ } else {
85
+ format!("{}l{}", parsed_value, unit)
86
+ }
87
88
+ format!("{}px", parsed_value)
89
90
+ });
91
+ generate_expr_lit_str!(result.to_string())
92
93
// use swc_core::ecma::ast::*;
94
// use swc_core::{
src/style_propetries/unit.rs
@@ -118,6 +118,21 @@ pub fn generate_expr_by_length_value(length_value: &LengthValue, platform: Platf
118
119
120
121
+ LengthValue::Ex(num) => {
122
+ match platform {
123
+ Platform::ReactNative => {
124
+ handler = Some(RN_CONVERT_STYLE_VU_FN.to_string());
125
+ args.push(generate_expr_lit_num!(*num as f64));
126
+ args.push(generate_expr_lit_str!("PX"));
127
128
+ Platform::Harmony => {
129
+ return generate_expr_lit_str!(format!("{}fp", num));
130
+ // handler = Some(CONVERT_STYLE_PX_FN.to_string());
131
+ // args.push(generate_expr_lit_num!(*num as f64));
132
+ // args.push(generate_expr_lit_str!("PX"));
133
134
135
136
_ => {}
137
138
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments