diff --git a/package-lock.json b/package-lock.json index 5565e6c..89fc311 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,10 @@ "dependencies": { "axios": "^1.5.1", "core-js": "^3.8.3", + "leaflet": "^1.9.4", "vue": "^2.6.14", - "vue-material": "^1.0.0-beta-16" + "vue-material": "^1.0.0-beta-16", + "vue2-leaflet": "^2.7.1" }, "devDependencies": { "@babel/core": "^7.12.16", @@ -2236,6 +2238,12 @@ "@types/send": "*" } }, + "node_modules/@types/geojson": { + "version": "7946.0.13", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.13.tgz", + "integrity": "sha512-bmrNrgKMOhM3WsafmbGmC+6dsF2Z308vLFsQ3a/bT8X8Sv5clVYpPars/UPq+sAaJP+5OoLAYgwbkS5QEJdLUQ==", + "peer": true + }, "node_modules/@types/html-minifier-terser": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz", @@ -2263,6 +2271,15 @@ "integrity": "sha512-RbSSoHliUbnXj3ny0CNFOoxrIDV6SUGyStHsvDqosw6CkdPV8TtWGlfecuK4ToyMEAql6pzNxgCFKanovUzlgQ==", "dev": true }, + "node_modules/@types/leaflet": { + "version": "1.9.8", + "resolved": "https://registry.npmjs.org/@types/leaflet/-/leaflet-1.9.8.tgz", + "integrity": "sha512-EXdsL4EhoUtGm2GC2ZYtXn+Fzc6pluVgagvo2VC1RHWToLGlTRwVYoDpqS/7QXa01rmDyBjJk3Catpf60VMkwg==", + "peer": true, + "dependencies": { + "@types/geojson": "*" + } + }, "node_modules/@types/mime": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.3.tgz", @@ -7249,6 +7266,11 @@ "launch-editor": "^2.6.1" } }, + "node_modules/leaflet": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.9.4.tgz", + "integrity": "sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==" + }, "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -11036,6 +11058,16 @@ "vue": "^2.6.10" } }, + "node_modules/vue2-leaflet": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/vue2-leaflet/-/vue2-leaflet-2.7.1.tgz", + "integrity": "sha512-K7HOlzRhjt3Z7+IvTqEavIBRbmCwSZSCVUlz9u4Rc+3xGCLsHKz4TAL4diAmfHElCQdPPVdZdJk8wPUt2fu6WQ==", + "peerDependencies": { + "@types/leaflet": "^1.5.7", + "leaflet": "^1.3.4", + "vue": "^2.5.17" + } + }, "node_modules/watchpack": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", diff --git a/package.json b/package.json index 744607e..c5e5459 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,10 @@ "dependencies": { "axios": "^1.5.1", "core-js": "^3.8.3", + "leaflet": "^1.9.4", "vue": "^2.6.14", - "vue-material": "^1.0.0-beta-16" + "vue-material": "^1.0.0-beta-16", + "vue2-leaflet": "^2.7.1" }, "devDependencies": { "@babel/core": "^7.12.16", diff --git a/src/App.vue b/src/App.vue index db4a16e..d7578e6 100644 --- a/src/App.vue +++ b/src/App.vue @@ -12,6 +12,8 @@ import Vue from "vue"; //import 'vue-material/dist/theme/default.css' import 'vue-material/dist/vue-material.min.css' +import 'leaflet/dist/leaflet.css'; + import MdTabs from "vue-material/dist/components/MdTabs"; import MdIcon from "vue-material/dist/components/MdIcon"; import MdCard from "vue-material/dist/components/MdCard"; diff --git a/src/api/GlobalApi.js b/src/api/GlobalApi.js index 9a12d9e..f18ad3a 100644 --- a/src/api/GlobalApi.js +++ b/src/api/GlobalApi.js @@ -45,6 +45,15 @@ export default class GlobalApi { document.title = "Факты 13"; } + human_name_impl(player_count, naming){ + let number = Math.abs(player_count) % 100; + let number_post = number % 10; + if (number > 10 && number < 20) { return naming[2]; } + if (number_post > 1 && number_post < 5) { return naming[1]; } + if (number_post === 1) { return naming[0] } + return naming[2]; + } + getHumanServerName(server) { for (const mode in this.stats['servers']) { for (const srv in this.stats['servers'][mode]) { diff --git a/src/components/ActionDialogs/WorldwideMap.vue b/src/components/ActionDialogs/WorldwideMap.vue new file mode 100644 index 0000000..4ace322 --- /dev/null +++ b/src/components/ActionDialogs/WorldwideMap.vue @@ -0,0 +1,80 @@ + + + + + + + {{srv['name']}} + {{srv['name']}}{{human_name_impl(srv['player_count'], srv['naming'])}}Подключиться + + + {{srv['name']}} + {{srv['name']}}{{human_name_impl(srv['player_count'], srv['naming'])}}Подключиться + + + {{srv['name']}} + {{srv['name']}}{{human_name_impl(srv['player_count'], srv['naming'])}} + + + Закрыть + + + + + + + + \ No newline at end of file diff --git a/src/components/TabsMenuElements/ServersView/Components/ServerFullInfo.vue b/src/components/TabsMenuElements/ServersView/Components/ServerFullInfo.vue index c991198..1458276 100644 --- a/src/components/TabsMenuElements/ServersView/Components/ServerFullInfo.vue +++ b/src/components/TabsMenuElements/ServersView/Components/ServerFullInfo.vue @@ -1,10 +1,10 @@ - + - {{serverData['name']}} + {{serverInfo['name']}} X @@ -12,15 +12,15 @@ - + - {{serverData['description']}} + {{serverInfo['description']}} - Чат сервера + Чат сервера | - Топ убийств + Топ убийств | - Топ смертей + Топ смертей @@ -28,9 +28,9 @@ Подключиться - {{serverData['address']}} + {{serverInfo['address']}} - + Workshop by Пельмень @@ -42,9 +42,9 @@ - На сервере пусто, заходи с друзьями... + На сервере пусто, заходи с друзьями... - Сейчас играет {{serverData['player_count']}}/{{serverData['max_players']}} + Сейчас играет {{serverInfo['player_count']}}/{{serverInfo['max_players']}} @@ -81,11 +81,13 @@ export default { showServerDialog: false, expandPlayers: false, players: [{score:0, name:"", duration:"", sec:0}], - selected_player: null + selected_player: null, + serverInfo: null }), methods: { - openFIF() { - this.players = this.serverData['players']; + openFIF(data) { + this.serverInfo = data === undefined ? this.serverData : data; + this.players = this.serverInfo['players']; this.players.forEach(p => p.sec = p.duration.split(':').reduce((acc,time) => (60 * acc) + +time)); this.showServerDialog = true; }, @@ -94,15 +96,29 @@ export default { }, onMove(select){ switch (select) { - case 'steam': return window.open(`steam://${this.serverData['address']}`, '_self').focus(); + case 'steam': return window.open(`steam://${this.serverInfo['address']}`, '_self').focus(); case 'workshop': return window.open(this.serverData['workshop'], '_blank').focus(); - case 'fastdl': return window.open(`https://tf2.pblr-nyk.pro/tf/maps/${this.serverData['map']}.bsp.bz2`, '_blank').focus(); + case 'fastdl': return window.open(`https://tf2.pblr-nyk.pro/tf/maps/${this.serverInfo['map']}.bsp.bz2`, '_blank').focus(); } }, openPlayer(item) { this.selected_player = item; this.$refs.pei.showPlayerDialog = true; } + }, + beforeMount() { + if (this.serverData !== null) + this.serverInfo = this.serverData; + else + this.serverInfo = { + 'name':'', + 'description':'', + 'address':'', + 'workshop':'', + 'player_count':'', + 'players':0, + 'max_player':0 + } } } diff --git a/src/components/TabsMenuElements/ServersView/ServersView.vue b/src/components/TabsMenuElements/ServersView/ServersView.vue index 0c26f7c..572cdae 100644 --- a/src/components/TabsMenuElements/ServersView/ServersView.vue +++ b/src/components/TabsMenuElements/ServersView/ServersView.vue @@ -21,6 +21,8 @@ Топ смертей + Карта серверов + где сейчас играют карлики где сейчас никого нет @@ -32,6 +34,7 @@ + @@ -41,9 +44,10 @@ import ServerCard from "@/components/TabsMenuElements/ServersView/Components/Ser import SnackLoader from "@/components/Others/Loader/SnackLoader.vue"; import MessagesDialog from "@/components/ActionDialogs/Tables/MessagesDialog.vue"; import KillDeadTop from "@/components/ActionDialogs/Tables/KillDeadTop.vue"; +import WorldwideMap from "@/components/ActionDialogs/WorldwideMap.vue"; export default { name: 'ServersView', - components: {KillDeadTop, MessagesDialog, SnackLoader, ServerCard, CharacterImage}, + components: {WorldwideMap, KillDeadTop, MessagesDialog, SnackLoader, ServerCard, CharacterImage}, data:() => ({ servers: {'w':[], 'n':[], 'e':[]}, lp_cache: null diff --git a/src/main.js b/src/main.js index a2a9e77..6ff0388 100644 --- a/src/main.js +++ b/src/main.js @@ -6,6 +6,15 @@ Vue.config.productionTip = false Vue.prototype.$API = Vue.observable(new GlobalApi()); Vue.material.locale.dateFormat = 'dd/MM/yyyy'; +import { Icon } from 'leaflet'; + +delete Icon.Default.prototype._getIconUrl; +Icon.Default.mergeOptions({ + iconRetinaUrl: require('leaflet/dist/images/marker-icon-2x.png'), + iconUrl: require('leaflet/dist/images/marker-icon.png'), + shadowUrl: require('leaflet/dist/images/marker-shadow.png'), +}); + new Vue({ render: h => h(App), }).$mount('#app')
{{srv['name']}}{{human_name_impl(srv['player_count'], srv['naming'])}}Подключиться
{{srv['name']}}{{human_name_impl(srv['player_count'], srv['naming'])}}
{{serverData['description']}}
{{serverInfo['description']}}
Чат сервера
|
Топ убийств
Топ смертей
Подключиться
{{serverData['address']}}
{{serverInfo['address']}}
Workshop
by Пельмень