Files
PORTAL_COD2/front/src/utils/universal_functions.js
T
2023-10-02 16:58:22 +03:00

63 lines
1.5 KiB
JavaScript

const str = 'hello';
import {useAccountStore} from '@/store/AccountStore'
import {useAppStore} from '@/store/app'
import { baseURL } from '@/utils/axios-api'
import { axiosApiInstance, clearAxios } from '@/utils/axios-api'
import { useRouter } from 'vue-router'
export function getfromserver(path, reactive){
try{
axiosApiInstance.get(path).then(result => {
reactive.value = result.data})}
catch(e){
console.log(e);
}
}
export function getfromserverfree(path, reactive){
try{
clearAxios.get(path).then(result => {
reactive.value = result.data})}
catch(e){
console.log(e);
}
}
export function checkremote(filecheck){
let tmp = new Image
tmp.src=filecheck
if(tmp.complete){
return filecheck
}
else {return "https://avatars.mds.yandex.net/i?id=e581fbd83b62938eb98e4d1110c176eabdb19946-9181179-images-thumbs&n=13"}
}
export default str;
export function pagecounter(){
console.log('Загружаю данные для циферок по количеству');
const router = useRouter()
const accountStore = useAccountStore()
const appStore = useAppStore()
let postdata = {user__id: "user" in accountStore && "id" in accountStore.user? accountStore.user.id: null, page: router.currentRoute.value.meta.title}
clearAxios.post(`${baseURL}api/watcher/counter/`, postdata)
.then(result => {
appStore.countvisitor = result.data})
}