Browse Source

chunk loading

master
gsd 1 year ago
parent
commit
4e923e57ee
  1. 2
      src/App.vue
  2. 36
      src/api/PlayerApi.js
  3. 1
      src/api/Stages.js
  4. 3
      src/components/Others/ProfileViewer.vue
  5. 93
      src/components/TabsMenuElements/ProfileView/Components/ProfileContainer.vue
  6. 2
      src/components/TabsMenuElements/ServersView/Components/PlayerExtendedInfo.vue
  7. 4
      src/components/TabsMenuElements/ServersView/Components/ServerFullInfo.vue

2
src/App.vue

@ -209,7 +209,7 @@ a {
.md-menu-content-container {
color: black;
background-color: #e0eddd;
background-color: #ffffff;
border: 3px solid black;
}

36
src/api/PlayerApi.js

@ -1,5 +1,7 @@
import axios from "axios";
export const PLAYER_REQUESTS = "steam_data,lastplay,permition,ban,attached_discord";
export default class PlayerApi {
store = {
permition: null,
@ -9,7 +11,8 @@ export default class PlayerApi {
gametime: {},
lastplay: {},
play_on: null,
donates: []
donates: [],
attached_discords:[]
}
discord = null;
@ -24,25 +27,25 @@ export default class PlayerApi {
}
}
getGametimeTotal(player) {
if (player === undefined) player = this.store;
getGametimeTotal(gametime) {
if (gametime === undefined) gametime = this.store['gametime'];
let t = 0;
for (const srv in player.gametime) {
for (const map_name in player.gametime[srv]) {
t += player.gametime[srv][map_name];
for (const srv in gametime) {
for (const map_name in gametime[srv]) {
t += gametime[srv][map_name];
}
}
return t;
}
getGametime(api, player) {
if (player === undefined) player = this.store;
getGametime(api, gametime) {
if (gametime === undefined) gametime = this.store['gametime'];
let t = [];
let total_on_server = [0];
for (const srv in player.gametime) {
for (const srv in gametime) {
total_on_server = [0];
for (const map_name in player.gametime[srv]) {
total_on_server[0] += player.gametime[srv][map_name];
for (const map_name in gametime[srv]) {
total_on_server[0] += gametime[srv][map_name];
}
t.push([api.getHumanServerName(srv), total_on_server[0]]);
}
@ -62,7 +65,7 @@ export default class PlayerApi {
}
async loadFull() {
return axios.get(`/api/profile/current`)
return axios.get(`/api/profile/current?requests=auth`)
.then(response => {
if (response.status === 200) {
this.store = response.data;
@ -77,10 +80,13 @@ export default class PlayerApi {
async loadThis(value) {
return axios.get(`/api/profile/current?requests=${value}`)
.then(response => {
if (response.status === 200) this.store[value] = response.data[value];
if (response.status === 200) {
this.store = response.data;
this.success_auth = true;
}
})
.catch(() => {
this.store[value] = null;
this.store = null;
});
}
@ -97,7 +103,7 @@ export default class PlayerApi {
async load(stages) {
console.log(`[PlayerAPI] request info`);
stages.add("profile");
if (this.auth('steam')) await this.loadFull();
if (this.auth('steam')) await this.loadThis(PLAYER_REQUESTS);
if (this.auth('discord')) await this.loadDiscord();
stages.remove("profile");
}

1
src/api/Stages.js

@ -17,6 +17,7 @@ export default class Stages {
case 'statistic': return 'молимся за здравия всех...';
case 'vip prices': return 'курс рубля к лаймовой краске...';
case 'vip statistic': return 'переводим деньги на СВО...';
case 'profile': return 'виталик ищет тебя...';
default: return s;
}
}

3
src/components/Others/ProfileViewer.vue

@ -12,6 +12,7 @@
<script>
import ProfileContainer from "@/components/TabsMenuElements/ProfileView/Components/ProfileContainer.vue";
import axios from "axios";
import {PLAYER_REQUESTS} from "@/api/PlayerApi";
export default {
name: "ProfileViewer",
@ -30,7 +31,7 @@ export default {
if (this.steam64.length === 0) return;
this.showProfileDialog = true;
this.loading = true;
axios.get("/api/profile/web?steam64=" + this.steam64).then(response => {
axios.get(`/api/profile/web?steam64=${this.steam64}&requests=${PLAYER_REQUESTS}`).then(response => {
if (response.status === 200) this.player = response.data;
else console.log("not permition");
}).catch((err) => {

93
src/components/TabsMenuElements/ProfileView/Components/ProfileContainer.vue

@ -22,15 +22,18 @@
<p class="profile-text" style="display: inline">Статус {{player['permition']['status']}} : </p>
<p class="profile-text" style="color: green;display: inline" v-if="player['permition']['status'] === 'VIP'"> Куплен</p>
<p class="profile-text" v-else style="color: #fd8846;display: inline">Имеется</p>
<br>
<p class="profile-text" style="display: inline">Дата окончания : </p>
<p class="profile-text" v-if="player['permition']['amount'] === 0" style="display: inline">Навсегда</p>
<p class="profile-text" v-else style="display: inline">{{new Date((player['permition']['u_timestamp'] + player['permition']['amount']) * 1000).toLocaleDateString()}}</p>
</div>
<hr>
<md-menu md-direction="bottom-start" md-size="auto">
<!--GAMETIME-->
<md-button v-on:click="loadingUserTime()" v-if="usertime.loaded === false" class="md-raised" style="color: #131213; font-family: tf2build; background: #fd8846; margin: 0% 0%" md-menu-trigger>{{usertime.loading?'Загрузка':'Статистика по картам'}}</md-button>
<md-menu v-else md-direction="bottom-start" md-size="auto">
<md-button class="md-raised" style="color: #131213; font-family: tf2build; background: #fd8846" md-menu-trigger>Статистика по картам</md-button>
<md-menu-content>
<md-menu-item v-for="g in getPlayerGametime()" :key="g[0]+'g'">{{g[0]}} - {{timeFormat(g[1])}}</md-menu-item>
<md-menu-item v-for="g in usertime.store" :key="g[0]+'g'">{{g[0]}} - {{timeFormat(g[1])}}</md-menu-item>
</md-menu-content>
</md-menu>
<br>
@ -41,17 +44,21 @@
</md-menu-content>
</md-menu>
<br>
<md-menu md-direction="bottom-start" md-size="auto" v-if="player['donates'].length > 0">
<!--DONATES-->
<md-button v-on:click="loadingDonates()" v-if="donates.loaded === false" class="md-raised" style="color: #131213; font-family: tf2build; background: #fd8846; margin: 0% 0%" md-menu-trigger>{{donates.loading?'Загрузка':'Покупки VIP'}}</md-button>
<md-menu v-else md-direction="bottom-start" md-size="auto">
<md-button class="md-raised" style="color: #131213; font-family: tf2build; background: #fd8846" md-menu-trigger>Покупки VIP</md-button>
<md-menu-content>
<md-menu-item v-for="d in player['donates']" :key="d['utime']+'d'">{{new Date(d['utime'] * 1000).toLocaleDateString()}} | {{d['status']}}</md-menu-item>
<md-menu-item v-for="d in donates.store" :key="d['utime']+'d'">{{new Date(d['utime'] * 1000).toLocaleDateString()}} | {{d['status']}}</md-menu-item>
</md-menu-content>
</md-menu>
<br>
<md-menu md-direction="bottom-start" md-size="auto" v-if="false">
<!--BAN LIST-->
<md-button v-on:click="loadingBanList()" v-if="ban_list.loaded === false" class="md-raised" style="color: #131213; font-family: tf2build; background: #fd8846; margin: 0% 0%" md-menu-trigger>{{ban_list.loading?'Загрузка':'История банов'}}</md-button>
<md-menu v-else md-direction="bottom-start" md-size="auto">
<md-button class="md-raised" style="color: #131213; font-family: tf2build; background: #fd8846" md-menu-trigger>История Банов</md-button>
<md-menu-content>
<md-menu-item v-for="d in []" :key="d['utime']+'d'">{{new Date(d['utime'] * 1000).toLocaleDateString()}} | {{d['status']}}</md-menu-item>
<md-menu-item v-for="b in ban_list.store" :key="b['id']+'b'">#{{b['id']}} | {{new Date(b['ban_utime'] * 1000).toLocaleDateString()}} | {{b['ban_length']===0?'Навсегда':`${b['ban_length']} минут`}}</md-menu-item>
</md-menu-content>
</md-menu>
</div>
@ -62,9 +69,9 @@
<p class="profile-text" style="text-align: right; cursor: pointer;" v-if="this.player['play_on'] !== null && 'ip' in this.player['play_on']" v-on:click="showIP()">IP : {{player_ip}}</p>
<p class="profile-text" style="text-align: right" v-if="this.player['play_on'] !== null && 'kills' in this.player['play_on']">Убийств : {{this.player['play_on']['kills']}}</p>
<p class="profile-text" style="text-align: right" v-if="this.player['play_on'] !== null && 'deads' in this.player['play_on']">Смертей : {{this.player['play_on']['deads']}}</p>
<p class="profile-text" style="text-align: right">Наиграно : {{getTotalPlaytime()}}</p>
<p class="profile-text" style="text-align: right; cursor: pointer" v-on:click="loadingUserTime()">Наиграно : {{usertime.total}}</p>
<div style="justify-content: right; display: flex">
<DiscordSvg :h="'10%'" :w="'40'" style="margin-left: 5%"/>
<DiscordSvg :h="'10%'" :w="'40'" style="margin-left: 5%" v-if="this.player['attached_discords'].filter(v => v['active'] === 1).length>0" :url="`https://discord.com/channels/@me/${this.player['attached_discords'].filter(v => v['active'] === 1)[0]['discord_id']}`"/>
<SteamSvg :h="'10%'" :w="'40'" style="margin-left: 5%" :url="this.player['steamids']['community_url']"/>
</div>
</div>
@ -90,7 +97,23 @@ export default {
},
},
data: () => ({
player_ip: "Показать"
player_ip: "Показать",
donates: {
loading: false,
loaded: false,
store: []
},
ban_list: {
loading: false,
loaded: false,
store: []
},
usertime: {
loading: false,
loaded: false,
store: [],
total: "Показать"
}
}),
methods: {
getAvatar() {
@ -100,15 +123,9 @@ export default {
return require('@/assets/profile-user.svg');
}
},
getPlayerGametime() {
return this.$API.player.getGametime(this.$API, this.player);
},
timeFormat(seconds) {
return this.$API.UNIX2FACTI_TIME(seconds);
},
getTotalPlaytime() {
return this.timeFormat(this.$API.player.getGametimeTotal(this.player));
},
getLastPlay() {
return this.$API.player.getLastplayList(this.player);
},
@ -127,6 +144,52 @@ export default {
}).catch(() => {
this.player_ip = "хаха нет";
})
},
loadingDonates(){
if (this.donates.loading) return;
this.donates.loading = true;
axios.get(`api/profile/web?steam64=${this.player['steamids']['steam64']}&requests=donates`)
.then(response => {
this.donates.store = response.data['donates'];
this.donates.loaded = true;
if (this.donates.store.length === 0) {
this.donates.store.push({"utime":Date.now()/1000, "status":"Пока тут пусто"})
}
})
.catch(() => this.donates.loaded = false)
.finally(() => this.donates.loading = false)
},
loadingBanList(){
if (this.ban_list.loading || this.ban_list.loaded) return;
this.ban_list.loading = true;
axios.get(`api/profile/web?steam64=${this.player['steamids']['steam64']}&requests=ban_list`)
.then(response => {
this.ban_list.store = response.data['ban_list'];
this.ban_list.loaded = true;
if (this.ban_list.store.length === 0) {
this.ban_list.store.push({"ban_utime":Date.now()/1000, "id":"Пока тут пусто, надеюсь", "ban_length":0})
}
})
.catch(() => this.ban_list.loaded = false)
.finally(() => this.ban_list.loading = false)
},
loadingUserTime(){
if (this.usertime.loading || this.usertime.loaded) return;
this.usertime.loading = true;
this.usertime.total = "считаем сколько";
axios.get(`api/profile/web?steam64=${this.player['steamids']['steam64']}&requests=usertime`)
.then(response => {
this.usertime.store = this.$API.player.getGametime(this.$API, response.data['gametime']);
this.usertime.total = this.timeFormat(this.$API.player.getGametimeTotal(response.data['gametime']));
this.usertime.loaded = true;
if (this.usertime.store.length === 0) {
this.usertime.store.push(["Не играл ни где", 0]);
this.usertime.total = "отсутствует";
}
})
.catch(() => this.usertime.loaded = false)
.finally(() => this.usertime.loading = false)
}
}
}

2
src/components/TabsMenuElements/ServersView/Components/PlayerExtendedInfo.vue

@ -33,7 +33,7 @@
<md-button v-if="showPlayerDialog && this.$API.admin.permition.kick" class="md-raised" style="color: #131213; font-family: tf2build; background: darkcyan">кикнуть</md-button>
<md-button v-if="showPlayerDialog && this.$API.admin.permition.ban" class="md-raised" style="color: #131213; font-family: tf2build; background: brown">забанить</md-button>
<md-button v-if="showPlayerDialog && this.$API.admin.permition.mute" style="color: #131213; font-family: tf2build; background: lightgreen">замьютить</md-button>
<md-button v-if="showPlayerDialog && this.$API.admin.permition.mute" style="color: #131213; font-family: tf2build; background: #fdecc1" v-on:click="showProfile()">информация</md-button>
<md-button v-if="showPlayerDialog && this.$API.player.success_auth" style="color: #131213; font-family: tf2build; background: #fdecc1" v-on:click="showProfile()">информация</md-button>
</div>
</div>
</div>

4
src/components/TabsMenuElements/ServersView/Components/ServerFullInfo.vue

@ -36,10 +36,10 @@
</div>
<hr width="30%">
<h3 v-if="serverData['player_count'] < 1" style="text-align: center; line-height: 1em">На сервере пусто, заходи с друзьями...</h3>
<div v-else>
<div>
<h3 style="text-align: center" class="sfi-current-player">Сейчас играет {{serverData['player_count']}}/{{serverData['max_players']}}</h3>
<hr width="30%">
<table style="margin-left: auto; margin-right: auto; height: 20em; padding-left: 10%; padding-right: 10%; padding-bottom: 5%">
<table v-if="serverData['players'].length > 0" style="margin-left: auto; margin-right: auto; height: 20em; padding-left: 10%; padding-right: 10%; padding-bottom: 5%">
<thead>
<tr>
<th style="text-align: left; font-family: tf2secondary; font-size: 2em; color: #131213" class="server-table-padding">Имя</th>

Loading…
Cancel
Save