Skip to content

Commit fb5aa62

Browse files
committed
fix: fix review
1 parent 7c2977c commit fb5aa62

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

Diff for: packages/common/component/ToolbarBase.vue

+3-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</template>
77
</component>
88
<slot></slot>
9-
<span v-if="isHideMulti()">{{ state.content }}</span>
9+
<span v-if="isShowContent">{{ state.content }}</span>
1010
</span>
1111
</template>
1212

@@ -50,13 +50,9 @@ export default {
5050
emit('click-api')
5151
}
5252
53-
const isShowMulti = () => (state.options?.collapsed || props.position === 'collapse') && state.options?.multiType
54-
const isHideMulti = () => (state.options?.collapsed || props.position === 'collapse') && !state.options?.multiType
53+
const isShowContent = computed(() => (state.options?.collapsed || props.position === 'collapse') && props.content)
5554
5655
const getRender = () => {
57-
if (isShowMulti()) {
58-
return false
59-
}
6056
if (props.options.renderType === 'button') {
6157
return ToolbarBaseButton
6258
}
@@ -70,8 +66,7 @@ export default {
7066
state,
7167
click,
7268
getRender,
73-
isShowMulti,
74-
isHideMulti
69+
isShowContent
7570
}
7671
}
7772
}

Diff for: packages/toolbars/themeSwitch/meta.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export default {
66
icon: {
77
default: 'light'
88
},
9-
renderType: 'icon',
10-
multiType: true
9+
renderType: 'icon'
1110
}
1211
}

Diff for: packages/toolbars/themeSwitch/src/Main.vue

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<template>
22
<div class="toolbar-theme-switch">
33
<toolbar-base
4-
:content="state.themeLabel"
5-
:icon="state.theme"
6-
:options="options"
4+
:content="baseContent"
5+
:icon="baseIcon"
6+
:options="optionsData"
77
:position="position"
88
@click-api="themeChange"
99
>
@@ -19,6 +19,7 @@
1919
</template>
2020

2121
<script>
22+
import { computed } from 'vue'
2223
import { ToolbarBase } from '@opentiny/tiny-engine-common'
2324
import { RadioGroup } from '@opentiny/vue'
2425
import useThemeSwitch from './composable/useThemeSwitch.js'
@@ -40,10 +41,21 @@ export default {
4041
},
4142
setup(props) {
4243
const THEME_DATA = useThemeSwitch().THEME_DATA
44+
const COLLAPSE = 'collapse'
4345
const state = useThemeSwitch().initThemeState()
46+
const optionsData = computed(() => {
47+
const options = { ...props.options }
48+
if (props.position === COLLAPSE) {
49+
options.renderType = ''
50+
}
51+
52+
return options
53+
})
54+
const baseContent = computed(() => (props.position === COLLAPSE ? '' : state.themeLabel))
55+
const baseIcon = computed(() => (props.position === COLLAPSE ? '' : state.theme))
4456
4557
const themeChange = () => {
46-
if (props.position === 'collapse') {
58+
if (props.position === COLLAPSE) {
4759
return
4860
}
4961
@@ -55,6 +67,9 @@ export default {
5567
return {
5668
THEME_DATA,
5769
state,
70+
optionsData,
71+
baseContent,
72+
baseIcon,
5873
themeChange,
5974
radioChange
6075
}

0 commit comments

Comments
 (0)