-
-
-
-
- {{ value.displayName }}
-
-
-
-
-
-
-
+
+
+
+
+ {{ option.displayName }}
+
+
@@ -39,9 +28,7 @@ import {
export default defineComponent({
name: 'ModelSelector',
components: {
- ElDropdown,
ElButton,
- ElDropdownItem,
FontAwesomeIcon
},
props: {
@@ -50,7 +37,7 @@ export default defineComponent({
required: true
}
},
- emits: ['update:modelValue'],
+ emits: ['update:modelValue', 'select'],
data() {
return {
value: this.modelValue,
@@ -64,22 +51,30 @@ export default defineComponent({
}
}
},
+ mounted() {
+ this.$emit('update:modelValue', this.value);
+ this.$emit('select', this.value);
+ },
methods: {
- onCommandChange(command: IMidjourneyChannel) {
- this.value = command;
- this.$emit('update:modelValue', command);
+ onSelect(option: IMidjourneyChannel) {
+ this.value = option;
+ this.$emit('update:modelValue', option);
+ this.$emit('select', option);
}
}
});
diff --git a/src/components/midjourney/PresetPanel.vue b/src/components/midjourney/PresetPanel.vue
index 59eb97ae..ce510ac8 100644
--- a/src/components/midjourney/PresetPanel.vue
+++ b/src/components/midjourney/PresetPanel.vue
@@ -1,10 +1,14 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -15,14 +19,23 @@ import VersionSelector from './VersionSelector.vue';
import StylizeSelector from './StylizeSelector.vue';
import ChaosSelector from './ChaosSelector.vue';
import ModelSelector from './ModelSelector.vue';
+import QualitySelector from './QualitySelector.vue';
+import WiredSelector from './WiredSelector.vue';
+import RawSelector from './RawSelector.vue';
+import AdvancedSelector from './AdvancedSelector.vue';
+
export default defineComponent({
name: 'PresetPanel',
components: {
ModelSelector,
+ QualitySelector,
RatioSelector,
VersionSelector,
StylizeSelector,
- ChaosSelector
+ ChaosSelector,
+ WiredSelector,
+ RawSelector,
+ AdvancedSelector
},
props: {
modelValue: {
diff --git a/src/components/midjourney/QualitySelector.vue b/src/components/midjourney/QualitySelector.vue
new file mode 100644
index 00000000..5dac4da8
--- /dev/null
+++ b/src/components/midjourney/QualitySelector.vue
@@ -0,0 +1,85 @@
+
+
+
画质
+
+
+ {{ item.label }}
+
+
+
+
+
+
+
+
diff --git a/src/components/midjourney/RawSelector.vue b/src/components/midjourney/RawSelector.vue
new file mode 100644
index 00000000..87e2dd8b
--- /dev/null
+++ b/src/components/midjourney/RawSelector.vue
@@ -0,0 +1,65 @@
+
+
+
原生
+
+
+
+
+
+
+
diff --git a/src/components/midjourney/TaskBriefList.vue b/src/components/midjourney/TaskBriefList.vue
new file mode 100644
index 00000000..bbbeda0e
--- /dev/null
+++ b/src/components/midjourney/TaskBriefList.vue
@@ -0,0 +1,104 @@
+
+
+
+
+
+
+
diff --git a/src/components/midjourney/TaskPreview.vue b/src/components/midjourney/TaskPreview.vue
new file mode 100644
index 00000000..e42979c6
--- /dev/null
+++ b/src/components/midjourney/TaskPreview.vue
@@ -0,0 +1,172 @@
+
+
+
+
+
+
+
+ {{ modelValue?.response?.detail }}
+
+
+
+
+
+
+ {{ modelValue?.response?.progress }}%
+
+
+
+
+ {{ actionMapping[action] }}
+
+
+
+
+
+
+
+
diff --git a/src/components/midjourney/VersionSelector.vue b/src/components/midjourney/VersionSelector.vue
index f56fc5e6..cdb18215 100644
--- a/src/components/midjourney/VersionSelector.vue
+++ b/src/components/midjourney/VersionSelector.vue
@@ -1,7 +1,7 @@
版本
-
+
diff --git a/src/components/midjourney/WiredSelector.vue b/src/components/midjourney/WiredSelector.vue
new file mode 100644
index 00000000..5d41ac7b
--- /dev/null
+++ b/src/components/midjourney/WiredSelector.vue
@@ -0,0 +1,64 @@
+
+
+
怪异度
+
+
+
+
+
+
+
diff --git a/src/operators/common/contants.ts b/src/operators/common/contants.ts
new file mode 100644
index 00000000..f98171d2
--- /dev/null
+++ b/src/operators/common/contants.ts
@@ -0,0 +1,2 @@
+export const ENDPOINT_API = 'https://api.zhishuyun.com';
+export const ENDPOINT_DATA = 'https://data.zhishuyun.com';
diff --git a/src/operators/index.ts b/src/operators/index.ts
index eb7679d2..11d3b0b5 100644
--- a/src/operators/index.ts
+++ b/src/operators/index.ts
@@ -4,3 +4,4 @@ export * from './user';
export * from './api';
export * from './chat';
export * from './midjourney';
+export * from './usage';
diff --git a/src/operators/midjourney/constants.ts b/src/operators/midjourney/constants.ts
index 746bb928..07bb2552 100644
--- a/src/operators/midjourney/constants.ts
+++ b/src/operators/midjourney/constants.ts
@@ -1,29 +1,29 @@
import { IMidjourneyChannel } from './models';
-export const MIDJOURNEY_CHANNEL_NAME_FAST = 'Fast';
-export const MIDJOURNEY_CHANNEL_NAME_RELAX = 'Relax';
-export const MIDJOURNEY_CHANNEL_NAME_TURBO = 'Turbo';
+export const MIDJOURNEY_CHANNEL_NAME_FAST = 'fast';
+export const MIDJOURNEY_CHANNEL_NAME_RELAX = 'relax';
+export const MIDJOURNEY_CHANNEL_NAME_TURBO = 'turbo';
export const API_ID_MIDJOURNEY_FAST = '9a628863-8879-462b-bbee-5dc46505b733';
export const API_ID_MIDJOURNEY_RELAX = 'c58713f3-fef7-4c18-824c-9f76b5a07a7f';
export const API_ID_MIDJOURNEY_TURBO = '62ec82bd-7de3-427f-b71a-ab3551ac7677';
export const MIDJOURNEY_CHANNEL_FAST: IMidjourneyChannel = {
- icon: 'fa-bolt fa-regular',
+ icon: 'fa-solid fa-wind',
apiId: API_ID_MIDJOURNEY_FAST,
name: MIDJOURNEY_CHANNEL_NAME_FAST,
displayName: 'Fast'
};
export const MIDJOURNEY_CHANNEL_RELAX: IMidjourneyChannel = {
- icon: 'fa-bolt fa-regular',
+ icon: 'fa-solid fa-mug-saucer',
apiId: API_ID_MIDJOURNEY_RELAX,
name: MIDJOURNEY_CHANNEL_NAME_RELAX,
displayName: 'Relax'
};
export const MIDJOURNEY_CHANNEL_TURBO: IMidjourneyChannel = {
- icon: 'fa-bolt fa-regular',
+ icon: 'fa-solid fa-bolt',
apiId: API_ID_MIDJOURNEY_TURBO,
name: MIDJOURNEY_CHANNEL_NAME_TURBO,
displayName: 'Turbo'
diff --git a/src/operators/midjourney/models.ts b/src/operators/midjourney/models.ts
index 080c1b7c..696d0615 100644
--- a/src/operators/midjourney/models.ts
+++ b/src/operators/midjourney/models.ts
@@ -15,7 +15,24 @@ export interface IMidjourneyPreset {
export enum MidjourneyImagineAction {
GENERATE = 'generate',
- UPSAMPLE1 = 'upsample1'
+ UPSAMPLE1 = 'upsample1',
+ UPSAMPLE2 = 'upsample2',
+ UPSAMPLE3 = 'upsample3',
+ UPSAMPLE4 = 'upsample4',
+ VARIATION1 = 'variation1',
+ VARIATION2 = 'variation2',
+ VARIATION3 = 'variation3',
+ VARIATION4 = 'variation4',
+ HIGH_VARIATION = 'high_variation',
+ LOW_VARIATION = 'low_variation',
+ ZOOM_OUT_2X = 'zoom_out_2x',
+ ZOOM_OUT_1_5X = 'zoom_out_1_5x',
+ SQUARE = 'square',
+ PAN_LEFT = 'pan_left',
+ PAN_UP = 'pan_up',
+ PAN_DOWN = 'pan_down',
+ PAN_RIGHT = 'pan_right',
+ REROLL = 'reroll'
}
export enum MidjourneyImagineState {
@@ -26,8 +43,8 @@ export enum MidjourneyImagineState {
}
export interface IMidjourneyImagineRequest {
- action: MidjourneyImagineAction;
- prompt: string;
+ action?: MidjourneyImagineAction;
+ prompt?: string;
image_id?: string;
}
@@ -37,11 +54,20 @@ export interface IMidjourneyImagineResponse {
image_id: string;
image_url: string;
actions: MidjourneyImagineAction[];
+ code?: string;
+ detail?: string;
+ success?: boolean;
+}
+
+export interface IMidjourneyImagineTask {
+ request?: IMidjourneyImagineRequest;
+ response?: IMidjourneyImagineResponse;
+ state?: MidjourneyImagineState;
}
export interface IMidjourneyImagineOptions {
stream?: (response: IMidjourneyImagineResponse) => void;
- token: string;
- endpoint: string;
- path: string;
+ token?: string;
+ endpoint?: string;
+ path?: string;
}
diff --git a/src/operators/midjourney/operator.ts b/src/operators/midjourney/operator.ts
index bc228348..3ff6e1b5 100644
--- a/src/operators/midjourney/operator.ts
+++ b/src/operators/midjourney/operator.ts
@@ -1,10 +1,33 @@
import axios, { AxiosResponse } from 'axios';
-import { IMidjourneyImagineOptions, IMidjourneyImagineRequest, IMidjourneyImagineResponse } from './models';
+import { IMidjourneyImagineRequest, IMidjourneyImagineResponse, IMidjourneyImagineTask } from './models';
+import { ENDPOINT_API } from '../common/contants';
class MidjourneyOperator {
+ async task(id: string): Promise> {
+ return await axios.post(
+ `/midjourney/tasks`,
+ {
+ action: 'retrieve',
+ id: id
+ },
+ {
+ headers: {
+ accept: 'application/json',
+ 'content-type': 'application/json'
+ },
+ baseURL: ENDPOINT_API
+ }
+ );
+ }
+
async imagine(
data: IMidjourneyImagineRequest,
- options: IMidjourneyImagineOptions
+ options: {
+ stream: (response: IMidjourneyImagineResponse) => void;
+ token: string;
+ endpoint: string;
+ path: string;
+ }
): Promise> {
return await axios.post(options.path, data, {
headers: {
diff --git a/src/operators/usage/contants.ts b/src/operators/usage/contants.ts
new file mode 100644
index 00000000..e69de29b
diff --git a/src/operators/usage/index.ts b/src/operators/usage/index.ts
new file mode 100644
index 00000000..2e04d2d9
--- /dev/null
+++ b/src/operators/usage/index.ts
@@ -0,0 +1,2 @@
+export * from './operator';
+export * from './models';
diff --git a/src/operators/usage/models.ts b/src/operators/usage/models.ts
new file mode 100644
index 00000000..3a8dfbd9
--- /dev/null
+++ b/src/operators/usage/models.ts
@@ -0,0 +1,19 @@
+import { IApi } from '../api';
+
+export interface IApiUsage {
+ id?: string;
+ api?: IApi;
+ api_id?: string;
+ application_id?: string;
+ trace_id?: string;
+ metadata?: any;
+ created_at?: string;
+ updated_at?: string;
+}
+
+export interface IApiUsageListResponse {
+ count: number;
+ items: IApiUsage[];
+}
+
+export type IApiUsageDetailResponse = IApiUsage;
diff --git a/src/operators/usage/operator.ts b/src/operators/usage/operator.ts
new file mode 100644
index 00000000..957db81f
--- /dev/null
+++ b/src/operators/usage/operator.ts
@@ -0,0 +1,27 @@
+import { AxiosResponse } from 'axios';
+import { httpClient } from '../instance';
+import { IApiUsageDetailResponse, IApiUsageListResponse } from './models';
+
+export interface IApiUsageQuery {
+ user_id?: string;
+ offset?: number;
+ limit?: number;
+ application_id?: string;
+ ordering?: string;
+}
+
+class ApiUsageOperator {
+ key = 'usage/apis';
+
+ async getAll(query: IApiUsageQuery): Promise> {
+ return await httpClient.get(`/${this.key}/`, {
+ params: query
+ });
+ }
+
+ async get(id: string): Promise> {
+ return await httpClient.get(`/${this.key}/${id}`);
+ }
+}
+
+export const apiUsageOperator = new ApiUsageOperator();
diff --git a/src/pages/midjourney/Index.vue b/src/pages/midjourney/Index.vue
index 4be69c6c..d8599a5f 100644
--- a/src/pages/midjourney/Index.vue
+++ b/src/pages/midjourney/Index.vue
@@ -1,15 +1,18 @@
@@ -22,7 +25,6 @@ import ElementsSelector from '@/components/midjourney/ElementsSelector.vue';
import IgnoreSelector from '@/components/midjourney/IgnoreSelector.vue';
import { ElButton, ElImage } from 'element-plus';
import ChannelSelector from '@/components/midjourney/ChannelSelector.vue';
-import ImaginePreview from '@/components/midjourney/ImaginePreview.vue';
import {
IApplication,
IMidjourneyChannel,
@@ -32,8 +34,12 @@ import {
MIDJOURNEY_CHANNEL_FAST,
applicationOperator,
midjourneyOperator,
- MidjourneyImagineState
+ MidjourneyImagineState,
+ IMidjourneyImagineTask,
+ IMidjourneyImagineRequest
} from '@/operators';
+import ApiStatus from '@/components/common/ApiStatus.vue';
+import TaskBriefList from '@/components/midjourney/TaskBriefList.vue';
interface IData {
channel: IMidjourneyChannel;
@@ -44,8 +50,7 @@ interface IData {
initializing: boolean;
applied: boolean | undefined;
application: IApplication | undefined;
- response: IMidjourneyImagineResponse | undefined;
- state: MidjourneyImagineState | undefined;
+ task: IMidjourneyImagineTask | undefined;
}
export default defineComponent({
@@ -57,7 +62,8 @@ export default defineComponent({
ElementsSelector,
IgnoreSelector,
ElButton,
- ImaginePreview
+ ApiStatus,
+ TaskBriefList
},
data(): IData {
return {
@@ -69,15 +75,17 @@ export default defineComponent({
ignore: '',
initializing: false,
applied: undefined,
- response: undefined,
- state: undefined
+ task: undefined
};
},
mounted() {
- this.onFetchChannel();
+ this.onFetchApplication();
},
methods: {
- async onFetchChannel() {
+ async onSelectChannel() {
+ await this.onFetchApplication();
+ },
+ async onFetchApplication() {
this.initializing = true;
const { data: applications } = await applicationOperator.getAll({
user_id: this.$store.state.user.id,
@@ -90,39 +98,60 @@ export default defineComponent({
}
this.application = applications.items[0];
},
- async onGenerate() {
- this.state = MidjourneyImagineState.PENDING;
+ async onStartTask(request: IMidjourneyImagineRequest) {
const token = this.application?.credential?.token;
const endpoint = this.application?.api?.endpoint;
const path = this.application?.api?.path;
- if (!token || !endpoint || !this.prompt || !path) {
+ if (!token || !endpoint || !path) {
console.error('no token or endpoint or question');
return;
}
+ this.task = {
+ ...this.task,
+ request,
+ state: MidjourneyImagineState.PENDING
+ };
midjourneyOperator
- .imagine(
- {
- prompt: this.prompt,
- action: MidjourneyImagineAction.GENERATE
- },
- {
- token,
- endpoint,
- path,
- stream: (response: IMidjourneyImagineResponse) => {
- console.log(response);
- this.state = MidjourneyImagineState.GENERATING;
- this.response = response;
- }
+ .imagine(request, {
+ token,
+ endpoint,
+ path,
+ stream: (response: IMidjourneyImagineResponse) => {
+ console.log(response);
+ this.task = {
+ ...this.task,
+ state: MidjourneyImagineState.GENERATING,
+ response
+ };
}
- )
- .then((res) => {
- this.state = MidjourneyImagineState.FINISHED;
- console.log(res);
})
- .catch(() => {
- this.state = MidjourneyImagineState.FAILED;
+ .then(() => {
+ this.task = {
+ ...this.task,
+ state: MidjourneyImagineState.FINISHED
+ };
+ })
+ .catch((error) => {
+ this.task = {
+ ...this.task,
+ state: MidjourneyImagineState.FAILED,
+ response: error?.response as IMidjourneyImagineResponse
+ };
});
+ },
+ async onCustom(payload: { image_id: string; action: MidjourneyImagineAction }) {
+ const request = {
+ image_id: payload.image_id,
+ action: payload.action
+ };
+ this.onStartTask(request);
+ },
+ async onGenerate() {
+ const request = {
+ prompt: this.prompt,
+ action: MidjourneyImagineAction.GENERATE
+ };
+ this.onStartTask(request);
}
}
});
@@ -137,7 +166,7 @@ export default defineComponent({
.presets {
width: 260px;
height: 100%;
- background-color: var(--el-bg-color-page);
+ // background-color: var(--el-bg-color-page);
}
.main {
flex: 1;
@@ -147,5 +176,10 @@ export default defineComponent({
margin-bottom: 10px;
}
}
+ .tasks {
+ width: 400px;
+ height: 100%;
+ // background-color: var(--el-bg-color-page);
+ }
}
diff --git a/src/plugins/font-awesome.ts b/src/plugins/font-awesome.ts
index 1836e671..fa180175 100644
--- a/src/plugins/font-awesome.ts
+++ b/src/plugins/font-awesome.ts
@@ -13,11 +13,13 @@ import {
faPalette as faSolidPalette,
faBars as faSolidBars,
faGear as faSolidGear,
+ faMugSaucer as faSolidMugSaucer,
faRotateRight as faSolidRotateRight,
faCheck as faSolidCheck,
faPlus as faSolidPlus,
faBolt as faSolidBolt,
faQuestion as faSolidQuestion,
+ faWind as faSolidWind,
faTrash as faSolidTrash,
faChevronDown as faSolidChevronDown,
faArrowsRotate as faSolidArrowsRotate,
@@ -45,9 +47,11 @@ library.add(faSolidTriangleExclamation);
library.add(faSolidUpRightFromSquare);
library.add(faSolidArrowsRotate);
library.add(faRegularPaperPlane);
+library.add(faSolidWind);
library.add(faRegularComment);
library.add(faSolidArrowRightFromBracket);
library.add(faSolidTrash);
library.add(faSolidChevronDown);
library.add(faSolidPalette);
library.add(faSolidWandMagicSparkles);
+library.add(faSolidMugSaucer);