Add mj describe (#257)
This commit is contained in:
1 parent
80c23d29d0
commit
d6dfe05ccc
27 files changed
+1319
-935
No files matched your search
@@ -18,6 +18,7 @@
|
||||
<image-weight-selector class="mb-2" />
|
||||
<style-selector class="mb-2" />
|
||||
</div>
|
||||
<prompt-input class="mb-4" />
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
@@ -25,15 +26,20 @@
|
||||
<div class="pt-2">
|
||||
<video-from-input v-show="config?.action === 'extend'" class="mb-4" />
|
||||
<image-url-input class="mb-2" />
|
||||
<prompt-input class="mb-4" />
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('midjourney.tab.describe')" name="describe">
|
||||
<div class="pt-2">
|
||||
<image-url-input2 class="mb-2" />
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<prompt-input class="mb-4" />
|
||||
</div>
|
||||
<div class="flex flex-col px-[15px] pb-[15px]">
|
||||
<consumption :value="consumption" :service="service" />
|
||||
<div class="flex gap-1">
|
||||
<mode-selector />
|
||||
<mode-selector v-if="activeTab !== 'describe'" />
|
||||
<el-button v-if="config.action === 'extend'" type="primary" class="btn w-full" round @click="$emit('generate')">
|
||||
{{ $t('midjourney.button.extend') }}
|
||||
</el-button>
|
||||
@@ -51,6 +57,7 @@ import RatioSelector from './config/RatioSelector.vue';
|
||||
import AdvancedSelector from './config/AdvancedSelector.vue';
|
||||
import VersionSelector from './config/VersionSelector.vue';
|
||||
import ImageUrlInput from './config/ImageUrlInput.vue';
|
||||
import ImageUrlInput2 from './config/ImageUrlInput2.vue';
|
||||
import StylizeSelector from './config/StylizeSelector.vue';
|
||||
import ChaosSelector from './config/ChaosSelector.vue';
|
||||
import ModelSelector from './config/ModelSelector.vue';
|
||||
@@ -86,6 +93,7 @@ export default defineComponent({
|
||||
ImageWeightSelector,
|
||||
ReferenceImage,
|
||||
ImageUrlInput,
|
||||
ImageUrlInput2,
|
||||
Consumption,
|
||||
VideoFromInput,
|
||||
ElTabs,
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
<template>
|
||||
<div class="relative">
|
||||
<div class="flex justify-between">
|
||||
<div class="flex justify-start items-center">
|
||||
<span class="text-sm font-bold">{{ $t('midjourney.name.imageUrl2') }}</span>
|
||||
<info-icon :content="$t('midjourney.description.imageUrl2')" />
|
||||
</div>
|
||||
</div>
|
||||
<el-upload
|
||||
v-model:file-list="fileList"
|
||||
name="file"
|
||||
:limit="5"
|
||||
class="upload-wrapper"
|
||||
accept=".png,.jpg,.jpeg,.gif,.bmp,.webp"
|
||||
:multiple="true"
|
||||
list-type="picture"
|
||||
:action="uploadUrl"
|
||||
:on-exceed="onExceed"
|
||||
:on-error="onError"
|
||||
:headers="headers"
|
||||
>
|
||||
<template #file="{ file }">
|
||||
<image-preview
|
||||
:url="file.url || (file.response as any)?.file_url"
|
||||
:name="file.name"
|
||||
:percentage="file.percentage"
|
||||
@remove="fileList.splice(fileList.indexOf(file), 1)"
|
||||
/>
|
||||
</template>
|
||||
<el-button round type="primary" size="small" class="btn btn-upload">
|
||||
<font-awesome-icon icon="fa-solid fa-upload" class="icon mr-1" />
|
||||
{{ $t('midjourney.button.uploadImageUrl') }}
|
||||
</el-button>
|
||||
</el-upload>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElUpload, ElButton, UploadFiles, UploadFile, ElMessage } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { getBaseUrlPlatform } from '@/utils';
|
||||
import InfoIcon from '@/components/common/InfoIcon.vue';
|
||||
import ImagePreview from '@/components/common/ImagePreview.vue';
|
||||
|
||||
interface IData {
|
||||
fileList: UploadFiles;
|
||||
uploadUrl: string;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ReferenceImage',
|
||||
components: {
|
||||
ElUpload,
|
||||
ElButton,
|
||||
InfoIcon,
|
||||
FontAwesomeIcon,
|
||||
ImagePreview
|
||||
},
|
||||
emits: ['change'],
|
||||
data(): IData {
|
||||
return {
|
||||
fileList: [],
|
||||
uploadUrl: getBaseUrlPlatform() + '/api/v1/files/'
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
headers() {
|
||||
return {
|
||||
Authorization: `Bearer ${this.$store.state.token.access}`
|
||||
};
|
||||
},
|
||||
urls() {
|
||||
// @ts-ignore
|
||||
return this.fileList.map((file: UploadFile) => file?.response?.file_url);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
urls: {
|
||||
handler(val) {
|
||||
console.debug('URLs changed:', val);
|
||||
this.$store.commit('midjourney/setConfig', {
|
||||
...this.$store.state.midjourney.config,
|
||||
image_url: val[0]
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onExceed() {
|
||||
ElMessage.warning(this.$t('midjourney.message.uploadStartImageExceed'));
|
||||
},
|
||||
onError() {
|
||||
ElMessage.error(this.$t('midjourney.message.uploadStartImageError'));
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin-bottom: 0;
|
||||
width: 30%;
|
||||
}
|
||||
.btn.btn-upload {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
.upload-wrapper {
|
||||
height: auto;
|
||||
display: flex;
|
||||
.el-upload-list {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -218,11 +218,119 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="modelValue?.type === 'describe'" class="item">
|
||||
<div class="left">
|
||||
<el-image src="https://cdn.acedata.cloud/wto43b.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 || '').toString()) * 1000)) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="info">
|
||||
<p v-if="modelValue?.request?.image_url" class="prompt mt-2">
|
||||
{{ modelValue?.request?.image_url }}
|
||||
<span v-if="!modelValue?.response?.descriptions"> - ({{ $t('midjourney.status.describePending') }}) </span>
|
||||
<span v-if="modelValue?.response?.descriptions"> - ({{ $t('midjourney.status.describeComplete') }}) </span>
|
||||
</p>
|
||||
</div>
|
||||
<!-- response error -->
|
||||
<div
|
||||
v-if="modelValue?.response && !modelValue?.response?.descriptions"
|
||||
:class="{ content: true, full: full, failed: true }"
|
||||
>
|
||||
<el-alert :closable="false" class="failure">
|
||||
<p class="text-[var(--el-text-color-regular)] text-xs mb-2">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('midjourney.field.taskId') }}:
|
||||
{{ modelValue?.id }}
|
||||
<copy-to-clipboard :content="modelValue?.id!" />
|
||||
</p>
|
||||
<p class="text-[var(--el-text-color-regular)] text-xs mb-2">
|
||||
<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!" />
|
||||
</p>
|
||||
<p class="text-[var(--el-text-color-regular)] text-xs mb-0">
|
||||
<font-awesome-icon icon="fa-solid fa-hashtag" class="mr-1" />
|
||||
{{ $t('midjourney.field.traceId') }}:
|
||||
{{ modelValue?.trace_id }}
|
||||
<copy-to-clipboard :content="modelValue?.trace_id" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
<!-- response success -->
|
||||
<div v-if="modelValue?.response?.descriptions" :class="{ content: true, full: full }">
|
||||
<div class="mb-4">
|
||||
<!-- 描述列表 -->
|
||||
<div class="mb-4">
|
||||
<div
|
||||
v-for="(description, index) in modelValue.response.descriptions"
|
||||
:key="index"
|
||||
class="flex items-start mb-3"
|
||||
>
|
||||
<div v-if="description !== ''">
|
||||
<!-- 使用 el-tag 美化序号 -->
|
||||
<el-tag
|
||||
effect="dark"
|
||||
color="#3574F0"
|
||||
size="small"
|
||||
type="primary"
|
||||
class="flex-shrink-0 font-bold mr-3 mt-0.5 border-0"
|
||||
>
|
||||
{{ index + 1 }}
|
||||
</el-tag>
|
||||
<span class="text-sm text-[var(--el-text-color-primary)]">
|
||||
{{ description }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 参考图片 -->
|
||||
<image-wrapper
|
||||
v-if="modelValue?.request?.image_url"
|
||||
:src="modelValue?.request?.image_url"
|
||||
:raw-src="modelValue?.request?.image_url"
|
||||
class="image w-full rounded-lg"
|
||||
/>
|
||||
</div>
|
||||
<el-alert :closable="false" class="mt-2 success">
|
||||
<p class="text-[var(--el-text-color-regular)] text-xs mb-2">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('midjourney.field.taskId') }}:
|
||||
{{ modelValue?.id }}
|
||||
<copy-to-clipboard :content="modelValue?.id!" />
|
||||
</p>
|
||||
<p class="text-[var(--el-text-color-regular)] text-xs mb-2">
|
||||
<font-awesome-icon icon="fa-solid fa-hashtag" class="mr-1" />
|
||||
{{ $t('midjourney.field.traceId') }}:
|
||||
{{ modelValue?.trace_id }}
|
||||
<copy-to-clipboard :content="modelValue?.trace_id" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
<!-- response pending -->
|
||||
<div v-if="!modelValue?.response">
|
||||
<el-alert :closable="false" class="mt-2 info">
|
||||
<p class="text-[var(--el-text-color-regular)] text-xs mb-0">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('midjourney.field.taskId') }}:
|
||||
{{ modelValue?.id }}
|
||||
<copy-to-clipboard :content="modelValue?.id!" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElImage, ElButton, ElTooltip, ElAlert } from 'element-plus';
|
||||
import { ElImage, ElButton, ElTooltip, ElAlert, ElTag } from 'element-plus';
|
||||
import { IMidjourneyTask, MidjourneyImagineAction, MidjourneyImagineState, IMidjourneyVideosResponse } from '@/models';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
@@ -243,6 +351,7 @@ export default defineComponent({
|
||||
FontAwesomeIcon,
|
||||
ElTooltip,
|
||||
ElAlert,
|
||||
ElTag,
|
||||
CopyToClipboard,
|
||||
VideoPlayer
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user