1 parent
2e0665f09c
commit
6be9299532
42 files changed
+2342
-5
No files matched your search
@@ -0,0 +1,78 @@
|
||||
<template>
|
||||
<div class="panel">
|
||||
<div class="config">
|
||||
<prompt-input class="mb-4" />
|
||||
<start-image-url-input 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">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
|
||||
{{ $t('luma.button.generate') }}
|
||||
</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') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElButton } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import EnhancementSelector from './config/EnhancementSelector.vue';
|
||||
import LoopSelector from './config/LoopSelector.vue';
|
||||
import EndImageUrlInput from './config/EndImageUrlInput.vue';
|
||||
import StartImageUrlInput from './config/StartImageUrlInput.vue';
|
||||
import PromptInput from './config/PromptInput.vue';
|
||||
export default defineComponent({
|
||||
name: 'PresetPanel',
|
||||
components: {
|
||||
LoopSelector,
|
||||
StartImageUrlInput,
|
||||
EndImageUrlInput,
|
||||
EnhancementSelector,
|
||||
ElButton,
|
||||
FontAwesomeIcon,
|
||||
PromptInput
|
||||
},
|
||||
emits: ['generate'],
|
||||
computed: {
|
||||
config() {
|
||||
return this.$store.state.luma?.config;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onGenerate() {
|
||||
this.$emit('generate');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.panel {
|
||||
height: 100%;
|
||||
padding: 15px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.config {
|
||||
width: 100%;
|
||||
height: calc(100% - 50px);
|
||||
flex: 1;
|
||||
}
|
||||
.actions {
|
||||
height: 50px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
.btn {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,23 @@
|
||||
<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>
|
||||
@@ -0,0 +1,77 @@
|
||||
<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('qrart.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>
|
||||
@@ -0,0 +1,131 @@
|
||||
<template>
|
||||
<div class="panel recent">
|
||||
<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">
|
||||
<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('luma.message.noTasks') }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import TaskPreview from './task/Preview.vue';
|
||||
import { ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'RecentPanel',
|
||||
components: {
|
||||
TaskPreview,
|
||||
ElSkeleton,
|
||||
ElSkeletonItem
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
job: 0
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
tasks() {
|
||||
// reverse the order of the tasks.items
|
||||
return {
|
||||
...this.$store.state.luma?.tasks,
|
||||
items: this.$store.state.luma?.tasks?.items?.slice().reverse()
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
</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>
|
||||
@@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title">{{ $t('luma.name.endImageUrl') }}</h2>
|
||||
<el-input v-model="value" class="value" :placeholder="$t('luma.placeholder.endImageUrl')" />
|
||||
<info-icon :content="$t('luma.description.endImageUrl')" class="info" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElInput } from 'element-plus';
|
||||
import InfoIcon from '@/components/common/InfoIcon.vue';
|
||||
export default defineComponent({
|
||||
name: 'EndImageUrlInput',
|
||||
components: {
|
||||
ElInput,
|
||||
InfoIcon
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.luma?.config?.end_image_url;
|
||||
},
|
||||
set(val) {
|
||||
console.debug('set end_image_url', val);
|
||||
this.$store.commit('luma/setConfig', {
|
||||
...this.$store.state.luma?.config,
|
||||
end_image_url: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = undefined;
|
||||
}
|
||||
}
|
||||
});
|
||||
</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>
|
||||
@@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title">{{ $t('luma.name.enhancement') }}</h2>
|
||||
<el-switch v-model="value" class="value" />
|
||||
<info-icon :content="$t('luma.description.enhancement')" class="info" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSwitch } from 'element-plus';
|
||||
import { LUMA_DEFAULT_ENHANCEMENT } from '@/constants';
|
||||
import InfoIcon from '@/components/common/InfoIcon.vue';
|
||||
export default defineComponent({
|
||||
name: 'EnhancementSelector',
|
||||
components: {
|
||||
ElSwitch,
|
||||
InfoIcon
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.luma?.config?.enhancement;
|
||||
},
|
||||
set(val) {
|
||||
console.debug('set enhancement', val);
|
||||
this.$store.commit('luma/setConfig', {
|
||||
...this.$store.state.luma?.config,
|
||||
enhancement: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.value === undefined) {
|
||||
this.value = LUMA_DEFAULT_ENHANCEMENT;
|
||||
}
|
||||
}
|
||||
});
|
||||
</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>
|
||||
@@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title">{{ $t('luma.name.loop') }}</h2>
|
||||
<el-switch v-model="value" class="value" />
|
||||
<info-icon :content="$t('luma.description.loop')" class="info" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSwitch } from 'element-plus';
|
||||
import { LUMA_DEFAULT_LOOP } from '@/constants';
|
||||
import InfoIcon from '@/components/common/InfoIcon.vue';
|
||||
export default defineComponent({
|
||||
name: 'LoopSelector',
|
||||
components: {
|
||||
ElSwitch,
|
||||
InfoIcon
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.luma?.config?.loop;
|
||||
},
|
||||
set(val) {
|
||||
console.debug('set loop', val);
|
||||
this.$store.commit('luma/setConfig', {
|
||||
...this.$store.state.luma?.config,
|
||||
loop: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.value === undefined) {
|
||||
this.value = LUMA_DEFAULT_LOOP;
|
||||
}
|
||||
}
|
||||
});
|
||||
</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>
|
||||
@@ -0,0 +1,70 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<div class="box">
|
||||
<h2 class="title">{{ $t('luma.name.prompt') }}</h2>
|
||||
<info-icon :content="$t('luma.description.prompt')" class="info" />
|
||||
</div>
|
||||
<el-input
|
||||
v-model="prompt"
|
||||
:rows="3"
|
||||
type="textarea"
|
||||
class="prompt"
|
||||
:placeholder="$t('luma.placeholder.prompt')"
|
||||
:maxlength="300"
|
||||
show-word-limit
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElInput } from 'element-plus';
|
||||
import InfoIcon from '@/components/common/InfoIcon.vue';
|
||||
|
||||
export const DEFAULT_PROMPT = '';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'PromptInput',
|
||||
components: {
|
||||
ElInput,
|
||||
InfoIcon
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
prompt: {
|
||||
get() {
|
||||
return this.$store.state.suno?.config?.prompt;
|
||||
},
|
||||
set(val) {
|
||||
console.debug('set prompt', val);
|
||||
this.$store.commit('suno/setConfig', {
|
||||
...this.$store.state.suno?.config,
|
||||
prompt: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = DEFAULT_PROMPT;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
.box {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title">{{ $t('luma.name.startImageUrl') }}</h2>
|
||||
<el-input v-model="value" class="value" :placeholder="$t('luma.placeholder.startImageUrl')" />
|
||||
<info-icon :content="$t('luma.description.startImageUrl')" class="info" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElInput } from 'element-plus';
|
||||
import InfoIcon from '@/components/common/InfoIcon.vue';
|
||||
export default defineComponent({
|
||||
name: 'StartImageUrlInput',
|
||||
components: {
|
||||
ElInput,
|
||||
InfoIcon
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.luma?.config?.start_image_url;
|
||||
},
|
||||
set(val) {
|
||||
console.debug('set start_image_url', val);
|
||||
this.$store.commit('luma/setConfig', {
|
||||
...this.$store.state.luma?.config,
|
||||
start_image_url: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = undefined;
|
||||
}
|
||||
}
|
||||
});
|
||||
</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>
|
||||
@@ -0,0 +1,176 @@
|
||||
<template>
|
||||
<div v-if="task" class="detail">
|
||||
<el-row class="h-full">
|
||||
<el-col :span="24" class="h-full">
|
||||
<el-row class="h-full main">
|
||||
<el-col :span="12" class="h-full p-4">
|
||||
<el-image
|
||||
v-if="task?.response?.image_url"
|
||||
:src="task?.response?.image_url"
|
||||
:preview-src-list="[task?.response?.image_url as string]"
|
||||
class="image"
|
||||
fit="contain"
|
||||
@error="onReload($event)"
|
||||
/>
|
||||
<el-alert v-else-if="task?.response?.success === false" :closable="false" class="failure">
|
||||
<template #template>
|
||||
<font-awesome-icon icon="fa-solid fa-exclamation-triangle" class="mr-1" />
|
||||
{{ $t('qrart.name.failure') }}
|
||||
</template>
|
||||
<p class="description">
|
||||
<font-awesome-icon icon="fa-solid fa-circle-info" class="mr-1" />
|
||||
{{ $t('qrart.name.failureReason') }}:
|
||||
{{ task?.response?.error?.message }}
|
||||
<copy-to-clipboard :content="task?.response?.error?.message!" class="btn-copy" />
|
||||
</p>
|
||||
<p class="description">
|
||||
<font-awesome-icon icon="fa-solid fa-hashtag" class="mr-1" />
|
||||
{{ $t('qrart.name.traceId') }}:
|
||||
{{ task?.response?.trace_id }}
|
||||
<copy-to-clipboard :content="task?.response?.trace_id" class="btn-copy" />
|
||||
</p>
|
||||
</el-alert>
|
||||
<el-image v-else class="image error">
|
||||
<template #error>
|
||||
<div class="image-slot">{{ $t('qrart.message.generating') }}</div>
|
||||
</template>
|
||||
</el-image>
|
||||
</el-col>
|
||||
<el-col :span="12" class="h-full overflow-scroll">
|
||||
<el-descriptions title="" :column="1">
|
||||
<el-descriptions-item :label="$t('qrart.name.taskId')">
|
||||
{{ task?.id }}
|
||||
<copy-to-clipboard :content="task?.id" class="btn-copy" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('qrart.name.type')">
|
||||
{{ task?.request?.type }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('qrart.name.content')">
|
||||
{{ task?.request?.content }}
|
||||
<copy-to-clipboard :content="task?.request?.content!" class="btn-copy" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('qrart.name.prompt')">
|
||||
{{ task?.request?.prompt }}
|
||||
<copy-to-clipboard v-if="task?.request?.prompt" :content="task?.request?.prompt" class="btn-copy" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('qrart.name.size')">
|
||||
{{ task?.response?.image_width }} x {{ task?.response?.image_height }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="task?.created_at" :label="$t('qrart.name.createdAt')">
|
||||
{{ $dayjs.format('' + new Date(parseFloat(task?.created_at) * 1000)) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('qrart.name.seed')">
|
||||
{{ task?.request?.seed || task?.response?.seed }}
|
||||
<copy-to-clipboard
|
||||
v-if="task?.request?.seed || task?.response?.seed"
|
||||
:content="task?.request?.seed || task?.response?.seed"
|
||||
class="btn-copy"
|
||||
/>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('qrart.name.steps')">
|
||||
{{ task?.request?.steps }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('qrart.name.qrw')">
|
||||
{{ task?.request?.qrw }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('qrart.name.preset')">
|
||||
{{ task?.request?.preset }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElImage, ElRow, ElCol, ElDescriptions, ElDescriptionsItem, ElAlert } from 'element-plus';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TaskDetail',
|
||||
components: {
|
||||
ElImage,
|
||||
ElAlert,
|
||||
FontAwesomeIcon,
|
||||
CopyToClipboard,
|
||||
ElDescriptions,
|
||||
ElDescriptionsItem,
|
||||
ElRow,
|
||||
ElCol
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
application() {
|
||||
return this.$store.state.qrart?.application;
|
||||
},
|
||||
task() {
|
||||
return this.$store.state.qrart?.tasks?.active;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.detail {
|
||||
height: 100%;
|
||||
padding: 5px 0;
|
||||
.main {
|
||||
padding: 15px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: 15px;
|
||||
}
|
||||
|
||||
.image {
|
||||
height: 100%;
|
||||
display: block;
|
||||
margin: auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
.detail {
|
||||
.image.error {
|
||||
background: var(--el-bg-color-page);
|
||||
.image-slot {
|
||||
font-size: 18px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
}
|
||||
.failure {
|
||||
background: var(--el-fill-color-light);
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,292 @@
|
||||
<template>
|
||||
<div class="preview">
|
||||
<div class="left">
|
||||
<el-image src="https://cdn.acedata.cloud/bcml67.png" class="avatar" />
|
||||
</div>
|
||||
<div class="main">
|
||||
<div class="bot">
|
||||
{{ $t('luma.name.lumaBot') }}
|
||||
<span class="datetime">
|
||||
<!-- {{ $dayjs.format('' + new Date(parseFloat(modelValue?.created_at || '') * 1000)) }} -->
|
||||
</span>
|
||||
</div>
|
||||
<div class="info">
|
||||
<p v-if="modelValue?.request?.prompt" class="prompt mt-2">
|
||||
{{ modelValue?.request?.prompt }}
|
||||
<span v-if="modelValue?.response && Object.keys(modelValue.response).length === 0">
|
||||
- ({{ $t('luma.status.pending') }})
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<!-- Display success message -->
|
||||
<div v-if="modelValue?.response?.success === true" :class="{ content: true, failed: true }">
|
||||
<div class="image-wrapper">
|
||||
<img
|
||||
v-if="modelValue?.response?.thumbnail_url"
|
||||
v-loading="!modelValue?.response?.thumbnail_url"
|
||||
:src="modelValue?.response?.thumbnail_url"
|
||||
class="image mb-3"
|
||||
/>
|
||||
<div v-if="modelValue?.response?.video_url" class="play-icon">
|
||||
<font-awesome-icon icon="fa-solid fa-play-circle" />
|
||||
</div>
|
||||
<el-button
|
||||
v-if="modelValue?.response?.video_url"
|
||||
type="info"
|
||||
round
|
||||
class="btn-raw"
|
||||
@click="onOpenUrl(modelValue?.response?.video_url)"
|
||||
>
|
||||
{{ $t('common.button.seeRawVideo') }}
|
||||
</el-button>
|
||||
</div>
|
||||
<el-alert :closable="false" class="mt-2 success">
|
||||
<p class="description">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('luma.name.taskId') }}:
|
||||
{{ modelValue?.id }}
|
||||
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
<!-- Display error message -->
|
||||
<div v-if="modelValue?.response?.success === false" :class="{ content: true }">
|
||||
<el-alert :closable="false" class="failure">
|
||||
<template #template>
|
||||
<font-awesome-icon icon="fa-solid fa-exclamation-triangle" class="mr-1" />
|
||||
{{ $t('luma.name.failure') }}
|
||||
</template>
|
||||
<p class="description">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('luma.name.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('luma.name.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('luma.name.traceId') }}:
|
||||
{{ modelValue?.response?.trace_id }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.trace_id" class="btn-copy" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
<!-- Display error message -->
|
||||
<div v-if="!modelValue?.response" :class="{ content: true }">
|
||||
<el-alert :closable="false" class="info">
|
||||
<template #template>
|
||||
<font-awesome-icon icon="fa-solid fa-exclamation-triangle" class="mr-1" />
|
||||
{{ $t('luma.name.failure') }}
|
||||
</template>
|
||||
<p class="description">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('luma.name.taskId') }}:
|
||||
{{ modelValue?.id }}
|
||||
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElImage, ElAlert, ElButton } from 'element-plus';
|
||||
import { ILumaTask } from '@/models';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TaskPreview',
|
||||
components: {
|
||||
ElImage,
|
||||
CopyToClipboard,
|
||||
FontAwesomeIcon,
|
||||
ElAlert,
|
||||
ElButton
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: Object as () => ILumaTask | undefined,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
application() {
|
||||
return this.$store.state.luma?.application;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onOpenLink(url: string) {
|
||||
window.open(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();
|
||||
},
|
||||
onOpenUrl(url: string) {
|
||||
window.open(url, '_blank');
|
||||
},
|
||||
onDownload(url: string) {
|
||||
// download image using javascript
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = url.split('/').pop() as string;
|
||||
link.click();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$left-width: 70px;
|
||||
.preview {
|
||||
width: 100%;
|
||||
height: fit-content;
|
||||
text-align: left;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin-bottom: 15px;
|
||||
.left {
|
||||
width: $left-width;
|
||||
.avatar {
|
||||
background-color: white;
|
||||
padding: 2px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
margin: 10px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
.main {
|
||||
flex: 1;
|
||||
width: calc(100% - $left-width);
|
||||
padding: 10px 10px 0 10px;
|
||||
|
||||
.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;
|
||||
}
|
||||
}
|
||||
|
||||
.info {
|
||||
.prompt {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
color: var(--el-text-color-regular);
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.image-wrapper {
|
||||
position: relative;
|
||||
width: fit-content;
|
||||
min-height: 50px;
|
||||
min-width: 100px;
|
||||
.image {
|
||||
max-height: 400px;
|
||||
max-width: 500px;
|
||||
display: block;
|
||||
width: fit-content;
|
||||
}
|
||||
.btn-raw {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 1000;
|
||||
display: none;
|
||||
}
|
||||
.play-icon {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
font-size: 48px;
|
||||
color: white;
|
||||
z-index: 500;
|
||||
pointer-events: none; /* Ensure the icon doesn't interfere with hover */
|
||||
}
|
||||
&:hover {
|
||||
.image {
|
||||
filter: brightness(0.6);
|
||||
}
|
||||
.btn-raw {
|
||||
display: block;
|
||||
}
|
||||
.play-icon {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
.preview {
|
||||
.image.error {
|
||||
background: var(--el-bg-color-page);
|
||||
.image-slot {
|
||||
font-size: 14px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
}
|
||||
.failure {
|
||||
background: var(--el-fill-color-light);
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user