add luma custom extend (#119)
This commit is contained in:
1 parent
2e652a658b
commit
65163e31d7
10 files changed
+287
-12
No files matched your search
@@ -1,20 +1,28 @@
|
||||
<template>
|
||||
<div class="panel">
|
||||
<div class="config">
|
||||
<extend-from-input v-if="config?.action === 'extend'" class="mb-4" />
|
||||
<extend-from-input v-if="config?.video_id || config?.video_url" class="mb-4" />
|
||||
<prompt-input class="mb-4" />
|
||||
<start-image-url-input v-if="!config?.action === 'extend'" class="mb-4" />
|
||||
<custom-selector v-if="!config?.video_id" class="mb-4" />
|
||||
<upload-video v-if="config?.custom" class="mb-4" />
|
||||
<start-image-url-input v-if="!(config?.video_id || config?.video_url) && !config?.custom" class="mb-4" />
|
||||
<end-image-url-input class="mb-4" />
|
||||
<enhancement-selector class="mb-4" />
|
||||
<loop-selector class="mb-4" />
|
||||
<div class="actions">
|
||||
<el-button v-if="config?.action !== 'extend'" type="primary" class="btn w-full" round @click="onGenerate">
|
||||
<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('luma.button.generate') }}
|
||||
{{ $t('luma.button.extend') }}
|
||||
</el-button>
|
||||
<el-button v-else type="primary" class="btn w-full" round @click="onGenerate">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
|
||||
{{ $t('luma.button.extend') }}
|
||||
{{ $t('luma.button.generate') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -26,9 +34,12 @@ import { defineComponent } from 'vue';
|
||||
import { ElButton } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import EnhancementSelector from './config/EnhancementSelector.vue';
|
||||
import CustomSelector from './config/CustomSelector.vue';
|
||||
import LoopSelector from './config/LoopSelector.vue';
|
||||
import EndImageUrlInput from './config/EndImageUrlInput.vue';
|
||||
import StartImageUrlInput from './config/StartImageUrlInput.vue';
|
||||
// @ts-ignore
|
||||
import UploadVideo from './config/UploadVideo.vue';
|
||||
import PromptInput from './config/PromptInput.vue';
|
||||
import ExtendFromInput from './config/ExtendFromInput.vue';
|
||||
export default defineComponent({
|
||||
@@ -41,7 +52,9 @@ export default defineComponent({
|
||||
ElButton,
|
||||
FontAwesomeIcon,
|
||||
PromptInput,
|
||||
ExtendFromInput
|
||||
ExtendFromInput,
|
||||
CustomSelector,
|
||||
UploadVideo
|
||||
},
|
||||
emits: ['generate'],
|
||||
computed: {
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title">{{ $t('luma.name.custom') }}</h2>
|
||||
<el-switch v-model="value" class="value" />
|
||||
<info-icon :content="$t('luma.description.custom')" class="info" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSwitch } from 'element-plus';
|
||||
import { LUMA_DEFAULT_CUSTOM } from '@/constants';
|
||||
import InfoIcon from '@/components/common/InfoIcon.vue';
|
||||
export default defineComponent({
|
||||
name: 'CustomSelector',
|
||||
components: {
|
||||
ElSwitch,
|
||||
InfoIcon
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.luma?.config?.custom;
|
||||
},
|
||||
set(val) {
|
||||
console.debug('set custom', val);
|
||||
this.$store.commit('luma/setConfig', {
|
||||
...this.$store.state.luma?.config,
|
||||
custom: val
|
||||
});
|
||||
console.log(JSON.stringify(this.$store.state.luma?.config));
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.value === undefined) {
|
||||
this.value = LUMA_DEFAULT_CUSTOM;
|
||||
}
|
||||
}
|
||||
});
|
||||
</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;
|
||||
margin-left: 60px; // Adjust this value as needed
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -22,6 +22,7 @@ import VuePlyr from '@skjnldsv/vue-plyr';
|
||||
// @ts-ignore
|
||||
import { ILumaTask } from '@/models';
|
||||
import '@skjnldsv/vue-plyr/dist/vue-plyr.css';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ExtendFromInput',
|
||||
components: { VuePlyr },
|
||||
@@ -50,15 +51,15 @@ export default defineComponent({
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between; // 添加这行
|
||||
justify-content: space-between;
|
||||
position: relative;
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.input-wrapper {
|
||||
width: 150px; // 根据需要调整宽度
|
||||
margin-left: 30px; // 增加左边距
|
||||
width: 150px;
|
||||
margin-left: 30px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title">{{ $t('luma.name.videoUrl') }}</h2>
|
||||
<div class="upload-wrapper">
|
||||
<el-upload
|
||||
v-model:file-list="fileList"
|
||||
accept=".mp4"
|
||||
name="file"
|
||||
class="value"
|
||||
:show-file-list="true"
|
||||
:limit="1"
|
||||
:multiple="false"
|
||||
:action="uploadUrl"
|
||||
:before-upload="beforeUpload"
|
||||
:on-exceed="onExceed"
|
||||
:on-error="onError"
|
||||
:on-success="onSuccess"
|
||||
:headers="headers"
|
||||
>
|
||||
<el-button size="small" type="primary" round>{{ $t('luma.button.uploadVideoUrl') }}</el-button>
|
||||
</el-upload>
|
||||
</div>
|
||||
<info-icon :content="$t('luma.description.videoUrl')" class="info" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElButton, ElUpload, ElMessage, UploadFiles } from 'element-plus';
|
||||
import { getBaseUrlPlatform } from '@/utils';
|
||||
import InfoIcon from '@/components/common/InfoIcon.vue';
|
||||
export const DEFAULT_CONTENT = '';
|
||||
|
||||
interface IData {
|
||||
fileList: UploadFiles;
|
||||
uploadUrl: string;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'UploadVideo',
|
||||
components: {
|
||||
ElUpload,
|
||||
ElButton,
|
||||
InfoIcon
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
fileList: [],
|
||||
uploadUrl: getBaseUrlPlatform() + '/api/v1/files/'
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
headers() {
|
||||
return {
|
||||
Authorization: `Bearer ${this.$store.state.token.access}`
|
||||
};
|
||||
},
|
||||
urls(): string[] {
|
||||
// @ts-ignore
|
||||
return this.fileList.map((file: UploadFile) => file?.response?.file_url);
|
||||
},
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.luma?.config?.video_url;
|
||||
},
|
||||
set(val: string) {
|
||||
const url = this.urls?.[0];
|
||||
this.$store.commit('luma/setConfig', {
|
||||
...this.$store.state.luma?.config,
|
||||
video_url: url
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = undefined;
|
||||
}
|
||||
this.onSetVideoUrl();
|
||||
},
|
||||
methods: {
|
||||
onExceed() {
|
||||
ElMessage.warning(this.$t('luma.message.uploadVideoExceed'));
|
||||
},
|
||||
onError() {
|
||||
ElMessage.error(this.$t('luma.message.uploadVideoError'));
|
||||
},
|
||||
beforeUpload(file: File) {
|
||||
const isMP4 = file.type === 'video/mp4';
|
||||
const isLt10M = file.size / 1024 / 1024 < 10;
|
||||
|
||||
if (!isMP4) {
|
||||
ElMessage.error(this.$t('luma.message.uploadVideoTypeFailed'));
|
||||
return false;
|
||||
}
|
||||
if (!isLt10M) {
|
||||
ElMessage.error(this.$t('luma.message.uploadVideoSizeExceed'));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
onSetVideoUrl() {
|
||||
const url = this.urls?.[0];
|
||||
this.$store.commit('luma/setConfig', {
|
||||
...this.$store.state.luma?.config,
|
||||
video_url: url,
|
||||
action: 'extend'
|
||||
});
|
||||
},
|
||||
async onSuccess() {
|
||||
this.onSetVideoUrl();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between; // Distribute space evenly
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
width: 30%;
|
||||
}
|
||||
.value {
|
||||
flex: 1;
|
||||
margin-left: 60px; // Adjust this value as needed
|
||||
}
|
||||
.upload-wrapper {
|
||||
transform: translate(-26px, 5px); // Move left and down
|
||||
}
|
||||
.info {
|
||||
margin-left: auto; // Pushes the info icon to the right
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -14,6 +14,11 @@
|
||||
<p v-if="modelValue?.request?.prompt" class="prompt mt-2">
|
||||
{{ modelValue?.request?.prompt }}
|
||||
<span v-if="!modelValue?.response"> - ({{ $t('luma.status.pending') }}) </span>
|
||||
<span
|
||||
v-if="modelValue?.response?.data?.state === 'processing' || modelValue?.response?.data?.state === 'pending'"
|
||||
>
|
||||
- ({{ $t('luma.status.processing') }})
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<!-- Display success message -->
|
||||
@@ -21,7 +26,7 @@
|
||||
<div class="image-wrapper">
|
||||
<VideoPlayer :model-value="modelValue" />
|
||||
</div>
|
||||
<div v-if="modelValue?.response" :class="{ operations: true, 'mt-2': true }">
|
||||
<div v-if="modelValue?.response && !config?.custom" :class="{ operations: true, 'mt-2': 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="onExtend($event, modelValue?.response)">
|
||||
{{ $t('luma.button.extend') }}
|
||||
@@ -113,13 +118,15 @@ export default defineComponent({
|
||||
computed: {
|
||||
application() {
|
||||
return this.$store.state.luma?.application;
|
||||
},
|
||||
config() {
|
||||
return this.$store.state.luma?.config;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onExtend(event: MouseEvent, response: ILumaGenerateResponse) {
|
||||
event.stopPropagation();
|
||||
console.log('on extend');
|
||||
// download url here
|
||||
// extend url here
|
||||
console.debug('set config', response);
|
||||
this.$store.commit('luma/setConfig', {
|
||||
...this.$store.state.luma?.config,
|
||||
|
||||
Reference in new issue
Block a user