aboutsummaryrefslogtreecommitdiff
path: root/src-vue/src/App.vue
blob: 9db6c4883e320fa20a23d92fd6924bb6d6568a19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<script lang="ts">
import ChangelogView from './views/ChangelogView.vue';
import DeveloperView from './views/DeveloperView.vue';
import PlayView from './views/PlayView.vue';
import ModsView from './views/ModsView.vue';
import SettingsView from './views/SettingsView.vue';
import { appWindow } from '@tauri-apps/api/window';
import { store } from './plugins/store';
import { Store } from 'tauri-plugin-store-api';
import { invoke } from "@tauri-apps/api";
import NotificationButton from "./components/NotificationButton.vue";

export default {
  components: {
      NotificationButton,
      ChangelogView,
      DeveloperView,
      PlayView,
      SettingsView,
      ModsView
  },
  data() {
    return {}
  },
  mounted: async function() {
    store.commit('initialize');

    // Initialize interface language
    const persistentStore = new Store('flight-core-settings.json');
    let lang: string | null = await persistentStore.get('lang');
    if (lang === null) {
      lang = navigator.language.substring(0, 2);
      persistentStore.set('lang', lang);
      await persistentStore.save();
    }
    this.$root!.$i18n.locale = lang;
  },
  methods: {
    minimize() {
      appWindow.minimize()
    },
    close() {
      invoke("close_application");
    }
  },
    computed: {
      bgStyle(): string {
          // @ts-ignore
          const shouldBlur = this.$route.path !== "/";
          return `filter: brightness(0.8) ${shouldBlur ? 'blur(5px)' : ''};`;
      }
    }
}
</script>

<template>
  <div class="app-inner">
    <div id="fc_bg__container" :style="bgStyle"/>

    <nav id="fc_menu-bar" v-if="$route.path !== '/repair'"><!-- Hide menu bar in repair view -->
      <!-- Navigation items -->
      <el-menu
        :default-active="$route.path"
        router
        mode="horizontal"
        id="fc__menu_items"
        data-tauri-drag-region
      >
        <el-menu-item index="/">{{ $t('menu.play') }}</el-menu-item>
        <el-menu-item index="/mods">{{ $t('menu.mods') }}</el-menu-item>
        <el-menu-item index="/changelog">{{ $t('menu.changelog') }}</el-menu-item>
        <el-menu-item index="/settings">{{ $t('menu.settings') }}</el-menu-item>
        <el-menu-item index="/dev" v-if="$store.state.developer_mode">{{ $t('menu.dev') }}</el-menu-item>
      </el-menu>

      <!-- Window controls -->
      <div id="fc_window__controls">
        <NotificationButton />
        <el-button color="white" icon="SemiSelect" @click="minimize" circle />
        <el-button color="white" icon="CloseBold" @click="close" circle />
      </div>
    </nav>

    <router-view></router-view>
  </div>
</template>

<style>
#fc_menu-bar {
  position: fixed;
  z-index: 1;
  top: 0;
  width: 100%;
  height: var(--fc-menu_height);
}

#fc__menu_bar::before {
    position: absolute;
    content: "";
    inset: 0; /* same as { top: 0; right: 0; bottom: 0; left: 0; } */
    background-image: linear-gradient(to bottom, red, orange);
    z-index: 1;
    opacity: 0;
    transition: opacity 1s linear;
}

#fc__menu_bar:hover::before {
    opacity: 1;
}

/* Borders reset */
#fc__menu_bar, #fc__menu_items {
    border: none !important;
}
.app-inner {
  height: 100%;
  width: 100%;
}

/* Header item */
#fc__menu_items {
  height: 100%;
  background-color: transparent;
  float: left;
  width: calc(100% - 168px); /* window controls container width */
}

#fc__menu_items .el-menu-item, #fc__menu_items .el-sub-menu__title {
  color: #b4b6b9;
  border-color: white;
}

#fc__menu_items > .el-menu-item {
  text-transform: uppercase;
  border: none !important;
  font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
  font-weight: bold;
  font-size: large;
  background-color: transparent !important;

  border-width: 2px !important;
  border-style: solid !important;
  border-color: transparent !important;
  border-radius: 10px !important;
  transition: none;
}

#fc__menu_items .el-menu-item:hover, #fc__menu_items .el-sub-menu__title {
  color: #c6c9ce;
  background-color: transparent;
}

#fc__menu_items .el-menu-item:focus-visible {
  border-color: rgb(160, 207, 255) !important;
}

#fc__menu_items .el-menu-item.is-active, #fc__menu_items .el-sub-menu.is-active > .el-sub-menu__title {
  color: white !important;
}

.app-inner > .fc__mods__container {
  overflow-y: auto;
  height: calc(100% - var(--fc-menu_height));
}

/* Header menu */
.developer_build {
  background: repeating-linear-gradient(
    45deg,
    rgba(0, 0, 0, 0.2),
    rgba(0, 0, 0, 0.2) 20px,
    rgba(0, 0, 0, 0.3) 20px,
    rgba(0, 0, 0, 0.3) 40px
  );
}

/* Window controls */
#fc_window__controls {
  float: right;
  height: 100%;
}

#fc_window__controls > button,
#fc_window__controls > .el-dropdown > button,
#fc_window__controls > .el-dropdown > .el-badge > button {
  color: white;
  font-size: 20px;
  margin: auto 5px;
  background: none;
  border: none;
  height: 100%;
}

#fc_window__controls > button:hover,
#fc_window__controls > .el-dropdown > button:hover,
#fc_window__controls > .el-dropdown > .el-badge > button:hover {
  color: #c6c9ce;
}

#fc_window__controls > button:active,
#fc_window__controls > .el-dropdown > button:active {
  color: #56585a;
}

#fc_window__controls > button:last-of-type {
  margin-right: 15px;
}

sup {
  border: none !important;
}

</style>