Refine ux of flux (#228)
Co-authored-by: AceDataCloud <office@acedata.cloud>
This commit is contained in:
1 parent
399fd707ce
commit
4c17ec244b
18 files changed
+262
-582
No files matched your search
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "minor",
|
||||
"comment": "new ui of flux",
|
||||
"packageName": "@acedatacloud/nexior",
|
||||
"email": "office@acedata.cloud",
|
||||
"dependentChangeType": "patch"
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<template>
|
||||
<div v-for="_ in 3" :key="_" class="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>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'BotPlaceholder',
|
||||
components: {
|
||||
ElSkeleton,
|
||||
ElSkeletonItem
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,86 @@
|
||||
<template>
|
||||
<div class="image-wrapper">
|
||||
<img v-if="src" :src="src" class="image" @error="onReload($event)" />
|
||||
<el-button v-if="rawSrc" type="info" round class="btn-raw" @click="onOpenUrl(rawSrc)">
|
||||
{{ $t('common.button.seeRawImage') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElButton } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ImageWrapper',
|
||||
components: {
|
||||
ElButton
|
||||
},
|
||||
props: {
|
||||
src: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
rawSrc: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: undefined
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onOpenUrl(url: string) {
|
||||
window.open(url, '_blank');
|
||||
},
|
||||
onReload(event: Event) {
|
||||
const target = event.target as HTMLImageElement;
|
||||
// append a random url query to existing url query, to force reload the image
|
||||
// extract exiting url query
|
||||
const url = new URL(target.src);
|
||||
// extract `retry` query
|
||||
const retry = url.searchParams.get('retry');
|
||||
if (!retry) {
|
||||
// if no retry query, set it as random string
|
||||
url.searchParams.set('retry', '1');
|
||||
} else if (parseInt(retry) < 2) {
|
||||
// if retry < 3, increase it by 1
|
||||
url.searchParams.set('retry', (parseInt(retry) + 1).toString());
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
// set the new url
|
||||
target.src = url.toString();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.image-wrapper {
|
||||
position: relative;
|
||||
width: fit-content;
|
||||
margin-bottom: 15px;
|
||||
.image {
|
||||
max-height: 400px;
|
||||
max-width: 300px;
|
||||
min-height: 200px;
|
||||
min-width: 200px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.btn-raw {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 1000;
|
||||
display: none;
|
||||
}
|
||||
&:hover {
|
||||
.image {
|
||||
filter: brightness(0.6);
|
||||
}
|
||||
.btn-raw {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -3,18 +3,9 @@
|
||||
<div class="config">
|
||||
<prompt-input class="mb-4" />
|
||||
<model-selector class="mb-4" />
|
||||
<count-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">
|
||||
<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>
|
||||
@@ -28,6 +19,7 @@ import { defineComponent } from 'vue';
|
||||
import { ElButton } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import ModelSelector from './config/ModelSelector.vue';
|
||||
import CountSelector from './config/CountSelector.vue';
|
||||
import PromptInput from './config/PromptInput.vue';
|
||||
|
||||
export default defineComponent({
|
||||
@@ -36,7 +28,8 @@ export default defineComponent({
|
||||
ElButton,
|
||||
FontAwesomeIcon,
|
||||
PromptInput,
|
||||
ModelSelector
|
||||
ModelSelector,
|
||||
CountSelector
|
||||
},
|
||||
emits: ['generate'],
|
||||
computed: {
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
<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>
|
||||
@@ -1,93 +0,0 @@
|
||||
<template>
|
||||
<div class="image-gallery">
|
||||
<div class="image-container">
|
||||
<img :src="modelValue?.image_url" alt="Image" />
|
||||
<button v-if="modelValue?.image_url" class="view-button" @click="viewImage(modelValue.image_url)">
|
||||
{{ $t('flux.button.viewImage') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IFluxImage } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ImageGallery',
|
||||
props: {
|
||||
modelValue: {
|
||||
type: Object as () => IFluxImage | undefined,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
setup() {
|
||||
// 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;
|
||||
margin-bottom: 10px;
|
||||
|
||||
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>
|
||||
@@ -1,77 +0,0 @@
|
||||
<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>
|
||||
@@ -1,44 +1,25 @@
|
||||
<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 v-if="tasks?.items === undefined" class="tasks">
|
||||
<bot-placeholder />
|
||||
</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" />
|
||||
</div>
|
||||
<p v-if="tasks?.items?.length === 0" class="description">
|
||||
{{ $t('flux.message.noTasks') }}
|
||||
</p>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import TaskPreview from './task/Preview.vue';
|
||||
import { ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import BotPlaceholder from '../common/BotPlaceholder.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'RecentPanel',
|
||||
components: {
|
||||
TaskPreview,
|
||||
ElSkeleton,
|
||||
ElSkeletonItem
|
||||
BotPlaceholder
|
||||
},
|
||||
emits: ['reach-top'],
|
||||
data() {
|
||||
@@ -68,74 +49,21 @@ export default defineComponent({
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
.description {
|
||||
text-align: left;
|
||||
font-size: 14px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.tasks {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
&.recent {
|
||||
overflow-y: auto;
|
||||
.task {
|
||||
margin-bottom: 15px;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
height: fit-content;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,40 +0,0 @@
|
||||
<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>
|
||||
+9
-9
@@ -6,7 +6,7 @@
|
||||
<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" />
|
||||
<el-input-number v-model="value" controls-position="right" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full">
|
||||
@@ -15,14 +15,14 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSlider, ElInputNumber } from 'element-plus';
|
||||
import InfoIcon from '@/components/common/InfoIcon.vue';
|
||||
import { FLUX_DEFAULT_NUMBERS } from '@/constants';
|
||||
import { FLUX_DEFAULT_COUNT } from '@/constants';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'NumbersSelector',
|
||||
name: 'CountSelector',
|
||||
components: {
|
||||
ElSlider,
|
||||
InfoIcon,
|
||||
@@ -31,20 +31,20 @@ export default defineComponent({
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.flux?.config?.numbers;
|
||||
return this.$store.state.flux?.config?.count;
|
||||
},
|
||||
set(val) {
|
||||
console.debug('set stylize', val);
|
||||
set(val: number) {
|
||||
console.debug('set count', val);
|
||||
this.$store.commit('flux/setConfig', {
|
||||
...this.$store.state.flux?.config,
|
||||
numbers: val
|
||||
count: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = FLUX_DEFAULT_NUMBERS;
|
||||
this.value = FLUX_DEFAULT_COUNT;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -28,10 +28,6 @@ export default defineComponent({
|
||||
data() {
|
||||
return {
|
||||
options: [
|
||||
{
|
||||
value: 'flux',
|
||||
label: 'flux'
|
||||
},
|
||||
{
|
||||
value: 'flux-schnell',
|
||||
label: 'flux-schnell'
|
||||
@@ -43,6 +39,22 @@ export default defineComponent({
|
||||
{
|
||||
value: 'flux-pro',
|
||||
label: 'flux-pro'
|
||||
},
|
||||
{
|
||||
value: 'flux-pro-1.1',
|
||||
label: 'flux-pro-1.1'
|
||||
},
|
||||
{
|
||||
value: 'flux-pro-1.1-ultra',
|
||||
label: 'flux-pro-1.1-ultra'
|
||||
},
|
||||
{
|
||||
value: 'flux-kontext-pro',
|
||||
label: 'flux-kontext-pro'
|
||||
},
|
||||
{
|
||||
value: 'flux-kontext-max',
|
||||
label: 'flux-kontext-max'
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -82,7 +94,7 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
.value {
|
||||
width: 120px;
|
||||
width: 160px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div v-for="(image, imageIndex) in images" :key="imageIndex" class="preview">
|
||||
<div class="preview">
|
||||
<div class="left">
|
||||
<el-image src="https://cdn.acedata.cloud/ogm2oa.png" class="avatar" />
|
||||
</div>
|
||||
@@ -14,29 +14,30 @@
|
||||
<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 class="flex justify-start items-center gap-4">
|
||||
<image-wrapper
|
||||
v-for="(image, imageIndex) in images"
|
||||
:key="imageIndex"
|
||||
:src="image?.image_url!"
|
||||
:raw-src="image?.image_url!"
|
||||
:model-value="image"
|
||||
/>
|
||||
</div>
|
||||
<el-alert :closable="false" class="mt-2 success">
|
||||
<p class="description">
|
||||
<p class="mb-2">
|
||||
<font-awesome-icon icon="fa-solid fa-hashtag" class="mr-1" />
|
||||
{{ $t('flux.name.model') }}:
|
||||
{{ modelValue?.request?.model }}
|
||||
</p>
|
||||
<p class="mb-2">
|
||||
<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" />
|
||||
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy inline-block" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
@@ -47,19 +48,19 @@
|
||||
<font-awesome-icon icon="fa-solid fa-exclamation-triangle" class="mr-1" />
|
||||
{{ $t('flux.name.failure') }}
|
||||
</template>
|
||||
<p class="description">
|
||||
<p class="mb-2">
|
||||
<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">
|
||||
<p class="mb-4">
|
||||
<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">
|
||||
<p class="mb-2">
|
||||
<font-awesome-icon icon="fa-solid fa-hashtag" class="mr-1" />
|
||||
{{ $t('flux.name.traceId') }}:
|
||||
{{ modelValue?.response?.trace_id }}
|
||||
@@ -67,17 +68,13 @@
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
<!-- Display error message -->
|
||||
<div
|
||||
v-if="!modelValue?.response || image?.state === 'processing' || image?.state === 'pending'"
|
||||
:class="{ content: true }"
|
||||
>
|
||||
<div v-if="!modelValue?.response" :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">
|
||||
<p class="mb-2">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('flux.name.taskId') }}:
|
||||
{{ modelValue?.id }}
|
||||
@@ -95,7 +92,7 @@ import { ElImage, ElAlert, ElButton, ElTooltip } from 'element-plus';
|
||||
import { IFluxTask, IFluxImage } from '@/models';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import ImageGallery from '../ImageGallery.vue';
|
||||
import ImageWrapper from '@/components/common/ImageWrapper.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TaskPreview',
|
||||
@@ -104,9 +101,7 @@ export default defineComponent({
|
||||
CopyToClipboard,
|
||||
FontAwesomeIcon,
|
||||
ElAlert,
|
||||
ElTooltip,
|
||||
ElButton,
|
||||
ImageGallery
|
||||
ImageWrapper
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
@@ -167,8 +162,6 @@ $left-width: 70px;
|
||||
.left {
|
||||
width: $left-width;
|
||||
.avatar {
|
||||
background-color: rgb(34, 34, 34);
|
||||
padding: 2px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
margin: 10px;
|
||||
@@ -219,70 +212,6 @@ $left-width: 70px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.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>
|
||||
|
||||
@@ -50,24 +50,12 @@
|
||||
</div>
|
||||
<!-- response success -->
|
||||
<div v-if="modelValue?.response?.success === true" :class="{ content: true, full: full }">
|
||||
<div class="image-wrapper">
|
||||
<img
|
||||
v-if="modelValue?.response?.image_url"
|
||||
:src="modelValue?.response?.image_url"
|
||||
:preview-src-list="[modelValue?.response?.raw_image_url as string]"
|
||||
class="image"
|
||||
@error="onReload($event)"
|
||||
/>
|
||||
<el-button
|
||||
v-if="modelValue?.response?.image_url"
|
||||
type="info"
|
||||
round
|
||||
class="btn-raw"
|
||||
@click="onOpenUrl(modelValue?.response?.raw_image_url)"
|
||||
>
|
||||
{{ $t('common.button.seeRawImage') }}
|
||||
</el-button>
|
||||
</div>
|
||||
<image-wrapper
|
||||
v-if="modelValue?.response?.raw_image_url"
|
||||
:src="modelValue?.response?.image_url"
|
||||
:raw-src="modelValue?.response?.raw_image_url"
|
||||
class="image"
|
||||
/>
|
||||
<div v-if="modelValue?.response?.actions" :class="{ operations: true, full, 'mt-2': true }">
|
||||
<el-tooltip
|
||||
v-for="(action, actionKey) in modelValue?.response?.actions"
|
||||
@@ -130,6 +118,7 @@ import { ElImage, ElButton, ElTooltip, ElAlert } from 'element-plus';
|
||||
import { IMidjourneyTask, MidjourneyImagineAction, MidjourneyImagineState } from '@/models';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import ImageWrapper from '@/components/common/ImageWrapper.vue';
|
||||
|
||||
interface IData {
|
||||
midjourneyImagineState: typeof MidjourneyImagineState;
|
||||
@@ -141,6 +130,7 @@ export default defineComponent({
|
||||
name: 'TaskPreview',
|
||||
components: {
|
||||
ElImage,
|
||||
ImageWrapper,
|
||||
ElButton,
|
||||
FontAwesomeIcon,
|
||||
ElTooltip,
|
||||
@@ -227,25 +217,6 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onReload(event: Event) {
|
||||
const target = event.target as HTMLImageElement;
|
||||
// append a random url query to existing url query, to force reload the image
|
||||
// extract exiting url query
|
||||
const url = new URL(target.src);
|
||||
// extract `retry` query
|
||||
const retry = url.searchParams.get('retry');
|
||||
if (!retry) {
|
||||
// if no retry query, set it as random string
|
||||
url.searchParams.set('retry', '1');
|
||||
} else if (parseInt(retry) < 2) {
|
||||
// if retry < 3, increase it by 1
|
||||
url.searchParams.set('retry', (parseInt(retry) + 1).toString());
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
// set the new url
|
||||
target.src = url.toString();
|
||||
},
|
||||
onCustom(action: string) {
|
||||
if (this.modelValue?.type === 'imagine') {
|
||||
this.$emit('custom', {
|
||||
@@ -254,9 +225,6 @@ export default defineComponent({
|
||||
});
|
||||
}
|
||||
},
|
||||
onOpenUrl(url: string) {
|
||||
window.open(url, '_blank');
|
||||
},
|
||||
onDownload(url: string) {
|
||||
// download image using javascript
|
||||
const link = document.createElement('a');
|
||||
@@ -351,34 +319,6 @@ $left-width: 70px;
|
||||
min-height: 200px;
|
||||
}
|
||||
}
|
||||
.image-wrapper {
|
||||
position: relative;
|
||||
width: fit-content;
|
||||
margin-bottom: 15px;
|
||||
.image {
|
||||
max-height: 400px;
|
||||
max-width: 300px;
|
||||
min-height: 200px;
|
||||
min-width: 200px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.btn-raw {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 1000;
|
||||
display: none;
|
||||
}
|
||||
&:hover {
|
||||
.image {
|
||||
filter: brightness(0.6);
|
||||
}
|
||||
.btn-raw {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
.progress {
|
||||
position: absolute;
|
||||
top: 49%;
|
||||
|
||||
@@ -1,22 +1,6 @@
|
||||
<template>
|
||||
<div v-if="tasks === 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>
|
||||
<bot-placeholder />
|
||||
</div>
|
||||
<div v-else-if="tasks && tasks?.length === 0">
|
||||
<p class="p-5 description">{{ $t('midjourney.message.noTasks') }}</p>
|
||||
@@ -32,13 +16,13 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import TaskItem from './TaskItem.vue';
|
||||
import { ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import BotPlaceholder from '@/components/common/BotPlaceholder.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TaskList',
|
||||
components: {
|
||||
TaskItem,
|
||||
ElSkeleton,
|
||||
ElSkeletonItem
|
||||
BotPlaceholder
|
||||
},
|
||||
emits: ['update:modelValue', 'custom', 'refresh', 'reach-top'],
|
||||
data() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export const FLUX_SERVICE_ID = 'e8ebe055-429a-48e9-9d34-5089eae5fd89';
|
||||
|
||||
export const FLUX_DEFAULT_MODEL = 'flux';
|
||||
export const FLUX_DEFAULT_MODEL = 'flux-dev';
|
||||
export const FLUX_DEFAULT_ASPECT_RATIO = '1:1';
|
||||
export const FLUX_DEFAULT_NUMBERS = 1;
|
||||
export const FLUX_DEFAULT_COUNT = 1;
|
||||
export const FLUX_DEFAULT_QUALITY = 80;
|
||||
@@ -1,5 +1,6 @@
|
||||
export interface IFluxConfig {
|
||||
action?: string;
|
||||
count?: number;
|
||||
prompt?: string;
|
||||
model?: string;
|
||||
callback_url?: string;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<config-panel @generate="onGenerate" />
|
||||
</template>
|
||||
<template #result>
|
||||
<recent-panel class="panel recent" @reach-top="onReachTop" />
|
||||
<recent-panel @reach-top="onReachTop" />
|
||||
</template>
|
||||
</layout>
|
||||
</template>
|
||||
@@ -47,27 +47,15 @@ export default defineComponent({
|
||||
loading() {
|
||||
return this.$store.state.flux?.status?.getApplications === Status.Request;
|
||||
},
|
||||
service() {
|
||||
return this.$store.state.flux?.service;
|
||||
},
|
||||
credential() {
|
||||
return this.$store.state.flux?.credential;
|
||||
},
|
||||
config() {
|
||||
return this.$store.state.flux?.config;
|
||||
},
|
||||
initializing() {
|
||||
return this.$store.state.flux?.status?.getApplications === Status.Request;
|
||||
},
|
||||
needApply() {
|
||||
return this.$store.state.flux?.status?.getApplications === Status.Success && !this.application;
|
||||
},
|
||||
application() {
|
||||
return this.$store.state.flux?.application;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.flux?.applications;
|
||||
},
|
||||
tasks() {
|
||||
return this.$store.state.flux?.tasks;
|
||||
}
|
||||
@@ -135,12 +123,12 @@ export default defineComponent({
|
||||
},
|
||||
async onScrollDown() {
|
||||
setTimeout(() => {
|
||||
// scroll to bottom for `.recent`
|
||||
const el = document.querySelector('.recent');
|
||||
// scroll to bottom for `.tasks`
|
||||
const el = document.querySelector('.tasks');
|
||||
if (el) {
|
||||
el.scrollTop = el.scrollHeight;
|
||||
}
|
||||
}, 500);
|
||||
}, 1000);
|
||||
},
|
||||
async onGetTasks(payload?: { limit?: number; createdAtMin?: number; createdAtMax?: number }) {
|
||||
if (this.loading) {
|
||||
@@ -173,16 +161,13 @@ export default defineComponent({
|
||||
})
|
||||
.then(() => {
|
||||
ElMessage.success(this.$t('flux.message.startTaskSuccess'));
|
||||
this.$store.commit('flux/setConfig', {
|
||||
config: undefined
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
const response = error?.response?.data;
|
||||
if (response?.error?.code === ERROR_CODE_USED_UP) {
|
||||
ElMessage.error(this.$t('flux.message.usedUp'));
|
||||
} else {
|
||||
ElMessage.error(this.$t('flux.message.startTaskFailed'));
|
||||
ElMessage.error(this.$t('flux.message.startTaskFailed') + response?.error?.message);
|
||||
}
|
||||
})
|
||||
.finally(async () => {
|
||||
@@ -195,27 +180,3 @@ export default defineComponent({
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.status {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.panel {
|
||||
&.detail {
|
||||
width: 100%;
|
||||
flex: 1;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
&.recent {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin-bottom: 10px;
|
||||
position: relative;
|
||||
justify-content: initial;
|
||||
}
|
||||
&.operation {
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1 +1 @@
|
||||
export default ['flux.credential', 'flux.application', 'flux.applications'];
|
||||
export default ['flux.config', 'flux.credential', 'flux.application', 'flux.applications'];
|
||||
Reference in new issue
Block a user