Skip to content

Commit a9be1e5

Browse files
committed
feat: add theme switch
1 parent b77a274 commit a9be1e5

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

components/OneHeader.vue

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
</a>
1919
</section>
2020
<section class="desc">
21+
<veui-radio-button-group
22+
ui="s"
23+
:items="themes"
24+
:value="theme"
25+
@change="$emit('themechange', $event)"
26+
/>
2127
<nuxt-link
2228
:class="{
2329
'locale-switch': true,
@@ -36,7 +42,7 @@
3642
</template>
3743

3844
<script>
39-
import { Icon } from 'veui'
45+
import { Icon, RadioButtonGroup } from 'veui'
4046
import i18n from '../common/i18n'
4147
import OneSearch from './OneSearch'
4248
@@ -53,9 +59,21 @@ export default {
5359
name: 'one-header',
5460
components: {
5561
'veui-icon': Icon,
62+
'veui-radio-button-group': RadioButtonGroup,
5663
'one-search': OneSearch
5764
},
5865
mixins: [i18n],
66+
props: {
67+
theme: String
68+
},
69+
data () {
70+
return {
71+
themes: [
72+
{ label: 'D20', value: '' },
73+
{ label: 'D22', value: 'd22' }
74+
]
75+
}
76+
},
5977
computed: {
6078
altLocale () {
6179
let { canonicalPath, locale, getLocalePath, isPathDisabled } = this
@@ -111,7 +129,7 @@ export default {
111129
align-items center
112130
padding 0 6px
113131
border 1px solid #dbdbdb
114-
border-radius 3px
132+
border-radius 4px
115133
height 28px
116134
font-size 12px
117135
text-decoration none

layouts/default.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<one-header
55
ref="header"
66
class="header"
7+
:theme="config.theme"
8+
@themechange="handleThemeChange"
79
/>
810
<div class="body">
911
<one-menu
@@ -79,7 +81,8 @@ export default {
7981
data () {
8082
return {
8183
config: {
82-
'link.routerLink': 'nuxt-link'
84+
'link.routerLink': 'nuxt-link',
85+
theme: ''
8386
},
8487
expanded: false,
8588
quickNavOpen: false
@@ -156,6 +159,9 @@ export default {
156159
}
157160
}
158161
}
162+
},
163+
handleThemeChange (theme) {
164+
this.config.theme = theme
159165
}
160166
}
161167
}

0 commit comments

Comments
 (0)