feat(products-feed): replace fixed image dimensions with aspect ratio selection
- Added image aspect ratio selection (1:1, 4:5, 3:4, 2:3) to ProductsFeed block configuration in Admin panel - Removed manual width/height input fields - Updated ProductsFeed block in SPA to send aspect ratio parameter instead of dimensions - Implemented backend logic to calculate image height based on selected aspect ratio and base width (300px) - Updated default configuration for products_feed block - Added descriptive help text for each aspect ratio option in the dropdown
This commit is contained in:
@@ -13,6 +13,10 @@
|
||||
<span class="tw:font-bold tw:dark:text-slate-200">Максимальное кол-во страниц:</span>
|
||||
{{ value.data.max_page_count }}
|
||||
</div>
|
||||
<div>
|
||||
<span class="tw:font-bold tw:dark:text-slate-200">Соотношение сторон:</span>
|
||||
{{ value.data.image_aspect_ratio || '1:1' }}
|
||||
</div>
|
||||
</div>
|
||||
</BaseBlock>
|
||||
</template>
|
||||
|
||||
@@ -26,6 +26,29 @@
|
||||
Ограничение страниц снижает нагрузку на сервер.
|
||||
</template>
|
||||
</FormItem>
|
||||
|
||||
<FormItem label="Соотношение сторон">
|
||||
<template #default>
|
||||
<Dropdown
|
||||
v-model="draft.data.image_aspect_ratio"
|
||||
:options="aspectRatioOptions"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
placeholder="Выберите соотношение"
|
||||
class="tw:w-full md:tw:w-96"
|
||||
>
|
||||
<template #option="slotProps">
|
||||
<div class="tw:flex tw:flex-col">
|
||||
<span class="tw:font-medium">{{ slotProps.option.label }}</span>
|
||||
<span class="tw:text-xs tw:text-gray-500 tw:whitespace-normal">{{ slotProps.option.description }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</Dropdown>
|
||||
</template>
|
||||
<template #help>
|
||||
Выберите соотношение сторон для изображений товаров.
|
||||
</template>
|
||||
</FormItem>
|
||||
</div>
|
||||
</BaseForm>
|
||||
</div>
|
||||
@@ -35,14 +58,31 @@
|
||||
import {computed, defineExpose, onMounted, ref} from "vue";
|
||||
import {md5} from "js-md5";
|
||||
import BaseForm from "@/components/MainPageConfigurator/Forms/BaseForm.vue";
|
||||
import {InputNumber} from "primevue";
|
||||
import {InputNumber, Dropdown} from "primevue";
|
||||
import FormItem from "@/components/MainPageConfigurator/Forms/FormItem.vue";
|
||||
|
||||
const draft = ref(null);
|
||||
const model = defineModel();
|
||||
const emit = defineEmits(['cancel']);
|
||||
|
||||
const isChanged = computed(() => md5(JSON.stringify(model.value)) !== md5(JSON.stringify(draft.value)));
|
||||
const aspectRatioOptions = [
|
||||
{ label: '1:1', value: '1:1', description: 'Универсально, аксессуары, мелкие товары, удобно для всех товаров — идеально для сетки.' },
|
||||
{ label: '4:5', value: '4:5', description: 'Одежда, обувь, вертикальные товары, где нужно показать высоту (футболки, платья).' },
|
||||
{ label: '3:4', value: '3:4', description: 'Одежда, обувь, вертикальные товары, где нужно показать высоту (футболки, платья).' },
|
||||
{ label: '2:3', value: '2:3', description: 'Цветы, высокие предметы (бутылки, букеты, декоративные элементы).' },
|
||||
];
|
||||
|
||||
const isChanged = computed(() => {
|
||||
const normalize = (obj) => {
|
||||
return JSON.stringify(obj, (key, value) => {
|
||||
if (['max_page_count'].includes(key)) {
|
||||
return value !== null && value !== undefined && value !== '' ? parseInt(value) : value;
|
||||
}
|
||||
return value;
|
||||
});
|
||||
};
|
||||
return md5(normalize(model.value)) !== md5(normalize(draft.value));
|
||||
});
|
||||
|
||||
function onApply() {
|
||||
model.value = JSON.parse(JSON.stringify(draft.value));
|
||||
@@ -50,6 +90,10 @@ function onApply() {
|
||||
|
||||
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';
|
||||
}
|
||||
});
|
||||
|
||||
defineExpose({isChanged});
|
||||
|
||||
@@ -58,6 +58,7 @@ export const blocks = [
|
||||
goal_name: '',
|
||||
data: {
|
||||
max_page_count: 10,
|
||||
image_aspect_ratio: '1:1',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user