Files
PORTAL_COD2/front/src/components/onlineUsers.vue
T
2023-10-10 12:50:55 +03:00

97 lines
2.2 KiB
Vue

<template>
<div>
<v-list-item v-for="x in onlineuser" v-show=" x!=accountStore.user.login"
:key="x"
:prepend-avatar="checkremote( `${spravURL}${x}.jpg`)"
title="x"
nav
@click="whatuser(x)"
>
<v-dialog
v-model="menuGetUserDialog"
persistent
width="600"
>
{{spravURL}}
<Card-users
:menuGetUserDialog="menuGetUserDialog"
:loging="loging"
@menusClose="menuGetUserDialog=false"
/>
</v-dialog>
</v-list-item>
</div>
</template>
<script>
import { ref,watch } from 'vue'
import { baseWS } from '@/utils/axios-api'
import {useAccountStore} from '@/store/AccountStore'
import { spravURL } from '@/utils/axios-api'
import {checkremote} from '@/utils/universal_functions'
import CardUsers from '@/components/cardUsers.vue'
export default {
components: { CardUsers},
setup(){
const loging = ref('')
const menuGetUserDialog=ref(false)
const wsfuncs={onliner:function(data){
let newset = new Set(data)
onlineuser.value = Array.from(newset)
}}
const accountStore = useAccountStore()
let onlineuser= ref([''])
// const userlinks = ref([])
// const loadlinksUser=async()=>{
// // console.log(`accountStore`, accountStore);
// const res = await clearAxios.get('api/accounts/getuser/?userlogin='+props.loging)
// userlinks.value=res.data
// }
// const gh = () => {
// console.log('hi');
// }
const connect = new WebSocket(baseWS+"ws/watcher/?token="+localStorage.access)
const whatuser=(x)=> {
loging.value = x
menuGetUserDialog.value=true
}
connect.onmessage=(e)=>{
let data = JSON.parse(e.data)
wsfuncs[data['message']['action']](data.message.data)
}
watch(()=>accountStore.cod2user,function(){
// console.log('newValue')
if (!accountStore.cod2user.value){
connect.close()
}
})
return {loging, menuGetUserDialog, onlineuser, checkremote,spravURL, whatuser, accountStore, gh}
}
}
</script>
<style>
</style>