This commit is contained in:
HCode authored and GitHub committed 2025-02-19 15:01:06 +00:00
1 parent 1203ef569b
commit 5d8902e566
40 files changed
+2416 -1

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
<template>
<el-menu mode="horizontal" :default-active="active">
<el-menu-item v-if="site?.features?.midjourney?.enabled" index="/midjourney" @click="$router.push('/midjourney')">
{{ $t('common.nav.midjourney') }}
</el-menu-item>
<el-menu-item v-if="site?.features?.flux?.enabled" index="/flux" @click="$router.push('/flux')">
{{ $t('common.nav.flux') }}
</el-menu-item>
</el-menu>
</template>
<script lang="ts">
import { ElMenu, ElMenuItem } from 'element-plus';
import { defineComponent } from 'vue';
export default defineComponent({
name: 'ImageNavigator',
components: {
ElMenu,
ElMenuItem
},
computed: {
site() {
return this.$store.state.site;
},
active() {
console.log(this.$route.path);
return this.$route.path;
}
}
});
</script>
<style lang="scss" scoped>
.el-menu {
justify-content: center;
}
</style>
+78
View File
@@ -0,0 +1,78 @@
<template>
<div class="panel">
<div class="config">
<prompt-input class="mb-4" />
<model-selector class="mb-4" />
<div class="actions">
<el-button
v-if="config?.video_url !== undefined || config?.custom"
type="primary"
class="btn w-full"
round
@click="onGenerate"
>
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
{{ $t('flux.button.extend') }}
</el-button>
<el-button v-else type="primary" class="btn w-full" round @click="onGenerate">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
{{ $t('flux.button.generate') }}
</el-button>
</div>
</div>
</div>
</template>
<script>
import { defineComponent } from 'vue';
import { ElButton } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import ModelSelector from './config/ModelSelector.vue';
import PromptInput from './config/PromptInput.vue';
// import RatioSelector from './config/RatioSelector.vue';
// import NumbersSelector from './config/NumbersSelector.vue';
// import QualitySelector from './config/QualitySelector.vue';
export default defineComponent({
name: 'PresetPanel',
components: {
ElButton,
FontAwesomeIcon,
PromptInput,
ModelSelector
},
emits: ['generate'],
computed: {
config() {
return this.$store.state.flux?.config;
}
},
methods: {
onGenerate() {
this.$emit('generate');
}
}
});
</script>
<style lang="scss" scoped>
.panel {
height: 100%;
padding: 15px;
display: flex;
flex-direction: column;
.config {
width: 100%;
height: calc(100% - 50px);
flex: 1;
}
.actions {
height: 50px;
display: flex;
justify-content: center;
align-items: center;
.btn {
width: 100%;
}
}
}
</style>
+23
View File
@@ -0,0 +1,23 @@
<template>
<div class="panel detail">
<task-detail />
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import TaskDetail from './task/Detail.vue';
export default defineComponent({
name: 'DetailPanel',
components: {
TaskDetail
},
data() {
return {
job: 0
};
},
computed: {}
});
</script>
+100
View File
@@ -0,0 +1,100 @@
<template>
<div class="image-gallery">
<div class="image-container">
<img :src="modelValue.image_url" alt="Image" />
<button class="view-button" @click="viewImage(modelValue.image_url)">
{{ $t('flux.button.viewImage') }}
</button>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent, computed } from 'vue';
import { IFluxImage } from '@/models';
interface IDataItem {
image_url: string;
// Add other properties if necessary
}
interface IResponse {
data: IDataItem[];
}
export default defineComponent({
name: 'ImageGallery',
props: {
modelValue: {
type: Object as () => IFluxImage | undefined,
required: true
}
},
setup(props) {
// Computed property to extract the first two images
// Method to handle the "View Image" button click
const viewImage = (url: string) => {
window.open(url, '_blank');
};
return {
viewImage
};
}
});
</script>
<style lang="scss" scoped>
.image-gallery {
display: flex;
justify-content: space-between;
gap: 16px;
}
.image-container {
position: relative;
width: 48%; /* Ensures two images fit side by side with some space */
overflow: hidden;
border: 1px solid #ddd;
border-radius: 8px;
img {
width: 100%;
height: auto;
display: block;
transition: transform 0.3s ease;
}
/* Zoom effect on hover */
&:hover img {
transform: scale(1.05);
}
.view-button {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.6);
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
opacity: 0;
transition: opacity 0.3s ease;
/* Optional: Add a slight delay for smoother appearance */
transition-delay: 0.1s;
&:hover {
background-color: rgba(0, 0, 0, 0.8);
}
}
/* Show the button on hover */
&:hover .view-button {
opacity: 1;
}
}
</style>
+77
View File
@@ -0,0 +1,77 @@
<template>
<div>
<el-card v-show="operating">
<content-input class="mb-4" />
<prompt-input class="mb-4" />
<preset-selector class="mb-4" />
<div class="actions">
<el-button type="primary" class="btn w-full" round @click="onGenerate">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
{{ $t('flux.button.generate') }}
</el-button>
</div>
</el-card>
<div>
<el-button type="primary" class="btn btn-operate" @click="operating = !operating">+</el-button>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { ElButton, ElCard } from 'element-plus';
import PresetSelector from './config/PresetSelector2.vue';
import ContentInput from './config/ContentInput.vue';
import PromptInput from './config/PromptInput.vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
export default defineComponent({
name: 'OperationPanel',
components: {
ElButton,
ElCard,
PresetSelector,
ContentInput,
PromptInput,
FontAwesomeIcon
},
emits: ['generate'],
data() {
return {
operating: false
};
},
methods: {
onGenerate() {
this.$emit('generate');
this.operating = false;
}
}
});
</script>
<style lang="scss" scoped>
.el-card {
width: 580px;
height: fit-content;
overflow-y: scroll;
position: absolute;
bottom: 70px;
left: calc(50% - 300px);
@media (max-width: 767px) {
width: 100%;
left: 0;
}
}
.btn-operate {
width: 50px;
height: 50px;
border-radius: 50%;
font-size: 24px;
line-height: 40px;
padding: 0;
margin: auto;
display: block;
}
</style>
+141
View File
@@ -0,0 +1,141 @@
<template>
<div ref="panel" class="panel recent" @scroll="onHandleScroll">
<div v-if="tasks?.items === undefined" class="tasks">
<div v-for="_ in 3" :key="_" class="task placeholder">
<div class="left">
<el-skeleton animated>
<template #template>
<el-skeleton-item variant="image" class="avatar" />
</template>
</el-skeleton>
</div>
<div class="main">
<el-skeleton animated>
<template #template>
<el-skeleton-item variant="p" class="title" />
<el-skeleton-item variant="image" class="icon" />
</template>
</el-skeleton>
</div>
</div>
</div>
<div v-else-if="tasks?.items?.length && tasks?.items?.length > 0" class="tasks">
<task-preview v-for="(task, taskIndex) in tasks?.items" :key="taskIndex" :model-value="task" class="preview" />
</div>
<p v-if="tasks?.items?.length === 0" class="description">
{{ $t('flux.message.noTasks') }}
</p>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import TaskPreview from './task/Preview.vue';
import { ElSkeleton, ElSkeletonItem } from 'element-plus';
export default defineComponent({
name: 'RecentPanel',
components: {
TaskPreview,
ElSkeleton,
ElSkeletonItem
},
emits: ['reach-top'],
data() {
return {
job: 0
};
},
computed: {
tasks() {
// reverse the order of the tasks.items
return {
...this.$store.state.flux?.tasks,
items: this.$store.state.flux?.tasks?.items?.slice()
};
}
},
methods: {
onHandleScroll() {
const el = this.$refs.panel as HTMLElement;
console.log('reach-top reach-top reach-top');
if (el.scrollTop === 0) {
this.$emit('reach-top');
}
}
}
});
</script>
<style lang="scss" scoped>
.panel {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
&.recent {
width: 100%;
height: 100%;
display: flex;
overflow-y: auto;
flex-direction: column;
.preview {
margin-right: 15px;
}
.description {
text-align: left;
font-size: 14px;
color: var(--el-text-color-secondary);
}
.tasks {
width: 100%;
.task {
margin-bottom: 15px;
width: 100%;
height: fit-content;
text-align: left;
&.placeholder {
display: flex;
flex-direction: row;
.left {
width: 70px;
padding: 10px;
.avatar {
width: 50px;
height: 50px;
border-radius: 50%;
}
}
.main {
width: calc(100% - 70px);
flex: 1;
padding: 10px;
margin-bottom: 10px;
.icon {
display: flex;
height: 200px;
width: 300px;
}
.title {
display: block;
width: 200px;
height: 20px;
margin-bottom: 15px;
}
}
}
.operations {
height: fit-content !important;
}
}
}
}
}
</style>
+40
View File
@@ -0,0 +1,40 @@
<template>
<div>
<vue-plyr :options="options" class="video">
<video controls crossorigin playsinline :data-poster="modelValue?.image_url">
<source size="1080" :src="modelValue?.video_url" type="video/mp4" />
</video>
</vue-plyr>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
// @ts-ignore
import VuePlyr from '@skjnldsv/vue-plyr';
// @ts-ignore
import { IPikaVideo } from '@/models';
import '@skjnldsv/vue-plyr/dist/vue-plyr.css';
export default defineComponent({
name: 'VideoPlayer',
components: { VuePlyr },
props: {
modelValue: {
type: Object as () => IPikaVideo | undefined,
required: true
}
},
data() {
return {
options: { quality: { default: '1080p' } }
};
}
});
</script>
<style lang="scss" scoped>
.video {
max-width: 100%;
height: 450px;
}
</style>
@@ -0,0 +1,115 @@
<template>
<div class="field">
<h2 class="title">{{ $t('pika.name.effect') }}</h2>
<el-select v-model="value" class="value" :placeholder="$t('pika.placeholder.select')" clearable>
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
<span class="float-left">{{ item.label }}</span>
<!-- <span class="float-right">{{ item.value }}</span> -->
</el-option>
</el-select>
</div>
</template>
<script>
import { defineComponent } from 'vue';
import { ElSelect, ElOption } from 'element-plus';
export default defineComponent({
name: 'EffectSelector',
components: {
ElSelect,
ElOption
},
data() {
return {};
},
computed: {
options() {
return [
{
value: 'Levitate',
label: this.$t('pika.style.effect1')
},
{
value: 'Decapitate',
label: this.$t('pika.style.effect2')
},
{
value: 'Eye-pop',
label: this.$t('pika.style.effect3')
},
{
value: 'Ta-da',
label: this.$t('pika.style.effect4')
},
{
value: 'Deflate',
label: this.$t('pika.style.effect5')
},
{
value: 'Crumble',
label: this.$t('pika.style.effect6')
},
{
value: 'Dissolve',
label: this.$t('pika.style.effect7')
},
{
value: 'Squish',
label: this.$t('pika.style.effect8')
},
{
value: 'Inflate',
label: this.$t('pika.style.effect9')
},
{
value: 'Melt',
label: this.$t('pika.style.effect10')
},
{
value: 'Cake-ify',
label: this.$t('pika.style.effect11')
},
{
value: 'Crush',
label: this.$t('pika.style.effect12')
},
{
value: 'Explode',
label: this.$t('pika.style.effect13')
}
];
},
value: {
get() {
return this.$store.state.pika?.config?.effect;
},
set(val) {
this.$store.commit('pika/setConfig', {
...this.$store.state.pika?.config,
effect: val
});
}
}
},
watch: {},
mounted() {}
});
</script>
<style lang="scss" scoped>
.field {
display: flex;
flex-direction: row;
align-items: center;
.title {
font-size: 14px;
margin: 0;
width: 30%;
}
.value {
flex: 1;
}
}
</style>
@@ -0,0 +1,87 @@
<template>
<div class="field">
<h2 class="title">{{ $t('flux.name.model') }}</h2>
<el-select v-model="value" class="value" :placeholder="$t('flux.placeholder.select')">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</div>
</template>
<script>
import { defineComponent } from 'vue';
import { ElSelect, ElOption } from 'element-plus';
import { FLUX_DEFAULT_MODEL } from '@/constants';
export default defineComponent({
name: 'ModelSelector',
components: {
ElSelect,
ElOption
},
props: {
modelValue: {
type: String,
default: undefined
}
},
emits: ['update:modelValue'],
data() {
return {
options: [
{
value: 'flux',
label: 'flux'
},
{
value: 'flux-schnell',
label: 'flux-schnell'
},
{
value: 'flux-dev',
label: 'flux-dev'
},
{
value: 'flux-pro',
label: 'flux-pro'
}
]
};
},
computed: {
value: {
get() {
return this.$store.state.flux?.config?.model;
},
set(val) {
this.$store.commit('flux/setConfig', {
...this.$store.state.flux.config,
model: val
});
}
}
},
mounted() {
if (!this.value) {
this.value = FLUX_DEFAULT_MODEL;
}
}
});
</script>
<style lang="scss" scoped>
.field {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
.title {
font-size: 14px;
margin: 0;
width: 30%;
}
.value {
width: 80px;
}
}
</style>
@@ -0,0 +1,51 @@
<template>
<div>
<div class="flex justify-between">
<div class="flex justify-start items-center">
<span class="text-sm font-bold">{{ $t('flux.name.numbers') }}</span>
<info-icon :content="$t('flux.description.numbers')" />
</div>
<div class="flex justify-end items-center">
<el-input-number v-model="value" size="small" controls-position="right" />
</div>
</div>
<div class="w-full">
<el-slider v-model="value" :min="1" :max="4" :step="1" />
</div>
</div>
</template>
<script>
import { defineComponent } from 'vue';
import { ElSlider, ElInputNumber } from 'element-plus';
import InfoIcon from '@/components/common/InfoIcon.vue';
import { FLUX_DEFAULT_NUMBERS } from '@/constants';
export default defineComponent({
name: 'NumbersSelector',
components: {
ElSlider,
InfoIcon,
ElInputNumber
},
computed: {
value: {
get() {
return this.$store.state.flux?.config?.numbers;
},
set(val) {
console.debug('set stylize', val);
this.$store.commit('flux/setConfig', {
...this.$store.state.flux?.config,
numbers: val
});
}
}
},
mounted() {
if (!this.value) {
this.value = FLUX_DEFAULT_NUMBERS;
}
}
});
</script>
@@ -0,0 +1,71 @@
<template>
<div class="field">
<div class="box">
<h2 class="title">{{ $t('flux.name.prompt') }}</h2>
<info-icon :content="$t('flux.description.prompt')" class="info" />
</div>
<el-input
v-model="prompt"
:rows="3"
type="textarea"
class="prompt"
:placeholder="$t('flux.placeholder.prompt')"
:maxlength="300"
show-word-limit
/>
</div>
</template>
<script>
import { defineComponent } from 'vue';
import { ElInput } from 'element-plus';
import InfoIcon from '@/components/common/InfoIcon.vue';
export const DEFAULT_PROMPT = '';
export default defineComponent({
name: 'PromptInput',
components: {
ElInput,
InfoIcon
},
computed: {
prompt: {
get() {
return this.$store.state.flux?.config?.prompt;
},
set(val) {
console.debug('set prompt', val);
this.$store.commit('flux/setConfig', {
...this.$store.state.flux?.config,
prompt: val
});
}
}
},
mounted() {
if (!this.value) {
this.value = DEFAULT_PROMPT;
}
}
});
</script>
<style lang="scss" scoped>
.field {
.box {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between; // Add this line to move the icon to the right
position: relative;
.title {
font-size: 14px;
margin-bottom: 10px;
}
}
.info {
margin-left: auto; // Ensure the icon stays on the right
}
}
</style>
@@ -0,0 +1,68 @@
<template>
<div>
<div class="flex justify-between">
<div class="flex justify-start items-center">
<span class="text-sm font-bold">{{ $t('flux.name.quality') }}</span>
<info-icon :content="$t('flux.description.quality')" />
</div>
<div class="flex justify-end items-center">
<el-input-number v-model="value" size="small" controls-position="right" />
</div>
</div>
<div class="w-full">
<el-slider v-model="value" :min="1" :max="100" :step="1" />
</div>
</div>
</template>
<script>
import { defineComponent } from 'vue';
import { ElSlider, ElInputNumber } from 'element-plus';
import InfoIcon from '@/components/common/InfoIcon.vue';
import { FLUX_DEFAULT_QUALITY } from '@/constants';
export default defineComponent({
name: 'QualitySelector',
components: {
ElSlider,
InfoIcon,
ElInputNumber
},
computed: {
value: {
get() {
return this.$store.state.flux.config.quality;
},
set(val) {
console.debug('set quality', val);
this.$store.commit('flux/setConfig', {
...this.$store.state.flux.config,
quality: val
});
}
}
},
mounted() {
if (!this.value) {
this.value = FLUX_DEFAULT_QUALITY;
}
}
});
</script>
<style lang="scss" scoped>
.field {
display: flex;
flex-direction: row;
align-items: center;
.title {
font-size: 14px;
margin: 0;
width: 30%;
}
.value {
flex: 1;
}
}
</style>
@@ -0,0 +1,168 @@
<template>
<div>
<h2 class="title">{{ $t('flux.name.ratio') }}</h2>
<div class="items">
<div
v-for="(option, optionKey) in options"
:key="optionKey"
:class="{ active: active === optionKey, item: true }"
@click="value = option.value"
>
<div class="preview" :class="option.label">
<div class="rect" :style="{ width: option.width + 'px', height: option.height + 'px' }"></div>
</div>
<p class="name">
{{ option.label }}
</p>
</div>
</div>
</div>
</template>
<script>
import { defineComponent } from 'vue';
import { FLUX_DEFAULT_ASPECT_RATIO } from '@/constants';
export default defineComponent({
name: 'RatioSelector',
data() {
return {
options: [
{
value: '1:1',
label: '1:1',
width: 20,
height: 20
},
{
value: '2:3',
label: '2:3',
width: 18,
height: 27
},
{
value: '3:2',
label: '3:2',
width: 27,
height: 18
},
{
value: '4:3',
label: '4:3',
width: 20,
height: 15
},
{
value: '3:4',
label: '3:4',
width: 15,
height: 20
},
{
value: '16:9',
label: '16:9',
width: 25,
height: 13
},
{
value: '9:16',
label: '9:16',
width: 13,
height: 25
}
]
};
},
computed: {
active() {
return this.options.findIndex((option) => option.value === this.value) || 0;
},
value: {
get() {
return this.$store.state.flux?.config?.aspect_ratio;
},
set(val) {
console.debug('set ratio', val);
this.$store.commit('flux/setConfig', {
...this.$store.state.flux.config,
aspect_ratio: val
});
}
}
},
mounted() {
if (!this.value) {
this.value = FLUX_DEFAULT_ASPECT_RATIO;
}
}
});
</script>
<style lang="scss" scoped>
.title {
font-size: 14px;
margin-bottom: 10px;
}
.items {
display: grid;
grid-template-columns: repeat(5, 48px); // 固定每行5列
gap: 8px; // 元素间距
justify-content: start; // 左对齐
.item {
width: 48px;
height: 65px;
border: 2px solid var(--el-border-color);
display: flex;
flex-direction: column;
align-items: center;
cursor: pointer;
border-radius: 5px;
flex-shrink: 0;
.preview {
margin-top: 8px;
width: 30px;
height: 30px;
display: flex;
align-items: center;
justify-content: center;
.rect {
border: 2px solid var(--el-border-color);
width: 20px;
height: 20px;
border-radius: 2px;
}
}
.name {
display: block;
font-size: 12px;
color: var(--el-text-color-primary);
}
&.active {
border-color: var(--el-color-primary);
.rect {
border-color: var(--el-color-primary);
}
}
}
}
/* 响应式处理 */
@media (max-width: 480px) {
.items {
grid-template-columns: repeat(5, 48px); // 固定每行5列
gap: 8px; // 元素间距
}
}
@media (min-width: 481px) and (max-width: 768px) {
.items {
grid-template-columns: repeat(5, 48px); // 固定每行5列
gap: 8px; // 元素间距
}
}
</style>
+306
View File
@@ -0,0 +1,306 @@
<template>
<div v-for="(image, imageIndex) in images" :key="imageIndex" class="preview">
<div class="left">
<el-image src="https://cdn.acedata.cloud/i80tgn.png" class="avatar" />
</div>
<div class="main">
<div class="bot">
{{ $t('flux.name.fluxBot') }}
<span class="datetime">
{{ $dayjs.format('' + new Date(parseFloat(modelValue?.created_at || '') * 1000)) }}
</span>
</div>
<div class="info">
<p v-if="modelValue?.request?.prompt" class="prompt mt-2">
{{ modelValue?.request?.prompt }}
<span v-if="!modelValue?.response"> - ({{ $t('flux.status.pending') }}) </span>
<span v-if="image?.state === 'processing' || image?.state === 'pending' || image?.state === 'completed'">
- ({{ $t('flux.status.processing') }})
</span>
</p>
</div>
<!-- Display success message -->
<div v-if="modelValue?.response?.success === true" :class="{ content: true, failed: true }">
<div class="image-wrapper">
<image-gallery :model-value="image" />
</div>
<div v-if="image" :class="{ operations: true, 'mt-2': true }">
<el-tooltip class="box-item" effect="dark" :content="$t('flux.message.downloadImage')" placement="top-start">
<el-button type="info" size="small" class="btn-action" @click="onDownload($event, image?.image_url)">
{{ $t('flux.button.download') }}
</el-button>
</el-tooltip>
</div>
<el-alert :closable="false" class="mt-2 success">
<p class="description">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
{{ $t('flux.name.taskId') }}:
{{ modelValue?.id }}
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy" />
</p>
</el-alert>
</div>
<!-- Display error message -->
<div v-if="modelValue?.response?.success === false" :class="{ content: true }">
<el-alert :closable="false" class="failure">
<template #template>
<font-awesome-icon icon="fa-solid fa-exclamation-triangle" class="mr-1" />
{{ $t('flux.name.failure') }}
</template>
<p class="description">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
{{ $t('flux.name.taskId') }}:
{{ modelValue?.id }}
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy" />
</p>
<p class="description">
<font-awesome-icon icon="fa-solid fa-circle-info" class="mr-1" />
{{ $t('flux.name.failureReason') }}:
{{ modelValue?.response?.error?.message }}
<copy-to-clipboard :content="modelValue?.response?.error?.message!" class="btn-copy" />
</p>
<p class="description">
<font-awesome-icon icon="fa-solid fa-hashtag" class="mr-1" />
{{ $t('flux.name.traceId') }}:
{{ modelValue?.response?.trace_id }}
<copy-to-clipboard :content="modelValue?.response?.trace_id" class="btn-copy" />
</p>
</el-alert>
</div>
<!-- Display error message -->
<div
v-if="!modelValue?.response || image?.state === 'processing' || image?.state === 'pending'"
:class="{ content: true }"
>
<el-alert :closable="false" class="info">
<template #template>
<font-awesome-icon icon="fa-solid fa-exclamation-triangle" class="mr-1" />
{{ $t('flux.name.failure') }}
</template>
<p class="description">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
{{ $t('flux.name.taskId') }}:
{{ modelValue?.id }}
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy" />
</p>
</el-alert>
</div>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { ElImage, ElAlert, ElButton, ElTooltip } from 'element-plus';
import { IFluxTask, IFluxGenerateResponse, IFluxImage } from '@/models';
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import ImageGallery from '../ImageGallery.vue';
export default defineComponent({
name: 'TaskPreview',
components: {
ElImage,
CopyToClipboard,
FontAwesomeIcon,
ElAlert,
ElTooltip,
ElButton,
ImageGallery
},
props: {
modelValue: {
type: Object as () => IFluxTask | undefined,
required: true
}
},
data() {
return {};
},
computed: {
application() {
return this.$store.state.flux?.application;
},
config() {
return this.$store.state.flux?.config;
},
images(): IFluxImage[] {
let result: IFluxImage[] = [];
// @ts-ignore
const action = this.modelValue?.request?.action;
if (Array.isArray(this.modelValue?.response?.data)) {
this.modelValue?.response?.data?.forEach((item: any) => {
let image = item as IFluxImage;
// Add the action field to the image object
if (action) {
image.action = action;
}
result.push(image);
});
}
return result;
}
},
methods: {
onDownload(event: MouseEvent, image_url: string) {
event.stopPropagation();
console.log('on download');
// download url here
window.open(image_url, '_blank');
},
onOpenImage(url: string) {
window.open(url, '_blank');
}
}
});
</script>
<style lang="scss" scoped>
$left-width: 70px;
.preview {
width: 100%;
height: fit-content;
text-align: left;
display: flex;
flex-direction: row;
margin-bottom: 15px;
.left {
width: $left-width;
.avatar {
background-color: rgb(34, 34, 34);
padding: 2px;
width: 50px;
height: 50px;
margin: 10px;
border-radius: 50%;
}
}
.main {
flex: 1;
width: calc(100% - $left-width);
padding: 10px 10px 0 10px;
.bot {
font-size: 16px;
font-weight: bold;
color: rgb(46, 204, 113);
margin-bottom: 0;
margin-top: 0;
.datetime {
font-size: 12px;
font-weight: normal;
color: var(--el-text-color-secondary);
margin-left: 10px;
}
}
.info {
.prompt {
font-size: 14px;
font-weight: bold;
color: var(--el-text-color-regular);
margin-bottom: 10px;
}
}
.content {
.el-alert {
border-left-width: 2px;
border-left-style: solid;
&.failure {
border-color: var(--el-color-danger);
}
&.success {
border-color: var(--el-color-success);
}
&.info {
border-color: var(--el-color-info);
}
}
}
.image-wrapper {
position: relative;
width: fit-content;
min-height: 50px;
min-width: 100px;
.image {
max-height: 400px;
max-width: 500px;
display: block;
width: fit-content;
}
.btn-raw {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
z-index: 1000;
display: none;
}
.play-icon {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 48px;
color: white;
z-index: 500;
pointer-events: none; /* Ensure the icon doesn't interfere with hover */
}
&:hover {
.image {
filter: brightness(0.6);
}
.btn-raw {
display: block;
}
.play-icon {
display: none;
}
}
}
.operations {
display: flex;
justify-content: left;
flex-direction: row;
width: 100%;
align-items: baseline;
flex-wrap: wrap;
overflow: hidden;
text-align: center;
color: var(--el-text-color-regular);
font-size: 14px;
overflow-y: scroll;
&.full {
height: 70px;
}
.btn-action {
margin-bottom: 10px;
}
}
}
}
</style>
<style lang="scss">
.preview {
.image.error {
background: var(--el-bg-color-page);
.image-slot {
font-size: 14px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
.failure {
background: var(--el-fill-color-light);
width: 100%;
}
}
</style>