+
+
+
{{ $t('midjourney.button.generate') }}
@@ -53,6 +56,7 @@ import {
MIDJOURNEY_DEFAULT_STYLIZE,
MIDJOURNEY_DEFAULT_WIRED
} from '@/constants';
+import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
interface IData {
prompt: string;
@@ -68,6 +72,7 @@ export default defineComponent({
components: {
ModeSelector,
ReferenceImage,
+ FontAwesomeIcon,
PresetPanel,
PromptInput,
ElementsSelector,
@@ -125,7 +130,7 @@ export default defineComponent({
if (this.preset.version && !content.includes(`--version `) && !content.includes(`--v `)) {
content += ` --version ${this.preset.version}`;
}
- if (this.preset.chaos && !content.includes(`--chaos `)) {
+ if (this.preset.chaos && this.preset.advanced && !content.includes(`--chaos `)) {
content += ` --chaos ${this.preset.chaos}`;
}
if (this.preset.quality && !content.includes(`--quality `) && !content.includes(`--q `)) {
@@ -143,6 +148,7 @@ export default defineComponent({
this.preset.stylize &&
!content.includes(`--stylize `) &&
!content.includes(`--s `) &&
+ this.preset.advanced &&
this.preset.stylize !== MIDJOURNEY_DEFAULT_STYLIZE
) {
content += ` --stylize ${this.preset.stylize}`;
@@ -151,6 +157,7 @@ export default defineComponent({
this.preset.weird &&
!content.includes(`--weird `) &&
!content.includes(`--w `) &&
+ this.preset.advanced &&
this.preset.weird !== MIDJOURNEY_DEFAULT_WIRED
) {
content += ` --weird ${this.preset.weird}`;
@@ -158,10 +165,15 @@ export default defineComponent({
if (this.ignore && !content.includes(`--no `)) {
content += ` --no ${this.ignore}`;
}
- if (this.preset.iw && !content.includes(`--iw `) && this.preset.iw !== MIDJOURNEY_DEFAULT_IMAGE_WEIGHT) {
+ if (
+ this.preset.iw &&
+ !content.includes(`--iw `) &&
+ this.preset.advanced &&
+ this.preset.iw !== MIDJOURNEY_DEFAULT_IMAGE_WEIGHT
+ ) {
content += ` --iw ${this.preset.iw}`;
}
- if (this.preset.style && !content.includes(`--style`)) {
+ if (this.preset.style && this.preset.advanced && !content.includes(`--style`)) {
content += ` --style ${this.preset.style}`;
}
return this.prompt || this.references?.length > 0 ? content : '';
@@ -209,6 +221,7 @@ export default defineComponent({
const request = {
image_id: payload.image_id,
action: payload.action,
+ mode: this.mode.name as MidjourneyImagineMode,
callback_url: CALLBACK_URL
};
this.onStartTask(request);
@@ -228,18 +241,17 @@ export default defineComponent({
diff --git a/src/pages/qrart/Index.vue b/src/pages/qrart/Index.vue
new file mode 100644
index 00000000..9da9cdc1
--- /dev/null
+++ b/src/pages/qrart/Index.vue
@@ -0,0 +1,154 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/plugins/font-awesome.ts b/src/plugins/font-awesome.ts
index fdc47c35..e27de94b 100644
--- a/src/plugins/font-awesome.ts
+++ b/src/plugins/font-awesome.ts
@@ -11,6 +11,7 @@ import { faDiscord as faBrandsDiscord } from '@fortawesome/free-brands-svg-icons
import {
faChevronRight as faSolidChevronRight,
faMoon as faSolidMoon,
+ faQrcode as faSolidQrcode,
faChevronLeft as faSolidChevronLeft,
faFire as faSolidFire,
faBook as faSolidBook,
@@ -89,6 +90,7 @@ library.add(faRegularClock);
library.add(faSolidArrowsRotate);
library.add(faRegularPaperPlane);
library.add(faSolidWind);
+library.add(faSolidQrcode);
library.add(faRegularComment);
library.add(faSolidArrowRightFromBracket);
library.add(faSolidTrash);
diff --git a/src/router/constants.ts b/src/router/constants.ts
index b31af101..960c54ad 100644
--- a/src/router/constants.ts
+++ b/src/router/constants.ts
@@ -9,6 +9,9 @@ export const ROUTE_CHAT_CONVERSATION_NEW = 'chat-conversation-new';
export const ROUTE_MIDJOURNEY_INDEX = 'midjourney-index';
export const ROUTE_MIDJOURNEY_HISTORY = 'midjourney-history';
+export const ROUTE_QRART_INDEX = 'qrart-index';
+export const ROUTE_QRART_HISTORY = 'qrart-history';
+
export const ROUTE_CHATDOC_INDEX = 'chatdoc-index';
export const ROUTE_CHATDOC_CONVERSATION = 'chatdoc-conversation';
export const ROUTE_CHATDOC_CONVERSATION_NEW = 'chatdoc-conversation-new';
diff --git a/src/router/index.ts b/src/router/index.ts
index 6246e72a..421addec 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -5,6 +5,7 @@ import chat from './chat';
import midjourney from './midjourney';
import distribution from './distribution';
import chatdoc from './chatdoc';
+import qrart from './qrart';
import { ROUTE_CHAT_CONVERSATION_NEW, ROUTE_INDEX } from './constants';
import store from '@/store';
@@ -22,6 +23,7 @@ const routes = [
chatdoc,
auth,
chat,
+ qrart,
midjourney,
distribution
];
diff --git a/src/router/qrart.ts b/src/router/qrart.ts
new file mode 100644
index 00000000..3645c249
--- /dev/null
+++ b/src/router/qrart.ts
@@ -0,0 +1,16 @@
+import { ROUTE_QRART_INDEX } from './constants';
+
+export default {
+ path: '/qrart',
+ meta: {
+ auth: true
+ },
+ component: () => import('@/layouts/Main.vue'),
+ children: [
+ {
+ path: '',
+ name: ROUTE_QRART_INDEX,
+ component: () => import('@/pages/qrart/Index.vue')
+ }
+ ]
+};
diff --git a/src/store/common/models.ts b/src/store/common/models.ts
index 2da099f7..32cea1be 100644
--- a/src/store/common/models.ts
+++ b/src/store/common/models.ts
@@ -1,7 +1,8 @@
+import { IToken, IUser } from '@/models';
import { IMidjourneyState } from '../midjourney/models';
import { IChatState } from '../chat/models';
import { IChatdocState } from '../chatdoc/models';
-import { IToken, IUser } from '@/models';
+import { IQrartState } from '../qrart/models';
export interface ISetting {
navigationCollapsed?: boolean;
@@ -19,4 +20,5 @@ export interface IRootState extends ICommonState {
midjourney: IMidjourneyState;
chat: IChatState;
chatdoc: IChatdocState;
+ qrart: IQrartState;
}
diff --git a/src/store/index.ts b/src/store/index.ts
index 8c514e80..6d2244fe 100644
--- a/src/store/index.ts
+++ b/src/store/index.ts
@@ -3,10 +3,12 @@ import createPersistedState from 'vuex-persistedstate';
import midjourney from './midjourney';
import chat from './chat';
import chatdoc from './chatdoc';
+import qrart from './qrart';
import root from './common';
import persistChat from './chat/persist';
import persistMidjourney from './midjourney/persist';
import persistChatdoc from './chatdoc/persist';
+import persistQrart from './qrart/persist';
import persistRoot from './common/persist';
const store = createStore({
@@ -14,11 +16,12 @@ const store = createStore({
modules: {
midjourney: midjourney,
chat: chat,
+ qrart: qrart,
chatdoc: chatdoc
},
plugins: [
createPersistedState({
- paths: [...persistRoot, ...persistChat, ...persistMidjourney, ...persistChatdoc]
+ paths: [...persistRoot, ...persistChat, ...persistMidjourney, ...persistChatdoc, ...persistQrart]
})
]
});
diff --git a/src/store/qrart/actions.ts b/src/store/qrart/actions.ts
new file mode 100644
index 00000000..80739db3
--- /dev/null
+++ b/src/store/qrart/actions.ts
@@ -0,0 +1,135 @@
+import { applicationOperator, qrartOperator, serviceOperator } from '@/operators';
+import { IQrartState } from './models';
+import { ActionContext } from 'vuex';
+import { log } from '@/utils/log';
+import { IRootState } from '../common/models';
+import { IApplication, ICredential, IQrartConfig, IQrartTask, IService } from '@/models';
+import { Status } from '@/models/common';
+import { QRART_SERVICE_ID } from '@/constants';
+
+export const resetAll = ({ commit }: ActionContext
): void => {
+ commit('resetAll');
+};
+
+export const setCredential = async ({ commit }: any, payload: ICredential): Promise => {
+ log(setCredential, 'set credential', payload);
+ commit('setCredential', payload);
+};
+
+export const setConfig = ({ commit }: any, payload: IQrartConfig) => {
+ commit('setConfig', payload);
+};
+
+export const setService = async ({ commit }: any, payload: IService): Promise => {
+ log(setService, 'set service', payload);
+ commit('setService', payload);
+};
+
+export const setApplication = ({ commit }: any, payload: IApplication[]) => {
+ commit('setApplication', payload);
+};
+
+export const getApplication = async ({
+ commit,
+ state,
+ rootState
+}: ActionContext): Promise => {
+ log(getApplication, 'start to get application for qrart');
+ return new Promise(async (resolve, reject) => {
+ state.status.getApplication = Status.Request;
+ applicationOperator
+ .getAll({
+ user_id: rootState?.user?.id,
+ service_id: QRART_SERVICE_ID
+ })
+ .then((response) => {
+ state.status.getApplication = Status.Success;
+ commit('setApplication', response.data.items[0]);
+ const credential = response.data.items?.[0]?.credentials?.find(
+ (credential) => credential?.host === window.location.origin
+ );
+ commit('setCredential', credential);
+ resolve(response.data.items[0]);
+ })
+ .catch((error) => {
+ state.status.getApplication = Status.Error;
+ reject(error);
+ });
+ });
+};
+
+export const setTasksItems = ({ commit }: any, payload: IQrartTask[]) => {
+ commit('setTasksItems', payload);
+};
+
+export const setTasksTotal = ({ commit }: any, payload: number) => {
+ commit('setTasksTotal', payload);
+};
+
+export const setTasksActive = ({ commit }: any, payload: IQrartTask) => {
+ commit('setTasksActive', payload);
+};
+
+export const getService = async ({ commit, state }: ActionContext): Promise => {
+ return new Promise(async (resolve, reject) => {
+ log(getService, 'start to get service for qrart');
+ state.status.getService = Status.Request;
+ serviceOperator
+ .get(QRART_SERVICE_ID)
+ .then((response) => {
+ state.status.getService = Status.Success;
+ commit('setService', response.data);
+ resolve(response.data);
+ })
+ .catch((error) => {
+ state.status.getService = Status.Error;
+ reject(error);
+ });
+ });
+};
+
+export const getTasks = async (
+ { commit, state }: ActionContext,
+ { offset, limit }: { offset?: number; limit?: number }
+): Promise => {
+ return new Promise(async (resolve, reject) => {
+ log(getTasks, 'start to get tasks', offset, limit);
+ const credential = state.credential;
+ const token = credential?.token;
+ if (!token) {
+ return reject('no token');
+ }
+ qrartOperator
+ .tasks(
+ {
+ applicationId: state.application?.id
+ },
+ {
+ token
+ }
+ )
+ .then((response) => {
+ log(getTasks, 'get imagine tasks success', response.data.items);
+ commit('setTasksItems', response.data.items);
+ commit('setTasksTotal', response.data.count);
+ resolve(response.data.items);
+ })
+ .catch((error) => {
+ return reject(error);
+ });
+ });
+};
+
+export default {
+ setService,
+ getService,
+ resetAll,
+ setCredential,
+ setConfig,
+ setApplication,
+ getApplication,
+ setTasksItems,
+ setTasksTotal,
+ setTasksActive,
+ getTasks
+};
diff --git a/src/store/qrart/index.ts b/src/store/qrart/index.ts
new file mode 100644
index 00000000..4c79cdfc
--- /dev/null
+++ b/src/store/qrart/index.ts
@@ -0,0 +1,14 @@
+import { Module } from 'vuex';
+import { IQrartState } from './models';
+import actions from './actions';
+import mutations from './mutations';
+import state from './state';
+
+export const qrart: Module = {
+ namespaced: true,
+ state,
+ mutations,
+ actions
+};
+
+export default qrart;
diff --git a/src/store/qrart/models.ts b/src/store/qrart/models.ts
new file mode 100644
index 00000000..81f9e272
--- /dev/null
+++ b/src/store/qrart/models.ts
@@ -0,0 +1,21 @@
+import { IApplication, ICredential, IService, Status } from '@/models';
+import { IQrartConfig, IQrartTask } from '@/models';
+
+export interface IQrartState {
+ application: IApplication | undefined;
+ service: IService | undefined;
+ credential: ICredential | undefined;
+ config: IQrartConfig | undefined;
+ tasks:
+ | {
+ items: IQrartTask[] | undefined;
+ total: number | undefined;
+ active: IQrartTask | undefined;
+ }
+ | undefined;
+ status: {
+ getService: Status;
+ getApplication: Status;
+ getTasks: Status;
+ };
+}
diff --git a/src/store/qrart/mutations.ts b/src/store/qrart/mutations.ts
new file mode 100644
index 00000000..6128ce90
--- /dev/null
+++ b/src/store/qrart/mutations.ts
@@ -0,0 +1,59 @@
+import { IApplication, ICredential, IQrartConfig, IQrartTask, IService } from '@/models';
+import { IQrartState } from './models';
+
+export const resetAll = (state: IQrartState): void => {
+ state.application = undefined;
+ state.config = {};
+ state.tasks = undefined;
+};
+
+export const setService = (state: IQrartState, payload: IService): void => {
+ state.service = payload;
+};
+
+export const setCredential = (state: IQrartState, payload: ICredential): void => {
+ state.credential = payload;
+};
+
+export const setApplication = (state: IQrartState, payload: IApplication): void => {
+ state.application = payload;
+};
+
+export const setConfig = (state: IQrartState, payload: IQrartConfig): void => {
+ state.config = payload;
+};
+
+export const setTasksItems = (state: IQrartState, payload: IQrartTask[]): void => {
+ const newPayload = {
+ ...state.tasks,
+ items: payload
+ } as typeof state.tasks;
+ state.tasks = newPayload;
+};
+
+export const setTasksTotal = (state: IQrartState, payload: number): void => {
+ const newPayload = {
+ ...state.tasks,
+ total: payload
+ } as typeof state.tasks;
+ state.tasks = newPayload;
+};
+
+export const setTasksActive = (state: IQrartState, payload: IQrartTask): void => {
+ const newPayload = {
+ ...state.tasks,
+ active: payload
+ } as typeof state.tasks;
+ state.tasks = newPayload;
+};
+
+export default {
+ setApplication,
+ setConfig,
+ setCredential,
+ setService,
+ setTasksActive,
+ setTasksItems,
+ setTasksTotal,
+ resetAll
+};
diff --git a/src/store/qrart/persist.ts b/src/store/qrart/persist.ts
new file mode 100644
index 00000000..37211546
--- /dev/null
+++ b/src/store/qrart/persist.ts
@@ -0,0 +1 @@
+export default ['qrart.config', 'qrart.credential', 'qrart.application', 'qrart.tasks'];
diff --git a/src/store/qrart/state.ts b/src/store/qrart/state.ts
new file mode 100644
index 00000000..97e8dfe9
--- /dev/null
+++ b/src/store/qrart/state.ts
@@ -0,0 +1,17 @@
+import { IQrartState } from './models';
+import { Status } from '@/models';
+
+export default (): IQrartState => {
+ return {
+ service: undefined,
+ application: undefined,
+ tasks: undefined,
+ credential: undefined,
+ config: {},
+ status: {
+ getService: Status.None,
+ getApplication: Status.None,
+ getTasks: Status.None
+ }
+ };
+};