Migrate new service (#1)
This commit is contained in:
1 parent
f13ca37d63
commit
28da0263dc
109 files changed
+1160
-1053
No files matched your search
@@ -1,29 +1,30 @@
|
||||
<template>
|
||||
<el-dialog :model-value="visible" width="500px" center @close="$emit('update:visible', false)">
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
width="500px"
|
||||
:title="$t('application.message.confirmApplying')"
|
||||
center
|
||||
@close="$emit('update:visible', false)"
|
||||
>
|
||||
<div class="content">
|
||||
<el-descriptions :column="1">
|
||||
<el-descriptions-item :label="$t('application.field.name')">
|
||||
{{ object?.title }}
|
||||
{{ service?.title }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('application.field.freeAmount')">
|
||||
<span v-if="type === applicationType.API">
|
||||
{{ object?.free_amount }}{{ $t(`api.unit.${object?.unit}`) }}
|
||||
</span>
|
||||
<span> {{ service?.free_amount }} {{ $t(`service.unit.${service?.unit}`) }} </span>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<p class="description">
|
||||
{{ $t('application.message.applyDescription') }}
|
||||
</p>
|
||||
<el-divider class="my-2" />
|
||||
<div class="policy">
|
||||
<el-checkbox v-model="checked" size="large" class="policy-checkbox" />
|
||||
<span class="policy-title"> {{ $t('application.message.readPolicy') }} </span>
|
||||
<span class="policy-title highlight" @click="showPolicy = true"> {{ $t('application.message.policy') }} </span>
|
||||
<span class="policy-title highlight" @click="showPolicy = true">
|
||||
{{ $t('application.message.policy') }}</span
|
||||
>
|
||||
<application-policy v-model.visible="showPolicy" />
|
||||
</div>
|
||||
<el-button type="primary" class="btn btn-apply" @click="onApply">
|
||||
{{ $t('common.button.applyForFree') }}
|
||||
</el-button>
|
||||
<el-button type="primary" @click="onApply">{{ $t('common.button.apply') }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -31,11 +32,10 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElDialog, ElDescriptions, ElDescriptionsItem, ElDivider, ElCheckbox, ElButton, ElMessage } from 'element-plus';
|
||||
import { IApi, IApplicationType } from '@/operators';
|
||||
import { IService } from '@/models';
|
||||
import ApplicationPolicy from './Policy.vue';
|
||||
|
||||
interface IData {
|
||||
applicationType: typeof IApplicationType;
|
||||
checked: boolean;
|
||||
showPolicy: boolean;
|
||||
}
|
||||
@@ -52,12 +52,8 @@ export default defineComponent({
|
||||
ApplicationPolicy
|
||||
},
|
||||
props: {
|
||||
object: {
|
||||
type: Object as () => IApi | undefined,
|
||||
required: true
|
||||
},
|
||||
type: {
|
||||
type: Object as () => IApplicationType,
|
||||
service: {
|
||||
type: Object as () => IService,
|
||||
required: true
|
||||
},
|
||||
visible: {
|
||||
@@ -69,8 +65,7 @@ export default defineComponent({
|
||||
emits: ['update:visible', 'apply'],
|
||||
data(): IData {
|
||||
return {
|
||||
applicationType: IApplicationType,
|
||||
checked: true,
|
||||
checked: false,
|
||||
showPolicy: false
|
||||
};
|
||||
},
|
||||
@@ -90,18 +85,8 @@ export default defineComponent({
|
||||
<style lang="scss" scoped>
|
||||
.content {
|
||||
padding: 10px 40px;
|
||||
|
||||
.description {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.btn-apply {
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.policy {
|
||||
margin-bottom: 10px;
|
||||
|
||||
.policy-checkbox {
|
||||
margin-right: 10px !important;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
</div>
|
||||
<div v-else-if="application" class="status">
|
||||
<span class="info">
|
||||
{{ $t('common.message.usedCount') }}: {{ application?.used_amount }} {{ $t('common.message.remainingCount') }}:
|
||||
{{ application?.remaining_amount }}
|
||||
{{ $t('common.message.usedAmount') }}: {{ application?.used_amount?.toFixed(6) }}
|
||||
{{ $t('common.message.remainingAmount') }}:
|
||||
{{ application?.remaining_amount?.toFixed(6) }}
|
||||
</span>
|
||||
<span class="actions">
|
||||
<el-button size="small" type="primary" @click="onBuyMore(application)">{{
|
||||
@@ -17,7 +18,7 @@
|
||||
}}</el-button>
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="needApply && api" class="text-center info">
|
||||
<div v-if="needApply && service" class="text-center info">
|
||||
<span class="mr-2">{{ $t('chat.message.notApplied') }}</span>
|
||||
<span>
|
||||
<el-button type="primary" class="btn btn-apply" size="small" @click="confirming = true">
|
||||
@@ -25,43 +26,40 @@
|
||||
</el-button>
|
||||
</span>
|
||||
<span class="ml-1">{{ $t('chat.message.tryForFree') }}</span>
|
||||
<application-confirm v-model.visible="confirming" :object="api" :type="applicationType.API" @apply="onApply" />
|
||||
<application-confirm v-if="service" v-model.visible="confirming" :service="service" @apply="onApply" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IApplication, IApplicationDetailResponse, applicationOperator } from '@/operators';
|
||||
import { applicationOperator } from '@/operators';
|
||||
import { ElButton, ElMessage, ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import ApplicationConfirm from '@/components/application/Confirm.vue';
|
||||
import { IApplicationType } from '@/operators';
|
||||
import { apiOperator } from '@/operators/api/operator';
|
||||
import { IApiDetailResponse, IApi } from '@/operators/api';
|
||||
import { IApplicationType, IApplication, IApplicationDetailResponse, IService } from '@/models';
|
||||
import { ERROR_CODE_DUPLICATION } from '@/constants/errorCode';
|
||||
import { ROUTE_CONSOLE_APPLICATION_BUY } from '@/router';
|
||||
|
||||
export interface IData {
|
||||
confirming: boolean;
|
||||
applicationType: typeof IApplicationType;
|
||||
api: IApi | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApiStatus',
|
||||
name: 'ApplicationStatus',
|
||||
components: { ElButton, ApplicationConfirm, ElSkeleton, ElSkeletonItem },
|
||||
props: {
|
||||
application: {
|
||||
type: Object as () => IApplication | undefined,
|
||||
required: true
|
||||
},
|
||||
apiId: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
initializing: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
service: {
|
||||
type: Object as () => IService | undefined,
|
||||
required: true
|
||||
},
|
||||
needApply: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
@@ -71,8 +69,7 @@ export default defineComponent({
|
||||
data(): IData {
|
||||
return {
|
||||
confirming: this.needApply,
|
||||
applicationType: IApplicationType,
|
||||
api: undefined
|
||||
applicationType: IApplicationType
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -88,20 +85,9 @@ export default defineComponent({
|
||||
if (val) {
|
||||
this.confirming = val;
|
||||
}
|
||||
},
|
||||
apiId() {
|
||||
this.onFetchApi();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.onFetchApi();
|
||||
},
|
||||
methods: {
|
||||
onFetchApi() {
|
||||
apiOperator.get(this.apiId).then(({ data: data }: { data: IApiDetailResponse }) => {
|
||||
this.api = data;
|
||||
});
|
||||
},
|
||||
onBuyMore(application: IApplication) {
|
||||
this.$router.push({
|
||||
name: ROUTE_CONSOLE_APPLICATION_BUY,
|
||||
@@ -114,7 +100,7 @@ export default defineComponent({
|
||||
applicationOperator
|
||||
.create({
|
||||
type: IApplicationType.API,
|
||||
api_id: this.apiId
|
||||
service_id: this.service?.id
|
||||
})
|
||||
.then(({ data: data }: { data: IApplicationDetailResponse }) => {
|
||||
ElMessage.success(this.$t('application.message.applySuccessfully'));
|
||||
@@ -50,8 +50,9 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElInput, ElMessage, ElTooltip, ElUpload } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { CHAT_MODEL_CHATGPT4_VISION, IChatModel } from '@/operators';
|
||||
import { IChatModel } from '@/models';
|
||||
import { getBaseUrlData } from '@/utils';
|
||||
import { CHAT_MODEL_GPT_4_VISION } from '@/constants';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'InputBox',
|
||||
@@ -96,7 +97,7 @@ export default defineComponent({
|
||||
return this.fileList.map((file: UploadFile) => file?.response?.file_url);
|
||||
},
|
||||
canUpload() {
|
||||
return [CHAT_MODEL_CHATGPT4_VISION.name].includes(this.model.name);
|
||||
return [CHAT_MODEL_GPT_4_VISION.name].includes(this.model.name);
|
||||
},
|
||||
model(): IChatModel {
|
||||
return this.$store.state.chat.model;
|
||||
|
||||
@@ -73,6 +73,7 @@ import { defineComponent } from 'vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import IntroductionItem from './IntroductionItem.vue';
|
||||
import { ElRow, ElCol } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ConversationIntroduction',
|
||||
components: {
|
||||
|
||||
@@ -33,7 +33,7 @@ import AnsweringMark from './AnsweringMark.vue';
|
||||
import copy from 'copy-to-clipboard';
|
||||
import { ElAlert, ElButton } from 'element-plus';
|
||||
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
|
||||
import { IApplication, IChatMessage, IChatMessageState } from '@/operators';
|
||||
import { IApplication, IChatMessage, IChatMessageState } from '@/models';
|
||||
import CopyToClipboard from '../common/CopyToClipboard.vue';
|
||||
import {
|
||||
ERROR_CODE_API_ERROR,
|
||||
@@ -48,6 +48,7 @@ import {
|
||||
} from '@/constants';
|
||||
import message from '@/i18n/zh/common/message';
|
||||
import { ROUTE_CONSOLE_APPLICATION_BUY } from '@/router';
|
||||
|
||||
interface IData {
|
||||
copied: boolean;
|
||||
messageState: typeof IChatMessageState;
|
||||
|
||||
@@ -49,28 +49,27 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElDropdown, ElButton, ElDropdownItem } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { IChatModel } from '@/models';
|
||||
import {
|
||||
CHAT_MODEL_CHATGPT,
|
||||
CHAT_MODEL_CHATGPT4,
|
||||
CHAT_MODEL_CHATGPT4_BROWSING,
|
||||
CHAT_MODEL_CHATGPT4_VISION,
|
||||
CHAT_MODEL_CHATGPT_16K,
|
||||
CHAT_MODEL_CHATGPT_BROWSING
|
||||
} from '@/operators/chat/constants';
|
||||
import { IChatModel } from '@/operators';
|
||||
CHAT_MODEL_GPT_3_5,
|
||||
CHAT_MODEL_GPT_3_5_BROWSING,
|
||||
CHAT_MODEL_GPT_4,
|
||||
CHAT_MODEL_GPT_4_BROWSING,
|
||||
CHAT_MODEL_GPT_4_VISION
|
||||
} from '@/constants';
|
||||
|
||||
const GROUPS = [
|
||||
{
|
||||
label: '3.5',
|
||||
value: 'base',
|
||||
icon: 'fa-solid fa-bolt',
|
||||
options: [CHAT_MODEL_CHATGPT, CHAT_MODEL_CHATGPT_16K, CHAT_MODEL_CHATGPT_BROWSING]
|
||||
options: [CHAT_MODEL_GPT_3_5, CHAT_MODEL_GPT_3_5_BROWSING]
|
||||
},
|
||||
{
|
||||
label: '4.0',
|
||||
value: 'plus',
|
||||
icon: 'fa-solid fa-wand-magic-sparkles',
|
||||
options: [CHAT_MODEL_CHATGPT4, CHAT_MODEL_CHATGPT4_BROWSING, CHAT_MODEL_CHATGPT4_VISION]
|
||||
options: [CHAT_MODEL_GPT_4, CHAT_MODEL_GPT_4_BROWSING, CHAT_MODEL_GPT_4_VISION]
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -70,8 +70,8 @@ import { ElSkeleton, ElInput } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_CONVERSATION_NEW } from '@/router/constants';
|
||||
import { chatOperator } from '@/operators';
|
||||
import { IChatConversation } from '@/operators/chat/models';
|
||||
import { Status } from '@/store/common/models';
|
||||
import { IChatConversation } from '@/models';
|
||||
import { Status } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SidePanel',
|
||||
@@ -89,11 +89,14 @@ export default defineComponent({
|
||||
conversations() {
|
||||
return this.$store.state.chat.conversations;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.chat.applications;
|
||||
application() {
|
||||
return this.$store.state.chat.application;
|
||||
},
|
||||
loading() {
|
||||
return this.$store.state.chat.getConversationsStatus === Status.Request;
|
||||
return this.$store.state.chat.status.getConversations === Status.Request;
|
||||
},
|
||||
token() {
|
||||
return this.application?.credentials?.[0].token;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -103,11 +106,20 @@ export default defineComponent({
|
||||
});
|
||||
},
|
||||
async onConfirm(conversation: IChatConversation) {
|
||||
const token = this.token;
|
||||
if (!token) {
|
||||
console.error('Token is not found');
|
||||
return;
|
||||
}
|
||||
if (conversation?.deleting) {
|
||||
await chatOperator.deleteConversation(conversation.id);
|
||||
await chatOperator.deleteConversation(conversation.id, {
|
||||
token
|
||||
});
|
||||
await this.$store.dispatch('chat/getConversations');
|
||||
} else if (conversation?.editing) {
|
||||
await chatOperator.updateConversation(conversation);
|
||||
await chatOperator.updateConversation(conversation, {
|
||||
token
|
||||
});
|
||||
await this.$store.dispatch('chat/getConversations');
|
||||
} else {
|
||||
conversation.editing = true;
|
||||
|
||||
@@ -69,7 +69,8 @@ import { defineComponent } from 'vue';
|
||||
import { ElSkeleton, ElInput } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { ROUTE_CHATDOC_CONVERSATION, ROUTE_CHATDOC_CONVERSATION_NEW } from '@/router/constants';
|
||||
import { IChatdocRepository, chatdocOperator, IChatdocConversation } from '@/operators';
|
||||
import { chatdocOperator } from '@/operators';
|
||||
import { IChatdocRepository, IChatdocConversation } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SidePanel',
|
||||
@@ -93,8 +94,8 @@ export default defineComponent({
|
||||
conversations() {
|
||||
return this.repository?.conversations;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.chatdoc.applications;
|
||||
application() {
|
||||
return this.$store.state.chatdoc.application;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElInput, ElMessage, ElTooltip, ElUpload } from 'element-plus';
|
||||
import { ElInput } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { CHAT_MODEL_CHATGPT4_VISION, IChatModel } from '@/operators';
|
||||
import { IChatModel } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'InputBox',
|
||||
|
||||
@@ -27,7 +27,7 @@ import AnsweringMark from './AnsweringMark.vue';
|
||||
import copy from 'copy-to-clipboard';
|
||||
import { ElAlert, ElButton } from 'element-plus';
|
||||
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
|
||||
import { IChatdocMessage, IChatdocMessageState } from '@/operators';
|
||||
import { IChatdocMessage, IChatdocMessageState } from '@/models';
|
||||
import CopyToClipboard from '../common/CopyToClipboard.vue';
|
||||
import {
|
||||
ERROR_CODE_API_ERROR,
|
||||
|
||||
@@ -69,8 +69,8 @@ import { defineComponent } from 'vue';
|
||||
import { ElSkeleton, ElInput } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_CONVERSATION_NEW } from '@/router/constants';
|
||||
import { chatdocOperator, IChatdocRepository } from '@/operators';
|
||||
import { Status } from '@/store/common/models';
|
||||
import { IChatdocRepository } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SidePanel',
|
||||
|
||||
@@ -88,7 +88,6 @@ import {
|
||||
ROUTE_MIDJOURNEY_HISTORY,
|
||||
ROUTE_MIDJOURNEY_INDEX
|
||||
} from '@/router/constants';
|
||||
import HelpEntry from './HelpEntry2.vue';
|
||||
import Chevron from './Chevron.vue';
|
||||
|
||||
export default defineComponent({
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApiPrice',
|
||||
props: {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElAlert } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'FinalPrompt',
|
||||
components: {
|
||||
|
||||
+8
-12
@@ -3,7 +3,7 @@
|
||||
<el-button
|
||||
v-for="(option, optionKey) in options"
|
||||
:key="optionKey"
|
||||
:class="{ button: true, active: option.name === channel.name }"
|
||||
:class="{ button: true, active: option.name === mode.name }"
|
||||
@click="onSelect(option)"
|
||||
>
|
||||
<font-awesome-icon :class="{ icon: true, [option.name]: true }" :icon="option.icon" />
|
||||
@@ -18,12 +18,8 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElButton } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import {
|
||||
IMidjourneyChannel,
|
||||
MIDJOURNEY_CHANNEL_FAST,
|
||||
MIDJOURNEY_CHANNEL_RELAX,
|
||||
MIDJOURNEY_CHANNEL_TURBO
|
||||
} from '@/operators';
|
||||
import { MIDJOURNEY_MODE_FAST, MIDJOURNEY_MODE_RELAX, MIDJOURNEY_MODE_TURBO } from '@/constants';
|
||||
import { IMidjourneyMode } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ModelSelector',
|
||||
@@ -34,17 +30,17 @@ export default defineComponent({
|
||||
emits: ['update:modelValue', 'select'],
|
||||
data() {
|
||||
return {
|
||||
options: [MIDJOURNEY_CHANNEL_FAST, MIDJOURNEY_CHANNEL_RELAX, MIDJOURNEY_CHANNEL_TURBO]
|
||||
options: [MIDJOURNEY_MODE_FAST, MIDJOURNEY_MODE_RELAX, MIDJOURNEY_MODE_TURBO]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
channel() {
|
||||
return this.$store.state.midjourney.channel;
|
||||
mode() {
|
||||
return this.$store.state.midjourney.mode;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onSelect(option: IMidjourneyChannel) {
|
||||
this.$store.dispatch('midjourney/setChannel', option);
|
||||
onSelect(option: IMidjourneyMode) {
|
||||
this.$store.dispatch('midjourney/setMode', option);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -13,7 +13,6 @@
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSelect, ElOption } from 'element-plus';
|
||||
import model from '@/i18n/zh/midjourney/model';
|
||||
|
||||
const DEFAULT_STYLE = '';
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</div>
|
||||
<div v-else-if="tasks.length > 0" class="tasks">
|
||||
<div v-for="(task, taskKey) in tasks" :key="taskKey" class="task">
|
||||
<task-preview :full="false" :model-value="task" :applications="applications" @custom="$emit('custom', $event)" />
|
||||
<task-preview :full="false" :model-value="task" @custom="$emit('custom', $event)" />
|
||||
</div>
|
||||
<el-button type="primary" class="btn mb-4" @click="onLoadHistory">{{ $t('midjourney.button.history') }}</el-button>
|
||||
</div>
|
||||
@@ -25,7 +25,7 @@ import { defineComponent } from 'vue';
|
||||
import TaskPreview from './TaskPreview.vue';
|
||||
import { ROUTE_MIDJOURNEY_HISTORY } from '@/router';
|
||||
import { ElButton, ElCard, ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import { Status } from '@/store/common/models';
|
||||
import { Status } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TaskBriefList',
|
||||
@@ -44,17 +44,18 @@ export default defineComponent({
|
||||
},
|
||||
computed: {
|
||||
loading() {
|
||||
return this.$store.state.midjourney.getImagineTasksStatus === Status.Request;
|
||||
return this.$store.state.midjourney.status.getApplication === Status.Request;
|
||||
},
|
||||
tasks() {
|
||||
return this.$store.state.midjourney.imagineTasks;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.midjourney.applications;
|
||||
application() {
|
||||
return this.$store.state.midjourney.application;
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
await this.$store.dispatch('midjourney/setImagineTasks', undefined);
|
||||
// @ts-ignore
|
||||
this.job = setInterval(() => {
|
||||
this.getImagineTasks();
|
||||
}, 5000);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div v-if="tasks" class="tasks">
|
||||
<div v-for="(task, taskKey) in tasks" :key="taskKey" class="task">
|
||||
<task-preview :full="true" :model-value="task" :applications="applications" @custom="onCustom($event)" />
|
||||
<task-preview :full="true" :model-value="task" @custom="onCustom($event)" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="tasks">
|
||||
@@ -23,8 +23,12 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import TaskPreview from './TaskPreview.vue';
|
||||
import Pagination from '@/components/common/Pagination.vue';
|
||||
import { ElRow, ElCol, ElCard, ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import { Status } from '@/store/common/models';
|
||||
import { ElCard, ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import { Status } from '@/models';
|
||||
|
||||
interface IData {
|
||||
job: number | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TaskFullList',
|
||||
@@ -36,9 +40,9 @@ export default defineComponent({
|
||||
ElCard
|
||||
},
|
||||
emits: ['update:modelValue', 'custom'],
|
||||
data() {
|
||||
data(): IData {
|
||||
return {
|
||||
job: 0
|
||||
job: undefined
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -55,13 +59,13 @@ export default defineComponent({
|
||||
return 12;
|
||||
},
|
||||
loading() {
|
||||
return this.$store.state.midjourney.getImagineTasksStatus === Status.Request;
|
||||
return this.$store.state.midjourney.status.getApplication === Status.Request;
|
||||
},
|
||||
tasks() {
|
||||
return this.$store.state.midjourney.imagineTasks;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.midjourney.applications;
|
||||
application() {
|
||||
return this.$store.state.midjourney.application;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -74,6 +78,7 @@ export default defineComponent({
|
||||
},
|
||||
async mounted() {
|
||||
await this.$store.dispatch('midjourney/setImagineTasks', undefined);
|
||||
// @ts-ignore
|
||||
this.job = setInterval(() => {
|
||||
this.getImagineTasks();
|
||||
}, 5000);
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
</el-tag>
|
||||
</div>
|
||||
<div class="right">
|
||||
<el-tag v-if="channel" type="info" class="channel">
|
||||
<font-awesome-icon :class="{ icon: true, [channel.name]: true }" :icon="channel?.icon" />
|
||||
{{ channel?.displayName }}
|
||||
<el-tag v-if="mode" type="info" class="channel">
|
||||
<font-awesome-icon :class="{ icon: true, [mode.name]: true }" :icon="mode.icon" />
|
||||
{{ mode?.displayName }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
@@ -45,8 +45,8 @@
|
||||
<p class="description">
|
||||
<font-awesome-icon icon="fa-solid fa-circle-info" class="mr-1" />
|
||||
{{ $t('midjourney.field.failureReason') }}:
|
||||
{{ modelValue?.response?.detail }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.detail!" class="btn-copy" />
|
||||
{{ 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" />
|
||||
@@ -56,7 +56,6 @@
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
|
||||
<div v-else :class="{ content: true, full: full }">
|
||||
<el-image
|
||||
v-if="modelValue?.response?.image_url"
|
||||
@@ -92,9 +91,9 @@
|
||||
</p>
|
||||
</div>
|
||||
<div class="extra">
|
||||
<p class="datetime">
|
||||
<p v-if="modelValue?.created_at" class="datetime">
|
||||
<font-awesome-icon icon="fa-regular fa-clock" class="mr-1" />
|
||||
{{ $dayjs.format(modelValue?.created_at) }}
|
||||
{{ $dayjs.format(new Date(parseFloat(modelValue?.created_at) * 1000)) }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -103,17 +102,15 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElImage, ElTag, ElButton, ElTooltip, ElSkeleton, ElAlert } from 'element-plus';
|
||||
import { IApplication, IMidjourneyImagineTask, MidjourneyImagineAction, MidjourneyImagineState } from '@/operators';
|
||||
import {
|
||||
API_ID_MIDJOURNEY_FAST,
|
||||
API_ID_MIDJOURNEY_RELAX,
|
||||
API_ID_MIDJOURNEY_TURBO,
|
||||
MIDJOURNEY_CHANNEL_FAST,
|
||||
MIDJOURNEY_CHANNEL_RELAX,
|
||||
MIDJOURNEY_CHANNEL_TURBO
|
||||
} from '@/operators/midjourney/constants';
|
||||
IMidjourneyImagineTask,
|
||||
MidjourneyImagineAction,
|
||||
MidjourneyImagineMode,
|
||||
MidjourneyImagineState
|
||||
} from '@/models';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import { MIDJOURNEY_MODE_FAST, MIDJOURNEY_MODE_RELAX, MIDJOURNEY_MODE_TURBO } from '@/constants';
|
||||
|
||||
interface IData {
|
||||
midjourneyImagineState: typeof MidjourneyImagineState;
|
||||
@@ -138,10 +135,6 @@ export default defineComponent({
|
||||
type: Object as () => IMidjourneyImagineTask | undefined,
|
||||
required: true
|
||||
},
|
||||
applications: {
|
||||
type: Object as () => IApplication[] | undefined,
|
||||
required: true
|
||||
},
|
||||
full: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
@@ -153,22 +146,26 @@ export default defineComponent({
|
||||
midjourneyImagineState: MidjourneyImagineState,
|
||||
actionMapping: {
|
||||
[MidjourneyImagineAction.GENERATE]: 'Generate',
|
||||
[MidjourneyImagineAction.UPSAMPLE1]: 'U1',
|
||||
[MidjourneyImagineAction.UPSAMPLE2]: 'U2',
|
||||
[MidjourneyImagineAction.UPSAMPLE3]: 'U3',
|
||||
[MidjourneyImagineAction.UPSAMPLE4]: 'U4',
|
||||
[MidjourneyImagineAction.UPSCALE1]: 'U1',
|
||||
[MidjourneyImagineAction.UPSCALE2]: 'U2',
|
||||
[MidjourneyImagineAction.UPSCALE3]: 'U3',
|
||||
[MidjourneyImagineAction.UPSCALE4]: 'U4',
|
||||
[MidjourneyImagineAction.VARIATION1]: 'V1',
|
||||
[MidjourneyImagineAction.VARIATION2]: 'V2',
|
||||
[MidjourneyImagineAction.VARIATION3]: 'V3',
|
||||
[MidjourneyImagineAction.VARIATION4]: 'V4',
|
||||
[MidjourneyImagineAction.HIGH_VARIATION]: 'Vary (Strong)',
|
||||
[MidjourneyImagineAction.LOW_VARIATION]: 'Vary (Subtle)',
|
||||
[MidjourneyImagineAction.VARIATION_STRONG]: 'Vary (Strong)',
|
||||
[MidjourneyImagineAction.VARIATION_SUBTLE]: 'Vary (Subtle)',
|
||||
[MidjourneyImagineAction.UPSCALE_CREATIVE]: 'Upscale (Creative)',
|
||||
[MidjourneyImagineAction.UPSCALE_SUBTLE]: 'Upscale (Subtle)',
|
||||
[MidjourneyImagineAction.ZOOM_OUT_2X]: 'Zoom Out 2x',
|
||||
[MidjourneyImagineAction.ZOOM_OUT_1_5X]: 'Zoom Out 1.5x',
|
||||
[MidjourneyImagineAction.UPSAMPLE_2X]: 'Upsample 2x',
|
||||
[MidjourneyImagineAction.UPSAMPLE_4X]: 'Upsample 4x',
|
||||
[MidjourneyImagineAction.REDO_UPSAMPLE_2X]: 'Redo Upsample 2x',
|
||||
[MidjourneyImagineAction.REDO_UPSAMPLE_4X]: 'Redo Upsample 4x',
|
||||
[MidjourneyImagineAction.UPSCALE_2X]: 'Upscale 2x',
|
||||
[MidjourneyImagineAction.UPSCALE_4X]: 'Upscale 4x',
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_2X]: 'Redo Upscale 2x',
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_4X]: 'Redo Upscale 4x',
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_SUBTLE]: 'Redo Upscale (Subtle)',
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_CREATIVE]: 'Redo Upscale (Creative)',
|
||||
[MidjourneyImagineAction.SQUARE]: 'Make Square',
|
||||
[MidjourneyImagineAction.PAN_LEFT]: '⬅️',
|
||||
[MidjourneyImagineAction.PAN_UP]: '⬆️',
|
||||
@@ -178,22 +175,26 @@ export default defineComponent({
|
||||
},
|
||||
descriptionMapping: {
|
||||
[MidjourneyImagineAction.GENERATE]: this.$t('midjourney.description.generate'),
|
||||
[MidjourneyImagineAction.UPSAMPLE1]: this.$t('midjourney.description.upsample1'),
|
||||
[MidjourneyImagineAction.UPSAMPLE2]: this.$t('midjourney.description.upsample2'),
|
||||
[MidjourneyImagineAction.UPSAMPLE3]: this.$t('midjourney.description.upsample3'),
|
||||
[MidjourneyImagineAction.UPSAMPLE4]: this.$t('midjourney.description.upsample4'),
|
||||
[MidjourneyImagineAction.UPSCALE1]: this.$t('midjourney.description.upscale1'),
|
||||
[MidjourneyImagineAction.UPSCALE2]: this.$t('midjourney.description.upscale2'),
|
||||
[MidjourneyImagineAction.UPSCALE3]: this.$t('midjourney.description.upscale3'),
|
||||
[MidjourneyImagineAction.UPSCALE4]: this.$t('midjourney.description.upscale4'),
|
||||
[MidjourneyImagineAction.VARIATION1]: this.$t('midjourney.description.variation1'),
|
||||
[MidjourneyImagineAction.VARIATION2]: this.$t('midjourney.description.variation2'),
|
||||
[MidjourneyImagineAction.VARIATION3]: this.$t('midjourney.description.variation3'),
|
||||
[MidjourneyImagineAction.VARIATION4]: this.$t('midjourney.description.variation4'),
|
||||
[MidjourneyImagineAction.HIGH_VARIATION]: this.$t('midjourney.description.high_variation'),
|
||||
[MidjourneyImagineAction.LOW_VARIATION]: this.$t('midjourney.description.low_variation'),
|
||||
[MidjourneyImagineAction.VARIATION_STRONG]: this.$t('midjourney.description.variation_strong'),
|
||||
[MidjourneyImagineAction.VARIATION_SUBTLE]: this.$t('midjourney.description.variation_subtle'),
|
||||
[MidjourneyImagineAction.ZOOM_OUT_2X]: this.$t('midjourney.description.zoom_out_2x'),
|
||||
[MidjourneyImagineAction.ZOOM_OUT_1_5X]: this.$t('midjourney.description.zoom_out_1_5x'),
|
||||
[MidjourneyImagineAction.UPSAMPLE_2X]: this.$t('midjourney.description.upsample_2x'),
|
||||
[MidjourneyImagineAction.UPSAMPLE_4X]: this.$t('midjourney.description.upsample_4x'),
|
||||
[MidjourneyImagineAction.REDO_UPSAMPLE_2X]: this.$t('midjourney.description.redo_upsample_2x'),
|
||||
[MidjourneyImagineAction.REDO_UPSAMPLE_4X]: this.$t('midjourney.description.redo_upsample_4x'),
|
||||
[MidjourneyImagineAction.UPSCALE_2X]: this.$t('midjourney.description.upscale_2x'),
|
||||
[MidjourneyImagineAction.UPSCALE_4X]: this.$t('midjourney.description.upscale_4x'),
|
||||
[MidjourneyImagineAction.UPSCALE_SUBTLE]: this.$t('midjourney.description.upscale_subtle'),
|
||||
[MidjourneyImagineAction.UPSCALE_CREATIVE]: this.$t('midjourney.description.upscale_creative'),
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_2X]: this.$t('midjourney.description.redo_upscale_2x'),
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_4X]: this.$t('midjourney.description.redo_upscale_4x'),
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_SUBTLE]: this.$t('midjourney.description.redo_upscale_subtle'),
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_CREATIVE]: this.$t('midjourney.description.redo_upscale_creative'),
|
||||
[MidjourneyImagineAction.SQUARE]: this.$t('midjourney.description.square'),
|
||||
[MidjourneyImagineAction.PAN_LEFT]: this.$t('midjourney.description.pan_left'),
|
||||
[MidjourneyImagineAction.PAN_UP]: this.$t('midjourney.description.pan_up'),
|
||||
@@ -205,19 +206,19 @@ export default defineComponent({
|
||||
},
|
||||
computed: {
|
||||
application() {
|
||||
return this.applications?.find((application) => {
|
||||
return application.id === this.modelValue?.request?.application_id;
|
||||
});
|
||||
return this.$store.state.midjourney.application;
|
||||
},
|
||||
channel() {
|
||||
if (this.application?.api_id === API_ID_MIDJOURNEY_FAST) {
|
||||
return MIDJOURNEY_CHANNEL_FAST;
|
||||
} else if (this.application?.api_id === API_ID_MIDJOURNEY_RELAX) {
|
||||
return MIDJOURNEY_CHANNEL_RELAX;
|
||||
} else if (this.application?.api_id === API_ID_MIDJOURNEY_TURBO) {
|
||||
return MIDJOURNEY_CHANNEL_TURBO;
|
||||
mode() {
|
||||
switch (this.modelValue?.mode) {
|
||||
case MidjourneyImagineMode.FAST:
|
||||
return MIDJOURNEY_MODE_FAST;
|
||||
case MidjourneyImagineMode.TURBO:
|
||||
return MIDJOURNEY_MODE_TURBO;
|
||||
case MidjourneyImagineMode.RELAX:
|
||||
return MIDJOURNEY_MODE_RELAX;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -233,6 +234,16 @@ export default defineComponent({
|
||||
link.href = url;
|
||||
link.download = url.split('/').pop() as string;
|
||||
link.click();
|
||||
},
|
||||
getModeIcon(mode: MidjourneyImagineMode): string | undefined {
|
||||
switch (mode) {
|
||||
case MidjourneyImagineMode.FAST:
|
||||
return MIDJOURNEY_MODE_FAST.icon;
|
||||
case MidjourneyImagineMode.TURBO:
|
||||
return MIDJOURNEY_MODE_TURBO.icon;
|
||||
case MidjourneyImagineMode.RELAX:
|
||||
return MIDJOURNEY_MODE_RELAX.icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { IApplication, IApplicationType, IOrderDetailResponse, IPackage, orderOperator } from '@/operators';
|
||||
import { IApplication, IApplicationType, IOrderDetailResponse, IPackage } from '@/models';
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { ROUTE_CONSOLE_ORDER_DETAIL } from '@/router';
|
||||
@@ -92,17 +92,12 @@ export default defineComponent({
|
||||
},
|
||||
computed: {
|
||||
price() {
|
||||
if (this.application?.type === IApplicationType.API) {
|
||||
if (this.application.api?.price && this.form.amount) {
|
||||
return this.form.amount * this.application.api?.price;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
package() {
|
||||
if (this.application?.type === IApplicationType.API) {
|
||||
if (this.application.api?.packages && this.form.packageId) {
|
||||
const filterPackages = this.application.api?.packages.filter((item) => item.id === this.form.packageId);
|
||||
if (this.application.service?.packages && this.form.packageId) {
|
||||
const filterPackages = this.application.service?.packages.filter((item) => item.id === this.form.packageId);
|
||||
if (filterPackages.length > 0) {
|
||||
return filterPackages[0];
|
||||
}
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { IOrder, IOrderDetailResponse, orderOperator, OrderState } from '@/operators';
|
||||
import { orderOperator } from '@/operators';
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElDialog } from 'element-plus';
|
||||
import { IOrder, IOrderDetailResponse, OrderState } from '@/models';
|
||||
|
||||
interface IData {
|
||||
refreshTimer: number | undefined;
|
||||
|
||||
@@ -17,10 +17,11 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { IOrder, IOrderDetailResponse, orderOperator, OrderState } from '@/operators';
|
||||
import { orderOperator } from '@/operators';
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElDialog, ElRow, ElCol } from 'element-plus';
|
||||
import QrCode from 'vue-qrcode';
|
||||
import { IOrder, IOrderDetailResponse, OrderState } from '@/models';
|
||||
|
||||
interface IData {
|
||||
refreshTimer: number | undefined;
|
||||
|
||||
Reference in new issue
Block a user