1 parent
54bf77175b
commit
2b894cf243
45 files changed
+10799
-9648
No files matched your search
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "minor",
|
||||
"comment": "add mj videos",
|
||||
"packageName": "@acedatacloud/nexior",
|
||||
"email": "1348977728@qq.com",
|
||||
"dependentChangeType": "patch"
|
||||
}
|
||||
@@ -1,14 +1,17 @@
|
||||
<template>
|
||||
<div class="panel flex flex-col">
|
||||
<div class="flex-1 overflow-y-scroll p-4">
|
||||
<model-selector class="mb-2" />
|
||||
<is-videos-selector class="mb-2" />
|
||||
<model-selector v-if="!config.is_videos" class="mb-2" />
|
||||
<prompt-input class="mb-2" />
|
||||
<ratio-selector class="mb-4" />
|
||||
<quality-selector class="mb-4" />
|
||||
<version-selector class="mb-4" />
|
||||
<reference-image class="mb-2" />
|
||||
<elements-selector class="mb-2" />
|
||||
<advanced-selector class="mb-2" />
|
||||
<image-url-input v-if="config.is_videos" class="mb-2" />
|
||||
<reference-image v-if="!config.is_videos" class="mb-2" />
|
||||
<ratio-selector v-if="!config.is_videos" class="mb-4" />
|
||||
<quality-selector v-if="!config.is_videos" class="mb-4" />
|
||||
<version-selector v-if="!config.is_videos" class="mb-4" />
|
||||
<reference-image v-if="!config.is_videos" class="mb-2" />
|
||||
<elements-selector v-if="!config.is_videos" class="mb-2" />
|
||||
<advanced-selector v-if="!config.is_videos" class="mb-2" />
|
||||
<stylize-selector v-show="config.advanced" class="mb-2" />
|
||||
<weird-selector v-show="config.advanced" class="mb-2" />
|
||||
<chaos-selector v-show="config.advanced" class="mb-2" />
|
||||
@@ -18,7 +21,10 @@
|
||||
<div class="h-12 px-4">
|
||||
<div class="flex gap-1">
|
||||
<mode-selector />
|
||||
<el-button type="primary" class="btn w-full" round @click="$emit('generate')">
|
||||
<el-button v-if="config.action === 'extend'" type="primary" class="btn w-full" round @click="$emit('generate')">
|
||||
{{ $t('midjourney.button.extend') }}
|
||||
</el-button>
|
||||
<el-button v-else type="primary" class="btn w-full" round @click="$emit('generate')">
|
||||
{{ $t('midjourney.button.generate') }}
|
||||
</el-button>
|
||||
</div>
|
||||
@@ -30,7 +36,9 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import RatioSelector from './config/RatioSelector.vue';
|
||||
import AdvancedSelector from './config/AdvancedSelector.vue';
|
||||
import IsVideosSelector from './config/IsVideosSelector.vue';
|
||||
import VersionSelector from './config/VersionSelector.vue';
|
||||
import ImageUrlInput from './config/ImageUrlInput.vue';
|
||||
import StylizeSelector from './config/StylizeSelector.vue';
|
||||
import ChaosSelector from './config/ChaosSelector.vue';
|
||||
import ModelSelector from './config/ModelSelector.vue';
|
||||
@@ -61,7 +69,9 @@ export default defineComponent({
|
||||
ChaosSelector,
|
||||
WeirdSelector,
|
||||
ImageWeightSelector,
|
||||
ReferenceImage
|
||||
ReferenceImage,
|
||||
IsVideosSelector,
|
||||
ImageUrlInput
|
||||
},
|
||||
emits: ['generate'],
|
||||
computed: {
|
||||
|
||||
@@ -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.imageUrl') }}</span>
|
||||
<info-icon :content="$t('midjourney.description.imageUrl')" />
|
||||
</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>
|
||||
@@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title">{{ $t('midjourney.name.isVideos') }}</h2>
|
||||
<el-switch v-model="value" class="value" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSwitch } from 'element-plus';
|
||||
|
||||
const DEFAULT_IS_VIDEOS = false;
|
||||
|
||||
export default defineComponent({
|
||||
name: 'IsVideosSelector',
|
||||
components: {
|
||||
ElSwitch
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.midjourney.config.is_videos;
|
||||
},
|
||||
set(val: boolean) {
|
||||
console.debug('set is_videos', val);
|
||||
this.$store.commit('midjourney/setConfig', {
|
||||
...this.$store.state.midjourney.config,
|
||||
is_videos: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.value === undefined) {
|
||||
this.value = DEFAULT_IS_VIDEOS;
|
||||
}
|
||||
}
|
||||
});
|
||||
</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;
|
||||
}
|
||||
.info {
|
||||
width: 20px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -110,16 +110,124 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="modelValue?.type === 'videos'" 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?.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?.video_id" class="prompt mt-2">
|
||||
{{ modelValue?.request?.video_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="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?.response?.trace_id }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.trace_id" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
<!-- response success -->
|
||||
<div v-if="modelValue?.response?.success === true" :class="{ content: true, full: full }">
|
||||
<div v-if="modelValue?.response.video_urls" class="mb-4">
|
||||
<video-player :src="modelValue?.response.video_urls[0]" />
|
||||
</div>
|
||||
<div
|
||||
v-if="modelValue?.response && modelValue?.response?.video_urls"
|
||||
:class="{ operations: true, 'mt-2': true, 'mb-4': true }"
|
||||
>
|
||||
<el-tooltip class="box-item" effect="dark" :content="$t('luma.message.extendVideo')" placement="top-start">
|
||||
<el-button type="info" size="small" class="btn-action" @click.stop="onExtend($event, modelValue?.response)">
|
||||
{{ $t('midjourney.button.extend') }}
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip class="box-item" effect="dark" :content="$t('luma.message.downloadVideo')" placement="top-start">
|
||||
<el-button
|
||||
type="info"
|
||||
size="small"
|
||||
class="btn-action"
|
||||
@click.stop="onDownload(modelValue.response.video_urls[0])"
|
||||
>
|
||||
{{ $t('midjourney.button.download') }}
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</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>
|
||||
<p class="text-[var(--el-text-color-regular)] text-xs mb-0">
|
||||
<font-awesome-icon icon="fa-solid fa-image" class="mr-1" />
|
||||
{{ $t('midjourney.field.videoId') }}:
|
||||
{{ modelValue?.response?.video_id }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.video_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 { IMidjourneyTask, MidjourneyImagineAction, MidjourneyImagineState } from '@/models';
|
||||
import { IMidjourneyTask, MidjourneyImagineAction, MidjourneyImagineState, IMidjourneyVideosResponse } from '@/models';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import ImageWrapper from '@/components/common/ImageWrapper.vue';
|
||||
|
||||
import VideoPlayer from '@/components/common/VideoPlayer.vue';
|
||||
interface IData {
|
||||
midjourneyImagineState: typeof MidjourneyImagineState;
|
||||
actionMapping: Record<MidjourneyImagineAction, string>;
|
||||
@@ -135,7 +243,8 @@ export default defineComponent({
|
||||
FontAwesomeIcon,
|
||||
ElTooltip,
|
||||
ElAlert,
|
||||
CopyToClipboard
|
||||
CopyToClipboard,
|
||||
VideoPlayer
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
@@ -214,6 +323,9 @@ export default defineComponent({
|
||||
computed: {
|
||||
application() {
|
||||
return this.$store.state.midjourney.application;
|
||||
},
|
||||
config() {
|
||||
return this.$store.state.midjourney?.config;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -225,6 +337,16 @@ export default defineComponent({
|
||||
});
|
||||
}
|
||||
},
|
||||
onExtend(_event: MouseEvent, response: IMidjourneyVideosResponse) {
|
||||
// extend url here
|
||||
console.debug('set config', response);
|
||||
this.$store.commit('midjourney/setConfig', {
|
||||
...this.$store.state.midjourney?.config,
|
||||
video_id: response.video_id,
|
||||
action: 'extend',
|
||||
is_videos: true
|
||||
});
|
||||
},
|
||||
onDownload(url: string) {
|
||||
// download image using javascript
|
||||
const link = document.createElement('a');
|
||||
|
||||
@@ -6,7 +6,13 @@
|
||||
<no-tasks />
|
||||
</div>
|
||||
<div v-else-if="tasks.length > 0" ref="panel" class="p-2 flex flex-col overflow-y-auto" @scroll="onHandleScroll">
|
||||
<task-item v-for="(task, taskKey) in tasks" :key="taskKey" :model-value="task" @custom="$emit('custom', $event)" />
|
||||
<task-item
|
||||
v-for="(task, taskKey) in tasks"
|
||||
:key="taskKey"
|
||||
:model-value="task"
|
||||
@extend="$emit('extend', $event)"
|
||||
@custom="$emit('custom', $event)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -23,7 +29,7 @@ export default defineComponent({
|
||||
BotPlaceholder,
|
||||
NoTasks
|
||||
},
|
||||
emits: ['custom', 'reach-top'],
|
||||
emits: ['custom', 'extend', 'reach-top'],
|
||||
data() {
|
||||
return {
|
||||
job: 0
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+638
-598
File diff suppressed because it is too large.
Load diff
+581
-541
File diff suppressed because it is too large.
Load diff
+693
-653
File diff suppressed because it is too large.
Load diff
+558
-518
File diff suppressed because it is too large.
Load diff
+518
-478
File diff suppressed because it is too large.
Load diff
+665
-625
File diff suppressed because it is too large.
Load diff
+542
-502
File diff suppressed because it is too large.
Load diff
+556
-516
File diff suppressed because it is too large.
Load diff
+610
-570
File diff suppressed because it is too large.
Load diff
+490
-450
File diff suppressed because it is too large.
Load diff
+591
-551
File diff suppressed because it is too large.
Load diff
+579
-539
File diff suppressed because it is too large.
Load diff
+597
-557
File diff suppressed because it is too large.
Load diff
+687
-646
File diff suppressed because it is too large.
Load diff
+609
-569
File diff suppressed because it is too large.
Load diff
+597
-557
File diff suppressed because it is too large.
Load diff
@@ -1443,6 +1443,14 @@
|
||||
"message": "普通",
|
||||
"description": "按钮文本,表示'低'图片质量"
|
||||
},
|
||||
"button.uploadImageUrl": {
|
||||
"message": "上传图片",
|
||||
"description": "上传图片的按钮文本"
|
||||
},
|
||||
"button.extend": {
|
||||
"message": "扩展",
|
||||
"description": "按钮文本,表示扩展视频"
|
||||
},
|
||||
"button.medium": {
|
||||
"message": "清晰",
|
||||
"description": "按钮文本,表示'中'图片质量"
|
||||
@@ -1515,6 +1523,10 @@
|
||||
"message": "图像ID",
|
||||
"description": "图像ID"
|
||||
},
|
||||
"field.videoId": {
|
||||
"message": "视频ID",
|
||||
"description": "视频ID"
|
||||
},
|
||||
"field.finalPrompt": {
|
||||
"message": "最终提示",
|
||||
"description": "用于生成图像的最终绘画提示"
|
||||
@@ -1603,6 +1615,10 @@
|
||||
"message": "--weird,探索具有实验性质的不寻常审美风格,范围为0-3000,默认为0",
|
||||
"description": "怪异参数的描述"
|
||||
},
|
||||
"description.imageUrl": {
|
||||
"message": "在创建视频的任务中,它必须上传一张图片。",
|
||||
"description": "参数'imageUrl'的描述"
|
||||
},
|
||||
"description.translation": {
|
||||
"message": "在生成过程中启用自动翻译,非中文内容将自动翻译为Midjourney的英文输入",
|
||||
"description": "翻译参数的描述"
|
||||
@@ -1744,7 +1760,7 @@
|
||||
"description": "重做放大 4 倍按钮的描述"
|
||||
},
|
||||
"message.promptPlaceholder": {
|
||||
"message": "请输入一句话描述您想生成的图像,例如:一只可爱的猫。额外的参数将覆盖默认预设参数",
|
||||
"message": "请输入一句话描述您想生成的图像或视频,例如:一只可爱的猫。额外的参数将覆盖默认预设参数",
|
||||
"description": "提示字段中的占位文本"
|
||||
},
|
||||
"message.uploadReferencesExceed": {
|
||||
@@ -1767,14 +1783,30 @@
|
||||
"message": "成功开始绘图任务",
|
||||
"description": "成功开始绘图任务时的成功消息"
|
||||
},
|
||||
"message.startVideosTaskSuccess": {
|
||||
"message": "成功开始视频生成任务",
|
||||
"description": "成功开始视频生成任务时的成功消息"
|
||||
},
|
||||
"message.startTaskFailed": {
|
||||
"message": "无法开始绘图任务,请联系管理员",
|
||||
"description": "无法开始绘图任务时的错误消息"
|
||||
},
|
||||
"message.startVideosTaskFailed": {
|
||||
"message": "无法开始视频生成任务,请联系管理员",
|
||||
"description": "无法开始视频生成任务时的错误消息"
|
||||
},
|
||||
"message.generating": {
|
||||
"message": "生成中...",
|
||||
"description": "图像生成中的消息"
|
||||
},
|
||||
"message.uploadStartImageExceed": {
|
||||
"message": "上传首帧图片数量超过限制",
|
||||
"description": "上传首帧图片数量超过限制时的错误信息"
|
||||
},
|
||||
"message.uploadStartImageError": {
|
||||
"message": "上传首帧图片失败",
|
||||
"description": "上传首帧图片失败时的错误信息"
|
||||
},
|
||||
"message.noOperations": {
|
||||
"message": "无可用操作",
|
||||
"description": "没有可用操作时的消息"
|
||||
@@ -1803,6 +1835,14 @@
|
||||
"message": "参考图",
|
||||
"description": "参考图像的名称"
|
||||
},
|
||||
"name.imageUrl": {
|
||||
"message": "首帧图片",
|
||||
"description": "首帧图片的名称"
|
||||
},
|
||||
"name.isVideos": {
|
||||
"message": "视频生成",
|
||||
"description": "视频生成的开关"
|
||||
},
|
||||
"name.midjourneyBot": {
|
||||
"message": "Midjourney Bot",
|
||||
"description": "Name of the Midjourney model"
|
||||
@@ -1916,7 +1956,7 @@
|
||||
"description": "原始参数的名称,用于启用 Midjourney 模型"
|
||||
},
|
||||
"placeholder.prompt": {
|
||||
"message": "输入一句话描述您想生成的图像,例如:一只可爱的猫。额外的参数将覆盖默认预设参数",
|
||||
"message": "输入一句话描述您想生成的图像或视频,例如:一只可爱的猫。额外的参数将覆盖默认预设参数",
|
||||
"description": "提示字段中的占位文本"
|
||||
},
|
||||
"placeholder.ignore": {
|
||||
|
||||
+790
-750
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,10 @@
|
||||
export interface IMidjourneyConfig {
|
||||
mode?: string;
|
||||
prompt?: string;
|
||||
action?: string;
|
||||
video_id?: string;
|
||||
image_url?: string;
|
||||
is_videos?: boolean;
|
||||
model?: string;
|
||||
ratio?: string;
|
||||
version?: string;
|
||||
@@ -46,6 +50,10 @@ export enum MidjourneyImagineAction {
|
||||
REDO_UPSCALE_SUBTLE = 'redo_upscale_subtle',
|
||||
REDO_UPSCALE_CREATIVE = 'redo_upscale_creative'
|
||||
}
|
||||
export enum MidjourneyVideosAction {
|
||||
GENERATE = 'generate',
|
||||
EXTEND = 'extend'
|
||||
}
|
||||
|
||||
export enum MidjourneyImagineState {
|
||||
PENDING = 'pending',
|
||||
@@ -64,6 +72,16 @@ export interface IMidjourneyImagineRequest {
|
||||
application_id?: string;
|
||||
}
|
||||
|
||||
export interface IMidjourneyVideosRequest {
|
||||
action?: MidjourneyVideosAction;
|
||||
mode?: string;
|
||||
prompt?: string;
|
||||
video_id?: string;
|
||||
image_url?: string;
|
||||
callback_url?: string;
|
||||
application_id?: string;
|
||||
}
|
||||
|
||||
export interface IMidjourneyDescribeRequest {
|
||||
image_url: string;
|
||||
application_id?: string;
|
||||
@@ -84,6 +102,22 @@ export interface IMidjourneyImagineResponse {
|
||||
success?: boolean;
|
||||
}
|
||||
|
||||
export interface IMidjourneyVideosResponse {
|
||||
task_id: string;
|
||||
type: 'videos';
|
||||
progress?: number;
|
||||
image_width?: number;
|
||||
image_height?: number;
|
||||
video_id?: string;
|
||||
trace_id: string;
|
||||
video_urls?: string[];
|
||||
error?: {
|
||||
code?: string;
|
||||
message?: string;
|
||||
};
|
||||
success?: boolean;
|
||||
}
|
||||
|
||||
export interface IMidjourneyDescribeResponse {
|
||||
descriptions: string[];
|
||||
}
|
||||
@@ -97,6 +131,15 @@ export interface IMidjourneyImagineTask {
|
||||
response?: IMidjourneyImagineResponse;
|
||||
state?: MidjourneyImagineState;
|
||||
}
|
||||
export interface IMidjourneyVideosTask {
|
||||
id: string;
|
||||
type: 'videos';
|
||||
created_at?: number;
|
||||
trace_id?: string;
|
||||
request?: IMidjourneyVideosRequest;
|
||||
response?: IMidjourneyVideosResponse;
|
||||
state?: MidjourneyImagineState;
|
||||
}
|
||||
|
||||
export interface IMidjourneyDescribeTask {
|
||||
id: string;
|
||||
@@ -106,7 +149,7 @@ export interface IMidjourneyDescribeTask {
|
||||
response?: IMidjourneyDescribeResponse;
|
||||
}
|
||||
|
||||
export type IMidjourneyTask = IMidjourneyImagineTask | IMidjourneyDescribeTask;
|
||||
export type IMidjourneyTask = IMidjourneyImagineTask | IMidjourneyDescribeTask | IMidjourneyVideosTask;
|
||||
|
||||
export type IMidjourneyTaskResponse = IMidjourneyTask;
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import axios, { AxiosResponse } from 'axios';
|
||||
import {
|
||||
IMidjourneyImagineRequest,
|
||||
IMidjourneyVideosRequest,
|
||||
IMidjourneyImagineResponse,
|
||||
IMidjourneyVideosResponse,
|
||||
IMidjourneyTaskResponse,
|
||||
IMidjourneyTasksResponse
|
||||
} from '@/models';
|
||||
@@ -112,6 +114,22 @@ class MidjourneyOperator {
|
||||
baseURL: BASE_URL_API
|
||||
});
|
||||
}
|
||||
|
||||
async videos(
|
||||
data: IMidjourneyVideosRequest,
|
||||
options: {
|
||||
token: string;
|
||||
}
|
||||
): Promise<AxiosResponse<IMidjourneyVideosResponse>> {
|
||||
return await axios.post('/midjourney/videos', data, {
|
||||
headers: {
|
||||
authorization: `Bearer ${options.token}`,
|
||||
'content-type': 'application/json',
|
||||
accept: 'application/x-ndjson'
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const midjourneyOperator = new MidjourneyOperator();
|
||||
@@ -18,7 +18,7 @@ import { midjourneyOperator } from '@/operators';
|
||||
import TaskList from '@/components/midjourney/tasks/TaskList.vue';
|
||||
import { ERROR_CODE_USED_UP } from '@/constants/errorCode';
|
||||
import { Status } from '@/models';
|
||||
import { IMidjourneyImagineRequest, MidjourneyImagineAction } from '@/models';
|
||||
import { IMidjourneyImagineRequest, IMidjourneyVideosRequest, MidjourneyImagineAction } from '@/models';
|
||||
import {
|
||||
MIDJOURNEY_DEFAULT_IMAGE_WEIGHT,
|
||||
MIDJOURNEY_DEFAULT_RATIO,
|
||||
@@ -215,6 +215,37 @@ export default defineComponent({
|
||||
// await this.onScrollDown();
|
||||
});
|
||||
},
|
||||
async onStartVideosTask(request: IMidjourneyVideosRequest) {
|
||||
const token = this.credential?.token;
|
||||
if (!token) {
|
||||
console.error('no token specified');
|
||||
return;
|
||||
}
|
||||
ElMessage.info(this.$t('midjourney.message.startingTask'));
|
||||
midjourneyOperator
|
||||
.videos(request, {
|
||||
token
|
||||
})
|
||||
.then(() => {
|
||||
ElMessage.success(this.$t('midjourney.message.startVideosTaskSuccess'));
|
||||
})
|
||||
.catch((error) => {
|
||||
const response = error?.response?.data;
|
||||
if (response?.error?.code === ERROR_CODE_USED_UP) {
|
||||
ElMessage.error(this.$t('midjourney.message.usedUp'));
|
||||
} else {
|
||||
ElMessage.error(this.$t('midjourney.message.startVideosTaskFailed'));
|
||||
}
|
||||
})
|
||||
.finally(async () => {
|
||||
setTimeout(async () => {
|
||||
await this.onGetTasks();
|
||||
await this.onScrollDown();
|
||||
}, 1000);
|
||||
// await this.onGetTasks();
|
||||
// await this.onScrollDown();
|
||||
});
|
||||
},
|
||||
async onCustom(payload: { image_id: string; action: MidjourneyImagineAction }) {
|
||||
const request = {
|
||||
image_id: payload.image_id,
|
||||
@@ -225,14 +256,27 @@ export default defineComponent({
|
||||
this.onStartTask(request);
|
||||
},
|
||||
async onGenerate() {
|
||||
const request = {
|
||||
mode: this.config?.mode || MIDJOURNEY_DEFAULT_MODE,
|
||||
prompt: this.finalPrompt,
|
||||
action: MidjourneyImagineAction.GENERATE,
|
||||
translation: this.config?.translation,
|
||||
callback_url: CALLBACK_URL
|
||||
};
|
||||
await this.onStartTask(request);
|
||||
if (this.config?.is_videos) {
|
||||
const request = {
|
||||
video_id: this.config?.video_id,
|
||||
image_url: this.config?.image_url,
|
||||
action: this.config?.action,
|
||||
prompt: this.config?.prompt,
|
||||
mode: this.config?.mode || MIDJOURNEY_DEFAULT_MODE,
|
||||
callback_url: CALLBACK_URL
|
||||
};
|
||||
// @ts-ignore
|
||||
await this.onStartVideosTask(request);
|
||||
} else {
|
||||
const request = {
|
||||
mode: this.config?.mode || MIDJOURNEY_DEFAULT_MODE,
|
||||
prompt: this.finalPrompt,
|
||||
action: MidjourneyImagineAction.GENERATE,
|
||||
translation: this.config?.translation,
|
||||
callback_url: CALLBACK_URL
|
||||
};
|
||||
await this.onStartTask(request);
|
||||
}
|
||||
},
|
||||
async onScrollDown() {
|
||||
await this.$nextTick();
|
||||
|
||||
@@ -144,8 +144,7 @@ export const getTasks = async (
|
||||
{
|
||||
userId: rootState?.user?.id,
|
||||
createdAtMin,
|
||||
createdAtMax,
|
||||
type: 'imagine'
|
||||
createdAtMax
|
||||
},
|
||||
{
|
||||
token
|
||||
|
||||
Reference in new issue
Block a user