Skip to content

Commit 1a1e619

Browse files
authored
refactor(radio): 修复 eslint 报错、格式化代码统一代码风格 (#299)
* refactor(radio): 修复 eslint 报错 * style(radio): 格式化代码,统一代码风格
1 parent 02e5131 commit 1a1e619

File tree

4 files changed

+23
-43
lines changed

4 files changed

+23
-43
lines changed

packages/devui-vue/devui/radio/index.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,14 @@ import type { App } from 'vue';
22
import Radio from './src/radio';
33
import RadioGroup from './src/radio-group';
44

5-
Radio.install = function(app: App) {
6-
app.component(Radio.name, Radio);
7-
};
8-
9-
RadioGroup.install = function(app: App) {
10-
app.component(RadioGroup.name, RadioGroup);
11-
};
12-
135
export { Radio, RadioGroup };
146

157
export default {
168
title: 'Radio 单选框',
179
category: '数据录入',
1810
status: '100%',
1911
install(app: App): void {
20-
app.use(Radio as any);
21-
app.use(RadioGroup as any);
22-
}
12+
app.component(Radio.name, Radio);
13+
app.component(RadioGroup.name, RadioGroup);
14+
},
2315
};

packages/devui-vue/devui/radio/src/radio-group.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default defineComponent({
2020
name: toRef(props, 'name'),
2121
disabled: toRef(props, 'disabled'),
2222
beforeChange: props.beforeChange,
23-
emitChange
23+
emitChange,
2424
});
2525
},
2626
render() {
@@ -54,12 +54,11 @@ export default defineComponent({
5454
'devui-radio-group',
5555
{
5656
'is-row': direction === 'row',
57-
'is-column': direction === 'column'
58-
}
59-
]}
60-
>
57+
'is-column': direction === 'column',
58+
},
59+
]}>
6160
{getContent()}
6261
</div>
6362
);
64-
}
63+
},
6564
});

packages/devui-vue/devui/radio/src/radio.scss

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333
.devui-radio-material-inner {
3434
opacity: 1;
3535
transform: scale(1);
36-
transition:
37-
transform 200ms cubic-bezier(0.23, 1, 0.32, 1),
38-
opacity 200ms cubic-bezier(0.23, 1, 0.32, 1);
36+
transition: transform 200ms cubic-bezier(0.23, 1, 0.32, 1), opacity 200ms cubic-bezier(0.23, 1, 0.32, 1);
3937
}
4038
}
4139

@@ -83,9 +81,7 @@
8381
opacity: 0;
8482
transform: scale(0);
8583
transform-origin: 50% 50%;
86-
transition:
87-
transform 200ms cubic-bezier(0.755, 0.05, 0.855, 0.06),
88-
opacity 200ms cubic-bezier(0.755, 0.05, 0.855, 0.06);
84+
transition: transform 200ms cubic-bezier(0.755, 0.05, 0.855, 0.06), opacity 200ms cubic-bezier(0.755, 0.05, 0.855, 0.06);
8985
fill: $devui-icon-fill-active;
9086
}
9187

packages/devui-vue/devui/radio/src/radio.tsx

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default defineComponent({
2121
});
2222
/** radio 的 name 属性 */
2323
const radioName = computed(() => {
24-
return radioGroupConf ? radioGroupConf.name.value : props.name;
24+
return radioGroupConf ? radioGroupConf.name.value : props.name || void 0;
2525
});
2626

2727
/** 判断是否允许切换 */
@@ -59,45 +59,38 @@ export default defineComponent({
5959
radioGroupConf?.emitChange(_value); // 触发父组件的change
6060
emit('update:modelValue', _value);
6161
emit('change', _value);
62-
}
62+
},
6363
};
6464
},
6565
render() {
66-
const {
67-
disabled,
68-
radioName,
69-
value,
70-
isChecked,
71-
$slots,
72-
handleChange
73-
} = this;
66+
const { disabled, radioName, value, isChecked, $slots, handleChange } = this;
7467
const labelCls = [
7568
'devui-radio',
7669
{
7770
active: isChecked,
78-
disabled
79-
}
71+
disabled,
72+
},
8073
];
8174

8275
return (
8376
<label class={labelCls}>
8477
<input
85-
type="radio"
78+
type='radio'
8679
name={radioName}
87-
class="devui-radio-input"
80+
class='devui-radio-input'
8881
disabled={disabled}
8982
onChange={handleChange}
9083
value={value}
9184
checked={isChecked}
9285
/>
93-
<span class="devui-radio-material">
94-
<svg height="100%" width="100%" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
95-
<circle class="devui-radio-material-outer" cx="512" cy="512" r="486.5" stroke-width="51" />
96-
<circle class="devui-radio-material-inner" cx="512" fill-rule="nonzero" cy="512" r="320" />
86+
<span class='devui-radio-material'>
87+
<svg height='100%' width='100%' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'>
88+
<circle class='devui-radio-material-outer' cx='512' cy='512' r='486.5' stroke-width='51' />
89+
<circle class='devui-radio-material-inner' cx='512' fill-rule='nonzero' cy='512' r='320' />
9790
</svg>
9891
</span>
99-
<span class="devui-radio-label">{$slots.default?.()}</span>
92+
<span class='devui-radio-label'>{$slots.default?.()}</span>
10093
</label>
10194
);
102-
}
95+
},
10396
});

0 commit comments

Comments
 (0)