/
App.vue
122 lines (116 loc) · 3.29 KB
/
App.vue
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
<template>
<div id="app">
<v-app :dark="isDarkMode">
<side-nav v-if="isLoggedIn" />
<confirm ref="confirm" />
<socket-notifications v-if="isLoggedIn && versionSatisfies('>=3.5.0')" />
<!-- Sizes your content based upon application components -->
<v-main>
<!-- Provides the application the proper gutter -->
<v-container fluid>
<!-- If using vue-router -->
<router-view />
</v-container>
</v-main>
<v-footer app>
<span class="mr-2">Copyright (c) 2020 BC Security |</span>
<a
class="mr-2"
target="_blank"
href="https://github.com/bc-security/starkiller"
@click.prevent="openExternalBrowser"
> Starkiller </a>
<span class="mr-2">|</span>
<a
target="_blank"
href="https://github.com/bc-security/empire"
@click.prevent="openExternalBrowser"
> Empire</a>
</v-footer>
</v-app>
</div>
</template>
<script>
import semver from 'semver';
import { mapGetters, mapState } from 'vuex';
import openExternalBrowser from '@/mixins/open-external';
import SideNav from '@/components/SideNav.vue';
import Confirm from '@/components/Confirm.vue';
import SocketNotifications from '@/components/SocketNotifications.vue';
export default {
name: 'App',
components: {
SideNav,
Confirm,
SocketNotifications,
},
mixins: [openExternalBrowser],
computed: {
...mapGetters({
isLoggedIn: 'application/isLoggedIn',
isDarkMode: 'application/isDarkMode',
}),
...mapState({
empireVersion: state => state.application.empireVersion,
}),
isLoginPage() {
return this.$route.name === 'home';
},
},
watch: {
isDarkMode: {
immediate: true,
handler(val) {
if (val === true) {
this.$vuetify.theme.dark = true;
} else {
this.$vuetify.theme.dark = false;
}
},
},
isLoggedIn(val) {
if (val === false && !this.isLoginPage) {
this.$router.push({ name: 'home' });
} else if (val === true && this.$route.name !== 'listeners') {
this.$router.push({ name: 'listeners' });
}
},
empireVersion: {
handler(val) {
if (val.length > 0) {
if (!semver.satisfies(val.split(' ')[0], '>=3.5.0')) {
this.$toast.error(
'Starkiller 1.4.x is recommended to be used with Empire 3.5.0 or greater.'
+ ' Some features may not work properly.',
{ timeout: 8000 },
);
}
}
},
immediate: true,
},
},
mounted() {
this.$root.$confirm = this.$refs.confirm.open;
if (this.isLoggedIn === false && !this.isLoginPage) {
this.$router.push({ name: 'home' });
} else if (this.isLoggedIn === true && this.$route.name === 'home') {
this.$router.push({ name: 'listeners' });
}
},
methods: {
versionSatisfies(version) {
return semver.satisfies(this.empireVersion.split(' ')[0], version);
},
},
};
</script>
<style lang="scss">
@import 'app.scss';
@import '../node_modules/@fortawesome/fontawesome-free/css/all.css';
@import '../node_modules/typeface-roboto/index.css';
#app {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
</style>