Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | 2x | 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";
import moment from "moment";
import { ref, onMounted } from "vue";
import defaultImage from '@/assets/FNS-logo-xs.png'
export function get_name(namestr) {
let arr = namestr.split("/");
return arr[arr.length - 1];
};
export function formatComa(date) {
return moment(date).format("DD.MM.YYYY");
}
export function formatDash(date) {
return moment(date).format("YYYY-MM-DD");
}
export function formaComaTime(date) {
return moment(date).format("DD.MM.YYYY H:mm");
}
export function formaDashTime(date) {
return moment(date).format("YYYY-MM-DD H:mm");
}
export function checking_for_entry(where, what) {
if (!where.includes(what)) {
where.push(what);
}
}
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) {
return process.env.NODE_ENV == "development"
? defaultImage
: filecheck;
}
export default str;
export function splitname(name) {
return name.familyname + " " + name.name[0] + "." + name.parentname[0] + ".";
}
export function pagecounter() {
// Функция записи посещения страницы сотрудникам.
// В случае, если в роуте присутствует ключ мета и в нем ико - тогда производится запись
const router = useRouter();
if('meta' in router.currentRoute.value && 'ico' in router.currentRoute.value.meta){
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,
fullPath: router.currentRoute.value.fullPath,
ico: router.currentRoute.value.meta.ico,
};
clearAxios.post(`${baseURL}api/watcher/counter/`, postdata).then((result) => {
appStore.countvisitor = result.data;
});
}
}
export function useICalReader(url) {
///
const events = ref([]);
const loadICalFile = async () => {
try {
const response = await fetch(url);
const data = await response.text();
const jcalData = ical.parse(data);
const icalComponent = new ical.Component(jcalData);
const name = icalComponent.getFirstPropertyValue("x-wr-calname");
const events = icalComponent
.getAllSubcomponents("vevent")
.map((vevent) => new ical.Event(vevent));
const calendarEvents = events.map((event) => {
return {
summary: event.summary,
description: event.description,
organizer: event.organizer,
attendee_count: event.attendees.length,
duration_seconds: event.duration.toSeconds(),
start: event.startDate.toJSDate().getTime() / 1000,
end: event.endDate.toJSDate().getTime() / 1000,
location: event.location,
}
})
return {
type: "calendar",
title: name,
calendar: calendarEvents,
}
// const vevents = comp.getAllSubcomponents('vevent')
// const eventsData = vevents.map(vevent => ({
// vevent: vevent,
// summary: vevent.getFirstPropertyValue('summary'),
// start: vevent.getFirstPropertyValue('dtstart'),
// end: vevent.getFirstPropertyValue('dtend')
// }))
// events.value = eventsData
} catch (error) {
console.error(error);
}
};
onMounted(() => {
loadICalFile();
});
return {
events,
};
}
// export function useICalReader(filePath) {
// const icsContent = ref('')
// const fetchICalFile = async () => {
// try {
// const response = await fetch(filePath)
// if (!response.ok) {
// throw new Error('Ошибка при загрузке файла')
// }
// const data = await response.text()
// icsContent.value = data
// } catch (error) {
// console.error('Ошибка при чтении файла:', error)
// }
// }
// return { icsContent, fetchICalFile }
// }
// Функция склонения числительных
export function declOfNum(value, titles) {
const cases = [2, 0, 1, 1, 1, 2];
return titles[(value % 100 > 4 && value % 100 < 20) ? 2 : cases[(value % 10 < 5) ? value % 10 : 5]];
} |