App.vue 4.6 KB
Newer Older
米司特包's avatar
米司特包 已提交
1
<template>
米司特包's avatar
米司特包 已提交
2 3 4 5 6 7 8 9 10 11 12
  <!-- Header -->
  <!-- 头部 -->
  <div class="header">
    <!-- navigation -->
    <!-- 导航 -->
    <div class="nav">
      <router-link to="/">{{ $t("nav.home") }}</router-link>
      <router-link to="/about">{{ $t("nav.about") }}</router-link>
    </div>
    <!-- Menu -->
    <!-- 菜单 -->
米司特包's avatar
米司特包 已提交
13
    <div class="menu">
米司特包's avatar
米司特包 已提交
14 15 16 17 18 19 20 21 22 23 24 25 26
      <div class="language">
        <div
          v-for="(item) in languages"
          :key="item"
          :class="{ active: item === locale }"
          @click="onclickLanguageHandle(item)"
          class="lang-item"
        >{{ $t("languages." + item) }}</div>
      </div>
      <div class="bar">
        <div class="bar-btn" @click="onclickMinimise">{{ $t("topbar.minimise") }}</div>
        <div class="bar-btn" @click="onclickExit">{{ $t("topbar.exit") }}</div>
      </div>
米司特包's avatar
米司特包 已提交
27
    </div>
米司特包's avatar
米司特包 已提交
28 29 30 31
  </div>
  <!-- Page -->
  <!-- 页面 -->
  <div class="view">
米司特包's avatar
米司特包 已提交
32 33 34 35
    <router-view />
  </div>
</template>

米司特包's avatar
米司特包 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
<script>
import { ref, watch } from 'vue'
import i18n from "@/i18n";

export default {
  setup() {
    // List of supported languages
    // 支持的语言列表
    const languages = i18n.global.availableLocales
    // Current language
    // 当前语言
    const locale = ref("zh-Hans")
    locale.value = i18n.global.locale

    // Click to switch language
    // 点击切换语言
    const onclickLanguageHandle = (item) => {
      (item !== locale.value) ? (locale.value = item) : false

    }
    // Monitor current language changes
    // 监听当前语言变动
    watch(locale, (newValue, oldValue) => {
      console.log('The new language is: ' + locale.value)
      i18n.global.locale = newValue
    })


    // Since the current js runtime has not been developed yet, so first call Go to complete. Later, 
    // it will be updated to be called directly when js is running.
    // 由于当前js运行时还没有开发完成,所以先调用Go完成。后续会更新为js运行时直接调用。
    const onclickMinimise = () => {
      alert(i18n.global.t("global.not-supported"))

    }
    const onclickExit = () => {
      alert(i18n.global.t("global.not-supported"))

    }

    return {
      languages,
      locale,
      onclickLanguageHandle,
      onclickMinimise,
      onclickExit
    }
  },
}
</script>

<style lang="stylus">
@import url("./assets/css/reset.css");
html,
米司特包's avatar
米司特包 已提交
90
body {
米司特包's avatar
米司特包 已提交
91 92 93 94
  width: 100%;
  height: 100%;
  margin 0
  padding 0
米司特包's avatar
米司特包 已提交
95 96
}
#app {
米司特包's avatar
米司特包 已提交
97 98 99 100 101 102
  position: relative;
  // width: 900px;
  // height: 520px;
  width 100%
  height 100%
  background-color: #dbbcef;
米司特包's avatar
米司特包 已提交
103
}
米司特包's avatar
米司特包 已提交
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
.header {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  padding: 0 10px;
  background-color: #ab7edc;
  .nav {
    a {
      display: inline-block;
      width: 50px;
      height: 30px;
      line-height: 30px;
      padding 0 5px
      margin-right: 8px;
      background-color: #ab7edc;
      border-radius: 2px;
      text-align: center;
      text-decoration: none;
      color: #000000;
      font-size: 14px;
      &:hover,
      &.router-link-exact-active {
        background-color: #d7a8d8;
        color: #ffffff;
      }
    }
  }
  .menu {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    .language {
      margin-right: 20px;
      border-radius: 2px;
      background-color: #c3c3c3;
      overflow: hidden;
      .lang-item {
        display: inline-block;
        min-width: 50px;
        height: 30px;
        line-height: 30px;
        padding 0 5px
        background-color: transparent;
        text-align: center;
        text-decoration: none;
        color: #000000;
        font-size: 14px;
        &:hover{
          cursor: pointer;
        }
        &.active {
          background-color: #ff050542;
          color: #ffffff;
          cursor: not-allowed;
        }
      }
    }
    .bar {
      display: flex;
      flex-direction: row;
      flex-wrap: nowrap;
      align-items: center;
      justify-content flex-end
      min-width 150px
      .bar-btn {
        display: inline-block;
        min-width: 50px;
        height: 30px;
        line-height: 30px;
        padding 0 5px
        margin-left: 8px;
        background-color: #ab7edc;
        border-radius: 2px;
        text-align: center;
        text-decoration: none;
        color: #000000;
        font-size: 14px;
        &:hover {
          background-color: #d7a8d8;
          color: #ffffff;
          cursor: pointer;
        }
      }
    }
  }
米司特包's avatar
米司特包 已提交
194 195
}

米司特包's avatar
米司特包 已提交
196 197 198 199 200 201 202
.view {
  position: absolute;
  top: 50px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow hidden
米司特包's avatar
米司特包 已提交
203 204
}
</style>