Skip to content

Commit

Permalink
Add feature support for qrart (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
AceDataCloud committed Apr 28, 2024
1 parent 091fa4d commit 2fe1cb4
Show file tree
Hide file tree
Showing 110 changed files with 5,767 additions and 334 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "major",
"comment": "Add Qrart support",
"packageName": "@acedatacloud/hub",
"email": "cqc@cuiqingcai.com",
"dependentChangeType": "patch"
}
Binary file modified src/assets/images/favicon.ico
Binary file not shown.
80 changes: 41 additions & 39 deletions src/components/application/Status.vue
Original file line number Diff line number Diff line change
@@ -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>

Expand Down
15 changes: 14 additions & 1 deletion src/components/common/Navigator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down
82 changes: 82 additions & 0 deletions src/components/qrart/ConfigPanel.vue
Original file line number Diff line number Diff line change
@@ -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>
25 changes: 25 additions & 0 deletions src/components/qrart/DetailPanel.vue
Original file line number Diff line number Diff line change
@@ -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>
85 changes: 85 additions & 0 deletions src/components/qrart/RecentPanel.vue
Original file line number Diff line number Diff line change
@@ -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>
Loading

0 comments on commit 2fe1cb4

Please sign in to comment.