Skip to content

Commit 81f2793

Browse files
committed
Add auto-router + mod checking
1 parent 40db65a commit 81f2793

14 files changed

+224
-220
lines changed

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
22
"name": "screepsmod-admin-utils-ui",
33
"version": "0.1.1",
4-
"main": "index.js",
54
"scripts": {
65
"serve": "vue-cli-service serve",
76
"build": "vue-cli-service build",
87
"lint": "vue-cli-service lint",
98
"2npm": "publish"
109
},
10+
"main": "index.js",
1111
"dependencies": {
12-
"express": "^4.14.0"
12+
"express": "^4.14.0",
13+
"vue-router-layout": "^0.1.2"
1314
},
1415
"devDependencies": {
1516
"@vue/cli-plugin-babel": "^4.2.0",
@@ -34,6 +35,8 @@
3435
"sass": "^1.25.0",
3536
"sass-loader": "^8.0.2",
3637
"vue": "^2.6.11",
38+
"vue-auto-routing": "^0.4.0",
39+
"vue-cli-plugin-auto-routing": "^0.3.3",
3740
"vue-cli-plugin-axios": "^0.0.4",
3841
"vue-cli-plugin-vuetify": "^2.0.5",
3942
"vue-router": "^3.1.5",

src/App.vue

+1-44
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,5 @@
11
<template>
2-
<v-app app dark>
3-
<v-navigation-drawer
4-
clipped
5-
fixed
6-
app
7-
:value="drawer"
8-
>
9-
<v-list>
10-
<v-list-item
11-
v-for="(item, i) in items"
12-
:key="i"
13-
:to="item.to"
14-
router
15-
exact
16-
>
17-
<v-list-item-action>
18-
<v-icon>{{ item.icon }}</v-icon>
19-
</v-list-item-action>
20-
<v-list-item-content>
21-
<v-list-item-title v-text="item.title" />
22-
</v-list-item-content>
23-
</v-list-item>
24-
</v-list>
25-
</v-navigation-drawer>
26-
<v-app-bar
27-
clipped-left
28-
fixed
29-
app
30-
>
31-
<v-app-bar-nav-icon @click="drawer = !drawer" />
32-
<v-toolbar-title v-text="title" />
33-
<v-spacer />
34-
</v-app-bar>
35-
<v-content>
36-
<v-container fill-height class="ma-2">
37-
<router-view />
38-
</v-container>
39-
</v-content>
40-
<v-footer
41-
app
42-
>
43-
<span>&copy; 2019</span>
44-
</v-footer>
45-
</v-app>
2+
<router-view />
463
</template>
474

485
<script>

src/layouts/default.vue

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<template>
2+
<v-app app dark>
3+
<v-navigation-drawer
4+
clipped
5+
app
6+
v-model="drawer"
7+
>
8+
<v-list>
9+
<v-list-item
10+
v-for="(item, i) in activeMenu"
11+
:key="i"
12+
:to="item.to"
13+
router
14+
exact
15+
>
16+
<v-list-item-action>
17+
<v-icon>{{ item.icon }}</v-icon>
18+
</v-list-item-action>
19+
<v-list-item-content>
20+
<v-list-item-title v-text="item.title" />
21+
</v-list-item-content>
22+
</v-list-item>
23+
</v-list>
24+
</v-navigation-drawer>
25+
<v-app-bar
26+
clipped-left
27+
fixed
28+
app
29+
>
30+
<v-app-bar-nav-icon @click="drawer = !drawer" />
31+
<v-toolbar-title v-text="title" />
32+
<v-spacer />
33+
</v-app-bar>
34+
<v-content>
35+
<v-container fill-height class="ma-2">
36+
<router-view />
37+
</v-container>
38+
</v-content>
39+
<v-footer
40+
app
41+
>
42+
<span>&copy; 2019</span>
43+
</v-footer>
44+
</v-app>
45+
</template>
46+
47+
<script>
48+
import { mapState } from 'vuex'
49+
50+
export default {
51+
data () {
52+
return {
53+
mini: true,
54+
menu: [
55+
{
56+
icon: 'mdi-home',
57+
title: 'Dashboard',
58+
to: '/'
59+
},
60+
{
61+
icon: 'mdi-format-list-numbered',
62+
title: 'Leaderboards',
63+
to: '/leaderboards'
64+
},
65+
{
66+
icon: 'mdi-textbox-password',
67+
title: 'Change Password',
68+
to: '/change-password',
69+
mod: 'screepsmod-auth'
70+
}
71+
],
72+
drawer: false,
73+
title: 'Screeps Server Dashboard'
74+
}
75+
},
76+
computed: {
77+
...mapState(['mods']),
78+
activeMenu () {
79+
return this.menu.filter(m => !m.mod || this.mods.includes(m.mod))
80+
}
81+
}
82+
}
83+
</script>
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/router.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import Vue from 'vue'
2+
import Router from 'vue-router'
3+
import routes from 'vue-auto-routing'
4+
import { createRouterLayout } from 'vue-router-layout'
5+
6+
Vue.use(Router)
7+
8+
const RouterLayout = createRouterLayout(layout => {
9+
return import('@/layouts/' + layout + '.vue')
10+
})
11+
12+
export default new Router({
13+
mode: 'history',
14+
base: process.env.BASE_URL,
15+
routes: [
16+
{
17+
path: '/',
18+
component: RouterLayout,
19+
children: routes
20+
}
21+
]
22+
})

src/router/index.js

-44
This file was deleted.

src/store/index.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ Vue.use(Vuex)
66

77
const store = new Vuex.Store({
88
state: {
9-
config: {},
10-
mods: [],
9+
mods: [
10+
'screepsmod-mongo',
11+
'screepsmod-auth',
12+
'screepsmod-admin-utils',
13+
'screepsmod-map-tool'
14+
],
1115
stats: {}
1216
},
1317
mutations: {
14-
SET_CONFIG (state, config) {
15-
state.config = config
16-
},
1718
SET_MODS (state, mods) {
1819
state.mods = mods
1920
},
@@ -26,13 +27,9 @@ const store = new Vuex.Store({
2627
const { data } = await axios.get('/stats')
2728
commit('SET_STATS', data)
2829
},
29-
async getConfig ({ commit }) {
30-
const { data } = await axios.get('/api/config')
31-
commit('SET_CONFIG', data)
32-
},
33-
async getAvailableMods ({ commit }) {
34-
const { data: { objects } } = await axios.get('http://registry.npmjs.org/-/v1/search?text=screepsmod')
35-
commit('SET_MODS', objects.map(o => o.package))
30+
async fetchMods ({ commit }) {
31+
const { data } = await axios.get('/api/mods')
32+
commit('SET_MODS', data)
3633
}
3734
},
3835
modules: {
@@ -41,5 +38,7 @@ const store = new Vuex.Store({
4138

4239
export default store
4340

41+
store.dispatch('fetchMods')
42+
4443
setInterval(() => store.dispatch('fetchStats'), 5000)
4544
setTimeout(() => store.dispatch('fetchStats'), 100)

src/views/About.vue

-5
This file was deleted.

src/views/Cli.vue

-49
This file was deleted.

src/views/Mods.vue

-53
This file was deleted.

0 commit comments

Comments
 (0)