diff --git a/src/app/components.d.ts b/src/app/components.d.ts index 053d35139dc98b727a9a7a7354c0732cd08813c3..df565292d4f5081e553a4cccdba79edd930c4ba8 100644 --- a/src/app/components.d.ts +++ b/src/app/components.d.ts @@ -17,9 +17,11 @@ declare module 'vue' { CropImageModal: typeof import('./../modules/CropImageModal.vue')['default'] Dialog: typeof import('primevue/dialog')['default'] Divider: typeof import('primevue/divider')['default'] + DividerItem: typeof import('./../modules/entities/DividerItem.vue')['default'] + DividerMenu: typeof import('./../modules/entities/menu/DividerMenu.vue')['default'] Drawer: typeof import('primevue/drawer')['default'] - EntitiesList: typeof import('./../modules/EntitiesList.vue')['default'] - EntityItem: typeof import('./../modules/EntityItem.vue')['default'] + EntitiesList: typeof import('./../modules/entities/EntitiesList.vue')['default'] + EntityItem: typeof import('./../modules/entities/EntityItem.vue')['default'] EntityTitle: typeof import('./../components/entities/share/EntityTitle.vue')['default'] HomePage: typeof import('./../pages/HomePage.vue')['default'] ImageItem: typeof import('./../modules/entities/ImageItem.vue')['default'] @@ -28,18 +30,20 @@ declare module 'vue' { ImageSizeMenu: typeof import('./../components/entities/image/ImageSizeMenu.vue')['default'] ImageStateMenu: typeof import('./../components/entities/image/ImageStateMenu.vue')['default'] LogoAndLabel: typeof import('./../components/LogoAndLabel.vue')['default'] + page: typeof import('./../modules/Home page.vue')['default'] PageBackgroundMenu: typeof import('./../modules/PageBackgroundMenu.vue')['default'] + PageHeader: typeof import('./../modules/PageHeader.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] SheetPage: typeof import('./../pages/[uuid]/SheetPage.vue')['default'] SpeedDial: typeof import('primevue/speeddial')['default'] - Splitter: typeof import('primevue/splitter')['default'] - SplitterPanel: typeof import('primevue/splitterpanel')['default'] + TelegramSection: typeof import('./../modules/TelegramSection.vue')['default'] TextFontMenu: typeof import('./../components/entities/share/TextFontMenu.vue')['default'] TextItem: typeof import('./../modules/entities/TextItem.vue')['default'] TextMenu: typeof import('./../modules/entities/menu/TextMenu.vue')['default'] TextPositionMenu: typeof import('./../components/entities/text/TextPositionMenu.vue')['default'] TextStateMenu: typeof import('./../components/entities/text/TextStateMenu.vue')['default'] + ToggleSwitch: typeof import('primevue/toggleswitch')['default'] Tree: typeof import('primevue/tree')['default'] UserInfoHeaderWithSettings: typeof import('./../components/UserInfoHeaderWithSettings.vue')['default'] } diff --git a/src/app/helpers/images.ts b/src/app/helpers/images.ts index 2372f5f92e96bbf7542e4d3cd865b6b28a2666c8..a32ed3dabf23f16d76570cf923b6b0d41604f32f 100644 --- a/src/app/helpers/images.ts +++ b/src/app/helpers/images.ts @@ -8,7 +8,7 @@ export const addUrlsToImageEntities = (entities: IEntity[]) => { const filesBuffer = filesWebsocketStore.filesBuffer; let index = 0; const entitiesToReturn = entities.map((entity: IEntity) => { - if (!entity.image_width) return entity; + if (!entity?.image_width) return entity; if (entity.imageUrl) return entity; if (filesWebsocketStore.imageUrl) { // редактирование сущности изображения @@ -26,7 +26,7 @@ export const addUrlsToImageEntities = (entities: IEntity[]) => { }; export const checkIsImage = (entity: IEntity) => { - if (!entity.image_width) { + if (!entity?.image_width) { return entity; } const entityToReturn = { ...entity }; diff --git a/src/app/helpers/index.ts b/src/app/helpers/index.ts index 252d449dadb7a715ee7151633fba19996323f007..5bb4a9d0e8ec18bdf214e15982eecd1c8826be0e 100644 --- a/src/app/helpers/index.ts +++ b/src/app/helpers/index.ts @@ -120,25 +120,25 @@ export const getImageSpeedDialSizeBiggerLabelsToRemove = (entity: IImage) => { } if ( initialImageWidth >= 960 || - initialImageHeight >= 960 || + initialImageHeight >= 560 || (initialImageWidth >= 640 && entity.text_position) ) { elementsLabelsToRemove.push('x1.25'); if ( initialImageWidth >= 800 || - initialImageHeight >= 800 || + initialImageHeight >= 467 || (initialImageWidth >= 533 && entity.text_position) ) { elementsLabelsToRemove.push('x1.5'); if ( initialImageWidth >= 685 || - initialImageHeight >= 685 || + initialImageHeight >= 400 || (initialImageWidth >= 457 && entity.text_position) ) { elementsLabelsToRemove.push('x1.75'); if ( initialImageWidth >= 600 || - initialImageHeight >= 600 || + initialImageHeight >= 350 || (initialImageWidth >= 400 && entity.text_position) ) { elementsLabelsToRemove.push('x2'); diff --git a/src/app/interfaces/entities.ts b/src/app/interfaces/entities.ts index 0767db1ca62f04565c4d7a52b3faa31126f43f12..b367311ad87eb2e26f7fa75050846d150157d3aa 100644 --- a/src/app/interfaces/entities.ts +++ b/src/app/interfaces/entities.ts @@ -26,6 +26,13 @@ type ITableColumnTypes = | 'rating' | 'knob'; +export interface IDivider extends IEntity { + entity_type: 'divider'; + entity_uuid: string; + divider_height: number; + divider_type: 'solid' | 'dashed' | 'dotted'; +} + export interface IText extends IEntity { entity_type: 'text'; entity_uuid: string; diff --git a/src/app/interfaces/environment.ts b/src/app/interfaces/environment.ts index c0a1f38281b1cc78fa79cc99d0c2b8a439f3b171..e307c3dc36d972708f365b6250ae1aaaf7dad480 100644 --- a/src/app/interfaces/environment.ts +++ b/src/app/interfaces/environment.ts @@ -13,6 +13,8 @@ export interface IEntity { user_nick_name?: string; entity_order?: number; entity_type: string; + divider_height?: number; + divider_type?: 'solid' | 'dashed' | 'dotted'; title?: string | null; text?: string | null; font_size?: string | null; diff --git a/src/app/main.ts b/src/app/main.ts index b61cec809f84be9d41071d18c73f86a17541de5e..dd3a5c7f283145f238d02269ec0f64910415cc5f 100644 --- a/src/app/main.ts +++ b/src/app/main.ts @@ -6,14 +6,34 @@ import PrimeVue from 'primevue/config'; import App from './App.vue'; import router from './router'; import Aura from '@primevue/themes/aura'; +import { definePreset } from '@primevue/themes'; const app = createApp(App); - +const theme = 'sky'; +const MyPreset = definePreset(Aura, { + semantic: { + primary: { + 50: `{${theme}.50}`, + 100: `{${theme}.100}`, + 200: `{${theme}.200}`, + 300: `{${theme}.300}`, + 400: `{${theme}.400}`, + 500: `{${theme}.500}`, + 600: `{${theme}.600}`, + 700: `{${theme}.700}`, + 800: `{${theme}.800}`, + 900: `{${theme}.900}`, + 950: `{${theme}.950}` + } + } +}); app .use(PrimeVue, { theme: { - preset: Aura, - options: {} + preset: MyPreset, + options: { + // darkModeSelector: '.darkModeToggle' + } } }) .use(createPinia()) diff --git a/src/app/stores/data.ts b/src/app/stores/data.ts index c19d38965f5e4589fc433aab6cc0bc3285193bca..0e3b2e99ba6071d89c9de63bacaf1547b0dcb13d 100644 --- a/src/app/stores/data.ts +++ b/src/app/stores/data.ts @@ -57,6 +57,7 @@ export const useDataStore = defineStore('dataStore', () => { function editHomeEntities(newState: IEntity) { homeEntities.value = newState; + console.log('homeEntities.value', homeEntities.value); } function setHomeEntities(entities: IEntity[]) { diff --git a/src/app/stores/websocket.ts b/src/app/stores/websocket.ts index 6638f7ca530cc35d496d7ce830330bbcd2ed789e..1cc5d245c0f3676ac48a13dab2a84e50c70db469 100644 --- a/src/app/stores/websocket.ts +++ b/src/app/stores/websocket.ts @@ -13,7 +13,7 @@ export const useWebsocketStore = defineStore('websocketStore', () => { const filesBufferLength = computed(() => filesWebsocketStore.filesBuffer.length); const homeEntities = computed(() => dataStore.homeEntities); const imageEntitiesCount = computed( - () => homeEntities.value.filter((entity) => entity.image_width).length + () => homeEntities.value.filter((entity) => entity?.image_width).length ); const socket = ref(); @@ -50,7 +50,7 @@ export const useWebsocketStore = defineStore('websocketStore', () => { } case 'createHomeEntity': { const entities = [...homeEntities.value]; - if (response.data.image_width) { + if (response.data?.image_width) { response.data.imageUrl = filesWebsocketStore.imageUrl; filesWebsocketStore.cleanImageUrl(); } @@ -74,7 +74,7 @@ export const useWebsocketStore = defineStore('websocketStore', () => { let entities = [...homeEntities.value]; entities = entities.map((entity: IEntity) => { if (entity.entity_uuid !== response.data.entity_uuid) return entity; - if (response.data.image_width) { + if (response.data?.image_width) { response.data.imageUrl = filesWebsocketStore.imageUrl; filesWebsocketStore.cleanImageUrl(); } @@ -122,7 +122,9 @@ export const useWebsocketStore = defineStore('websocketStore', () => { watch([filesBufferLength, homeEntities], () => { if ( - (homeEntities.value.length && filesBufferLength.value === imageEntitiesCount.value) || + (homeEntities.value.length && + filesBufferLength.value === imageEntitiesCount.value && + imageEntitiesCount.value) || (isInitialAddUrlsToImageEntitiesFinished.value && filesBufferLength.value) ) { const entitiesAddedUrls = addUrlsToImageEntities(homeEntities.value); diff --git a/src/components/CreateEntityMenu.vue b/src/components/CreateEntityMenu.vue index 60176cdcaf8502f6414418daa2d8b610c54376be..e8a699352cf7201e2991258dd49b4bf461fe199b 100644 --- a/src/components/CreateEntityMenu.vue +++ b/src/components/CreateEntityMenu.vue @@ -27,10 +27,16 @@ const addImage = async (files: FileList) => { const buffer = await blob.arrayBuffer(); const { width: windowWidth } = useWindowSize(); const maxWidth = windowWidth.value - 128; + const maxHeight = 700; if (image.width > maxWidth) { - image.height = Math.floor(maxWidth / image.width) * image.height; + image.height = Math.floor((maxWidth / image.width) * image.height); image.width = maxWidth; } + if (image.height > maxHeight) { + image.width = Math.floor((maxHeight / image.height) * image.width); + console.log('image.width', image.width); + image.height = maxHeight; + } emit('createEntity', { entity_type: 'image', entity_uuid: imageUuid, @@ -50,6 +56,18 @@ onChange((files) => { }); const speedDialItems = ref([ + { + label: 'Divider', + icon: 'pi pi-pause', + command: () => { + emit('createEntity', { + entity_type: 'divider', + entity_uuid: uuidv4(), + divider_height: 1, + divider_type: 'solid' + }); + } + }, { label: 'Text', icon: 'pi pi-pencil', @@ -100,7 +118,7 @@ const speedDialItems = ref([