Add feature support for qrart (#34)
This commit is contained in:
1 parent
091fa4d18a
commit
2fe1cb4e1d
110 files changed
+5767
-334
No files matched your search
@@ -1,44 +1,46 @@
|
||||
<template>
|
||||
<div v-if="initializing && application === undefined">
|
||||
<el-skeleton :rows="1" class="text-center">
|
||||
<template #template>
|
||||
<el-skeleton-item variant="p" class="shimmer" />
|
||||
</template>
|
||||
</el-skeleton>
|
||||
</div>
|
||||
<div v-else-if="application" class="status">
|
||||
<span class="info">
|
||||
{{ $t('common.message.usedAmount') }}: {{ application?.used_amount?.toFixed(6) }}
|
||||
{{ $t(`service.unit.` + application?.service?.unit + 's') }}
|
||||
{{ $t('common.message.remainingAmount') }}:
|
||||
{{ application?.remaining_amount?.toFixed(6) }}
|
||||
{{ $t(`service.unit.` + application?.service?.unit + 's') }}
|
||||
</span>
|
||||
<span class="actions">
|
||||
<el-button round size="small" type="primary" class="mr-1" @click="onBuyMore(application)">{{
|
||||
$t('common.button.buyMore')
|
||||
}}</el-button>
|
||||
<api-price
|
||||
v-if="showPrice && application?.service?.apis?.[0]?.price"
|
||||
class="price inline-block"
|
||||
:price="application?.service?.apis?.[0]?.price"
|
||||
<div>
|
||||
<div v-if="initializing && application === undefined">
|
||||
<el-skeleton :rows="1" class="text-center">
|
||||
<template #template>
|
||||
<el-skeleton-item variant="p" class="shimmer" />
|
||||
</template>
|
||||
</el-skeleton>
|
||||
</div>
|
||||
<div v-else-if="application" class="status">
|
||||
<span class="info">
|
||||
{{ $t('common.message.usedAmount') }}: {{ application?.used_amount?.toFixed(6) }}
|
||||
{{ $t(`service.unit.` + application?.service?.unit + 's') }}
|
||||
{{ $t('common.message.remainingAmount') }}:
|
||||
{{ application?.remaining_amount?.toFixed(6) }}
|
||||
{{ $t(`service.unit.` + application?.service?.unit + 's') }}
|
||||
</span>
|
||||
<span class="actions">
|
||||
<el-button round size="small" type="primary" class="mr-1" @click="onBuyMore(application)">{{
|
||||
$t('common.button.buyMore')
|
||||
}}</el-button>
|
||||
<api-price
|
||||
v-if="showPrice && application?.service?.apis?.[0]?.price"
|
||||
class="price inline-block"
|
||||
:price="application?.service?.apis?.[0]?.price"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="needApply && service" class="text-center info">
|
||||
<span class="mr-2">{{ $t('chat.message.notApplied') }}</span>
|
||||
<span>
|
||||
<el-button round type="primary" class="btn btn-apply" size="small" @click="confirming = true">
|
||||
{{ $t('common.button.apply') }}
|
||||
</el-button>
|
||||
</span>
|
||||
<span class="ml-1">{{ $t('chat.message.tryForFree') }}</span>
|
||||
<application-confirm
|
||||
v-if="service && authenticated"
|
||||
v-model.visible="confirming"
|
||||
:service="service"
|
||||
@apply="onApply"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="needApply && service" class="text-center info">
|
||||
<span class="mr-2">{{ $t('chat.message.notApplied') }}</span>
|
||||
<span>
|
||||
<el-button round type="primary" class="btn btn-apply" size="small" @click="confirming = true">
|
||||
{{ $t('common.button.apply') }}
|
||||
</el-button>
|
||||
</span>
|
||||
<span class="ml-1">{{ $t('chat.message.tryForFree') }}</span>
|
||||
<application-confirm
|
||||
v-if="service && authenticated"
|
||||
v-model.visible="confirming"
|
||||
:service="service"
|
||||
@apply="onApply"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -100,7 +100,9 @@ import {
|
||||
ROUTE_DISTRIBUTION_INDEX,
|
||||
ROUTE_INDEX,
|
||||
ROUTE_MIDJOURNEY_HISTORY,
|
||||
ROUTE_MIDJOURNEY_INDEX
|
||||
ROUTE_MIDJOURNEY_INDEX,
|
||||
ROUTE_QRART_INDEX,
|
||||
ROUTE_QRART_HISTORY
|
||||
} from '@/router/constants';
|
||||
import Chevron from './Chevron.vue';
|
||||
import Logo from './Logo.vue';
|
||||
@@ -152,6 +154,17 @@ export default defineComponent({
|
||||
});
|
||||
}
|
||||
|
||||
if (this.$config.navigation?.qrart) {
|
||||
links.push({
|
||||
route: {
|
||||
name: ROUTE_QRART_INDEX
|
||||
},
|
||||
displayName: this.$t('common.nav.qrart'),
|
||||
icon: 'fa-solid fa-qrcode',
|
||||
routes: [ROUTE_QRART_INDEX, ROUTE_QRART_HISTORY]
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
links,
|
||||
activeIndex: this.$route.name as string
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<div class="panel">
|
||||
<div class="config">
|
||||
<type-selector class="mb-4" />
|
||||
<content-input class="mb-4" />
|
||||
<prompt-input class="mb-4" />
|
||||
<aspect-ratio-selector class="mb-4" />
|
||||
<qrw-selector class="mb-4" />
|
||||
<steps-selector class="mb-4" />
|
||||
<preset-selector class="mb-4" />
|
||||
</div>
|
||||
<div class="actions">
|
||||
<el-button type="primary" class="btn" round @click="onGenerate">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
|
||||
{{ $t('qrart.button.generate') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import TypeSelector from './config/TypeSelector.vue';
|
||||
import ContentInput from './config/ContentInput.vue';
|
||||
import PromptInput from './config/PromptInput.vue';
|
||||
import AspectRatioSelector from './config/AspectRatioSelector.vue';
|
||||
import QrwSelector from './config/QrwSelector.vue';
|
||||
import StepsSelector from './config/StepsSelector.vue';
|
||||
import PresetSelector from './config/PresetSelector.vue';
|
||||
import { ElButton } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'PresetPanel',
|
||||
components: {
|
||||
TypeSelector,
|
||||
FontAwesomeIcon,
|
||||
ContentInput,
|
||||
PromptInput,
|
||||
AspectRatioSelector,
|
||||
ElButton,
|
||||
QrwSelector,
|
||||
StepsSelector,
|
||||
PresetSelector
|
||||
},
|
||||
emits: ['generate'],
|
||||
computed: {
|
||||
config() {
|
||||
return this.$store.state.qrart?.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;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
.actions {
|
||||
height: 50px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
.btn {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,25 @@
|
||||
<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>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<div class="panel recent">
|
||||
<task-preview
|
||||
v-for="(task, taskIndex) in tasks?.items"
|
||||
:key="taskIndex"
|
||||
:model-value="task"
|
||||
class="preview"
|
||||
@click="onSelectTask(task)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import TaskPreview from './task/Preview.vue';
|
||||
import { Status, IQrartTask } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'RecentPanel',
|
||||
components: {
|
||||
TaskPreview
|
||||
},
|
||||
emits: ['select'],
|
||||
data() {
|
||||
return {
|
||||
job: 0
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
loading() {
|
||||
return this.$store.state.qrart.status.getApplication === Status.Request;
|
||||
},
|
||||
tasks() {
|
||||
return this.$store.state.qrart.tasks;
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
await this.$store.dispatch('qrart/setTasks', undefined);
|
||||
this.getTasks();
|
||||
// @ts-ignore
|
||||
this.job = setInterval(() => {
|
||||
this.getTasks();
|
||||
}, 5000);
|
||||
},
|
||||
methods: {
|
||||
async onLoadHistory() {
|
||||
// this.$router.push({ name: ROUTE_MIDJOURNEY_HISTORY });
|
||||
},
|
||||
async onSelectTask(task: IQrartTask) {
|
||||
this.$store.dispatch('qrart/setTasksActive', task);
|
||||
},
|
||||
async getTasks() {
|
||||
// ensure that the previous request has been completed
|
||||
if (this.loading) {
|
||||
return;
|
||||
}
|
||||
await this.$store.dispatch('qrart/getTasks', {
|
||||
limit: 12,
|
||||
offset: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
&.recent {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
overflow-x: scroll;
|
||||
.preview {
|
||||
margin-right: 15px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,141 @@
|
||||
<template>
|
||||
<div>
|
||||
<h2 class="title">{{ $t('qrart.name.aspectRatio') }}</h2>
|
||||
<div class="items">
|
||||
<div
|
||||
v-for="(option, optionKey) in options"
|
||||
:key="optionKey"
|
||||
:class="{ active: active === optionKey, item: true }"
|
||||
@click="value = option.value"
|
||||
>
|
||||
<div class="preview" :class="option.label">
|
||||
<div class="rect" :style="{ width: option.width + 'px', height: option.height + 'px' }"></div>
|
||||
</div>
|
||||
<p class="name">
|
||||
{{ option.label }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { MIDJOURNEY_DEFAULT_RATIO } from '@/constants';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'AspectRatioSelector',
|
||||
data() {
|
||||
return {
|
||||
options: [
|
||||
{
|
||||
value: '1:1',
|
||||
label: '1:1',
|
||||
width: 30,
|
||||
height: 30
|
||||
},
|
||||
{
|
||||
value: '4:3',
|
||||
label: '4:3',
|
||||
width: 32,
|
||||
height: 24
|
||||
},
|
||||
{
|
||||
value: '3:4',
|
||||
label: '3:4',
|
||||
width: 24,
|
||||
height: 32
|
||||
},
|
||||
{
|
||||
value: '16:9',
|
||||
label: '16:9',
|
||||
width: 32,
|
||||
height: 18
|
||||
},
|
||||
{
|
||||
value: '9:16',
|
||||
label: '9:16',
|
||||
width: 18,
|
||||
height: 32
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
active() {
|
||||
return this.options.findIndex((option) => option.value === this.value) || 0;
|
||||
},
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.qrart.config?.aspect_ratio;
|
||||
},
|
||||
set(val) {
|
||||
console.debug('set aspect ratio', val);
|
||||
this.$store.commit('qrart/setConfig', {
|
||||
...this.$store.state.qrart.config,
|
||||
aspect_ratio: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = MIDJOURNEY_DEFAULT_RATIO;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.items {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.item {
|
||||
width: 55px;
|
||||
height: 75px;
|
||||
border: 2px solid var(--el-border-color);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
border-radius: 5px;
|
||||
|
||||
.preview {
|
||||
margin-top: 8px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.rect {
|
||||
border: 2px solid var(--el-border-color);
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.name {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
&.active {
|
||||
border-color: var(--el-color-primary);
|
||||
.rect {
|
||||
border-color: var(--el-color-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,53 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title">{{ $t('qrart.name.content') }}</h2>
|
||||
<el-input v-model="value" class="content" :placeholder="$t('qrart.placeholder.content')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElInput } from 'element-plus';
|
||||
|
||||
export const DEFAULT_CONTENT = '';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ContentInput',
|
||||
components: {
|
||||
ElInput
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.qrart.config?.content;
|
||||
},
|
||||
set(val) {
|
||||
console.debug('set content', val);
|
||||
this.$store.commit('qrart/setConfig', {
|
||||
...this.$store.state.qrart.config,
|
||||
content: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = DEFAULT_CONTENT;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
width: 30%;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,162 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title">{{ $t('qrart.name.preset') }}</h2>
|
||||
<el-select v-model="value" class="value" :placeholder="$t('qrart.placeholder.select')">
|
||||
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ElSlider } from 'element-plus';
|
||||
import InfoIcon from '@/components/common/InfoIcon.vue';
|
||||
import { QRART_DEFAULT_PRESET } from '@/constants';
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSelect, ElOption } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'PresetSelector',
|
||||
components: {
|
||||
ElSelect,
|
||||
ElOption
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
options: [
|
||||
{
|
||||
value: 'sunset',
|
||||
label: this.$t('qrart.preset.sunset')
|
||||
},
|
||||
{
|
||||
value: 'floral',
|
||||
label: this.$t('qrart.preset.floral')
|
||||
},
|
||||
{
|
||||
value: 'snowflakes',
|
||||
label: this.$t('qrart.preset.snowflakes')
|
||||
},
|
||||
{
|
||||
value: 'feathers',
|
||||
label: this.$t('qrart.preset.feathers')
|
||||
},
|
||||
{
|
||||
value: 'raindrops',
|
||||
label: this.$t('qrart.preset.raindrops')
|
||||
},
|
||||
{
|
||||
value: 'ultra-realism',
|
||||
label: this.$t('qrart.preset.ultraRealism')
|
||||
},
|
||||
{
|
||||
value: 'epic-realms',
|
||||
label: this.$t('qrart.preset.epicRealms')
|
||||
},
|
||||
{
|
||||
value: 'intricate-studio',
|
||||
label: this.$t('qrart.preset.intricateStudio')
|
||||
},
|
||||
{
|
||||
value: 'symmetric-masterpiece',
|
||||
label: this.$t('qrart.preset.symmetricMasterpiece')
|
||||
},
|
||||
{
|
||||
value: 'luminous-highway',
|
||||
label: this.$t('qrart.preset.luminousHighway')
|
||||
},
|
||||
{
|
||||
value: 'celestial-journey',
|
||||
label: this.$t('qrart.preset.celestialJourney')
|
||||
},
|
||||
{
|
||||
value: 'neon-mech',
|
||||
label: this.$t('qrart.preset.neonMech')
|
||||
},
|
||||
{
|
||||
value: 'ethereal-low-poly',
|
||||
label: this.$t('qrart.preset.etherealLowPoly')
|
||||
},
|
||||
{
|
||||
value: 'golden-vista',
|
||||
label: this.$t('qrart.preset.goldenVista')
|
||||
},
|
||||
{
|
||||
value: 'cinematic-expanse',
|
||||
label: this.$t('qrart.preset.cinematicExpanse')
|
||||
},
|
||||
{
|
||||
value: 'cinematic-warm',
|
||||
label: this.$t('qrart.preset.cinematicWarm')
|
||||
},
|
||||
{
|
||||
value: 'desolate-wilderness',
|
||||
label: this.$t('qrart.preset.desolateWilderness')
|
||||
},
|
||||
{
|
||||
value: 'vibrant-palette',
|
||||
label: this.$t('qrart.preset.vibrantPalette')
|
||||
},
|
||||
{
|
||||
value: 'enigmatic-journey',
|
||||
label: this.$t('qrart.preset.enigmaticJourney')
|
||||
},
|
||||
{
|
||||
value: 'timeless-cinematic',
|
||||
label: this.$t('qrart.preset.timelessCinematic')
|
||||
},
|
||||
{
|
||||
value: 'regal-galaxy',
|
||||
label: this.$t('qrart.preset.regalGalaxy')
|
||||
},
|
||||
{
|
||||
value: 'illustrious-canvas',
|
||||
label: this.$t('qrart.preset.illustriousCanvas')
|
||||
},
|
||||
{
|
||||
value: 'expressive-mural',
|
||||
label: this.$t('qrart.preset.expressiveMural')
|
||||
},
|
||||
{
|
||||
value: 'serene-haze',
|
||||
label: this.$t('qrart.preset.sereneHaze')
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.qrart.config?.preset;
|
||||
},
|
||||
set(val) {
|
||||
console.debug('set qrw', val);
|
||||
this.$store.commit('qrart/setConfig', {
|
||||
...this.$store.state.qrart.config,
|
||||
preset: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = QRART_DEFAULT_STEPS;
|
||||
}
|
||||
}
|
||||
});
|
||||
</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,53 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title">{{ $t('qrart.name.prompt') }}</h2>
|
||||
<el-input v-model="value" :rows="3" type="textarea" class="prompt" :placeholder="$t('qrart.placeholder.prompt')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElInput } from 'element-plus';
|
||||
|
||||
export const DEFAULT_PROMPT = '';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'PromptInput',
|
||||
components: {
|
||||
ElInput
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.qrart.config?.prompt;
|
||||
},
|
||||
set(val) {
|
||||
console.debug('set prompt', val);
|
||||
this.$store.commit('qrart/setConfig', {
|
||||
...this.$store.state.qrart.config,
|
||||
prompt: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = DEFAULT_PROMPT;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
width: 30%;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title">{{ $t('qrart.name.qrw') }}</h2>
|
||||
<el-slider v-model="value" :min="1.5" :max="3" :step="0.1" class="value" />
|
||||
<info-icon :content="$t('qrart.description.qrw')" class="info" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ElSlider } from 'element-plus';
|
||||
import InfoIcon from '@/components/common/InfoIcon.vue';
|
||||
import { QRART_DEFAULT_QRW } from '@/constants';
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'QrwSelector',
|
||||
components: {
|
||||
ElSlider,
|
||||
InfoIcon
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.qrart.config?.qrw;
|
||||
},
|
||||
set(val) {
|
||||
console.debug('set qrw', val);
|
||||
this.$store.commit('qrart/setConfig', {
|
||||
...this.$store.state.qrart.config,
|
||||
qrw: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = QRART_DEFAULT_QRW;
|
||||
}
|
||||
}
|
||||
});
|
||||
</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('qrart.name.steps') }}</h2>
|
||||
<el-slider v-model="value" :min="10" :max="20" :step="1" class="value" />
|
||||
<info-icon :content="$t('qrart.description.steps')" class="info" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ElSlider } from 'element-plus';
|
||||
import InfoIcon from '@/components/common/InfoIcon.vue';
|
||||
import { QRART_DEFAULT_STEPS } from '@/constants';
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'StepsSelector',
|
||||
components: {
|
||||
ElSlider,
|
||||
InfoIcon
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.qrart.config?.steps;
|
||||
},
|
||||
set(val) {
|
||||
console.debug('set qrw', val);
|
||||
this.$store.commit('qrart/setConfig', {
|
||||
...this.$store.state.qrart.config,
|
||||
steps: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = QRART_DEFAULT_STEPS;
|
||||
}
|
||||
}
|
||||
});
|
||||
</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,80 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title">{{ $t('qrart.name.type') }}</h2>
|
||||
<el-select v-model="value" class="value" :placeholder="$t('qrart.placeholder.select')">
|
||||
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSelect, ElOption } from 'element-plus';
|
||||
|
||||
const DEFAULT_TYPE = 'Link';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'VersionSelector',
|
||||
components: {
|
||||
ElSelect,
|
||||
ElOption
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: undefined
|
||||
}
|
||||
},
|
||||
emits: ['update:modelValue'],
|
||||
data() {
|
||||
return {
|
||||
options: [
|
||||
{
|
||||
label: 'Text',
|
||||
value: 'text'
|
||||
},
|
||||
{
|
||||
label: 'Link',
|
||||
value: 'link'
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.qrart.config?.type;
|
||||
},
|
||||
set(val) {
|
||||
console.debug('set type', val);
|
||||
this.$store.commit('qrart/setConfig', {
|
||||
...this.$store.state.qrart.config,
|
||||
type: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = DEFAULT_TYPE;
|
||||
}
|
||||
}
|
||||
});
|
||||
</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,158 @@
|
||||
<template>
|
||||
<div 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-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 :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 :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,
|
||||
ElTag,
|
||||
ElButton,
|
||||
ElTooltip,
|
||||
ElSkeleton,
|
||||
ElAlert,
|
||||
ElRow,
|
||||
ElCol,
|
||||
ElDescriptions,
|
||||
ElDescriptionsItem
|
||||
} from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TaskDetail',
|
||||
components: {
|
||||
ElImage,
|
||||
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%);
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,114 @@
|
||||
<template>
|
||||
<div class="preview">
|
||||
<el-image
|
||||
v-if="modelValue?.response"
|
||||
v-loading="!modelValue?.response?.image_url"
|
||||
:src="modelValue?.response?.image_url"
|
||||
fit="contain"
|
||||
class="image"
|
||||
/>
|
||||
<el-image v-else class="image error">
|
||||
<template #error>
|
||||
<div class="image-slot">{{ $t('qrart.message.generating') }}</div>
|
||||
</template>
|
||||
</el-image>
|
||||
<p class="prompt">
|
||||
{{ modelValue?.request?.prompt }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElImage } from 'element-plus';
|
||||
import { IQrartTask } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TaskPreview',
|
||||
components: {
|
||||
ElImage
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: Object as () => IQrartTask | undefined,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
application() {
|
||||
return this.$store.state.midjourney.application;
|
||||
}
|
||||
},
|
||||
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();
|
||||
},
|
||||
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>
|
||||
.preview {
|
||||
width: 250px;
|
||||
height: 280px;
|
||||
padding: 15px;
|
||||
cursor: pointer;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: 15px;
|
||||
.image {
|
||||
width: 220px;
|
||||
height: 220px;
|
||||
display: block;
|
||||
margin: auto;
|
||||
}
|
||||
.prompt {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-regular);
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
</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%);
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user