From e9c6ed8ddf801d3cfbb91c08733ab118fec3de21 Mon Sep 17 00:00:00 2001 From: Nikita Kiselev Date: Mon, 8 Dec 2025 21:25:00 +0300 Subject: [PATCH] feat: add options to select aspect ratio and cron algo for product images --- .../MainPageConfigurator/Blocks/BaseBlock.vue | 4 - .../Blocks/ProductsFeedBlock.vue | 4 - .../Forms/ProductsCarouselForm.vue | 31 +----- .../Forms/ProductsFeedForm.vue | 11 --- .../MainPageConfigurator/availableBlocks.js | 2 - frontend/admin/src/stores/settings.js | 2 + frontend/admin/src/views/GeneralView.vue | 26 +++++ .../MainPage/Blocks/ProductsFeedBlock.vue | 2 - frontend/spa/src/components/ProductsList.vue | 4 +- frontend/spa/src/stores/SettingsStore.js | 12 +-- frontend/spa/src/utils/AppMetaInitializer.ts | 7 -- .../unit/utils/AppMetaInitializer.test.ts | 13 --- .../upload/oc_telegram_shop/configs/app.php | 4 +- .../framework/ImageTool/ImageFactory.php | 7 +- .../src/Handlers/ProductsHandler.php | 2 - .../src/Handlers/SettingsHandler.php | 50 +--------- .../src/Services/BlocksService.php | 5 +- .../src/Services/ProductsService.php | 99 ++++++++++--------- .../upload/oc_telegram_shop/src/routes.php | 1 - 19 files changed, 98 insertions(+), 188 deletions(-) diff --git a/frontend/admin/src/components/MainPageConfigurator/Blocks/BaseBlock.vue b/frontend/admin/src/components/MainPageConfigurator/Blocks/BaseBlock.vue index 4a66b95..a6c2bec 100644 --- a/frontend/admin/src/components/MainPageConfigurator/Blocks/BaseBlock.vue +++ b/frontend/admin/src/components/MainPageConfigurator/Blocks/BaseBlock.vue @@ -61,7 +61,3 @@ function confirmedRemove(event) { }); } - - diff --git a/frontend/admin/src/components/MainPageConfigurator/Blocks/ProductsFeedBlock.vue b/frontend/admin/src/components/MainPageConfigurator/Blocks/ProductsFeedBlock.vue index d781402..05cf9aa 100644 --- a/frontend/admin/src/components/MainPageConfigurator/Blocks/ProductsFeedBlock.vue +++ b/frontend/admin/src/components/MainPageConfigurator/Blocks/ProductsFeedBlock.vue @@ -13,10 +13,6 @@ Максимальное кол-во страниц: {{ value.data.max_page_count }} -
- Соотношение сторон: - {{ value.data.image_aspect_ratio || '1:1' }} -
diff --git a/frontend/admin/src/components/MainPageConfigurator/Forms/ProductsCarouselForm.vue b/frontend/admin/src/components/MainPageConfigurator/Forms/ProductsCarouselForm.vue index 4a8c1bd..b466d36 100644 --- a/frontend/admin/src/components/MainPageConfigurator/Forms/ProductsCarouselForm.vue +++ b/frontend/admin/src/components/MainPageConfigurator/Forms/ProductsCarouselForm.vue @@ -37,18 +37,6 @@ - -
-

Изображения

- - - - -
@@ -149,30 +137,13 @@ import BaseForm from "@/components/MainPageConfigurator/Forms/BaseForm.vue"; import FormItem from "@/components/MainPageConfigurator/Forms/FormItem.vue"; import CategorySelect from "@/components/Form/CategorySelect.vue"; import {Fieldset, InputNumber, InputText, Panel, ToggleSwitch} from "primevue"; -import AspectRatioSelect from "@/components/MainPageConfigurator/Forms/AspectRatioSelect.vue"; const draft = ref(null); const model = defineModel(); const emit = defineEmits(['cancel']); -const imageAspectRatio = computed({ - get() { - return draft.value.data.image_aspect_ratio || '1:1'; - }, - set(value) { - draft.value.data.image_aspect_ratio = value; - } -}); - const isChanged = computed(() => { - const normalize = (obj) => { - const clone = JSON.parse(JSON.stringify(obj)); - if (clone.data && !clone.data.image_aspect_ratio) { - clone.data.image_aspect_ratio = '1:1'; - } - return JSON.stringify(clone); - }; - return md5(normalize(model.value)) !== md5(normalize(draft.value)); + return md5(JSON.stringify(model.value)) !== md5(JSON.stringify(draft.value)); }); // Инициализация carousel, если его нет (только для записи) diff --git a/frontend/admin/src/components/MainPageConfigurator/Forms/ProductsFeedForm.vue b/frontend/admin/src/components/MainPageConfigurator/Forms/ProductsFeedForm.vue index da3b3de..2597e74 100644 --- a/frontend/admin/src/components/MainPageConfigurator/Forms/ProductsFeedForm.vue +++ b/frontend/admin/src/components/MainPageConfigurator/Forms/ProductsFeedForm.vue @@ -26,15 +26,6 @@ Ограничение страниц снижает нагрузку на сервер. - - - - - @@ -46,7 +37,6 @@ import {md5} from "js-md5"; import BaseForm from "@/components/MainPageConfigurator/Forms/BaseForm.vue"; import {InputNumber} from "primevue"; import FormItem from "@/components/MainPageConfigurator/Forms/FormItem.vue"; -import AspectRatioSelect from "@/components/MainPageConfigurator/Forms/AspectRatioSelect.vue"; const draft = ref(null); const model = defineModel(); @@ -72,7 +62,6 @@ onMounted(() => { draft.value = JSON.parse(JSON.stringify(model.value)); if (draft.value.data) { if (draft.value.data.max_page_count) draft.value.data.max_page_count = parseInt(draft.value.data.max_page_count); - if (!draft.value.data.image_aspect_ratio) draft.value.data.image_aspect_ratio = '1:1'; } }); diff --git a/frontend/admin/src/components/MainPageConfigurator/availableBlocks.js b/frontend/admin/src/components/MainPageConfigurator/availableBlocks.js index c6be263..2ec0d99 100644 --- a/frontend/admin/src/components/MainPageConfigurator/availableBlocks.js +++ b/frontend/admin/src/components/MainPageConfigurator/availableBlocks.js @@ -58,7 +58,6 @@ export const blocks = [ goal_name: '', data: { max_page_count: 10, - image_aspect_ratio: '1:1', }, }, { @@ -70,7 +69,6 @@ export const blocks = [ data: { category_id: null, all_text: null, - image_aspect_ratio: '1:1', carousel: { slides_per_view: null, space_between: null, diff --git a/frontend/admin/src/stores/settings.js b/frontend/admin/src/stores/settings.js index 2b9b4c0..a2cf8a2 100644 --- a/frontend/admin/src/stores/settings.js +++ b/frontend/admin/src/stores/settings.js @@ -18,6 +18,8 @@ export const useSettingsStore = defineStore('settings', { theme_dark: 'dark', app_debug: false, privacy_policy_link: null, + image_aspect_ratio: '1:1', + image_crop_algorithm: 'cover', }, telegram: { diff --git a/frontend/admin/src/views/GeneralView.vue b/frontend/admin/src/views/GeneralView.vue index aee0eb2..38b782e 100644 --- a/frontend/admin/src/views/GeneralView.vue +++ b/frontend/admin/src/views/GeneralView.vue @@ -49,6 +49,19 @@ Режим разработчика. Рекомендуется включать только по необходимости. В остальных случаях, для нормальной работы магазина, должен быть выключен. + + + Выберите соотношение сторон для изображений товаров. Это глобальная настройка, которая будет применяться ко всем изображениям в списках товаров: карусель товаров, лента товаров, результаты поиска. + + + + Выберите алгоритм обрезки изображений. Эта настройка применяется глобально ко всем изображениям в списках товаров (карусель товаров, лента товаров, результаты поиска): + +