diff --git a/change/@acedatacloud-nexior-6b9c53cb-1536-4d6d-9351-5cc67f9c4034.json b/change/@acedatacloud-nexior-6b9c53cb-1536-4d6d-9351-5cc67f9c4034.json
new file mode 100644
index 00000000..f725b9d5
--- /dev/null
+++ b/change/@acedatacloud-nexior-6b9c53cb-1536-4d6d-9351-5cc67f9c4034.json
@@ -0,0 +1,7 @@
+{
+ "type": "patch",
+ "comment": "fit getApplications",
+ "packageName": "@acedatacloud/nexior",
+ "email": "1348977728@qq.com",
+ "dependentChangeType": "patch"
+}
diff --git a/src/components/chatdoc/UploadDocument.vue b/src/components/chatdoc/UploadDocument.vue
index 5c77bd3d..97fd4b29 100644
--- a/src/components/chatdoc/UploadDocument.vue
+++ b/src/components/chatdoc/UploadDocument.vue
@@ -91,7 +91,7 @@ export default defineComponent({
ElMessage.success(this.$t('chatdoc.message.createDocumentSuccess'));
this.dialogVisible = false;
this.$store.dispatch('chatdoc/getDocuments', { repositoryId: this.$route.params.repositoryId });
- this.$store.dispatch('chatdoc/getApplication');
+ this.$store.dispatch('chatdoc/getApplications');
})
.catch(() => {
ElMessage.error(this.$t('chatdoc.message.createDocumentError'));
diff --git a/src/layouts/Chatdoc.vue b/src/layouts/Chatdoc.vue
index 86a0f141..4d83a25b 100644
--- a/src/layouts/Chatdoc.vue
+++ b/src/layouts/Chatdoc.vue
@@ -101,7 +101,7 @@ export default defineComponent({
await this.$store.dispatch('chatdoc/getService');
},
async onGetApplications() {
- await this.$store.dispatch('chatdoc/getApplication');
+ await this.$store.dispatch('chatdoc/getApplications');
},
async onGetRepositories() {
await this.$store.dispatch('chatdoc/getRepositories');
diff --git a/src/pages/chatdoc/Conversation.vue b/src/pages/chatdoc/Conversation.vue
index 4595bef2..f316a4c3 100644
--- a/src/pages/chatdoc/Conversation.vue
+++ b/src/pages/chatdoc/Conversation.vue
@@ -11,7 +11,7 @@
:application="application"
:need-apply="needApply"
:service="service"
- @refresh="$store.dispatch('chatdoc/getApplication')"
+ @refresh="$store.dispatch('chatdoc/getApplications')"
/>
diff --git a/src/pages/chatdoc/Index.vue b/src/pages/chatdoc/Index.vue
index 94c71c65..c31c793b 100644
--- a/src/pages/chatdoc/Index.vue
+++ b/src/pages/chatdoc/Index.vue
@@ -15,7 +15,7 @@
:application="application"
:need-apply="needApply"
:service="service"
- @refresh="$store.dispatch('chatdoc/getApplication')"
+ @refresh="$store.dispatch('chatdoc/getApplications')"
/>
@@ -93,7 +93,7 @@ export default defineComponent({
return this.$store.state.chatdoc.repositories;
},
needApply() {
- return this.$store.state.chatdoc.status.getApplication === Status.Success && !this.application;
+ return this.$store.state.chatdoc.status.getApplications === Status.Success && !this.application;
},
application() {
return this.$store.state.chatdoc.application;
@@ -102,7 +102,7 @@ export default defineComponent({
return this.$store.state.chatdoc.service;
},
initializing() {
- return this.$store.state.chatdoc.status.getApplication === Status.Request;
+ return this.$store.state.chatdoc.status.getApplications === Status.Request;
}
},
async mounted() {},
diff --git a/src/pages/chatdoc/Manage.vue b/src/pages/chatdoc/Manage.vue
index 48eeac85..83bde670 100644
--- a/src/pages/chatdoc/Manage.vue
+++ b/src/pages/chatdoc/Manage.vue
@@ -15,7 +15,7 @@
:application="application"
:need-apply="needApply"
:service="service"
- @refresh="$store.dispatch('chatdoc/getApplication')"
+ @refresh="$store.dispatch('chatdoc/getApplications')"
/>
@@ -99,7 +99,7 @@ export default defineComponent({
return this.repository?.documents;
},
needApply() {
- return this.$store.state.chatdoc.status.getApplication === Status.Success && !this.application;
+ return this.$store.state.chatdoc.status.getApplications === Status.Success && !this.application;
},
service() {
return this.$store.state.chatdoc.service;
@@ -108,7 +108,7 @@ export default defineComponent({
return this.$store.state.chatdoc.application;
},
initializing() {
- return this.$store.state.chatdoc.status.getApplication === Status.Request;
+ return this.$store.state.chatdoc.status.getApplications === Status.Request;
}
},
async mounted() {
diff --git a/src/pages/luma/Index.vue b/src/pages/luma/Index.vue
index cc06dc66..19ef73ac 100644
--- a/src/pages/luma/Index.vue
+++ b/src/pages/luma/Index.vue
@@ -53,7 +53,7 @@ export default defineComponent({
},
computed: {
loading() {
- return this.$store.state.luma?.status?.getApplication === Status.Request;
+ return this.$store.state.luma?.status?.getApplications === Status.Request;
},
service() {
return this.$store.state.luma.service;
@@ -65,10 +65,10 @@ export default defineComponent({
return this.$store.state.luma.config;
},
initializing() {
- return this.$store.state.luma.status.getApplication === Status.Request;
+ return this.$store.state.luma.status.getApplications === Status.Request;
},
needApply() {
- return this.$store.state.luma.status.getApplication === Status.Success && !this.application;
+ return this.$store.state.luma.status.getApplications === Status.Success && !this.application;
},
application() {
return this.$store.state.luma.application;
@@ -96,7 +96,7 @@ export default defineComponent({
},
async onGetApplication() {
console.debug('start onGetApplication');
- await this.$store.dispatch('luma/getApplication');
+ await this.$store.dispatch('luma/getApplications');
console.debug('end onGetApplication');
await this.onGetTasks();
},
diff --git a/src/pages/qrart/Index.vue b/src/pages/qrart/Index.vue
index cbb5e479..5d971f7f 100644
--- a/src/pages/qrart/Index.vue
+++ b/src/pages/qrart/Index.vue
@@ -55,7 +55,7 @@ export default defineComponent({
},
computed: {
loading() {
- return this.$store.state.qrart?.status?.getApplication === Status.Request;
+ return this.$store.state.qrart?.status?.getApplications === Status.Request;
},
service() {
return this.$store.state.qrart.service;
diff --git a/src/pages/suno/Index.vue b/src/pages/suno/Index.vue
index 19491f9f..b500b14e 100644
--- a/src/pages/suno/Index.vue
+++ b/src/pages/suno/Index.vue
@@ -60,7 +60,7 @@ export default defineComponent({
},
computed: {
loading() {
- return this.$store.state.suno?.status?.getApplication === Status.Request;
+ return this.$store.state.suno?.status?.getApplications === Status.Request;
},
service() {
return this.$store.state.suno.service;
diff --git a/src/store/chat/actions.ts b/src/store/chat/actions.ts
index bd283fe8..29b30946 100644
--- a/src/store/chat/actions.ts
+++ b/src/store/chat/actions.ts
@@ -87,9 +87,19 @@ export const getApplications = async ({
if (application && application?.remaining_amount) {
console.debug('set application with Period', application);
commit('setApplication', application);
+ const credential = application?.credentials?.find(
+ (credential) => credential?.host === window.location.origin
+ );
+ console.debug('set credential with Period', application);
+ commit('setCredential', credential);
} else if (application2) {
console.debug('set application with Usage', application2);
commit('setApplication', application2);
+ const credential = application2?.credentials?.find(
+ (credential) => credential?.host === window.location.origin
+ );
+ console.debug('set credential with Usage', application);
+ commit('setCredential', credential);
}
resolve(response.data.items);
console.debug('save applications success', response.data.items);
diff --git a/src/store/chatdoc/actions.ts b/src/store/chatdoc/actions.ts
index 5661cd54..89dc1987 100644
--- a/src/store/chatdoc/actions.ts
+++ b/src/store/chatdoc/actions.ts
@@ -9,7 +9,8 @@ import {
IChatdocRepository,
ICredential,
IService,
- Status
+ Status,
+ IApplicationType
} from '@/models';
import { chatdocOperator, applicationOperator, serviceOperator } from '@/operators';
import { CHATDOC_SERVICE_ID } from '@/constants';
@@ -32,29 +33,49 @@ export const setRepository = async ({ commit }: any, payload: { repository: ICha
commit('setRepository', payload);
};
-export const getApplication = async ({
+export const getApplications = async ({
commit,
- rootState,
- state
-}: ActionContext): Promise => {
- return new Promise(async (resolve, reject) => {
- state.status.getApplication = Status.Request;
+ state,
+ rootState
+}: ActionContext): Promise => {
+ console.debug('start to get applications for chatdoc');
+ return new Promise((resolve, reject) => {
+ state.status.getApplications = Status.Request;
applicationOperator
.getAll({
user_id: rootState?.user?.id,
service_id: CHATDOC_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]);
+ console.debug('get applications success', response?.data);
+ state.status.getApplications = Status.Success;
+ commit('setApplications', response.data.items);
+ // check if there is any application with 'Period' type
+ const application = response.data.items?.find((application) => application?.type === IApplicationType.PERIOD);
+ const application2 = response.data.items?.find((application) => application?.type === IApplicationType.USAGE);
+ if (application && application?.remaining_amount) {
+ console.debug('set application with Period', application);
+ commit('setApplication', application);
+ const credential = application?.credentials?.find(
+ (credential) => credential?.host === window.location.origin
+ );
+ console.debug('set credential with Period', application);
+ commit('setCredential', credential);
+ } else if (application2) {
+ console.debug('set application with Usage', application2);
+ commit('setApplication', application2);
+ const credential = application2?.credentials?.find(
+ (credential) => credential?.host === window.location.origin
+ );
+ console.debug('set credential with Usage', application);
+ commit('setCredential', credential);
+ }
+ resolve(response.data.items);
+ console.debug('save applications success', response.data.items);
})
.catch((error) => {
- state.status.getApplication = Status.Error;
+ console.error('get applications error', error);
+ state.status.getApplications = Status.Error;
reject(error);
});
});
@@ -301,7 +322,7 @@ export default {
getService,
createRepository,
setApplication,
- getApplication,
+ getApplications,
getRepositories,
setCredential,
deleteRepository,
diff --git a/src/store/chatdoc/models.ts b/src/store/chatdoc/models.ts
index e005edc9..a4c2cc67 100644
--- a/src/store/chatdoc/models.ts
+++ b/src/store/chatdoc/models.ts
@@ -7,7 +7,7 @@ export interface IChatdocState {
credential: ICredential | undefined;
status: {
getService: Status;
- getApplication: Status;
+ getApplications: Status;
getRepositories: Status;
};
}
diff --git a/src/store/chatdoc/state.ts b/src/store/chatdoc/state.ts
index 511a4c56..70e45fc0 100644
--- a/src/store/chatdoc/state.ts
+++ b/src/store/chatdoc/state.ts
@@ -9,7 +9,7 @@ export default (): IChatdocState => {
credential: undefined,
status: {
getService: Status.None,
- getApplication: Status.None,
+ getApplications: Status.None,
getRepositories: Status.None
}
};
diff --git a/src/store/luma/actions.ts b/src/store/luma/actions.ts
index 24477053..ec9bcee6 100644
--- a/src/store/luma/actions.ts
+++ b/src/store/luma/actions.ts
@@ -51,9 +51,19 @@ export const getApplications = async ({
if (application && application?.remaining_amount) {
console.debug('set application with Period', application);
commit('setApplication', application);
+ const credential = application?.credentials?.find(
+ (credential) => credential?.host === window.location.origin
+ );
+ console.debug('set credential with Period', application);
+ commit('setCredential', credential);
} else if (application2) {
console.debug('set application with Usage', application2);
commit('setApplication', application2);
+ const credential = application2?.credentials?.find(
+ (credential) => credential?.host === window.location.origin
+ );
+ console.debug('set credential with Usage', application);
+ commit('setCredential', credential);
}
resolve(response.data.items);
console.debug('save applications success', response.data.items);
@@ -101,7 +111,7 @@ export const getService = async ({ commit, state }: ActionContext,
+ { commit, state, rootState }: ActionContext,
{ offset, limit }: { offset?: number; limit?: number }
): Promise => {
return new Promise((resolve, reject) => {
@@ -114,7 +124,7 @@ export const getTasks = async (
lumaOperator
.tasks(
{
- applicationId: state.application?.id
+ userId: rootState?.user?.id
},
{
token
diff --git a/src/store/midjourney/actions.ts b/src/store/midjourney/actions.ts
index 5750e337..c4c33edb 100644
--- a/src/store/midjourney/actions.ts
+++ b/src/store/midjourney/actions.ts
@@ -63,9 +63,19 @@ export const getApplications = async ({
if (application && application?.remaining_amount) {
console.debug('set application with Period', application);
commit('setApplication', application);
+ const credential = application?.credentials?.find(
+ (credential) => credential?.host === window.location.origin
+ );
+ console.debug('set credential with Period', application);
+ commit('setCredential', credential);
} else if (application2) {
console.debug('set application with Usage', application2);
commit('setApplication', application2);
+ const credential = application2?.credentials?.find(
+ (credential) => credential?.host === window.location.origin
+ );
+ console.debug('set credential with Usage', application);
+ commit('setCredential', credential);
}
resolve(response.data.items);
console.debug('save application success', response.data.items[0]);
diff --git a/src/store/qrart/actions.ts b/src/store/qrart/actions.ts
index 9f494237..ced391f3 100644
--- a/src/store/qrart/actions.ts
+++ b/src/store/qrart/actions.ts
@@ -51,9 +51,19 @@ export const getApplications = async ({
if (application && application?.remaining_amount) {
console.debug('set application with Period', application);
commit('setApplication', application);
+ const credential = application?.credentials?.find(
+ (credential) => credential?.host === window.location.origin
+ );
+ console.debug('set credential with Period', application);
+ commit('setCredential', credential);
} else if (application2) {
console.debug('set application with Usage', application2);
commit('setApplication', application2);
+ const credential = application2?.credentials?.find(
+ (credential) => credential?.host === window.location.origin
+ );
+ console.debug('set credential with Usage', application);
+ commit('setCredential', credential);
}
resolve(response.data.items);
console.debug('save applications success', response.data.items);
diff --git a/src/store/suno/actions.ts b/src/store/suno/actions.ts
index 3e4546b1..df020a08 100644
--- a/src/store/suno/actions.ts
+++ b/src/store/suno/actions.ts
@@ -50,9 +50,19 @@ export const getApplications = async ({
if (application && application?.remaining_amount) {
console.debug('set application with Period', application);
commit('setApplication', application);
+ const credential = application?.credentials?.find(
+ (credential) => credential?.host === window.location.origin
+ );
+ console.debug('set credential with Period', application);
+ commit('setCredential', credential);
} else if (application2) {
console.debug('set application with Usage', application2);
commit('setApplication', application2);
+ const credential = application2?.credentials?.find(
+ (credential) => credential?.host === window.location.origin
+ );
+ console.debug('set credential with Usage', application);
+ commit('setCredential', credential);
}
resolve(response.data.items);
console.debug('save applications success', response.data.items);