<template>
	<view>
		<b-navbar toggleable="lg" type="dark" class="b-navbar">
			<b-navbar-brand href="#">
				<img src="@/static/hdk-top-logo.png" width="63px" height="32px" style="margin-left: 10px;" alt="Kitten">
			</b-navbar-brand>
			<b-navbar-toggle target="nav-collapse"></b-navbar-toggle>
			<b-collapse id="nav-collapse" is-nav>
				<!-- <b-navbar-nav>
		        <b-nav-item href="#">Link</b-nav-item>
		        <b-nav-item href="#" disabled>Disabled</b-nav-item>
		      </b-navbar-nav> -->

				<!-- Right aligned nav items -->
				<b-navbar-nav class="ml-auto">
					<b-navbar-nav>
						<b-nav-item href="#" active
							active-class="activeCSS">{{$t('hdk.productInformation')}}</b-nav-item>
						<b-nav-item href="#" active-class="activeCSS">{{$t('hdk.inspectionInformation')}}</b-nav-item>
						<b-nav-item href="#" active-class="activeCSS">{{$t('hdk.attachmentInformation')}}</b-nav-item>
					</b-navbar-nav>

					<b-nav-item-dropdown :text="selectedLanguage" right>
						<b-dropdown-item href="#" @click="changeLanguage('en')">{{$t('locale.en')}}</b-dropdown-item>
						<b-dropdown-item href="#"
							@click="changeLanguage('zh-hans')">{{$t('locale.zh-hans')}}</b-dropdown-item>
					</b-nav-item-dropdown>
				</b-navbar-nav>
			</b-collapse>
		</b-navbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				selectedLanguage: this.$t('index.language'),
				title: this.$t('')
			}
		},
		methods: {
			changeLanguage(locale) {
				console.log('切换语言为:', locale);
				// 更新选择的语言
				if (locale === 'en') {
					this.$i18n.locale = 'en';
					this.selectedLanguage = `${this.$t('index.language')}:${this.$t('locale.en')}`;
				} else if (locale === 'zh-hans') {
					this.$i18n.locale = 'zh-Hans';
					this.selectedLanguage = `${this.$t('index.language')}:${this.$t('locale.zh-hans')}`;
				}
			}
		}
	}
</script>

<style>
	.uni-top-window {
		height: 60px;
		padding: 0 15px;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
		border-bottom: 1px solid #e1e1e1;
		background-color: #00AEAA;
		color: #333;
	}

	.b-navbar {
		width: 100vw;
		background-color: #00AEAA;
	}

	.nav-item {}

	.activeCSS {
		background: #fff;

	}
</style>