Refine Midjourney UX layout (#59)
Co-authored-by: Germey <germey@acedata.cloud> Co-authored-by: AceDataCloud <office@acedata.cloud>
This commit is contained in:
50 files changed
+5797
-5833
No files matched your search
@@ -0,0 +1,189 @@
|
||||
<template>
|
||||
<div class="input-box">
|
||||
<el-tooltip class="box-item" effect="dark" :content="$t('midjourney.message.operation')" placement="top">
|
||||
<span class="btn btn-upload" @click="$emit('toggle-panel')" @mouseenter="$emit('open-panel')">
|
||||
<font-awesome-icon icon="fa-solid fa-plus" class="icon icon-operation" />
|
||||
</span>
|
||||
</el-tooltip>
|
||||
<span
|
||||
:class="{
|
||||
btn: true,
|
||||
'btn-send': true,
|
||||
disabled: !promptValue
|
||||
}"
|
||||
@click="onSubmit"
|
||||
>
|
||||
<font-awesome-icon icon="fa-solid fa-location-arrow" class="icon icon-send" />
|
||||
</span>
|
||||
<!-- add this textarea -->
|
||||
<textarea
|
||||
ref="textarea"
|
||||
v-model="promptValue"
|
||||
class="input"
|
||||
:placeholder="$t('midjourney.message.promptPlaceholder')"
|
||||
:style="{ height: inputHeight }"
|
||||
@keydown.enter.exact.prevent="onSubmit"
|
||||
@focus="$emit('close-panel')"
|
||||
@input="adjustTextareaHeight"
|
||||
></textarea>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElTooltip } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'InputBox',
|
||||
components: {
|
||||
ElTooltip,
|
||||
FontAwesomeIcon
|
||||
},
|
||||
props: {
|
||||
prompt: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
emits: ['update:prompt', 'submit', 'open-panel', 'toggle-panel', 'close-panel'],
|
||||
data() {
|
||||
return {
|
||||
inputHeight: '35px', //add inputHeight
|
||||
promptValue: this.prompt
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
promptValue(val: string) {
|
||||
this.$emit('update:prompt', val);
|
||||
},
|
||||
prompt(val: string) {
|
||||
if (val !== this.promptValue) {
|
||||
this.promptValue = val;
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// add textarea method
|
||||
adjustTextareaHeight() {
|
||||
this.$nextTick(() => {
|
||||
const textarea = this.$refs.textarea;
|
||||
if (textarea) {
|
||||
// @ts-ignore
|
||||
textarea.style.height = '35px';
|
||||
// @ts-ignore
|
||||
if (this.prompt) {
|
||||
textarea.style.height = textarea.scrollHeight + 'px';
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
onSubmit() {
|
||||
if (!this.prompt) {
|
||||
return;
|
||||
}
|
||||
this.$emit('submit');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
textarea.input {
|
||||
font-size: 14px;
|
||||
min-height: 35px;
|
||||
max-height: 350px;
|
||||
border: none;
|
||||
background: none;
|
||||
box-shadow: none;
|
||||
resize: none;
|
||||
line-height: 25px;
|
||||
width: calc(100% - 80px);
|
||||
margin-left: 30px;
|
||||
font-family: var(--el-font-family);
|
||||
padding-top: 6px;
|
||||
}
|
||||
textarea.input:focus {
|
||||
outline: none;
|
||||
}
|
||||
.input-box {
|
||||
position: relative;
|
||||
.input {
|
||||
textarea {
|
||||
max-height: 100px;
|
||||
border: none;
|
||||
background: none;
|
||||
box-shadow: none;
|
||||
resize: none;
|
||||
line-height: 35px;
|
||||
}
|
||||
}
|
||||
|
||||
.el-textarea.is-disabled .el-textarea__inner {
|
||||
background-color: initial;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.input-box {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
margin: auto;
|
||||
position: relative;
|
||||
border-radius: 10px;
|
||||
background: var(--el-color-info-light-9);
|
||||
padding: 5px;
|
||||
.upload {
|
||||
display: inline-block;
|
||||
&.disabled {
|
||||
.btn-upload {
|
||||
cursor: not-allowed;
|
||||
.icon-attachment {
|
||||
color: var(--el-text-color-disabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.input {
|
||||
border: none;
|
||||
width: calc(100% - 80px);
|
||||
margin-left: 35px;
|
||||
line-height: 28px;
|
||||
}
|
||||
.btn {
|
||||
display: block;
|
||||
z-index: 100;
|
||||
cursor: pointer;
|
||||
bottom: 15px;
|
||||
position: absolute;
|
||||
&.btn-upload {
|
||||
left: 15px;
|
||||
background: var(--el-color-info-light-5);
|
||||
border-radius: 50%;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
padding-top: 2px;
|
||||
.icon-attachment {
|
||||
font-size: 16px;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
}
|
||||
&.btn-send {
|
||||
right: 15px;
|
||||
&.disabled {
|
||||
.icon-send {
|
||||
color: var(--el-text-color-disabled);
|
||||
}
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.icon-send {
|
||||
font-size: 16px;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,113 +0,0 @@
|
||||
<template>
|
||||
<div class="channel-selector">
|
||||
<el-button
|
||||
v-for="(option, optionKey) in options"
|
||||
:key="optionKey"
|
||||
:class="{ button: true, active: option.name === mode.name }"
|
||||
@click="onSelect(option)"
|
||||
>
|
||||
<font-awesome-icon :class="{ icon: true, [option.name]: true }" :icon="option.icon" />
|
||||
<span>
|
||||
{{ option.getDisplayName() }}
|
||||
</span>
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElButton } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { MIDJOURNEY_MODE_FAST, MIDJOURNEY_MODE_RELAX, MIDJOURNEY_MODE_TURBO } from '@/constants';
|
||||
import { IMidjourneyMode } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ModelSelector',
|
||||
components: {
|
||||
ElButton,
|
||||
FontAwesomeIcon
|
||||
},
|
||||
emits: ['update:modelValue', 'select'],
|
||||
data() {
|
||||
return {
|
||||
options: [MIDJOURNEY_MODE_FAST, MIDJOURNEY_MODE_RELAX, MIDJOURNEY_MODE_TURBO]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
mode() {
|
||||
return this.$store.state.midjourney.mode;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onSelect(option: IMidjourneyMode) {
|
||||
this.$store.dispatch('midjourney/setMode', option);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.channel-selector {
|
||||
background-color: var(--el-bg-color-page);
|
||||
padding: 7px 6px;
|
||||
border-radius: 15px;
|
||||
margin-bottom: 5px;
|
||||
width: fit-content;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
.button {
|
||||
padding: 20px 30px;
|
||||
color: var(--el-text-color-primary);
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
margin: 0 3px;
|
||||
background-color: inherit;
|
||||
&:hover,
|
||||
&:focus,
|
||||
&.active {
|
||||
background-color: var(--el-fill-color-extra-light);
|
||||
}
|
||||
.icon {
|
||||
display: inline-block;
|
||||
margin-right: 5px;
|
||||
&.turbo {
|
||||
color: #ff9900;
|
||||
}
|
||||
&.fast {
|
||||
color: #2dc49c;
|
||||
}
|
||||
&.relax {
|
||||
color: #ce65e6;
|
||||
}
|
||||
}
|
||||
.fa-chevron-down {
|
||||
margin-left: 5px;
|
||||
font-weight: 100;
|
||||
color: #999;
|
||||
transform: scale(0.8);
|
||||
}
|
||||
}
|
||||
}
|
||||
.menu {
|
||||
.option {
|
||||
.icon {
|
||||
display: inline-block;
|
||||
margin-right: 5px;
|
||||
&.base {
|
||||
color: #ff9900;
|
||||
}
|
||||
&.plus {
|
||||
color: #ce65e6;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.channel-selector {
|
||||
.button {
|
||||
padding: 20px 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -2,9 +2,9 @@
|
||||
<div class="panel">
|
||||
<model-selector class="mb-4" />
|
||||
<ratio-selector class="mb-4" />
|
||||
<mode-selector class="mb-4" />
|
||||
<quality-selector class="mb-4" />
|
||||
<version-selector class="mb-4" />
|
||||
<translation-selector class="mb-4" />
|
||||
<advanced-selector class="mb-4" />
|
||||
<stylize-selector v-if="preset.advanced" class="mb-4" />
|
||||
<weird-selector v-if="preset.advanced" class="mb-4" />
|
||||
@@ -25,13 +25,14 @@ import QualitySelector from './preset/QualitySelector.vue';
|
||||
import ImageWeightSelector from './preset/ImageWeightSelector.vue';
|
||||
import WeirdSelector from './preset/WeirdSelector.vue';
|
||||
import AdvancedSelector from './preset/AdvancedSelector.vue';
|
||||
import TranslationSelector from './preset/TranslationSelector.vue';
|
||||
import StyleSelector from './preset/StyleSelector.vue';
|
||||
import ModeSelector from './preset/ModeSelector.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'PresetPanel',
|
||||
components: {
|
||||
ModelSelector,
|
||||
ModeSelector,
|
||||
StyleSelector,
|
||||
QualitySelector,
|
||||
RatioSelector,
|
||||
@@ -40,8 +41,7 @@ export default defineComponent({
|
||||
ChaosSelector,
|
||||
WeirdSelector,
|
||||
AdvancedSelector,
|
||||
ImageWeightSelector,
|
||||
TranslationSelector
|
||||
ImageWeightSelector
|
||||
},
|
||||
computed: {
|
||||
preset() {
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title">{{ $t('midjourney.name.mode') }}</h2>
|
||||
<el-radio-group v-model="value" size="small" class="mode">
|
||||
<el-radio-button v-for="item in options" :key="item.value" :label="item.value">
|
||||
{{ item.label }}
|
||||
</el-radio-button>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElRadioButton, ElRadioGroup } from 'element-plus';
|
||||
|
||||
export const DEFAULT_MODE = 'fast';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ModeSelector',
|
||||
components: {
|
||||
ElRadioButton,
|
||||
ElRadioGroup
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
options: [
|
||||
{
|
||||
label: this.$t('midjourney.button.fast'),
|
||||
value: 'fast'
|
||||
},
|
||||
{
|
||||
label: this.$t('midjourney.button.relax'),
|
||||
value: 'relax'
|
||||
},
|
||||
{
|
||||
label: this.$t('midjourney.button.turbo'),
|
||||
value: 'turbo'
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.midjourney.preset?.mode;
|
||||
},
|
||||
set(val) {
|
||||
console.debug('set mode', val);
|
||||
this.$store.commit('midjourney/setPreset', {
|
||||
...this.$store.state.midjourney.preset,
|
||||
mode: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = DEFAULT_MODE;
|
||||
}
|
||||
}
|
||||
});
|
||||
</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>
|
||||
|
||||
<style lang="scss">
|
||||
.mode {
|
||||
.el-radio-button--small .el-radio-button__inner {
|
||||
padding: 8px 11px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -12,8 +12,7 @@
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElRadioButton, ElRadioGroup } from 'element-plus';
|
||||
|
||||
export const DEFAULT_QUALITY = '.5';
|
||||
import { MIDJOURNEY_DEFAULT_QUALITY } from '@/constants';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'QualitySelector',
|
||||
@@ -55,7 +54,7 @@ export default defineComponent({
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = DEFAULT_QUALITY;
|
||||
this.value = MIDJOURNEY_DEFAULT_QUALITY;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
<template>
|
||||
<div v-if="tasks" class="tasks">
|
||||
<div v-for="(task, taskKey) in tasks" :key="taskKey" class="task">
|
||||
<task-preview :full="true" :model-value="task" @custom="onCustom($event)" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="tasks">
|
||||
<el-card v-for="_ in 12" :key="_" class="task">
|
||||
<el-skeleton animated>
|
||||
<template #template>
|
||||
<el-skeleton-item variant="image" class="icon-placeholder" />
|
||||
<el-skeleton-item variant="p" class="title-placeholder" />
|
||||
</template>
|
||||
</el-skeleton>
|
||||
</el-card>
|
||||
</div>
|
||||
<div class="pagination">
|
||||
<pagination :current-page="page" :page-size="limit" :total="total" @change="onPageChange" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import TaskPreview from './TaskPreview.vue';
|
||||
import Pagination from '@/components/common/Pagination.vue';
|
||||
import { ElCard, ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import { Status } from '@/models';
|
||||
|
||||
interface IData {
|
||||
job: number | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TaskFullList',
|
||||
components: {
|
||||
TaskPreview,
|
||||
Pagination,
|
||||
ElSkeleton,
|
||||
ElSkeletonItem,
|
||||
ElCard
|
||||
},
|
||||
emits: ['update:modelValue', 'custom', 'refresh'],
|
||||
data(): IData {
|
||||
return {
|
||||
job: undefined
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
page() {
|
||||
return parseInt(this.$route.query.page?.toString() || '1');
|
||||
},
|
||||
total() {
|
||||
return this.$store.state.midjourney.imagineTasksTotal;
|
||||
},
|
||||
offset() {
|
||||
return (this.page - 1) * this.limit;
|
||||
},
|
||||
limit() {
|
||||
return 12;
|
||||
},
|
||||
loading() {
|
||||
return this.$store.state.midjourney.status.getApplication === Status.Request;
|
||||
},
|
||||
tasks() {
|
||||
return this.$store.state.midjourney.imagineTasks;
|
||||
},
|
||||
application() {
|
||||
return this.$store.state.midjourney.application;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
page: {
|
||||
async handler() {
|
||||
await this.$store.dispatch('midjourney/setImagineTasks', undefined);
|
||||
this.getImagineTasks();
|
||||
}
|
||||
},
|
||||
tasks: {
|
||||
handler(val, oldVal) {
|
||||
if (val && oldVal && JSON.stringify(val) !== JSON.stringify(oldVal)) {
|
||||
this.$emit('refresh', val);
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
await this.$store.dispatch('midjourney/setImagineTasks', undefined);
|
||||
this.getImagineTasks();
|
||||
// @ts-ignore
|
||||
this.job = setInterval(() => {
|
||||
this.getImagineTasks();
|
||||
}, 5000);
|
||||
},
|
||||
unmounted() {
|
||||
clearInterval(this.job);
|
||||
},
|
||||
methods: {
|
||||
onPageChange(page: number) {
|
||||
this.$router.push({
|
||||
name: this.$route.name?.toString(),
|
||||
query: {
|
||||
page: page
|
||||
}
|
||||
});
|
||||
},
|
||||
async onCustom(event: any) {
|
||||
this.$emit('custom', event);
|
||||
setTimeout(() => {
|
||||
this.$router.push({
|
||||
name: this.$route.name?.toString(),
|
||||
query: {
|
||||
page: 1
|
||||
}
|
||||
});
|
||||
}, 3000);
|
||||
},
|
||||
async getImagineTasks() {
|
||||
// ensure that the previous request has been completed
|
||||
if (this.loading) {
|
||||
return;
|
||||
}
|
||||
await this.$store.dispatch('midjourney/getImagineTasks', {
|
||||
limit: this.limit,
|
||||
offset: this.offset
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.tasks {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
overflow-y: scroll;
|
||||
flex-wrap: wrap;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
max-width: 1700px;
|
||||
margin: 15px auto;
|
||||
padding-top: 10px;
|
||||
.task {
|
||||
width: 350px;
|
||||
margin-bottom: 30px;
|
||||
|
||||
.icon-placeholder {
|
||||
display: flex;
|
||||
height: 310px;
|
||||
width: 310px;
|
||||
margin: 0 auto 15px auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.title-placeholder {
|
||||
display: block;
|
||||
width: 80px;
|
||||
height: 20px;
|
||||
margin: 0 auto 10px auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pagination {
|
||||
height: 60px;
|
||||
padding-top: 10px;
|
||||
width: fit-content;
|
||||
margin: auto;
|
||||
}
|
||||
</style>
|
||||
+221
-225
@@ -1,118 +1,120 @@
|
||||
<template>
|
||||
<div class="preview">
|
||||
<div class="info mb-4">
|
||||
<div class="left">
|
||||
<el-tag v-if="modelValue?.response?.success === true" type="success">
|
||||
{{ $t('midjourney.button.success') }}
|
||||
</el-tag>
|
||||
<el-tag v-if="modelValue?.response?.success === false" type="danger">
|
||||
{{ $t('midjourney.button.failed') }}
|
||||
</el-tag>
|
||||
<el-tag v-if="!modelValue?.response" type="info">
|
||||
{{ $t('midjourney.button.generating') }}
|
||||
</el-tag>
|
||||
<div class="item">
|
||||
<div class="left">
|
||||
<el-image src="https://cdn.acedata.cloud/05daz4.png" class="avatar" />
|
||||
</div>
|
||||
<div class="preview">
|
||||
<div class="bot">
|
||||
{{ $t('midjourney.name.midjourneyBot') }}
|
||||
<span class="datetime">
|
||||
{{ $dayjs.format('' + new Date(parseFloat(modelValue?.created_at || '') * 1000)) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="right">
|
||||
<el-tag v-if="mode" type="info" class="channel">
|
||||
<font-awesome-icon :class="{ icon: true, [mode.name]: true }" :icon="mode.icon" />
|
||||
{{ mode?.getDisplayName() }}
|
||||
</el-tag>
|
||||
<div class="info">
|
||||
<p v-if="modelValue?.request?.prompt" class="prompt mt-2">
|
||||
{{ modelValue?.request?.prompt }}
|
||||
<span v-if="!modelValue?.response"> - ({{ $t('midjourney.status.pending') }}) </span>
|
||||
<span v-if="modelValue?.response?.progress !== undefined && modelValue?.response?.progress !== 100">
|
||||
- ({{ modelValue?.response?.progress }}%)
|
||||
</span>
|
||||
<span>({{ modelValue?.request?.mode }})</span>
|
||||
</p>
|
||||
<p v-if="modelValue?.request?.image_id" class="prompt mt-2">
|
||||
{{ modelValue?.request?.image_id }} - {{ modelValue?.request?.action }}
|
||||
<span v-if="!modelValue?.response"> - ({{ $t('midjourney.status.pending') }}) </span>
|
||||
<span>({{ modelValue?.request?.mode }})</span>
|
||||
</p>
|
||||
</div>
|
||||
<!-- response error -->
|
||||
<div v-if="modelValue?.response?.success === false" :class="{ content: true, full: full, failed: true }">
|
||||
<el-alert :closable="false" class="failure">
|
||||
<p class="description">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('midjourney.field.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('midjourney.field.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('midjourney.field.traceId') }}:
|
||||
{{ modelValue?.response?.trace_id }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.trace_id" class="btn-copy" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
<!-- response success -->
|
||||
<div v-if="modelValue?.response?.success === true" :class="{ content: true, full: full }">
|
||||
<el-image
|
||||
v-if="modelValue?.response?.image_url"
|
||||
:src="modelValue?.response?.image_url"
|
||||
:preview-src-list="[modelValue?.response?.raw_image_url as string]"
|
||||
fit="contain"
|
||||
class="image"
|
||||
:lazy="true"
|
||||
@error="onReload($event)"
|
||||
/>
|
||||
<div v-if="modelValue?.response?.actions" :class="{ operations: true, full, 'mt-2': true }">
|
||||
<el-tooltip
|
||||
v-for="(action, actionKey) in modelValue?.response?.actions"
|
||||
:key="actionKey"
|
||||
class="box-item"
|
||||
effect="dark"
|
||||
:content="descriptionMapping[action]"
|
||||
placement="top-start"
|
||||
>
|
||||
<el-button
|
||||
v-show="actionMapping[action]"
|
||||
type="info"
|
||||
size="small"
|
||||
class="btn-action"
|
||||
@click="onCustom(action)"
|
||||
>
|
||||
{{ actionMapping[action] }}
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-alert :closable="false" class="mt-2 success">
|
||||
<p class="description">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('midjourney.field.taskId') }}:
|
||||
{{ modelValue?.id }}
|
||||
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy" />
|
||||
</p>
|
||||
<p class="description">
|
||||
<font-awesome-icon icon="fa-solid fa-image" class="mr-1" />
|
||||
{{ $t('midjourney.field.imageId') }}:
|
||||
{{ modelValue?.response?.image_id }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.image_id" class="btn-copy" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
</div>
|
||||
<!-- response pending -->
|
||||
<div v-if="!modelValue?.response">
|
||||
<el-alert :closable="false" class="mt-2 info">
|
||||
<p class="description">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('midjourney.field.taskId') }}:
|
||||
{{ modelValue?.id }}
|
||||
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
</div>
|
||||
<div class="extra">
|
||||
<p v-if="modelValue?.request?.prompt" class="prompt">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ modelValue?.request?.prompt }}
|
||||
</p>
|
||||
</div>
|
||||
<div v-if="!modelValue?.response" :class="{ content: true, full: !!full }">
|
||||
<el-image class="image">
|
||||
<template #error>
|
||||
<div class="image-slot">{{ $t('midjourney.message.generating') }}</div>
|
||||
</template>
|
||||
</el-image>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="modelValue?.response.success === false"
|
||||
:class="{ content: true, full: full, failed: true, 'p-2': true }"
|
||||
>
|
||||
<el-alert :closable="false">
|
||||
<template #template>
|
||||
<font-awesome-icon icon="fa-solid fa-exclamation-triangle" class="mr-1" />
|
||||
{{ $t('midjourney.field.failure') }}
|
||||
</template>
|
||||
<p class="description">
|
||||
<font-awesome-icon icon="fa-solid fa-circle-info" class="mr-1" />
|
||||
{{ $t('midjourney.field.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('midjourney.field.traceId') }}:
|
||||
{{ modelValue?.response?.trace_id }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.trace_id" class="btn-copy" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
<div v-else :class="{ content: true, full: full }">
|
||||
<el-image
|
||||
v-if="modelValue?.response?.image_url"
|
||||
:src="modelValue?.response?.image_url"
|
||||
:preview-src-list="[modelValue?.response?.raw_image_url as string]"
|
||||
fit="contain"
|
||||
class="image"
|
||||
:lazy="true"
|
||||
@error="onReload($event)"
|
||||
/>
|
||||
<p v-if="modelValue?.response?.progress !== undefined && modelValue?.response?.progress !== 100" class="progress">
|
||||
{{ modelValue?.response?.progress }}%
|
||||
</p>
|
||||
</div>
|
||||
<div v-if="modelValue?.response?.actions" :class="{ operations: true, full }">
|
||||
<el-tooltip
|
||||
v-for="(action, actionKey) in modelValue?.response?.actions"
|
||||
:key="actionKey"
|
||||
class="box-item"
|
||||
effect="dark"
|
||||
:content="descriptionMapping[action]"
|
||||
placement="top-start"
|
||||
>
|
||||
<el-button v-show="actionMapping[action]" type="info" size="small" class="btn-action" @click="onCustom(action)">
|
||||
{{ actionMapping[action] }}
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<div v-else-if="!modelValue?.response" v-show="full" :class="{ operations: true, full }">
|
||||
<el-skeleton :rows="1" />
|
||||
</div>
|
||||
<div v-else v-show="full" :class="{ operations: true, full }">
|
||||
<p>
|
||||
{{ $t('midjourney.message.noOperations') }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="extra">
|
||||
<p v-if="modelValue?.created_at" class="datetime">
|
||||
<font-awesome-icon icon="fa-regular fa-clock" class="mr-1" />
|
||||
{{ $dayjs.format('' + new Date(parseFloat(modelValue?.created_at) * 1000)) }}
|
||||
</p>
|
||||
<p class="description">{{ $t('midjourney.field.taskId') }}: {{ modelValue?.id }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElImage, ElTag, ElButton, ElTooltip, ElSkeleton, ElAlert } from 'element-plus';
|
||||
import {
|
||||
IMidjourneyImagineTask,
|
||||
MidjourneyImagineAction,
|
||||
MidjourneyImagineMode,
|
||||
MidjourneyImagineState
|
||||
} from '@/models';
|
||||
import { ElImage, ElButton, ElTooltip, ElAlert } from 'element-plus';
|
||||
import { IMidjourneyImagineTask, MidjourneyImagineAction, MidjourneyImagineState } from '@/models';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import { MIDJOURNEY_MODE_FAST, MIDJOURNEY_MODE_RELAX, MIDJOURNEY_MODE_TURBO } from '@/constants';
|
||||
|
||||
interface IData {
|
||||
midjourneyImagineState: typeof MidjourneyImagineState;
|
||||
@@ -124,11 +126,9 @@ export default defineComponent({
|
||||
name: 'TaskPreview',
|
||||
components: {
|
||||
ElImage,
|
||||
ElTag,
|
||||
ElButton,
|
||||
FontAwesomeIcon,
|
||||
ElTooltip,
|
||||
ElSkeleton,
|
||||
ElAlert,
|
||||
CopyToClipboard
|
||||
},
|
||||
@@ -209,18 +209,6 @@ export default defineComponent({
|
||||
computed: {
|
||||
application() {
|
||||
return this.$store.state.midjourney.application;
|
||||
},
|
||||
mode() {
|
||||
switch (this.modelValue?.request?.mode) {
|
||||
case MidjourneyImagineMode.FAST:
|
||||
return MIDJOURNEY_MODE_FAST;
|
||||
case MidjourneyImagineMode.TURBO:
|
||||
return MIDJOURNEY_MODE_TURBO;
|
||||
case MidjourneyImagineMode.RELAX:
|
||||
return MIDJOURNEY_MODE_RELAX;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -255,62 +243,68 @@ export default defineComponent({
|
||||
link.href = url;
|
||||
link.download = url.split('/').pop() as string;
|
||||
link.click();
|
||||
},
|
||||
getModeIcon(mode: MidjourneyImagineMode): string | undefined {
|
||||
switch (mode) {
|
||||
case MidjourneyImagineMode.FAST:
|
||||
return MIDJOURNEY_MODE_FAST.icon;
|
||||
case MidjourneyImagineMode.TURBO:
|
||||
return MIDJOURNEY_MODE_TURBO.icon;
|
||||
case MidjourneyImagineMode.RELAX:
|
||||
return MIDJOURNEY_MODE_RELAX.icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.preview {
|
||||
width: 350px;
|
||||
padding: 15px;
|
||||
$left-width: 70px;
|
||||
.item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
border-radius: 20px;
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
|
||||
.description {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-regular);
|
||||
margin-bottom: 10px;
|
||||
flex-direction: row;
|
||||
.left {
|
||||
width: $left-width;
|
||||
.avatar {
|
||||
background-color: white;
|
||||
padding: 8px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
margin: 10px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
.info {
|
||||
.preview {
|
||||
flex: 1;
|
||||
width: calc(100% - $left-width);
|
||||
padding: 10px 10px 0 10px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: stretch;
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
|
||||
.left {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
flex: 1;
|
||||
.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;
|
||||
}
|
||||
}
|
||||
|
||||
.right {
|
||||
.description {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-regular);
|
||||
margin-bottom: 10px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.info {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-end;
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
|
||||
.btn {
|
||||
cursor: pointer;
|
||||
.prompt {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
color: var(--el-text-color-regular);
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.channel {
|
||||
.mode {
|
||||
.icon {
|
||||
display: inline-block;
|
||||
margin-right: 2px;
|
||||
@@ -326,82 +320,84 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.content {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
margin-bottom: 10px;
|
||||
&.full {
|
||||
height: 220px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.image {
|
||||
min-height: 200px;
|
||||
}
|
||||
}
|
||||
&.failed {
|
||||
.image {
|
||||
.image-slot {
|
||||
font-size: 16px;
|
||||
padding: 20px;
|
||||
|
||||
.content {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
margin-bottom: 10px;
|
||||
&.full {
|
||||
height: 220px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.image {
|
||||
min-height: 200px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 100px;
|
||||
.image-slot {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: var(--el-fill-color-light);
|
||||
color: var(--el-text-color-regular);
|
||||
&.failed {
|
||||
.image {
|
||||
.image-slot {
|
||||
font-size: 16px;
|
||||
padding: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.image {
|
||||
height: 350px;
|
||||
.image-slot {
|
||||
display: flex;
|
||||
justify-content: left;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: var(--el-fill-color-light);
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
}
|
||||
.progress {
|
||||
position: absolute;
|
||||
top: 49%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
text-shadow: 0 0 5px black;
|
||||
}
|
||||
}
|
||||
.progress {
|
||||
position: absolute;
|
||||
top: 49%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
text-shadow: 0 0 5px black;
|
||||
}
|
||||
}
|
||||
|
||||
.operations {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
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;
|
||||
.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);
|
||||
}
|
||||
}
|
||||
|
||||
.btn-action {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.extra {
|
||||
text-align: center;
|
||||
.datetime,
|
||||
.prompt {
|
||||
font-size: 12px;
|
||||
.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);
|
||||
margin-bottom: 5px;
|
||||
font-size: 14px;
|
||||
overflow-y: scroll;
|
||||
|
||||
&.full {
|
||||
height: 70px;
|
||||
}
|
||||
|
||||
.btn-action {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+57
-35
@@ -1,40 +1,44 @@
|
||||
<template>
|
||||
<div v-if="tasks === undefined" class="tasks">
|
||||
<el-card v-for="_ in 3" :key="_" class="task">
|
||||
<el-skeleton animated>
|
||||
<template #template>
|
||||
<el-skeleton-item variant="image" class="icon-placeholder" />
|
||||
<el-skeleton-item variant="p" class="title-placeholder" />
|
||||
</template>
|
||||
</el-skeleton>
|
||||
</el-card>
|
||||
<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 && tasks?.length === 0">
|
||||
<p class="p-5 description">{{ $t('midjourney.message.noTasks') }}</p>
|
||||
</div>
|
||||
<div v-else-if="tasks.length > 0" class="tasks">
|
||||
<div v-for="(task, taskKey) in tasks" :key="taskKey" class="task">
|
||||
<task-preview :full="false" :model-value="task" @custom="$emit('custom', $event)" />
|
||||
<task-item :full="false" :model-value="task" @custom="$emit('custom', $event)" />
|
||||
</div>
|
||||
<el-button type="primary" round class="btn mb-4" @click="onLoadHistory">{{
|
||||
$t('midjourney.button.history')
|
||||
}}</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import TaskPreview from './TaskPreview.vue';
|
||||
import TaskItem from './TaskItem.vue';
|
||||
import { ROUTE_MIDJOURNEY_HISTORY } from '@/router';
|
||||
import { ElButton, ElCard, ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import { ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import { Status } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TaskBriefList',
|
||||
name: 'TaskList',
|
||||
components: {
|
||||
TaskPreview,
|
||||
ElButton,
|
||||
ElCard,
|
||||
TaskItem,
|
||||
ElSkeleton,
|
||||
ElSkeletonItem
|
||||
},
|
||||
@@ -49,7 +53,8 @@ export default defineComponent({
|
||||
return this.$store.state.midjourney.status.getApplication === Status.Request;
|
||||
},
|
||||
tasks() {
|
||||
return this.$store.state.midjourney.imagineTasks;
|
||||
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
||||
return this.$store.state.midjourney.imagineTasks?.reverse();
|
||||
},
|
||||
application() {
|
||||
return this.$store.state.midjourney.application;
|
||||
@@ -86,7 +91,7 @@ export default defineComponent({
|
||||
return;
|
||||
}
|
||||
await this.$store.dispatch('midjourney/getImagineTasks', {
|
||||
limit: 12,
|
||||
limit: 50,
|
||||
offset: 0
|
||||
});
|
||||
}
|
||||
@@ -101,31 +106,48 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
.tasks {
|
||||
padding-top: 20px;
|
||||
overflow-y: scroll;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
.task {
|
||||
margin-bottom: 15px;
|
||||
width: 350px;
|
||||
margin: 8px;
|
||||
width: 100%;
|
||||
height: fit-content;
|
||||
text-align: left;
|
||||
|
||||
.icon-placeholder {
|
||||
&.placeholder {
|
||||
display: flex;
|
||||
height: 310px;
|
||||
width: 310px;
|
||||
margin: 0 auto 15px auto;
|
||||
text-align: center;
|
||||
}
|
||||
flex-direction: row;
|
||||
.left {
|
||||
width: 70px;
|
||||
padding: 10px;
|
||||
|
||||
.title-placeholder {
|
||||
display: block;
|
||||
width: 80px;
|
||||
height: 20px;
|
||||
margin: 0 auto 10px auto;
|
||||
.avatar {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
.main {
|
||||
width: calc(100% - 70px);
|
||||
flex: 1;
|
||||
padding: 0 10px;
|
||||
|
||||
.icon {
|
||||
display: flex;
|
||||
height: 300px;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.title {
|
||||
display: block;
|
||||
width: 200px;
|
||||
height: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.operations {
|
||||
Reference in new issue
Block a user