App.vue 4.4 KB
Newer Older
1
<template>
2 3 4 5 6 7
  <!-- Header -->
  <!-- 头部 -->
  <div class="header" data-wails-drag>
    <!-- navigation -->
    <!-- 导航 -->
    <div class="nav" data-wails-no-drag>
8 9
      <router-link to="/">{{ t("nav.home") }}</router-link>
      <router-link to="/about">{{ t("nav.about") }}</router-link>
10 11 12 13
    </div>
    <!-- Menu -->
    <!-- 菜单 -->
    <div class="menu" data-wails-no-drag>
14
      <div class="language">
15 16 17 18 19 20 21
        <div
          v-for="item in languages"
          :key="item"
          :class="{ active: item === locale }"
          @click="onclickLanguageHandle(item)"
          class="lang-item"
        >
22
          {{ t("languages." + item) }}
23
        </div>
24
      </div>
25 26
      <div class="bar">
        <div class="bar-btn" @click="onclickMinimise">
27
          {{ t("topbar.minimise") }}
28
        </div>
29
        <div class="bar-btn" @click="onclickQuit">{{ t("topbar.quit") }}</div>
30 31 32 33 34 35 36 37
      </div>
    </div>
  </div>
  <!-- Page -->
  <!-- 页面 -->
  <div class="view">
    <router-view />
  </div>
38 39
</template>

40
<script lang="ts">
41 42
import { defineComponent } from "vue";
import { useI18n } from "vue-i18n";
43

44
export default defineComponent({
45
  setup() {
46
    const { t, availableLocales, locale } = useI18n({ useScope: "global" });
47 48
    // List of supported languages
    // 支持的语言列表
49
    const languages = availableLocales;
50 51 52

    // Click to switch language
    // 点击切换语言
53 54 55
    const onclickLanguageHandle = (item: string) => {
      item !== locale.value ? (locale.value = item) : false;
    };
56 57 58 59 60 61 62 63 64

    const onclickMinimise = () => {
      window.runtime.WindowMinimise();
    };
    const onclickQuit = () => {
      window.runtime.Quit();
    };

    return {
65 66 67 68
      t,
      languages,
      locale,
      onclickLanguageHandle,
69 70 71 72
      onclickMinimise,
      onclickQuit,
    };
  },
73
});
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
</script>

<style lang="scss">
@import url("./assets/css/reset.css");
@import url("./assets/css/font.css");

html {
  width: 100%;
  height: 100%;
}
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: "JetBrainsMono";
  background-color: transparent;
}

93
#app {
94 95 96 97
  position: relative;
  // width: 900px;
  // height: 520px;
  height: 100%;
98
  background-color: rgba(219, 188, 239, 0.9);
99 100 101 102 103 104 105 106 107 108
  overflow: hidden;
}
.header {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  padding: 0 10px;
109
  background-color: rgba(171, 126, 220, 0.9);
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 194 195 196 197 198 199 200 201
  .nav {
    a {
      display: inline-block;
      min-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;
      white-space: nowrap;
      &: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 {
          background-color: #ff050542;
          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: 80px;
        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;
        }
      }
    }
  }
}

.view {
  position: absolute;
  top: 50px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
202 203
}
</style>