Files
PORTAL_COD2/front/src/utils/universal_functions.js
T
2023-10-25 15:00:49 +03:00

64 lines
1.6 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){
axiosApiInstance.get(filecheck).then(result => {
console.log(result, '-------------');
}).catch(e=>{
return "https://pixelbox.ru/wp-content/uploads/2021/11/avatar-whatsapp-pixelbox.ru-36.jpg"
})
// let tmp = new Image
// tmp.src=filecheck
// if(tmp.complete){
// return filecheck
// }
// else {return "https://pixelbox.ru/wp-content/uploads/2021/11/avatar-whatsapp-pixelbox.ru-36.jpg"}
}
export default str;
export function pagecounter(){
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})
}