Update qrart style (#61)

Co-authored-by: AceDataCloud <office@acedata.cloud>
Co-authored-by: Germey <germey@acedata.cloud>
This commit is contained in:
authored and GitHub committed 2024-06-30 11:18:28 +00:00
1 parent a0a7cd9bc8
commit c3176e41b8
80 files changed
+4533 -3120

No files matched your search

+57 -38
View File
@@ -50,15 +50,24 @@
</div>
<!-- response success -->
<div v-if="modelValue?.response?.success === true" :class="{ content: true, full: full }">
<el-image
v-if="modelValue?.response?.image_url"
:src="modelValue?.response?.image_url"
:preview-src-list="[modelValue?.response?.raw_image_url as string]"
fit="contain"
class="image"
:lazy="true"
@error="onReload($event)"
/>
<div class="image-wrapper">
<img
v-if="modelValue?.response?.image_url"
:src="modelValue?.response?.image_url"
:preview-src-list="[modelValue?.response?.raw_image_url as string]"
class="image"
@error="onReload($event)"
/>
<el-button
v-if="modelValue?.response?.image_url"
type="info"
round
class="btn-raw"
@click="onOpenUrl(modelValue?.response?.raw_image_url)"
>
{{ $t('common.button.seeRawImage') }}
</el-button>
</div>
<div v-if="modelValue?.response?.actions" :class="{ operations: true, full, 'mt-2': true }">
<el-tooltip
v-for="(action, actionKey) in modelValue?.response?.actions"
@@ -78,21 +87,21 @@
{{ actionMapping[action] }}
</el-button>
</el-tooltip>
<el-alert :closable="false" class="mt-2 success">
<p class="description">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
{{ $t('midjourney.field.taskId') }}:
{{ modelValue?.id }}
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy" />
</p>
<p class="description">
<font-awesome-icon icon="fa-solid fa-image" class="mr-1" />
{{ $t('midjourney.field.imageId') }}:
{{ modelValue?.response?.image_id }}
<copy-to-clipboard :content="modelValue?.response?.image_id" class="btn-copy" />
</p>
</el-alert>
</div>
<el-alert :closable="false" class="mt-2 success">
<p class="description">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
{{ $t('midjourney.field.taskId') }}:
{{ modelValue?.id }}
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy" />
</p>
<p class="description">
<font-awesome-icon icon="fa-solid fa-image" class="mr-1" />
{{ $t('midjourney.field.imageId') }}:
{{ modelValue?.response?.image_id }}
<copy-to-clipboard :content="modelValue?.response?.image_id" class="btn-copy" />
</p>
</el-alert>
</div>
<!-- response pending -->
<div v-if="!modelValue?.response">
@@ -237,6 +246,9 @@ export default defineComponent({
image_id: this.modelValue?.response?.image_id
});
},
onOpenUrl(url: string) {
window.open(url, '_blank');
},
onDownload(url: string) {
// download image using javascript
const link = document.createElement('a');
@@ -333,23 +345,30 @@ $left-width: 70px;
min-height: 200px;
}
}
&.failed {
.image-wrapper {
position: relative;
width: fit-content;
min-height: 50px;
min-width: 100px;
.image {
.image-slot {
font-size: 16px;
padding: 20px;
}
max-height: 400px;
max-width: 300px;
}
}
.image {
height: 350px;
.image-slot {
display: flex;
justify-content: left;
width: 100%;
height: 100%;
background: var(--el-fill-color-light);
color: var(--el-text-color-regular);
.btn-raw {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
z-index: 1000;
display: none;
}
&:hover {
.image {
filter: brightness(0.6);
}
.btn-raw {
display: block;
}
}
}
.progress {
+2 -26
View File
@@ -2,15 +2,12 @@
<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" />
<position-selector class="mb-4" />
<advanced-selector class="mb-4" />
<steps-selector v-if="config?.advanced" class="mb-4" />
<seed-input v-if="config?.advanced" class="mb-4" />
<position-selector v-if="config?.advanced" class="mb-4" />
<pixel-style-selector v-if="config?.advanced" class="mb-4" />
<marker-shape-selector v-if="config?.advanced" class="mb-4" />
<sub-marker-selector v-if="config?.advanced" class="mb-4" />
@@ -19,24 +16,15 @@
<padding-level-selector v-if="config?.advanced" class="mb-4" />
<padding-noise-selector v-if="config?.advanced" 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 AdvancedSelector from './config/AdvancedSelector.vue';
import MarkerShapeSelector from './config/MarkerShapeSelector.vue';
import SubMarkerSelector from './config/SubMarkerSelector.vue';
@@ -47,27 +35,20 @@ import PaddingLevelSelector from './config/PaddingLevelSelector.vue';
import PaddingNoiseSelector from './config/PaddingNoiseSelector.vue';
import PixelStyleSelector from './config/PixelStyleSelector.vue';
import SeedInput from './config/SeedInput.vue';
import { ElButton } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
export default defineComponent({
name: 'PresetPanel',
components: {
TypeSelector,
FontAwesomeIcon,
ContentInput,
PositionSelector,
PixelStyleSelector,
PaddingLevelSelector,
SeedInput,
PromptInput,
AspectRatioSelector,
ElButton,
QrwSelector,
EclSelector,
StepsSelector,
PaddingNoiseSelector,
PresetSelector,
AdvancedSelector,
MarkerShapeSelector,
SubMarkerSelector,
@@ -78,11 +59,6 @@ export default defineComponent({
config() {
return this.$store.state.qrart?.config;
}
},
methods: {
onGenerate() {
this.$emit('generate');
}
}
});
</script>
+77
View File
@@ -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>
+25 -22
View File
@@ -1,12 +1,6 @@
<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 class="panel recent tasks">
<task-preview v-for="(task, taskIndex) in tasks?.items" :key="taskIndex" :model-value="task" class="preview" />
<p v-if="tasks?.items?.length === 0">
{{ $t('qrart.message.noTasks') }}
</p>
@@ -16,14 +10,13 @@
<script lang="ts">
import { defineComponent } from 'vue';
import TaskPreview from './task/Preview.vue';
import { Status, IQrartTask } from '@/models';
import { Status } from '@/models';
export default defineComponent({
name: 'RecentPanel',
components: {
TaskPreview
},
emits: ['select'],
data() {
return {
job: 0
@@ -34,23 +27,34 @@ export default defineComponent({
return this.$store.state.qrart?.status?.getApplication === Status.Request;
},
tasks() {
return this.$store.state.qrart?.tasks;
// reverse the order of the tasks.items
return {
...this.$store.state.qrart?.tasks,
items: this.$store.state.qrart?.tasks?.items?.slice().reverse()
};
}
},
async mounted() {
await this.$store.dispatch('qrart/setTasks', undefined);
this.getTasks();
await this.getTasks();
await this.onScrollDown();
// @ts-ignore
this.job = setInterval(() => {
this.getTasks();
}, 5000);
},
async unmounted() {
clearInterval(this.job);
},
methods: {
async onLoadHistory() {
// this.$router.push({ name: ROUTE_MIDJOURNEY_HISTORY });
},
async onSelectTask(task: IQrartTask) {
this.$store.dispatch('qrart/setTasksActive', task);
async onScrollDown() {
setTimeout(() => {
// scroll to bottom for `.tasks`
const el = document.querySelector('.tasks');
if (el) {
el.scrollTop = el.scrollHeight;
}
}, 500);
},
async getTasks() {
// ensure that the previous request has been completed
@@ -58,7 +62,7 @@ export default defineComponent({
return;
}
await this.$store.dispatch('qrart/getTasks', {
limit: 12,
limit: 50,
offset: 0
});
}
@@ -75,11 +79,10 @@ export default defineComponent({
height: 100%;
&.recent {
width: 100%;
height: 300px;
height: 100%;
display: flex;
flex-direction: row;
justify-content: flex-start;
overflow-x: scroll;
overflow-y: auto;
flex-direction: column;
.preview {
margin-right: 15px;
}
@@ -98,7 +98,7 @@ export default defineComponent({
justify-content: space-between;
.item {
width: 55px;
width: 45px;
height: 75px;
border: 2px solid var(--el-border-color);
display: flex;
+90 -9
View File
@@ -1,34 +1,87 @@
<template>
<div class="field">
<h2 class="title">{{ $t('qrart.name.content') }}</h2>
<el-input v-model="value" class="content" :placeholder="$t('qrart.placeholder.content')" />
<el-radio-group v-model="inputWay" class="mb-4">
<el-radio-button label="input">{{ $t('qrart.inputWay.input') }} </el-radio-button>
<el-radio-button label="upload">{{ $t('qrart.inputWay.upload') }} </el-radio-button>
</el-radio-group>
<el-input
v-if="inputWay == 'input'"
v-model="value"
class="content"
:placeholder="$t('qrart.placeholder.content')"
/>
<el-upload
v-if="inputWay == 'upload'"
v-model:file-list="fileList"
accept=".png,.jpg,.jpeg,.gif,.bmp,.webp"
name="file"
class="upload"
:show-file-list="true"
:limit="1"
:multiple="false"
:action="uploadUrl"
:on-exceed="onExceed"
:on-error="onError"
:on-success="onSuccess"
:headers="headers"
>
<el-button type="primary" round>{{ $t('qrart.button.uploadQr') }}</el-button>
</el-upload>
<p v-if="inputWay == 'upload'" class="description">
{{ $t('qrart.message.uploadQr') }}
</p>
</div>
</template>
<script>
<script lang="ts">
import { defineComponent } from 'vue';
import { ElInput } from 'element-plus';
import { ElInput, ElRadioGroup, ElRadioButton, ElButton, ElUpload, ElMessage, UploadFiles } from 'element-plus';
import { getBaseUrlPlatform } from '@/utils';
export const DEFAULT_CONTENT = '';
interface IData {
inputWay: 'input' | 'upload';
fileList: UploadFiles;
uploadUrl: string;
}
export default defineComponent({
name: 'ContentInput',
components: {
ElInput
ElInput,
ElUpload,
ElRadioGroup,
ElButton,
ElRadioButton
},
data() {
return {};
data(): IData {
return {
inputWay: 'input',
fileList: [],
uploadUrl: getBaseUrlPlatform() + '/api/v1/files/'
};
},
computed: {
headers() {
return {
Authorization: `Bearer ${this.$store.state.token.access}`
};
},
urls(): string[] {
// @ts-ignore
return this.fileList.map((file: UploadFile) => file?.response?.file_url);
},
value: {
get() {
return this.$store.state.qrart?.config?.content;
},
set(val) {
console.debug('set content', val);
set(val: string) {
this.$store.commit('qrart/setConfig', {
...this.$store.state.qrart?.config,
content: val
content: val,
content_image_url: undefined
});
}
}
@@ -37,6 +90,27 @@ export default defineComponent({
if (!this.value) {
this.value = DEFAULT_CONTENT;
}
this.onSetContentImageUrl();
},
methods: {
onExceed() {
ElMessage.warning(this.$t('chatdoc.message.uploadDocumentsExceed'));
},
onError() {
ElMessage.error(this.$t('chatdoc.message.uploadDocumentsError'));
},
onSetContentImageUrl() {
const url = this.urls?.[0];
console.log('content_image_url', url);
this.$store.commit('qrart/setConfig', {
...this.$store.state.qrart?.config,
content: undefined,
content_image_url: url
});
},
async onSuccess() {
this.onSetContentImageUrl();
}
}
});
</script>
@@ -49,5 +123,12 @@ export default defineComponent({
width: 30%;
margin-bottom: 10px;
}
.description {
display: block;
font-size: 12px;
margin: 0;
margin-top: 10px;
color: var(--el-text-color-secondary);
}
}
</style>
@@ -0,0 +1,247 @@
<template>
<div class="field">
<h2 class="title">{{ $t('qrart.name.preset') }}</h2>
<div class="pane">
<div
v-for="(option, optionKey) in options"
:key="optionKey"
:class="{
item: true,
active: value === option.value
}"
@click="value === option.value ? (value = undefined) : (value = option.value)"
>
<el-image :src="option.url" fit="fill" class="preview" />
<span class="name">{{ option.label }}</span>
</div>
</div>
</div>
</template>
<script>
import { QRART_DEFAULT_PRESET } from '@/constants';
import { defineComponent } from 'vue';
import { ElImage } from 'element-plus';
export default defineComponent({
name: 'PresetSelector',
components: {
ElImage
},
data() {
return {
options: [
{
value: 'sunset',
label: this.$t('qrart.preset.sunset'),
url: 'https://cdn.acedata.cloud/rp1h1s.png'
},
{
value: 'floral',
label: this.$t('qrart.preset.floral'),
url: 'https://cdn.acedata.cloud/upyikx.png'
},
{
value: 'snowflakes',
label: this.$t('qrart.preset.snowflakes'),
url: 'https://cdn.acedata.cloud/j447da.png'
},
{
value: 'feathers',
label: this.$t('qrart.preset.feathers'),
url: 'https://cdn.acedata.cloud/d2ctz9.png'
},
{
value: 'raindrops',
label: this.$t('qrart.preset.raindrops'),
url: 'https://cdn.acedata.cloud/xv2t3s.png'
},
{
value: 'ultra-realism',
label: this.$t('qrart.preset.ultraRealism'),
url: 'https://cdn.acedata.cloud/nlor4y.png'
},
{
value: 'epic-realms',
label: this.$t('qrart.preset.epicRealms'),
url: 'https://cdn.acedata.cloud/wwzkvy.png'
},
{
value: 'intricate-studio',
label: this.$t('qrart.preset.intricateStudio'),
url: 'https://cdn.acedata.cloud/4kzf5y.png'
},
{
value: 'symmetric-masterpiece',
label: this.$t('qrart.preset.symmetricMasterpiece'),
url: 'https://cdn.acedata.cloud/ff4ii2.png'
},
{
value: 'luminous-highway',
label: this.$t('qrart.preset.luminousHighway'),
url: 'https://cdn.acedata.cloud/cliodt.png'
},
{
value: 'celestial-journey',
label: this.$t('qrart.preset.celestialJourney'),
url: 'https://cdn.acedata.cloud/ejellf.png'
},
{
value: 'neon-mech',
label: this.$t('qrart.preset.neonMech'),
url: 'https://cdn.acedata.cloud/3z0y6z.png'
},
{
value: 'ethereal-low-poly',
label: this.$t('qrart.preset.etherealLowPoly'),
url: 'https://cdn.acedata.cloud/36o0mm.png'
},
{
value: 'golden-vista',
label: this.$t('qrart.preset.goldenVista'),
url: 'https://cdn.acedata.cloud/xa0267.png'
},
{
value: 'cinematic-expanse',
label: this.$t('qrart.preset.cinematicExpanse'),
url: 'https://cdn.acedata.cloud/krl5qp.png'
},
{
value: 'cinematic-warm',
label: this.$t('qrart.preset.cinematicWarm'),
url: 'https://cdn.acedata.cloud/e1aahg.png'
},
{
value: 'desolate-wilderness',
label: this.$t('qrart.preset.desolateWilderness'),
url: 'https://cdn.acedata.cloud/9evqqu.png'
},
{
value: 'vibrant-palette',
label: this.$t('qrart.preset.vibrantPalette'),
url: 'https://cdn.acedata.cloud/3fvsmz.png'
},
{
value: 'enigmatic-journey',
label: this.$t('qrart.preset.enigmaticJourney'),
url: 'https://cdn.acedata.cloud/l6kku0.png'
},
{
value: 'timeless-cinematic',
label: this.$t('qrart.preset.timelessCinematic'),
url: 'https://cdn.acedata.cloud/h5mzyn.png'
},
{
value: 'regal-galaxy',
label: this.$t('qrart.preset.regalGalaxy'),
url: 'https://cdn.acedata.cloud/czkegd.png'
},
{
value: 'illustrious-canvas',
label: this.$t('qrart.preset.illustriousCanvas'),
url: 'https://cdn.acedata.cloud/m8hwzh.png'
},
{
value: 'expressive-mural',
label: this.$t('qrart.preset.expressiveMural'),
url: 'https://cdn.acedata.cloud/g4v1rb.png'
},
{
value: 'serene-haze',
label: this.$t('qrart.preset.sereneHaze'),
url: 'https://cdn.acedata.cloud/3w3ixr.png'
}
]
};
},
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_PRESET;
}
}
});
</script>
<style lang="scss" scoped>
.field {
display: flex;
flex-direction: column;
align-items: left;
.title {
font-size: 14px;
margin: 0;
width: 30%;
margin-bottom: 10px;
}
.pane {
display: flex;
flex-direction: row;
justify-content: left;
align-items: center;
flex-wrap: wrap;
height: auto;
max-height: 210px;
overflow-y: scroll;
@media (max-width: 767px) {
justify-content: center;
}
.item {
$height: 100px;
$width: 100px;
position: relative;
width: $width;
height: $height;
margin-right: 8px;
margin-bottom: 8px;
border-width: 3px;
border-style: solid;
border-color: var(--el-border-color);
border-radius: 5px;
overflow: hidden;
cursor: pointer;
&.hidden {
display: none;
}
&.active {
border-color: var(--el-color-primary);
}
.preview {
width: $height;
height: $width;
}
.name {
position: absolute;
bottom: 0;
left: 0;
right: 0;
width: $width;
background-color: rgba(0, 0, 0, 0.5);
color: white;
font-size: 10px;
text-align: center;
padding: 0 5px;
}
}
}
}
</style>
+1 -1
View File
@@ -47,7 +47,7 @@
</el-descriptions-item>
<el-descriptions-item :label="$t('qrart.name.content')">
{{ task?.request?.content }}
<copy-to-clipboard :content="task?.request?.content" class="btn-copy" />
<copy-to-clipboard :content="task?.request?.content!" class="btn-copy" />
</el-descriptions-item>
<el-descriptions-item :label="$t('qrart.name.prompt')">
{{ task?.request?.prompt }}
+214 -55
View File
@@ -1,44 +1,125 @@
<template>
<div class="preview">
<el-image
v-if="modelValue?.response?.image_url"
v-loading="!modelValue?.response?.image_url"
:src="modelValue?.response?.image_url"
fit="contain"
class="image"
/>
<el-alert v-else-if="modelValue?.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') }}:
{{ 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('qrart.name.traceId') }}:
{{ modelValue?.response?.trace_id }}
<copy-to-clipboard :content="modelValue?.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>
<p class="prompt">
{{ modelValue?.request?.prompt }}
</p>
<div class="left">
<el-image src="https://cdn.acedata.cloud/bcml67.png" class="avatar" />
</div>
<div class="main">
<div class="bot">
{{ $t('qrart.name.qrartBot') }}
<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"> - ({{ $t('qrart.status.pending') }}) </span>
</p>
</div>
<div v-if="modelValue?.response?.success === true" :class="{ content: true, failed: true }">
<div class="image-wrapper">
<img
v-if="modelValue?.response?.image_url"
v-loading="!modelValue?.response?.image_url"
:src="modelValue?.response?.image_url"
class="image mb-3"
/>
<el-button
v-if="modelValue?.response?.image_url"
type="info"
round
class="btn-raw"
@click="onOpenUrl(modelValue?.response?.image_url)"
>
{{ $t('common.button.seeRawImage') }}
</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('qrart.name.taskId') }}:
{{ modelValue?.id }}
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy" />
</p>
<p class="description">
<font-awesome-icon icon="fa-solid fa-diamond" class="mr-1" />
{{ $t('qrart.name.type') }}:
{{ $t('qrart.type.' + modelValue?.request?.type) }}
<copy-to-clipboard :content="modelValue?.request?.type!" class="btn-copy" />
</p>
<p v-if="modelValue?.request?.content" class="description">
<font-awesome-icon icon="fa-regular fa-message" class="mr-1" />
{{ $t('qrart.name.content') }}:
{{ modelValue?.request?.content }}
<copy-to-clipboard :content="modelValue?.request?.content!" class="btn-copy" />
</p>
<p v-if="modelValue?.request?.content_image_url" class="description">
<font-awesome-icon icon="fa-regular fa-message" class="mr-1" />
{{ $t('qrart.name.contentImageUrl') }}:
<font-awesome-icon
icon="fa-solid fa-up-right-from-square"
class="mr-1 cursor-pointer"
@click="onOpenLink(modelValue?.request?.content_image_url)"
/>
</p>
<p v-if="modelValue?.request?.seed || modelValue?.response?.seed" class="description">
<font-awesome-icon icon="fa-solid fa-seedling" class="mr-1" />
{{ $t('qrart.name.seed') }}:
{{ modelValue?.request?.seed || modelValue?.response?.seed }}
<copy-to-clipboard
:content="(modelValue?.request?.seed || modelValue?.response?.seed).toString()!"
class="btn-copy"
/>
</p>
</el-alert>
</div>
<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('qrart.name.failure') }}
</template>
<p class="description">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
{{ $t('qrart.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('qrart.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('qrart.name.traceId') }}:
{{ modelValue?.response?.trace_id }}
<copy-to-clipboard :content="modelValue?.response?.trace_id" class="btn-copy" />
</p>
</el-alert>
</div>
<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('qrart.name.failure') }}
</template>
<p class="description">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
{{ $t('qrart.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 } from 'element-plus';
import { ElImage, ElAlert, ElButton } from 'element-plus';
import { IQrartTask } from '@/models';
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
@@ -49,7 +130,8 @@ export default defineComponent({
ElImage,
CopyToClipboard,
FontAwesomeIcon,
ElAlert
ElAlert,
ElButton
},
props: {
modelValue: {
@@ -66,6 +148,9 @@ export default defineComponent({
}
},
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
@@ -85,6 +170,9 @@ export default defineComponent({
// 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');
@@ -97,26 +185,98 @@ export default defineComponent({
</script>
<style lang="scss" scoped>
$left-width: 70px;
.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;
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%;
}
}
.prompt {
font-size: 12px;
color: var(--el-text-color-regular);
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
.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: 300px;
display: block;
width: fit-content;
}
.btn-raw {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
z-index: 1000;
display: none;
}
&:hover {
.image {
filter: brightness(0.6);
}
.btn-raw {
display: block;
}
}
}
}
}
</style>
@@ -135,8 +295,7 @@ export default defineComponent({
}
.failure {
background: var(--el-fill-color-light);
height: 220px;
width: 220px;
width: 100%;
}
}
</style>