12 changed files with 190 additions and 135 deletions
@ -1,23 +1,27 @@ |
|||||
import axios from "axios"; |
import axios from "axios"; |
||||
|
|
||||
export default { |
export default class AdminApi { |
||||
name: 'AdminApi', |
permition = { |
||||
data: () => ({ |
ban:false, |
||||
allowBan: false |
mute:false, |
||||
}), |
kick:false |
||||
checkAllowBan() { |
} |
||||
return axios.options("/api/admin/ban") |
|
||||
|
async checkPermition(name) { |
||||
|
return axios.options(`/api/admin/${name}`) |
||||
.then(response => { |
.then(response => { |
||||
return response.status === 200; |
if (response.status === 200) this.permition[name] = true; |
||||
}) |
}) |
||||
.catch((err) => { |
.catch((err) => { |
||||
return err.response.status === 200 |
if (err.response.status === 200) this.permition[name] = true; |
||||
}); |
}); |
||||
}, |
} |
||||
async serverPrefetch() { |
|
||||
this.checkAllowBan().then((r) => { |
async load() { |
||||
console.log("[AdminApi] allow ban: " + r); |
console.log(`[AdminAPI] request permissions`); |
||||
this.allowBan = true; |
if (document.cookie.indexOf("steam64=") === -1) return; |
||||
}) |
await this.checkPermition('ban') |
||||
|
await this.checkPermition('mute') |
||||
|
await this.checkPermition('kick') |
||||
} |
} |
||||
} |
} |
@ -0,0 +1,80 @@ |
|||||
|
import axios from "axios"; |
||||
|
import AdminApi from "@/api/AdminApi"; |
||||
|
|
||||
|
export default class GlobalApi { |
||||
|
stats = { |
||||
|
'statistic':null, |
||||
|
'servers': null, |
||||
|
'uniq': null |
||||
|
} |
||||
|
loading = false; |
||||
|
|
||||
|
admin = new AdminApi() |
||||
|
|
||||
|
constructor() { |
||||
|
} |
||||
|
|
||||
|
async fillThis(value) { |
||||
|
console.log(`[API] load: ${value}`); |
||||
|
return await axios.get(`/api/stats?filter=${value}`) |
||||
|
.then(response => response.data) |
||||
|
.then(response => { |
||||
|
this.stats[value] = response[value]; |
||||
|
}) |
||||
|
.catch(err => { |
||||
|
console.log(`[API] cannot request ${value}, err: ${err}`); |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
async fillServers() { |
||||
|
console.log(`[API] load: servers`); |
||||
|
return axios.get("/api/stats?filter=servers") |
||||
|
.then(response => response.data['servers']) |
||||
|
.then(response => { |
||||
|
let srvs = { |
||||
|
'w':[], |
||||
|
"e":[], |
||||
|
'n':[] |
||||
|
}; |
||||
|
for (let srv in response) { |
||||
|
if (response[srv]['status'] == false) srvs.n.push(response[srv]); |
||||
|
else if (response[srv]['player_count'] > 0) srvs.w.push(response[srv]); |
||||
|
else srvs.e.push(response[srv]); |
||||
|
} |
||||
|
this.stats['servers'] = srvs; |
||||
|
}) |
||||
|
.catch(err => { |
||||
|
console.log(`[API] cannot request servers, err: ${err}`); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
async load() { |
||||
|
this.loading = true; |
||||
|
await this.fillThis('statistic'); |
||||
|
await this.fillThis('uniq'); |
||||
|
await this.fillServers(); |
||||
|
await this.admin.load(); |
||||
|
this.loading = false; |
||||
|
} |
||||
|
|
||||
|
getRandomBackground() { |
||||
|
const backgrounds = [ |
||||
|
require('../assets/images/backgrounds/1.png'), |
||||
|
require('../assets/images/backgrounds/2.png'), |
||||
|
require('../assets/images/backgrounds/3.png'), |
||||
|
require('../assets/images/backgrounds/4.png') |
||||
|
]; |
||||
|
return backgrounds[Math.floor(Math.random() * backgrounds.length)]; |
||||
|
} |
||||
|
|
||||
|
getRules(){ |
||||
|
return [ |
||||
|
[{"name":"Читы", "about":"Бан навсегда сука", "image": require('@/assets/images/rules/cheats.jpg')}, |
||||
|
{"name":"Реклама серверов", "about":"Кроме мге, бан навсегда сука", "image": require('@/assets/images/rules/ads.jpg')}, |
||||
|
{"name":"Багоюз", "about":"Пиздец тебе, бан навсегда", "image": require('@/assets/images/rules/bug_use.jpg')}], |
||||
|
[{"name":"Абуз команды !mir", "about":"Блокировка дверей, открытие спавна и т.д", "image":require('@/assets/images/rules/abuse.jpg')}, |
||||
|
{"name":"Абуз випки на сервере", "about":"Модеры сам решат как и за что", "image":require('@/assets/images/rules/abuse_vip.jpg')}, |
||||
|
{"name":"Делай короче чё хочешь", "about":":troll_face:", "image":require('@/assets/images/rules/make_everyone.jpg')}] |
||||
|
]; |
||||
|
} |
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
<template> |
||||
|
<md-snackbar :md-position="position" :md-active.sync="loading" md-persistent> |
||||
|
<p>{{s_text}}</p> |
||||
|
</md-snackbar> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default { |
||||
|
name: 'SnackLoader', |
||||
|
data: () => ({ |
||||
|
loading: false |
||||
|
}), |
||||
|
props: { |
||||
|
position: { |
||||
|
type: String, |
||||
|
default: 'left' |
||||
|
}, |
||||
|
s_text: { |
||||
|
type: String |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
setLoading(b) { |
||||
|
this.loading = b; |
||||
|
}} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style> |
||||
|
.md-snackbar { |
||||
|
background-color: #131213; |
||||
|
} |
||||
|
</style> |
@ -1,81 +0,0 @@ |
|||||
import axios from "axios"; |
|
||||
|
|
||||
export default { |
|
||||
name: "PublicMethods", |
|
||||
methods: {}, |
|
||||
getBackground(){ |
|
||||
const backgrounds = [ |
|
||||
require('../assets/images/backgrounds/1.png'), |
|
||||
require('../assets/images/backgrounds/2.png'), |
|
||||
require('../assets/images/backgrounds/3.png'), |
|
||||
require('../assets/images/backgrounds/4.png') |
|
||||
]; |
|
||||
return backgrounds[Math.floor(Math.random()*backgrounds.length)]; |
|
||||
}, |
|
||||
getApi(){ |
|
||||
console.log("[PublicMethods] request api/stats"); |
|
||||
return axios.get("/api/stats") |
|
||||
.then(response => response.data) |
|
||||
.then(response => { |
|
||||
console.log("[PublicMethods] success get api/stats"); |
|
||||
console.log(response); |
|
||||
return response; |
|
||||
}) |
|
||||
.catch(err => { |
|
||||
console.log(`[PublicMethods] cannot request api/stats, err: ${err}`); |
|
||||
}) |
|
||||
}, |
|
||||
getStatistics(){ |
|
||||
console.log("[PublicMethods] request api/stats/statistics"); |
|
||||
return axios.get("/api/stats?filter=statistic") |
|
||||
.then(response => response.data) |
|
||||
.then(response => { |
|
||||
return response; |
|
||||
}) |
|
||||
.catch(err => { |
|
||||
console.log(`[PublicMethods] cannot request api/stats/statistic, err: ${err}`); |
|
||||
}) |
|
||||
}, |
|
||||
getServers(){ |
|
||||
console.log("[PublicMethods] request api/stats/servers"); |
|
||||
return axios.get("/api/stats?filter=servers") |
|
||||
.then(response => response.data['servers']) |
|
||||
.then(response => { |
|
||||
let srvs = { |
|
||||
'w':[], |
|
||||
"e":[], |
|
||||
'n':[] |
|
||||
}; |
|
||||
for (let srv in response) { |
|
||||
if (response[srv]['status'] == false) srvs.n.push(response[srv]); |
|
||||
else if (response[srv]['player_count'] > 0) srvs.w.push(response[srv]); |
|
||||
else srvs.e.push(response[srv]); |
|
||||
} |
|
||||
return srvs; |
|
||||
}) |
|
||||
.catch(err => { |
|
||||
console.log(`[PublicMethods] cannot request api/stats/statistic, err: ${err}`); |
|
||||
}); |
|
||||
}, |
|
||||
getUniq(){ |
|
||||
console.log("[PublicMethods] request api/stats/uniq"); |
|
||||
return axios.get("/api/stats?filter=uniq") |
|
||||
.then(response => response.data) |
|
||||
.then(response => { |
|
||||
return response; |
|
||||
}) |
|
||||
.catch(err => { |
|
||||
console.log(`[PublicMethods] cannot request api/stats/statistic, err: ${err}`); |
|
||||
}) |
|
||||
}, |
|
||||
getRules(){ |
|
||||
return [ |
|
||||
[{"name":"Читы", "about":"Бан навсегда сука", "image": require('@/assets/images/rules/cheats.jpg')}, |
|
||||
{"name":"Реклама серверов", "about":"Кроме мге, бан навсегда сука", "image": require('@/assets/images/rules/ads.jpg')}, |
|
||||
{"name":"Багоюз", "about":"Пиздец тебе, бан навсегда", "image": require('@/assets/images/rules/bug_use.jpg')}], |
|
||||
[{"name":"Абуз команды !mir", "about":"Блокировка дверей, открытие спавна и т.д", "image":require('@/assets/images/rules/abuse.jpg')}, |
|
||||
{"name":"Абуз випки на сервере", "about":"Модеры сам решат как и за что", "image":require('@/assets/images/rules/abuse_vip.jpg')}, |
|
||||
{"name":"Делай короче чё хочешь", "about":":troll_face:", "image":require('@/assets/images/rules/make_everyone.jpg')}] |
|
||||
]; |
|
||||
} |
|
||||
} |
|
@ -1,8 +1,11 @@ |
|||||
import Vue from 'vue' |
import Vue from 'vue' |
||||
import App from './App.vue' |
import App from './App.vue' |
||||
|
import GlobalApi from './api/GlobalApi' |
||||
|
|
||||
Vue.config.productionTip = false |
Vue.config.productionTip = false |
||||
|
Vue.prototype.$API = new GlobalApi(); |
||||
new Vue({ |
Vue.prototype.$API.load().then(() => { |
||||
render: h => h(App), |
new Vue({ |
||||
}).$mount('#app') |
render: h => h(App), |
||||
|
}).$mount('#app') |
||||
|
}); |
Loading…
Reference in new issue