From 1a1e619eaa0183121f85bdcdbb6a22d76527e5d3 Mon Sep 17 00:00:00 2001 From: Jay Date: Sat, 19 Mar 2022 15:14:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor(radio):=20=E4=BF=AE=E5=A4=8D=20eslint?= =?UTF-8?q?=20=E6=8A=A5=E9=94=99=E3=80=81=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=BB=9F=E4=B8=80=E4=BB=A3=E7=A0=81=E9=A3=8E?= =?UTF-8?q?=E6=A0=BC=20(#299)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor(radio): 修复 eslint 报错 * style(radio): 格式化代码,统一代码风格 --- packages/devui-vue/devui/radio/index.ts | 14 ++------ .../devui-vue/devui/radio/src/radio-group.tsx | 11 +++---- packages/devui-vue/devui/radio/src/radio.scss | 8 ++--- packages/devui-vue/devui/radio/src/radio.tsx | 33 ++++++++----------- 4 files changed, 23 insertions(+), 43 deletions(-) diff --git a/packages/devui-vue/devui/radio/index.ts b/packages/devui-vue/devui/radio/index.ts index 1f001f32a6..2b09f1357e 100644 --- a/packages/devui-vue/devui/radio/index.ts +++ b/packages/devui-vue/devui/radio/index.ts @@ -2,14 +2,6 @@ import type { App } from 'vue'; import Radio from './src/radio'; import RadioGroup from './src/radio-group'; -Radio.install = function(app: App) { - app.component(Radio.name, Radio); -}; - -RadioGroup.install = function(app: App) { - app.component(RadioGroup.name, RadioGroup); -}; - export { Radio, RadioGroup }; export default { @@ -17,7 +9,7 @@ export default { category: '数据录入', status: '100%', install(app: App): void { - app.use(Radio as any); - app.use(RadioGroup as any); - } + app.component(Radio.name, Radio); + app.component(RadioGroup.name, RadioGroup); + }, }; diff --git a/packages/devui-vue/devui/radio/src/radio-group.tsx b/packages/devui-vue/devui/radio/src/radio-group.tsx index c38edb33ed..728dec4ca2 100644 --- a/packages/devui-vue/devui/radio/src/radio-group.tsx +++ b/packages/devui-vue/devui/radio/src/radio-group.tsx @@ -20,7 +20,7 @@ export default defineComponent({ name: toRef(props, 'name'), disabled: toRef(props, 'disabled'), beforeChange: props.beforeChange, - emitChange + emitChange, }); }, render() { @@ -54,12 +54,11 @@ export default defineComponent({ 'devui-radio-group', { 'is-row': direction === 'row', - 'is-column': direction === 'column' - } - ]} - > + 'is-column': direction === 'column', + }, + ]}> {getContent()} ); - } + }, }); diff --git a/packages/devui-vue/devui/radio/src/radio.scss b/packages/devui-vue/devui/radio/src/radio.scss index dc53fdcfbf..e7594dc7a9 100644 --- a/packages/devui-vue/devui/radio/src/radio.scss +++ b/packages/devui-vue/devui/radio/src/radio.scss @@ -33,9 +33,7 @@ .devui-radio-material-inner { opacity: 1; transform: scale(1); - transition: - transform 200ms cubic-bezier(0.23, 1, 0.32, 1), - opacity 200ms cubic-bezier(0.23, 1, 0.32, 1); + transition: transform 200ms cubic-bezier(0.23, 1, 0.32, 1), opacity 200ms cubic-bezier(0.23, 1, 0.32, 1); } } @@ -83,9 +81,7 @@ opacity: 0; transform: scale(0); transform-origin: 50% 50%; - 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); + 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); fill: $devui-icon-fill-active; } diff --git a/packages/devui-vue/devui/radio/src/radio.tsx b/packages/devui-vue/devui/radio/src/radio.tsx index 260eb55a6e..7fff86bfea 100644 --- a/packages/devui-vue/devui/radio/src/radio.tsx +++ b/packages/devui-vue/devui/radio/src/radio.tsx @@ -21,7 +21,7 @@ export default defineComponent({ }); /** radio 的 name 属性 */ const radioName = computed(() => { - return radioGroupConf ? radioGroupConf.name.value : props.name; + return radioGroupConf ? radioGroupConf.name.value : props.name || void 0; }); /** 判断是否允许切换 */ @@ -59,45 +59,38 @@ export default defineComponent({ radioGroupConf?.emitChange(_value); // 触发父组件的change emit('update:modelValue', _value); emit('change', _value); - } + }, }; }, render() { - const { - disabled, - radioName, - value, - isChecked, - $slots, - handleChange - } = this; + const { disabled, radioName, value, isChecked, $slots, handleChange } = this; const labelCls = [ 'devui-radio', { active: isChecked, - disabled - } + disabled, + }, ]; return ( ); - } + }, });