Newer
Older

Дмитрий Малюгин
committed
<script setup lang="ts">
import { useFileDialog, useWindowSize } from '@vueuse/core';
import { useAuthorizationStore } from '@/app/stores/authorization';
import { useFilesWebsocketStore } from '@/app/stores/filesWebsocket';
import { useDataStore } from '@/app/stores/data';
import cookies from '@/app/plugins/Cookie';

Дмитрий Малюгин
committed

Дмитрий Малюгин
committed
accept: 'image/*',
reset: true
const dataStore = useDataStore();
const themeColor: string = cookies.get('favorite_color');
const isMenu = ref(false);
const userNickName = computed(() => authorizationStore.userNickName);
const entitiesCount = computed(() => dataStore.entities.length);
if (!files[0]) return;
const url = URL.createObjectURL(files[0]);
image.src = url;
image.onload = async () => {
const filesWebsocketStore = useFilesWebsocketStore();
filesWebsocketStore.saveImageUrl(url);
const response = await fetch(url);
const blob = await response.blob();
const { width: windowWidth } = useWindowSize();
const maxWidth = windowWidth.value - 128;
image.height = Math.floor((maxWidth / image.width) * image.height);
if (image.height > maxHeight) {
image.width = Math.floor((maxHeight / image.height) * image.width);
image.height = maxHeight;
}
entity_order: entitiesCount.value + 1,
entity_position: 'left',
entity_title_position: 'center',
image_width: image.width,
image_height: image.height,
image_scale: '1'
});
};
};
onChange((files) => {
if (files && files?.length > 0) {
addImage(files);
}
});

Дмитрий Малюгин
committed
const speedDialItems = ref([
{
label: 'Divider',
textStyle: 'bold',
theme: 'blue',
onClick: () => {
emit('createEntity', {
entity_type: 'divider',
entity_order: entitiesCount.value + 1,
divider_height: 1,
divider_type: 'solid'
});
}
},

Дмитрий Малюгин
committed
{
textStyle: 'bold',
theme: 'green',
onClick: () => {
entity_type: 'paragraph',
entity_order: entitiesCount.value + 1,
text: '',
paragraph_size: 'full',
font_size: '24',
entity_position: 'left'

Дмитрий Малюгин
committed
});
}
},
{
label: 'Image',
textStyle: 'bold',
theme: 'orange',
onClick: () => uploadFile()

Дмитрий Малюгин
committed
},
{
label: 'Table',
textStyle: 'bold',
theme: 'red',
onClick: () => {
entity_order: entitiesCount.value + 1,

Дмитрий Малюгин
committed
{
name: 'Name',
type: 'text'
},
{
name: 'Description',
type: 'text'
},
{
name: 'Status',
type: 'status'
}
]
});
}
}
]);
</script>
<template>
<MenuDial v-model:isActive="isMenu" :items="speedDialItems" size="extraLarge" :theme="themeColor">
<template #1IconAfter>
<HorizontalLineIcon color="white" size="25" />
</template>
<template #2IconAfter>
<ParagraphIcon color="white" size="25" />
</template>
<template #3IconAfter>
<ImageIcon color="white" size="25" />
</template>
<template #4IconAfter>
<TableIcon color="white" size="30" />

Дмитрий Малюгин
committed
</template>
</MenuDial>

Дмитрий Малюгин
committed
</template>
<style scoped></style>