Модели плюс 38_доделка
This commit is contained in:
1 parent
7268f1ea70
commit
71717a708c
11 files changed
+480
-309
No files matched your search
@@ -5,7 +5,9 @@ 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 ical from 'ical.js'
|
||||
|
||||
|
||||
export function formatComa(date) {
|
||||
@@ -92,3 +94,54 @@ export function pagecounter(){
|
||||
return process.env.NODE_ENV == 'development'?true:false
|
||||
}
|
||||
|
||||
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 comp = new ical.Component(jcalData)
|
||||
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 }
|
||||
// }
|
||||
Reference in new issue
Block a user