naive-ui/demo/header.vue

105 lines
1.6 KiB
Vue
Raw Normal View History

2019-09-23 11:32:50 +08:00
<i18n>
{
"zh-cn": {
"dark": "深色",
"light": "浅色"
},
"en-us": {
"dark": "Dark",
"light": "Light"
}
}
</i18n>
2019-09-17 19:28:28 +08:00
<template>
<div class="nav">
<div class="ui-logo">
2019-09-20 00:22:55 +08:00
NAIVE UI ({{ version }})
2019-09-17 19:28:28 +08:00
</div>
<div />
<div class="theme-picker">
<n-select
2019-09-27 15:56:01 +08:00
v-model="NApp.$parent.theme"
2019-09-17 19:28:28 +08:00
size="small"
:options="options"
/>
</div>
2019-09-21 17:03:37 +08:00
<div class="lang-picker">
<n-select
2019-09-24 16:59:07 +08:00
:value="lang"
2019-09-21 17:03:37 +08:00
size="small"
:options="langOptions"
2019-09-24 16:59:07 +08:00
@input="handleLangInput"
2019-09-21 17:03:37 +08:00
/>
</div>
2019-09-17 19:28:28 +08:00
</div>
</template>
<script>
2019-09-20 00:22:55 +08:00
import { version } from '../package.json'
2019-09-17 19:28:28 +08:00
import withapp from '../packages/mixins/withapp'
export default {
mixins: [withapp],
2019-09-24 16:59:07 +08:00
props: {
lang: {
type: String,
required: true
}
},
2019-09-17 19:28:28 +08:00
data () {
return {
2019-09-20 00:22:55 +08:00
version,
2019-09-24 16:59:07 +08:00
theme: 'dark',
2019-09-21 17:03:37 +08:00
langOptions: [
{
label: '中文',
value: 'zh-cn'
},
{
label: 'English',
value: 'en-us'
}
2019-09-17 19:28:28 +08:00
]
}
},
2019-09-23 11:32:50 +08:00
computed: {
options: function () {
return [
{
label: this.$t('dark'),
2019-09-24 16:59:07 +08:00
value: 'dark'
2019-09-23 11:32:50 +08:00
},
{
label: this.$t('light'),
value: 'light'
}
]
}
},
2019-09-17 19:28:28 +08:00
methods: {
2019-09-24 16:59:07 +08:00
handleLangInput (lang) {
this.$emit('lang-change', lang)
2019-09-17 19:28:28 +08:00
}
}
}
</script>
<style lang="scss" scoped>
.nav {
display: grid;
2019-09-21 17:03:37 +08:00
grid-template-columns: 272px 1fr 128px 160px;
2019-09-17 19:28:28 +08:00
grid-template-rows: 64px;
align-items: center;
}
.ui-logo {
padding-left: 48px;
}
.theme-picker {
2019-09-21 17:03:37 +08:00
padding-right: 16px;
}
.lang-picker {
2019-09-17 19:28:28 +08:00
padding-right: 48px;
}
</style>