finish refactor of mj
This commit is contained in:
1 parent
6ab318e3f0
commit
a75a000974
14 files changed
+232
-196
No files matched your search
@@ -38,14 +38,13 @@ import InputBox from '@/components/chat/InputBox.vue';
|
||||
import ModelSelector from '@/components/chat/ModelSelector.vue';
|
||||
import { ERROR_CODE_CANCELED, ERROR_CODE_UNKNOWN } from '@/constants/errorCode';
|
||||
import ApiStatus from '@/components/common/ApiStatus.vue';
|
||||
import { ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_CONVERSATION_NEW } from '@/router';
|
||||
import { ROUTE_CHAT_CONVERSATION } from '@/router';
|
||||
import { Status } from '@/store/common/models';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
export interface IData {
|
||||
model: IChatModel;
|
||||
question: '';
|
||||
// messages: IChatMessage[];
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="presets">
|
||||
<preset-panel v-model="preset" />
|
||||
<preset-panel />
|
||||
</div>
|
||||
<div class="main">
|
||||
<channel-selector v-model="channel" class="mb-4" @select="onSelectChannel" />
|
||||
@@ -10,9 +10,9 @@
|
||||
:application="application"
|
||||
class="mb-4"
|
||||
:api-id="channel.apiId"
|
||||
@refresh="onFetchApplications"
|
||||
@refresh="onGetApplications"
|
||||
/>
|
||||
<task-full-list :applications="applications" @custom="onCustom" />
|
||||
<task-full-list @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" />
|
||||
{{ $t('midjourney.button.generateNew') }}
|
||||
@@ -28,33 +28,25 @@ import { ElMessage, ElButton } from 'element-plus';
|
||||
import ChannelSelector from '@/components/midjourney/ChannelSelector.vue';
|
||||
import ApiStatus from '@/components/common/ApiStatus.vue';
|
||||
import {
|
||||
IApplication,
|
||||
IMidjourneyChannel,
|
||||
MidjourneyImagineAction,
|
||||
IMidjourneyPreset,
|
||||
MIDJOURNEY_CHANNEL_FAST,
|
||||
MIDJOURNEY_CHANNEL_TURBO,
|
||||
MIDJOURNEY_CHANNEL_RELAX,
|
||||
applicationOperator,
|
||||
midjourneyOperator,
|
||||
IMidjourneyImagineTask,
|
||||
IMidjourneyImagineRequest
|
||||
IMidjourneyImagineRequest,
|
||||
IApplication
|
||||
} from '@/operators';
|
||||
import TaskFullList from '@/components/midjourney/tasks/TaskFullList.vue';
|
||||
import { ROUTE_MIDJOURNEY_INDEX } from '@/router';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { Status } from '@/store/common/models';
|
||||
|
||||
interface IData {
|
||||
channel: IMidjourneyChannel;
|
||||
preset: IMidjourneyPreset;
|
||||
prompt: string;
|
||||
elements: string[];
|
||||
ignore: string;
|
||||
initializing: boolean;
|
||||
applied: boolean | undefined;
|
||||
applications: IApplication[];
|
||||
references: string[];
|
||||
task: IMidjourneyImagineTask | undefined;
|
||||
}
|
||||
|
||||
const CALLBACK_URL = 'https://webhook.zhishuyun.com/midjourney';
|
||||
@@ -71,28 +63,28 @@ export default defineComponent({
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
applications: [],
|
||||
channel: MIDJOURNEY_CHANNEL_FAST,
|
||||
preset: this.$store.state.midjourney.preset,
|
||||
prompt: '',
|
||||
elements: [],
|
||||
ignore: '',
|
||||
initializing: false,
|
||||
applied: undefined,
|
||||
task: undefined,
|
||||
references: []
|
||||
ignore: ''
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
applications() {
|
||||
return this.$store.state.midjourney.applications;
|
||||
},
|
||||
initializing() {
|
||||
return this.$store.state.midjourney.getApplicationsStatus === Status.Request;
|
||||
},
|
||||
application() {
|
||||
if (this.applications && this.applications.length > 0) {
|
||||
return this.applications.filter((item) => item.api_id === this.channel.apiId)[0];
|
||||
return this.applications.filter((item: IApplication) => item.api_id === this.channel.apiId)[0];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.onFetchApplications();
|
||||
async mounted() {
|
||||
await this.onGetApplications();
|
||||
},
|
||||
methods: {
|
||||
async onGenerateNew() {
|
||||
@@ -100,17 +92,11 @@ export default defineComponent({
|
||||
name: ROUTE_MIDJOURNEY_INDEX
|
||||
});
|
||||
},
|
||||
async onFetchApplications() {
|
||||
this.initializing = true;
|
||||
const { data: applications } = await applicationOperator.getAll({
|
||||
user_id: this.$store.state.user.id,
|
||||
api_id: [MIDJOURNEY_CHANNEL_FAST.apiId, MIDJOURNEY_CHANNEL_RELAX.apiId, MIDJOURNEY_CHANNEL_TURBO.apiId]
|
||||
});
|
||||
this.initializing = false;
|
||||
this.applications = applications?.items;
|
||||
async onGetApplications() {
|
||||
await this.$store.dispatch('midjourney/getApplications');
|
||||
},
|
||||
async onSelectChannel() {
|
||||
await this.onFetchApplications();
|
||||
await this.onGetApplications();
|
||||
},
|
||||
async onStartTask(request: IMidjourneyImagineRequest) {
|
||||
const token = this.application?.credential?.token;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="presets">
|
||||
<preset-panel v-model="preset" />
|
||||
<preset-panel />
|
||||
</div>
|
||||
<div class="main">
|
||||
<channel-selector v-model="channel" class="mb-4" @select="onSelectChannel" />
|
||||
@@ -10,7 +10,7 @@
|
||||
:application="application"
|
||||
:api-id="channel.apiId"
|
||||
class="mb-4"
|
||||
@apply="onFetchApplications"
|
||||
@apply="onGetApplications"
|
||||
/>
|
||||
<div class="pt-4">
|
||||
<reference-image class="mb-4" @change="references = $event" />
|
||||
@@ -42,10 +42,7 @@ import {
|
||||
IApplication,
|
||||
IMidjourneyChannel,
|
||||
MidjourneyImagineAction,
|
||||
IMidjourneyPreset,
|
||||
MIDJOURNEY_CHANNEL_FAST,
|
||||
MIDJOURNEY_CHANNEL_TURBO,
|
||||
MIDJOURNEY_CHANNEL_RELAX,
|
||||
applicationOperator,
|
||||
midjourneyOperator,
|
||||
IMidjourneyImagineTask,
|
||||
@@ -56,18 +53,14 @@ import ApiStatus from '@/components/common/ApiStatus.vue';
|
||||
import TaskBriefList from '@/components/midjourney/tasks/TaskBriefList.vue';
|
||||
import FinalPrompt from '@/components/midjourney/FinalPrompt.vue';
|
||||
import { ERROR_CODE_DUPLICATION } from '@/constants/errorCode';
|
||||
import { Status } from '@/store/common/models';
|
||||
|
||||
interface IData {
|
||||
channel: IMidjourneyChannel;
|
||||
preset: IMidjourneyPreset;
|
||||
prompt: string;
|
||||
elements: string[];
|
||||
ignore: string;
|
||||
initializing: boolean;
|
||||
applied: boolean | undefined;
|
||||
applications: IApplication[];
|
||||
references: string[];
|
||||
task: IMidjourneyImagineTask | undefined;
|
||||
}
|
||||
|
||||
const CALLBACK_URL = 'https://webhook.zhishuyun.com/midjourney';
|
||||
@@ -88,22 +81,26 @@ export default defineComponent({
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
applications: [],
|
||||
channel: MIDJOURNEY_CHANNEL_FAST,
|
||||
preset: this.$store.state.midjourney.preset || {},
|
||||
prompt: '',
|
||||
elements: [],
|
||||
ignore: '',
|
||||
initializing: false,
|
||||
applied: undefined,
|
||||
task: undefined,
|
||||
references: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
preset() {
|
||||
return this.$store.state.midjourney.preset;
|
||||
},
|
||||
initializing() {
|
||||
return this.$store.state.midjourney.getApplicationsStatus === Status.Request;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.midjourney.applications;
|
||||
},
|
||||
application() {
|
||||
if (this.applications && this.applications.length > 0) {
|
||||
return this.applications.filter((item) => item.api_id === this.channel.apiId)[0];
|
||||
return this.applications.filter((item: IApplication) => item.api_id === this.channel.apiId)[0];
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
@@ -151,8 +148,8 @@ export default defineComponent({
|
||||
return this.prompt || this.references?.length > 0 ? content : '';
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.onFetchApplications();
|
||||
async mounted() {
|
||||
await this.onGetApplications();
|
||||
},
|
||||
methods: {
|
||||
onApply() {
|
||||
@@ -172,16 +169,10 @@ export default defineComponent({
|
||||
});
|
||||
},
|
||||
async onSelectChannel() {
|
||||
await this.onFetchApplications();
|
||||
await this.onGetApplications();
|
||||
},
|
||||
async onFetchApplications() {
|
||||
this.initializing = true;
|
||||
const { data: applications } = await applicationOperator.getAll({
|
||||
user_id: this.$store.state.user.id,
|
||||
api_id: [MIDJOURNEY_CHANNEL_FAST.apiId, MIDJOURNEY_CHANNEL_RELAX.apiId, MIDJOURNEY_CHANNEL_TURBO.apiId]
|
||||
});
|
||||
this.initializing = false;
|
||||
this.applications = applications?.items;
|
||||
async onGetApplications() {
|
||||
await this.$store.dispatch('midjourney/getApplications');
|
||||
},
|
||||
async onStartTask(request: IMidjourneyImagineRequest) {
|
||||
const token = this.application?.credential?.token;
|
||||
|
||||
Reference in new issue
Block a user