Add pixverse (#240)
This commit is contained in:
1 parent
79e1bf0d6d
commit
d6f6bfd33a
141 files changed
+9107
-1501
No files matched your search
@@ -0,0 +1,86 @@
|
||||
<template>
|
||||
<div class="panel">
|
||||
<div class="config">
|
||||
<prompt-input class="mb-4" />
|
||||
<model-selector class="mb-4" />
|
||||
<style-selector class="mb-4" />
|
||||
<motion-selector class="mb-4" />
|
||||
<quality-selector class="mb-4" />
|
||||
<start-image class="mb-2" />
|
||||
<seed-selector class="mb-4" />
|
||||
<duration-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('pixverse.button.generate') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElButton } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import ModelSelector from './config/ModelSelector.vue';
|
||||
import QualitySelector from './config/QualitySelector.vue';
|
||||
import MotionSelector from './config/MotionSelector.vue';
|
||||
import StyleSelector from './config/StyleSelector.vue';
|
||||
import SeedSelector from './config/SeedSelector.vue';
|
||||
import DurationSelector from './config/DurationSelector.vue';
|
||||
import StartImage from './config/StartImage.vue';
|
||||
import PromptInput from './config/PromptInput.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ConfigPanel',
|
||||
components: {
|
||||
ElButton,
|
||||
FontAwesomeIcon,
|
||||
PromptInput,
|
||||
ModelSelector,
|
||||
QualitySelector,
|
||||
MotionSelector,
|
||||
StyleSelector,
|
||||
DurationSelector,
|
||||
StartImage,
|
||||
SeedSelector
|
||||
},
|
||||
emits: ['generate'],
|
||||
computed: {
|
||||
config() {
|
||||
return this.$store.state.pixverse?.config;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onGenerate() {
|
||||
this.$emit('generate');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.panel {
|
||||
height: 100%;
|
||||
padding: 15px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
height: calc(100% - 40px);
|
||||
.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,51 @@
|
||||
<template>
|
||||
<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" class="w-full h-full flex items-center justify-center">
|
||||
<no-tasks />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import TaskPreview from './task/Preview.vue';
|
||||
import BotPlaceholder from '@/components/common/BotPlaceholder.vue';
|
||||
import NoTasks from '@/components/common/NoTasks.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'RecentPanel',
|
||||
components: {
|
||||
TaskPreview,
|
||||
NoTasks,
|
||||
BotPlaceholder
|
||||
},
|
||||
emits: ['reach-top'],
|
||||
data() {
|
||||
return {
|
||||
job: 0
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
tasks() {
|
||||
// reverse the order of the tasks.items
|
||||
return {
|
||||
...this.$store.state.pixverse?.tasks,
|
||||
items: this.$store.state.pixverse?.tasks?.items?.slice()
|
||||
};
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onHandleScroll() {
|
||||
const el = this.$refs.panel as HTMLElement;
|
||||
console.log('reach-top reach-top reach-top');
|
||||
if (el.scrollTop === 0) {
|
||||
this.$emit('reach-top');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,79 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title font-bold">{{ $t('pixverse.name.duration') }}</h2>
|
||||
<el-select v-model="value" class="value" :placeholder="$t('pixverse.placeholder.select')">
|
||||
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSelect, ElOption } from 'element-plus';
|
||||
import { PIXVERSE_DEFAULT_DURATION } from '@/constants';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'DurationSelector',
|
||||
components: {
|
||||
ElSelect,
|
||||
ElOption
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: undefined
|
||||
}
|
||||
},
|
||||
emits: ['update:modelValue'],
|
||||
data() {
|
||||
return {
|
||||
options: [
|
||||
{
|
||||
value: 5,
|
||||
label: '5s'
|
||||
},
|
||||
{
|
||||
value: 8,
|
||||
label: '8s'
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.pixverse?.config?.duration;
|
||||
},
|
||||
set(val: string) {
|
||||
this.$store.commit('pixverse/setConfig', {
|
||||
...this.$store.state.pixverse.config,
|
||||
duration: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = PIXVERSE_DEFAULT_DURATION;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
width: 30%;
|
||||
}
|
||||
.value {
|
||||
width: 80px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,87 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title font-bold">{{ $t('pixverse.name.model') }}</h2>
|
||||
<el-select v-model="value" class="value" :placeholder="$t('pixverse.placeholder.select')">
|
||||
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSelect, ElOption } from 'element-plus';
|
||||
import { PIXVERSE_DEFAULT_MODEL } from '@/constants';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ModelSelector',
|
||||
components: {
|
||||
ElSelect,
|
||||
ElOption
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: undefined
|
||||
}
|
||||
},
|
||||
emits: ['update:modelValue'],
|
||||
data() {
|
||||
return {
|
||||
options: [
|
||||
{
|
||||
value: 'v3',
|
||||
label: 'V3'
|
||||
},
|
||||
{
|
||||
value: 'v3.5',
|
||||
label: 'V3-5'
|
||||
},
|
||||
{
|
||||
value: 'v2',
|
||||
label: 'V2'
|
||||
},
|
||||
{
|
||||
value: 'v4.5',
|
||||
label: 'V4-5'
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.pixverse?.config?.model;
|
||||
},
|
||||
set(val: string) {
|
||||
this.$store.commit('pixverse/setConfig', {
|
||||
...this.$store.state.pixverse.config,
|
||||
model: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = PIXVERSE_DEFAULT_MODEL;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
width: 30%;
|
||||
}
|
||||
.value {
|
||||
width: 80px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,78 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title font-bold">{{ $t('pixverse.name.motion') }}</h2>
|
||||
<el-select v-model="value" class="value" :placeholder="$t('pixverse.placeholder.select')">
|
||||
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSelect, ElOption } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'MotionSelector',
|
||||
components: {
|
||||
ElSelect,
|
||||
ElOption
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: undefined
|
||||
}
|
||||
},
|
||||
emits: ['update:modelValue'],
|
||||
data() {
|
||||
return {
|
||||
options: [
|
||||
{
|
||||
value: 'normal',
|
||||
label: this.$t('pixverse.name.motion1')
|
||||
},
|
||||
{
|
||||
value: 'fast',
|
||||
label: this.$t('pixverse.name.motion2')
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.pixverse?.config?.motion;
|
||||
},
|
||||
set(val: string) {
|
||||
this.$store.commit('pixverse/setConfig', {
|
||||
...this.$store.state.pixverse.config,
|
||||
motion: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
width: 30%;
|
||||
}
|
||||
.value {
|
||||
width: 80px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,71 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<div class="box">
|
||||
<h2 class="title font-bold">{{ $t('pixverse.name.prompt') }}</h2>
|
||||
<info-icon :content="$t('pixverse.description.prompt')" class="info" />
|
||||
</div>
|
||||
<el-input
|
||||
v-model="prompt"
|
||||
:rows="3"
|
||||
type="textarea"
|
||||
class="prompt"
|
||||
:placeholder="$t('pixverse.placeholder.prompt')"
|
||||
:maxlength="500"
|
||||
show-word-limit
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
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
|
||||
},
|
||||
computed: {
|
||||
prompt: {
|
||||
get() {
|
||||
return this.$store.state.pixverse?.config?.prompt;
|
||||
},
|
||||
set(val: string) {
|
||||
console.debug('set prompt', val);
|
||||
this.$store.commit('pixverse/setConfig', {
|
||||
...this.$store.state.pixverse?.config,
|
||||
prompt: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.prompt) {
|
||||
this.prompt = DEFAULT_PROMPT;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
.box {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between; // Add this line to move the icon to the right
|
||||
position: relative;
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
.info {
|
||||
margin-left: auto; // Ensure the icon stays on the right
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,86 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title font-bold">{{ $t('pixverse.name.quality') }}</h2>
|
||||
<el-select v-model="value" class="value" :placeholder="$t('pixverse.placeholder.select')">
|
||||
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSelect, ElOption } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'QualitySelector',
|
||||
components: {
|
||||
ElSelect,
|
||||
ElOption
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: undefined
|
||||
}
|
||||
},
|
||||
emits: ['update:modelValue'],
|
||||
data() {
|
||||
return {
|
||||
options: [
|
||||
{
|
||||
value: '360p',
|
||||
label: '360p'
|
||||
},
|
||||
{
|
||||
value: '540p',
|
||||
label: '540p'
|
||||
},
|
||||
{
|
||||
value: '720p',
|
||||
label: '720p'
|
||||
},
|
||||
{
|
||||
value: '1080p',
|
||||
label: '1080p'
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.pixverse?.config?.quality;
|
||||
},
|
||||
set(val: string) {
|
||||
this.$store.commit('pixverse/setConfig', {
|
||||
...this.$store.state.pixverse.config,
|
||||
quality: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
width: 30%;
|
||||
}
|
||||
.value {
|
||||
width: 80px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,50 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="flex justify-between">
|
||||
<div class="flex justify-start items-center">
|
||||
<span class="text-sm font-bold">{{ $t('pixverse.name.seed') }}</span>
|
||||
<info-icon :content="$t('pixverse.description.seed')" />
|
||||
</div>
|
||||
<div class="flex justify-end items-center">
|
||||
<el-input-number v-model="value" controls-position="right" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full">
|
||||
<el-slider v-model="value" :min="0" :max="1000" :step="1" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSlider, ElInputNumber } from 'element-plus';
|
||||
import InfoIcon from '@/components/common/InfoIcon.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SeedSelector',
|
||||
components: {
|
||||
ElSlider,
|
||||
InfoIcon,
|
||||
ElInputNumber
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state?.pixverse?.config?.seed;
|
||||
},
|
||||
set(val: string) {
|
||||
console.debug('set cfg_scale', val);
|
||||
this.$store.commit('pixverse/setConfig', {
|
||||
...this.$store.state?.pixverse?.config,
|
||||
seed: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = undefined;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,140 @@
|
||||
<template>
|
||||
<div class="relative">
|
||||
<div class="flex justify-between">
|
||||
<div class="flex justify-start items-center">
|
||||
<span class="text-sm font-bold">{{ $t('pixverse.name.startImage') }}</span>
|
||||
<info-icon :content="$t('pixverse.description.uploadStartImage')" />
|
||||
</div>
|
||||
</div>
|
||||
<el-upload
|
||||
v-model:file-list="fileList"
|
||||
name="file"
|
||||
accept=".png,.jpg,.jpeg,.gif,.bmp,.webp"
|
||||
:limit="5"
|
||||
class="upload-wrapper"
|
||||
:multiple="false"
|
||||
:action="uploadUrl"
|
||||
list-type="picture"
|
||||
:on-exceed="onExceed"
|
||||
:on-error="onError"
|
||||
:on-success="onSuccess"
|
||||
:headers="headers"
|
||||
>
|
||||
<template #file="{ file }">
|
||||
<image-preview
|
||||
v-if="file.url && file.percentage !== undefined"
|
||||
:url="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('pixverse.button.uploadReferences') }}
|
||||
</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: 'StartImage',
|
||||
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);
|
||||
},
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state?.pixverse?.config?.image_url;
|
||||
},
|
||||
set() {
|
||||
// this.$store.commit('pixverse/setConfig', {
|
||||
// ...this.$store.state?.pixverse?.config,
|
||||
// start_image_url: val
|
||||
// });
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = undefined;
|
||||
}
|
||||
this.onSetStartImageUrl();
|
||||
},
|
||||
methods: {
|
||||
onExceed() {
|
||||
ElMessage.warning(this.$t('pixverse.message.uploadReferencesExceed'));
|
||||
},
|
||||
onError() {
|
||||
ElMessage.error(this.$t('pixverse.message.uploadReferencesError'));
|
||||
},
|
||||
onSetStartImageUrl() {
|
||||
const url = this.urls?.[0];
|
||||
this.$store.commit('pixverse/setConfig', {
|
||||
...this.$store.state?.pixverse?.config,
|
||||
image_url: url
|
||||
});
|
||||
},
|
||||
async onSuccess() {
|
||||
this.onSetStartImageUrl();
|
||||
}
|
||||
}
|
||||
});
|
||||
</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,91 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title font-bold">{{ $t('pixverse.name.style') }}</h2>
|
||||
<el-select v-model="value" class="value" :placeholder="$t('pixverse.placeholder.select')">
|
||||
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSelect, ElOption } from 'element-plus';
|
||||
import { PIXVERSE_DEFAULT_MODEL } from '@/constants';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'StyleSelector',
|
||||
components: {
|
||||
ElSelect,
|
||||
ElOption
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: undefined
|
||||
}
|
||||
},
|
||||
emits: ['update:modelValue'],
|
||||
data() {
|
||||
return {
|
||||
options: [
|
||||
{
|
||||
value: 'cyberpunk',
|
||||
label: this.$t('pixverse.name.style1')
|
||||
},
|
||||
{
|
||||
value: 'anime',
|
||||
label: this.$t('pixverse.name.style2')
|
||||
},
|
||||
{
|
||||
value: 'comic',
|
||||
label: this.$t('pixverse.name.style3')
|
||||
},
|
||||
{
|
||||
value: 'clay',
|
||||
label: this.$t('pixverse.name.style4')
|
||||
},
|
||||
{
|
||||
value: '3d_animation',
|
||||
label: this.$t('pixverse.name.style5')
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.pixverse?.config?.style;
|
||||
},
|
||||
set(val: string) {
|
||||
this.$store.commit('pixverse/setConfig', {
|
||||
...this.$store.state.pixverse.config,
|
||||
style: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = PIXVERSE_DEFAULT_MODEL;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
width: 30%;
|
||||
}
|
||||
.value {
|
||||
width: 80px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,259 @@
|
||||
<template>
|
||||
<div class="preview">
|
||||
<div class="left">
|
||||
<el-image src="https://cdn.acedata.cloud/viy61r.jpg" class="avatar" />
|
||||
</div>
|
||||
<div class="main">
|
||||
<div class="bot">
|
||||
{{ $t('pixverse.name.pixverseBot') }}
|
||||
<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('pixverse.status.pending') }}) </span>
|
||||
<span
|
||||
v-if="
|
||||
modelValue?.response?.data &&
|
||||
(modelValue?.response?.data[0]?.state === 'processing' ||
|
||||
modelValue?.response?.data[0]?.state === 'pending')
|
||||
"
|
||||
>
|
||||
- ({{ $t('pixverse.status.processing') }})
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<!-- Display success message -->
|
||||
<div
|
||||
v-if="modelValue?.response?.success === true && modelValue?.response?.data"
|
||||
:class="{ content: true, failed: true }"
|
||||
>
|
||||
<div v-if="modelValue?.response?.data[0]?.video_url" class="mb-4">
|
||||
<video-player :src="modelValue?.response?.data[0]?.video_url" />
|
||||
</div>
|
||||
<div v-if="modelValue?.response.success" :class="{ operations: true, 'mt-2': true }">
|
||||
<el-tooltip
|
||||
class="box-item"
|
||||
effect="dark"
|
||||
:content="$t('pixverse.message.downloadVideo')"
|
||||
placement="top-start"
|
||||
>
|
||||
<el-button
|
||||
v-if="modelValue?.response?.data[0]?.video_url"
|
||||
type="info"
|
||||
size="small"
|
||||
class="btn-action"
|
||||
@click="onDownload($event, modelValue?.response?.data[0]?.video_url)"
|
||||
>
|
||||
{{ $t('pixverse.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-hashtag" class="mr-1" />
|
||||
{{ $t('pixverse.name.model') }}:
|
||||
{{ modelValue?.request?.model }}
|
||||
</p>
|
||||
<p class="text-[var(--el-text-color-regular)] text-xs mb-0">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('pixverse.name.taskId') }}:
|
||||
{{ modelValue?.id }}
|
||||
<copy-to-clipboard :content="modelValue?.id!" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
<!-- Display error message -->
|
||||
<div v-if="modelValue?.response?.success === false" :class="{ content: true }">
|
||||
<el-alert :closable="false" class="info">
|
||||
<template #template>
|
||||
<font-awesome-icon icon="fa-solid fa-exclamation-triangle" class="mr-1" />
|
||||
{{ $t('pixverse.name.failure') }}
|
||||
</template>
|
||||
<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('pixverse.name.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-2">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('pixverse.name.taskId') }}:
|
||||
{{ modelValue?.id }}
|
||||
<copy-to-clipboard :content="modelValue?.id!" />
|
||||
</p>
|
||||
<p v-if="modelValue?.response?.trace_id" class="text-[var(--el-text-color-regular)] text-xs mb-0">
|
||||
<font-awesome-icon icon="fa-solid fa-hashtag" class="mr-1" />
|
||||
{{ $t('pixverse.name.traceId') }}:
|
||||
{{ modelValue?.response?.trace_id }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.trace_id" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElImage, ElAlert, ElButton, ElTooltip } from 'element-plus';
|
||||
import { IPixverseTask } from '@/models';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import VideoPlayer from '@/components/common/VideoPlayer.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TaskPreview',
|
||||
components: {
|
||||
ElImage,
|
||||
CopyToClipboard,
|
||||
FontAwesomeIcon,
|
||||
ElAlert,
|
||||
VideoPlayer,
|
||||
ElTooltip,
|
||||
ElButton
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: Object as () => IPixverseTask | undefined,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
application() {
|
||||
return this.$store.state.pixverse?.application;
|
||||
},
|
||||
config() {
|
||||
return this.$store.state.pixverse?.config;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onDownload(event: MouseEvent, video_url: string) {
|
||||
event.stopPropagation();
|
||||
console.log('on download');
|
||||
// download url here
|
||||
window.open(video_url, '_blank');
|
||||
},
|
||||
onOpenVideo(url: string) {
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
}
|
||||
});
|
||||
</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 {
|
||||
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: 16px;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.operations {
|
||||
display: flex;
|
||||
justify-content: left;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
align-items: baseline;
|
||||
flex-wrap: wrap;
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 14px;
|
||||
overflow-y: scroll;
|
||||
|
||||
&.full {
|
||||
height: 70px;
|
||||
}
|
||||
|
||||
.btn-action {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</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%;
|
||||
.el-alert__content {
|
||||
p {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user