Skip to content

Commit

Permalink
start conv
Browse files Browse the repository at this point in the history
  • Loading branch information
Germey committed Dec 23, 2023
1 parent b687533 commit b7925c4
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 30 deletions.
8 changes: 5 additions & 3 deletions src/components/application/Confirm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@ export default defineComponent({
.content {
padding: 10px 40px;
.btn-apply {
border-radius: 20px;
}
.policy {
margin-bottom: 10px;
.btn-apply {
border-radius: 20px;
}
.policy-checkbox {
margin-right: 10px !important;
}
Expand Down
11 changes: 7 additions & 4 deletions src/components/chat/Sidebar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<template>
<div class="sidebar">
<el-skeleton v-if="loading && conversations.length === 0" />
<el-skeleton v-if="loading && conversations === undefined" />
<div v-else-if="conversations?.length === 0">
<p class="p-5 description">{{ $t('chat.message.noConversations') }}</p>
</div>
<div v-else class="conversations">
<div
v-for="(conversation, conversationIndex) in conversations"
Expand Down Expand Up @@ -58,15 +61,15 @@

<script lang="ts">
import { defineComponent } from 'vue';
import { ElTooltip, ElButton, ElSkeleton, ElInput } from 'element-plus';
import { ElSkeleton, ElInput } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { ROUTE_CHAT_CONVERSATION } from '@/router/constants';
import { apiUsageOperator, IApplication, chatOperator } from '@/operators';
import { IChatConversation } from '@/operators/chat/models';
interface IData {
loading: boolean;
conversations: IChatConversation[];
conversations: IChatConversation[] | undefined;
}
export default defineComponent({
Expand All @@ -86,7 +89,7 @@ export default defineComponent({
data(): IData {
return {
loading: false,
conversations: []
conversations: undefined
};
},
watch: {
Expand Down
36 changes: 29 additions & 7 deletions src/components/common/ApiStatus.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<template>
<div v-if="application" class="status">
<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.usedCount') }}: {{ application?.used_amount }} {{ $t('common.message.remainingCount') }}:
{{ application?.remaining_amount }}
Expand All @@ -23,7 +30,7 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { IApplication, IApplicationDetailResponse, applicationOperator } from '@/operators';
import { ElButton, ElMessage } from 'element-plus';
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';
Expand All @@ -38,7 +45,7 @@ export interface IData {
export default defineComponent({
name: 'ApiStatus',
components: { ElButton, ApplicationConfirm },
components: { ElButton, ApplicationConfirm, ElSkeleton, ElSkeletonItem },
props: {
application: {
type: Object as () => IApplication | undefined,
Expand All @@ -47,6 +54,10 @@ export default defineComponent({
apiId: {
type: String,
required: true
},
initializing: {
type: Boolean,
default: false
}
},
emits: ['apply', 'refresh'],
Expand All @@ -58,12 +69,20 @@ export default defineComponent({
};
},
computed: {},
watch: {
apiId() {
this.onFetchApi();
}
},
mounted() {
apiOperator.get(this.apiId).then(({ data: data }: { data: IApiDetailResponse }) => {
this.api = data;
});
this.onFetchApi();
},
methods: {
onFetchApi() {
apiOperator.get(this.apiId).then(({ data: data }: { data: IApiDetailResponse }) => {
this.api = data;
});
},
onBuy() {
const url = `https://data.zhishuyun.com/console/applications/${this.application?.id}/buy`;
window.open(url, '_blank');
Expand All @@ -75,7 +94,6 @@ export default defineComponent({
api_id: this.apiId
})
.then(({ data: data }: { data: IApplicationDetailResponse }) => {
// this.application = data;
ElMessage.success(this.$t('application.message.applySuccessfully'));
setTimeout(() => {
this.$emit('refresh');
Expand All @@ -94,6 +112,10 @@ export default defineComponent({
</script>

<style lang="scss" scoped>
.shimmer {
width: 300px;
margin: auto;
}
.status {
display: block;
width: fit-content;
Expand Down
28 changes: 18 additions & 10 deletions src/components/midjourney/tasks/TaskBriefList.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<template>
<div v-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)" />
</div>
<el-button type="primary" class="btn mb-4" @click="onLoadHistory">{{ $t('midjourney.button.history') }}</el-button>
</div>
<div v-else class="tasks">
<div v-if="tasks === undefined" class="tasks">
<el-card v-for="_ in 3" :key="_" class="task">
<el-skeleton animated>
<template #template>
Expand All @@ -15,6 +9,15 @@
</el-skeleton>
</el-card>
</div>
<div v-else-if="tasks && tasks?.length === 0">
<p class="p-5 description">{{ $t('midjourney.message.noTasks') }}</p>
</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)" />
</div>
<el-button type="primary" class="btn mb-4" @click="onLoadHistory">{{ $t('midjourney.button.history') }}</el-button>
</div>
</template>

<script lang="ts">
Expand All @@ -25,7 +28,7 @@ import { ROUTE_MIDJOURNEY_HISTORY } from '@/router';
import { ElButton, ElCard, ElSkeleton, ElSkeletonItem } from 'element-plus';
interface IData {
tasks: IMidjourneyImagineTask[];
tasks: IMidjourneyImagineTask[] | undefined;
mounted: boolean;
loading: boolean;
}
Expand All @@ -48,7 +51,7 @@ export default defineComponent({
emits: ['update:modelValue', 'custom'],
data(): IData {
return {
tasks: [],
tasks: undefined,
mounted: false,
loading: false
};
Expand Down Expand Up @@ -105,13 +108,18 @@ export default defineComponent({
</script>

<style lang="scss" scoped>
.description {
font-size: 14px;
color: #333;
}
.tasks {
padding-top: 20px;
overflow-y: scroll;
border-left: 1px solid var(--el-border-color);
display: flex;
flex-direction: column;
align-items: center;
.task {
margin-bottom: 15px;
width: 350px;
Expand Down
2 changes: 1 addition & 1 deletion src/components/midjourney/tasks/TaskFullList.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div v-if="tasks.length > 0" class="tasks">
<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)" />
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/zh/chat/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ export default {
errorUsedUp: '您的套餐次数已经用完,请购买更多次数继续使用',
errorUnknown: '服务器出现未知错误,请稍后重试或联系客服',
errorTimeout: '回答问题超时,请稍后重试',
howToBreakLine: '按 Shift+Enter 键可以换行'
howToBreakLine: '按 Shift+Enter 键可以换行',
noConversations: '没有历史会话,请先发起一个新的会话'
};
3 changes: 2 additions & 1 deletion src/i18n/zh/midjourney/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export default {
startTaskSuccess: '发起绘图任务成功',
startTaskFailed: '发起绘图任务失败',
generating: '生成中...',
noOperations: '没有可用操作'
noOperations: '没有可用操作',
noTasks: '没有历史任务,请先发起一个新的任务'
};
7 changes: 6 additions & 1 deletion src/pages/chat/Conversation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
<sidebar class="left" :applications="applications" @click="onFetchHistory" />
<div class="main">
<model-selector v-model="model" class="model-selector" @select="onSelectModel" />
<api-status :application="application" :api-id="model.apiId" />
<api-status
:initializing="initializing"
:application="application"
:api-id="model.apiId"
@refresh="onFetchApplications"
/>
<div class="dialogue">
<introduction v-if="messages && messages.length === 0" />
<div v-else class="messages">
Expand Down
8 changes: 7 additions & 1 deletion src/pages/midjourney/History.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
</div>
<div class="main">
<channel-selector v-model="channel" class="mb-4" @select="onSelectChannel" />
<api-status :application="application" class="mb-4" :api-id="channel.apiId" @refresh="onFetchApplications" />
<api-status
:initializing="initializing"
:application="application"
class="mb-4"
:api-id="channel.apiId"
@refresh="onFetchApplications"
/>
<task-full-list :applications="applications" @custom="onCustom" />
<el-button type="primary" class="btn btn-generate" @click="onGenerateNew">
<font-awesome-icon icon="fa-solid fa-chevron-left" class="icon icon-rotate mr-1" />
Expand Down
9 changes: 8 additions & 1 deletion src/pages/midjourney/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
</div>
<div class="main">
<channel-selector v-model="channel" class="mb-4" @select="onSelectChannel" />
<api-status :application="application" :api-id="channel.apiId" class="mb-4" @apply="onFetchApplications" />
<api-status
:initializing="initializing"
:application="application"
:api-id="channel.apiId"
class="mb-4"
@apply="onFetchApplications"
/>
<div class="pt-4">
<reference-image class="mb-4" @change="references = $event" />
<prompt-input v-model="prompt" class="mb-4" />
Expand Down Expand Up @@ -248,6 +254,7 @@ export default defineComponent({
overflow-y: scroll;
width: 400px;
height: 100%;
border-left: 1px solid var(--el-border-color);
}
}
</style>

0 comments on commit b7925c4

Please sign in to comment.