App.vue 4.7 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
      <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>
25
        <div class="bar-btn" @click="onclickQuit">{{ $t("topbar.quit") }}</div>
米司特包's avatar
米司特包 已提交
26
      </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
<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"))

    }
71
    const onclickQuit = () => {
米司特包's avatar
米司特包 已提交
72 73 74 75 76 77 78 79 80
      alert(i18n.global.t("global.not-supported"))

    }

    return {
      languages,
      locale,
      onclickLanguageHandle,
      onclickMinimise,
81
      onclickQuit
米司特包's avatar
米司特包 已提交
82 83 84 85 86
    }
  },
}
</script>

87
<style lang="scss">
米司特包's avatar
米司特包 已提交
88
@import url("./assets/css/reset.css");
89
@import url("./assets/css/font.css");
90

米司特包's avatar
米司特包 已提交
91
html,
米司特包's avatar
米司特包 已提交
92
body {
米司特包's avatar
米司特包 已提交
93 94
  width: 100%;
  height: 100%;
95 96
  margin: 0;
  padding: 0;
97
  font-family: "JetBrainsMono";
米司特包's avatar
米司特包 已提交
98
}
99

米司特包's avatar
米司特包 已提交
100
#app {
米司特包's avatar
米司特包 已提交
101 102 103
  position: relative;
  // width: 900px;
  // height: 520px;
104 105
  width: 100%;
  height: 100%;
米司特包's avatar
米司特包 已提交
106
  background-color: #dbbcef;
米司特包's avatar
米司特包 已提交
107
}
米司特包's avatar
米司特包 已提交
108 109 110 111 112 113 114 115 116 117 118 119
.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;
120
      min-width: 50px;
米司特包's avatar
米司特包 已提交
121 122
      height: 30px;
      line-height: 30px;
123
      padding: 0 5px;
米司特包's avatar
米司特包 已提交
124 125 126 127 128 129 130
      margin-right: 8px;
      background-color: #ab7edc;
      border-radius: 2px;
      text-align: center;
      text-decoration: none;
      color: #000000;
      font-size: 14px;
131
      white-space: nowrap;
米司特包's avatar
米司特包 已提交
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
      &: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;
155
        padding: 0 5px;
米司特包's avatar
米司特包 已提交
156 157 158 159 160
        background-color: transparent;
        text-align: center;
        text-decoration: none;
        color: #000000;
        font-size: 14px;
161
        &:hover {
162
          background-color: #ff050542;
米司特包's avatar
米司特包 已提交
163 164 165 166 167 168 169 170 171 172 173 174 175 176
          cursor: pointer;
        }
        &.active {
          background-color: #ff050542;
          color: #ffffff;
          cursor: not-allowed;
        }
      }
    }
    .bar {
      display: flex;
      flex-direction: row;
      flex-wrap: nowrap;
      align-items: center;
177 178
      justify-content: flex-end;
      min-width: 150px;
米司特包's avatar
米司特包 已提交
179 180 181 182 183
      .bar-btn {
        display: inline-block;
        min-width: 50px;
        height: 30px;
        line-height: 30px;
184
        padding: 0 5px;
米司特包's avatar
米司特包 已提交
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
        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
米司特包 已提交
200 201
}

米司特包's avatar
米司特包 已提交
202 203 204 205 206 207
.view {
  position: absolute;
  top: 50px;
  left: 0;
  right: 0;
  bottom: 0;
208
  overflow: hidden;
米司特包's avatar
米司特包 已提交
209 210
}
</style>