Refine video ui (#229)
Co-authored-by: AceDataCloud <office@acedata.cloud>
This commit is contained in:
1 parent
2997079593
commit
a0eb57c21a
113 files changed
+1740
-2556
No files matched your search
@@ -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,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('kling.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,46 +1,27 @@
|
||||
<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">
|
||||
<!-- {{ tasks?.items }} -->
|
||||
<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('kling.message.noTasks') }}
|
||||
</p>
|
||||
<div v-if="tasks?.items === undefined">
|
||||
<bot-placeholder />
|
||||
</div>
|
||||
<div v-else-if="tasks?.items?.length && tasks?.items?.length > 0" class="h-full w-full overflow-y-auto">
|
||||
<task-preview v-for="(task, taskIndex) in tasks?.items" :key="taskIndex" :model-value="task" />
|
||||
</div>
|
||||
<div v-if="tasks?.items?.length === 0">
|
||||
<no-tasks />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import TaskPreview from './task/Preview.vue';
|
||||
import { ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import BotPlaceholder from '@/components/common/BotPlaceholder.vue';
|
||||
import NoTasks from '@/components/common/NoTasks.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'RecentPanel',
|
||||
components: {
|
||||
TaskPreview,
|
||||
ElSkeleton,
|
||||
ElSkeletonItem
|
||||
NoTasks,
|
||||
BotPlaceholder
|
||||
},
|
||||
emits: ['reach-top'],
|
||||
data() {
|
||||
@@ -68,76 +49,3 @@ export default defineComponent({
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
&.recent {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,40 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<vue-plyr :options="options" class="video">
|
||||
<video controls crossorigin playsinline>
|
||||
<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 { IKlingVideo } from '@/models';
|
||||
import '@skjnldsv/vue-plyr/dist/vue-plyr.css';
|
||||
export default defineComponent({
|
||||
name: 'VideoPlayer',
|
||||
components: { VuePlyr },
|
||||
props: {
|
||||
modelValue: {
|
||||
type: Object as () => IKlingVideo | undefined,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
options: { quality: { default: '1080p' } }
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.video {
|
||||
max-width: 100%;
|
||||
height: 450px;
|
||||
}
|
||||
</style>
|
||||
@@ -9,6 +9,7 @@
|
||||
<el-upload
|
||||
v-model:file-list="fileList"
|
||||
name="file"
|
||||
accept=".png,.jpg,.jpeg,.gif,.bmp,.webp"
|
||||
:limit="5"
|
||||
class="upload-wrapper"
|
||||
:multiple="false"
|
||||
|
||||
@@ -88,7 +88,7 @@ export default defineComponent({
|
||||
|
||||
.item {
|
||||
width: 48px;
|
||||
height: 65px;
|
||||
height: 70px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -100,6 +100,7 @@ export default defineComponent({
|
||||
margin-top: 8px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin-bottom: 4px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<el-upload
|
||||
v-model:file-list="fileList"
|
||||
name="file"
|
||||
accept=".png,.jpg,.jpeg,.gif,.bmp,.webp"
|
||||
:limit="5"
|
||||
class="upload-wrapper"
|
||||
:multiple="false"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div class="bot">
|
||||
{{ $t('kling.name.klingBot') }}
|
||||
<span class="datetime">
|
||||
{{ $dayjs.format('' + new Date(parseFloat(modelValue?.created_at || '') * 1000)) }}
|
||||
{{ $dayjs.format('' + new Date(parseFloat((modelValue?.created_at || '').toString()) * 1000)) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="info">
|
||||
@@ -28,12 +28,13 @@
|
||||
</div>
|
||||
<!-- Display success message -->
|
||||
<div v-if="modelValue?.response?.success === true" :class="{ content: true, failed: true }">
|
||||
<div class="image-wrapper">
|
||||
<VideoPlayer :model-value="modelValue?.response" />
|
||||
<div class="mb-4">
|
||||
<video-player :model-value="modelValue?.response" />
|
||||
</div>
|
||||
<div v-if="modelValue?.response.success" :class="{ operations: true, 'mt-2': true }">
|
||||
<el-tooltip class="box-item" effect="dark" :content="$t('kling.message.downloadVideo')" placement="top-start">
|
||||
<el-button
|
||||
v-if="modelValue?.response.video_url"
|
||||
type="info"
|
||||
size="small"
|
||||
class="btn-action"
|
||||
@@ -44,11 +45,16 @@
|
||||
</el-tooltip>
|
||||
</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('kling.name.model') }}:
|
||||
{{ modelValue?.request?.model }}
|
||||
</p>
|
||||
<p class="mb-2">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('kling.name.taskId') }}:
|
||||
{{ modelValue?.id }}
|
||||
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy" />
|
||||
<copy-to-clipboard :content="modelValue?.id!" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
@@ -59,51 +65,44 @@
|
||||
<font-awesome-icon icon="fa-solid fa-exclamation-triangle" class="mr-1" />
|
||||
{{ $t('kling.name.failure') }}
|
||||
</template>
|
||||
<p class="description">
|
||||
<p class="mb-2">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('kling.name.taskId') }}:
|
||||
{{ modelValue?.id }}
|
||||
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy" />
|
||||
<copy-to-clipboard :content="modelValue?.id!" />
|
||||
</p>
|
||||
<p class="description">
|
||||
<p class="mb-2">
|
||||
<font-awesome-icon icon="fa-solid fa-circle-info" class="mr-1" />
|
||||
{{ $t('kling.name.failureReason') }}:
|
||||
{{ modelValue?.response?.error?.message }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.error?.message!" class="btn-copy" />
|
||||
<copy-to-clipboard :content="modelValue?.response?.error?.message!" />
|
||||
</p>
|
||||
<p v-if="modelValue?.response?.trace_id" class="description">
|
||||
<p v-if="modelValue?.response?.trace_id" class="mb-2">
|
||||
<font-awesome-icon icon="fa-solid fa-hashtag" class="mr-1" />
|
||||
{{ $t('kling.name.traceId') }}:
|
||||
{{ modelValue?.response?.trace_id }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.trace_id" class="btn-copy" />
|
||||
<copy-to-clipboard :content="modelValue?.response?.trace_id" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
<!-- Display error message -->
|
||||
<div
|
||||
v-if="
|
||||
!modelValue?.response ||
|
||||
modelValue?.response?.state === 'processing' ||
|
||||
modelValue?.response?.state === 'pending'
|
||||
"
|
||||
:class="{ content: true }"
|
||||
>
|
||||
<div v-if="modelValue?.response?.success === undefined" :class="{ content: true }">
|
||||
<el-alert :closable="false" class="info">
|
||||
<template #template>
|
||||
<font-awesome-icon icon="fa-solid fa-exclamation-triangle" class="mr-1" />
|
||||
{{ $t('kling.name.failure') }}
|
||||
</template>
|
||||
<p class="description">
|
||||
<p class="mb-2">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('kling.name.taskId') }}:
|
||||
{{ modelValue?.id }}
|
||||
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy" />
|
||||
<copy-to-clipboard :content="modelValue?.id!" />
|
||||
</p>
|
||||
<p v-if="modelValue?.response?.trace_id" class="description">
|
||||
<p v-if="modelValue?.response?.trace_id" class="mb-2">
|
||||
<font-awesome-icon icon="fa-solid fa-hashtag" class="mr-1" />
|
||||
{{ $t('kling.name.traceId') }}:
|
||||
{{ modelValue?.response?.trace_id }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.trace_id" class="btn-copy" />
|
||||
<copy-to-clipboard :content="modelValue?.response?.trace_id" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
@@ -117,7 +116,8 @@ import { ElImage, ElAlert, ElButton, ElTooltip } from 'element-plus';
|
||||
import { IKlingTask } from '@/models';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import VideoPlayer from '../VideoPlayer.vue';
|
||||
import VideoPlayer from '@/components/common/VideoPlayer.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TaskPreview',
|
||||
components: {
|
||||
@@ -147,44 +147,12 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// onExtend(event: MouseEvent, response: IKlingGenerateResponse) {
|
||||
// event.stopPropagation();
|
||||
// // extend url here
|
||||
// console.debug('set config', response);
|
||||
// this.$store.commit('kling/setConfig', {
|
||||
// ...this.$store.state.kling?.config,
|
||||
// video_id: response.video_id,
|
||||
// prompt: response.prompt,
|
||||
// action: 'extend',
|
||||
// thumbnail_url: response.thumbnail_url,
|
||||
// video_url: response.video_url
|
||||
// });
|
||||
// },
|
||||
onDownload(event: MouseEvent, video_url: string) {
|
||||
event.stopPropagation();
|
||||
console.log('on download');
|
||||
// download url here
|
||||
window.open(video_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();
|
||||
},
|
||||
onOpenVideo(url: string) {
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user