Spaces:
Sleeping
Sleeping
File size: 11,373 Bytes
343eed9 8b64092 702a754 8b64092 343eed9 8b64092 343eed9 8b64092 343eed9 8b64092 702a754 343eed9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | <template>
<div class="step-visuals [ stack ]" data-composition="step-container">
<header class="[ stack ]" data-stack-gap="medium">
<h2 class="[ text-step-title ] [ text-primary ]">Étape 2 : Configuration Visuelle</h2>
<p class="[ text-secondary ]">Définissez l'esthétique et le format de votre histoire horrifique.</p>
</header>
<div v-if="!currentStory" class="[ card-placeholder ] [ stack items-center justify-center p-12 ]">
<p class="text-muted">Veuillez d'abord sélectionner une histoire.</p>
<Button label="RETOUR" icon="pi pi-arrow-left" @click="uiStore.setStep(1)" severity="secondary" class="mt-4" />
</div>
<div v-else class="[ stack ]" style="gap: 3rem">
<div class="[ grid-main ]">
<!-- Left Column: Settings -->
<div class="[ stack ]" style="gap: 2rem">
<section class="[ p-card ] [ stack ]">
<h3 class="property-label">Moteur de Rendu</h3>
<Select v-model="form.model" :options="modelOptions" optionLabel="label" optionValue="value" class="w-full" />
<p class="text-tiny text-muted mt-2">Le modèle FLUX.1 offre la meilleure fidélité pour le style Dark Anime.</p>
</section>
<section class="[ p-card ] [ stack ]">
<h3 class="property-label">Format de Sortie</h3>
<div class="[ flex gap-3 ]">
<div
v-for="ratio in ratios"
:key="ratio.value"
class="ratio-card [ stack items-center justify-center cursor-pointer ]"
:class="{ active: form.aspectRatio === ratio.value }"
@click="form.aspectRatio = ratio.value"
>
<div class="ratio-preview" :class="'ratio-' + ratio.value.replace(':', '-')"></div>
<span class="text-tiny mt-2 font-bold">{{ ratio.label }}</span>
</div>
</div>
</section>
</div>
<!-- Right Column: Styles -->
<section class="[ p-card ] [ stack ]">
<h3 class="property-label">Style Artistique</h3>
<div class="style-grid">
<div
v-for="style in styles"
:key="style.value"
class="style-item [ flex items-center gap-3 p-3 cursor-pointer ]"
:class="{ active: form.style === style.value }"
@click="form.style = style.value"
>
<div class="style-indicator"></div>
<span class="text-small font-bold uppercase">{{ style.label }}</span>
</div>
</div>
</section>
</div>
<!-- Scenes Content Editor -->
<section class="[ stack ]" data-stack-gap="medium">
<div class="[ flex justify-between items-center px-2 ]">
<h3 class="property-label m-0">Prompts Visuels par Scène</h3>
<div class="flex items-center gap-4">
<span class="text-tiny uppercase tracking-tighter text-red">Total : {{ currentStory.scenes.length }} scènes</span>
<Button
label="AMÉLIORER AVEC IA"
icon="pi pi-sparkles"
severity="help"
size="small"
@click="triggerImproveVisuals"
:loading="storiesStore.isLoading"
text
/>
<Button
label="GÉNÉRER TOUTES LES IMAGES"
icon="pi pi-bolt"
severity="danger"
size="small"
@click="triggerImageGeneration"
:loading="uiStore.isGenerating"
/>
</div>
</div>
<div class="[ scenes-grid ]">
<div v-for="(scene, index) in currentStory.scenes" :key="scene.id" class="[ p-card scene-card ]">
<div class="flex items-center justify-between mb-4">
<span class="scene-number">#{{ index + 1 }}</span>
</div>
<!-- Image Preview -->
<div v-if="getSceneImage(scene.id)" class="scene-image-preview mb-4">
<img :src="getSceneImage(scene.id)" class="w-full rounded border border-red-dark" style="aspect-ratio: 16/10; object-fit: cover;" />
</div>
<Textarea
v-model="scenePrompts[scene.id]"
autoResize
rows="3"
class="w-full p-inputtext-sm visual-textarea"
placeholder="Prompt visuel de la scène..."
/>
</div>
</div>
</section>
<!-- Footer -->
<div class="[ flex justify-between items-center mt-8 ]">
<Button label="PRÉCÉDENT" icon="pi pi-chevron-left" @click="uiStore.setStep(1)" severity="secondary" text />
<div class="flex items-center gap-4">
<span v-if="hasChanges" class="text-tiny italic text-red">Modifications non enregistrées</span>
<Button label="ENREGISTRER & CONTINUER" icon="pi pi-arrow-right" iconPos="right" @click="handleSave" :loading="isSubmitting" severity="primary" />
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, computed, watch, reactive } from 'vue';
import { useStoriesStore, useUIStore } from '@presentation/stores';
import Select from 'primevue/select';
import Textarea from 'primevue/textarea';
import Button from 'primevue/button';
const storiesStore = useStoriesStore();
const uiStore = useUIStore();
const currentStory = computed(() => storiesStore.currentStory);
const isSubmitting = ref(false);
const modelOptions = [
{ label: 'Black Forest FLUX.1 (Premium)', value: 'flux' },
{ label: 'SSD-1B (Optimisé)', value: 'ssd-1b' },
{ label: 'Stable Diffusion XL', value: 'sdxl' },
{ label: 'API Gateway', value: 'api' }
];
const ratios = [
{ label: 'TikTok (9:16)', value: '9:16' },
{ label: 'Square (1:1)', value: '1:1' },
{ label: 'YouTube (16:9)', value: '16:9' }
];
const styles = [
{ label: 'Dark Anime', value: 'anime' },
{ label: 'Gothic Horror', value: 'gothic' },
{ label: 'CCTV Footage', value: 'cctv' },
{ label: 'VHS Vintage', value: 'vhs' },
{ label: 'Glitch Digital', value: 'glitch' }
];
const form = ref({
model: 'flux',
aspectRatio: '9:16',
style: 'anime'
});
const scenePrompts = reactive<Record<string, string>>({});
const getSceneImage = (sceneId: string) => {
const asset = storiesStore.currentAssets.find(a => a.sceneId === sceneId && a.type === 'image');
return asset?.url || null;
};
watch(currentStory, (story) => {
if (story) {
if (story.visualConfig) {
form.value = {
model: story.visualConfig.model.value,
aspectRatio: story.visualConfig.aspectRatio.value,
style: story.visualConfig.style.value
};
}
story.scenes.forEach(scene => {
scenePrompts[scene.id] = scene.visualPrompt;
});
}
}, { immediate: true });
const hasChanges = computed(() => {
if (!currentStory.value) return false;
const config = currentStory.value.visualConfig;
const configChanged = form.value.model !== config.model.value ||
form.value.aspectRatio !== config.aspectRatio.value ||
form.value.style !== config.style.value;
let promptChanged = false;
currentStory.value.scenes.forEach(scene => {
if (scenePrompts[scene.id] !== scene.visualPrompt) promptChanged = true;
});
return configChanged || promptChanged;
});
const triggerImageGeneration = async () => {
if (!currentStory.value) return;
try {
// 1. First save the current prompts
const sceneUpdates = Object.entries(scenePrompts).map(([id, visualPrompt]) => ({ id, visualPrompt }));
await storiesStore.updateVisualConfig(form.value.model, form.value.aspectRatio, form.value.style, sceneUpdates);
// 2. Trigger the backend generation
await storiesStore.launchImageGeneration();
} catch (err) {
console.error('Image generation failed', err);
}
};
const triggerImproveVisuals = async () => {
if (!currentStory.value) return;
try {
await storiesStore.improveVisuals(form.value.style);
uiStore.addNotification('Prompts améliorés avec succès', 'success');
} catch (err) {
uiStore.addNotification('Échec de l\'amélioration des prompts', 'error');
}
};
const handleSave = async () => {
isSubmitting.value = true;
try {
const sceneUpdates = Object.entries(scenePrompts).map(([id, visualPrompt]) => ({ id, visualPrompt }));
await storiesStore.updateVisualConfig(form.value.model, form.value.aspectRatio, form.value.style, sceneUpdates);
uiStore.setStep(3);
} catch (err) {
console.error(err);
} finally {
isSubmitting.value = false;
}
};
</script>
<style scoped>
.step-visuals {
padding: 1.5rem 2.5rem;
flex: 1;
width: 100%;
max-width: 1200px;
margin: 0 auto;
display: flex;
flex-direction: column;
}
.grid-main {
display: grid;
grid-template-columns: 1.2fr 1fr;
gap: 1.5rem;
align-items: start;
}
.ratio-card {
flex: 1;
background: rgba(255, 255, 255, 0.02);
border: 1px solid var(--border-color);
padding: 1.5rem;
border-radius: 12px;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.ratio-card:hover {
border-color: var(--text-muted);
background: rgba(255, 255, 255, 0.04);
}
.ratio-card.active {
border-color: var(--accent-red);
background: rgba(204, 0, 0, 0.1);
box-shadow: 0 0 20px rgba(204, 0, 0, 0.1);
transform: translateY(-2px);
}
.ratio-preview {
background: #222;
border-radius: 4px;
transition: all 0.3s ease;
}
.ratio-preview.ratio-9-16 { width: 18px; height: 32px; }
.ratio-preview.ratio-1-1 { width: 28px; height: 28px; }
.ratio-preview.ratio-16-9 { width: 38px; height: 22px; }
.active .ratio-preview {
background: var(--accent-red-bright);
box-shadow: 0 0 10px var(--accent-red-bright);
}
.style-grid {
display: grid;
grid-template-columns: 1fr;
gap: 0.75rem;
}
.style-item {
border-radius: 8px;
border: 1px solid transparent;
background: rgba(255, 255, 255, 0.01);
transition: all 0.2s ease;
}
.style-item:hover {
background: rgba(255, 255, 255, 0.03);
transform: translateX(4px);
}
.style-item.active {
background: rgba(204, 0, 0, 0.08);
border-color: rgba(204, 0, 0, 0.3);
}
.style-indicator {
width: 6px;
height: 6px;
border-radius: 50%;
background: #333;
transition: all 0.3s ease;
}
.active .style-indicator {
background: var(--accent-red-bright);
box-shadow: 0 0 8px var(--accent-red-bright);
}
.scenes-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
gap: 1.5rem;
}
.scene-card {
border: 1px solid var(--border-color) !important;
background: rgba(255, 255, 255, 0.01) !important;
transition: all 0.3s ease;
}
.scene-card:focus-within {
border-color: var(--accent-red) !important;
background: rgba(255, 255, 255, 0.02) !important;
}
.scene-number {
font-size: 0.7rem;
font-weight: 800;
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.1rem;
}
.visual-textarea {
background: rgba(0, 0, 0, 0.3) !important;
border: 1px solid var(--border-color) !important;
border-radius: 8px;
font-size: 0.8rem;
line-height: 1.6;
color: var(--text-main) !important;
}
.w-full { width: 100%; }
</style>
|