From ada9fbe6742ca38a18b22814cfd3f449806bf999 Mon Sep 17 00:00:00 2001 From: AceDataCloud Date: Mon, 15 Apr 2024 01:23:57 +0800 Subject: [PATCH] Add support for renew credentials (#27) --- ...-2036b5ab-7ee3-404b-bf2b-085dfff320ce.json | 7 +++ src/components/application/Status.vue | 40 ++++++++----- src/components/chat/InputBox.vue | 4 +- src/components/chat/SidePanel.vue | 2 +- .../midjourney/preset/ImageWeightSelector.vue | 5 +- .../midjourney/preset/RatioSelector.vue | 5 +- .../midjourney/preset/StylizeSelector.vue | 5 +- .../midjourney/preset/WeirdSelector.vue | 5 +- .../midjourney/tasks/TaskPreview.vue | 22 +++++++ src/constants/midjourney.ts | 5 ++ src/models/credential.ts | 1 + src/pages/chat/Conversation.vue | 5 +- src/pages/chatdoc/Conversation.vue | 5 +- src/pages/midjourney/History.vue | 5 +- src/pages/midjourney/Index.vue | 34 +++++++++-- src/store/chat/actions.ts | 18 ++++-- src/store/chat/models.ts | 3 +- src/store/chat/mutations.ts | 7 ++- src/store/chat/persist.ts | 2 +- src/store/chat/state.ts | 3 + src/store/chatdoc/actions.ts | 57 +++++++++++-------- src/store/chatdoc/models.ts | 3 +- src/store/chatdoc/mutations.ts | 7 ++- src/store/chatdoc/persist.ts | 2 +- src/store/chatdoc/state.ts | 1 + src/store/midjourney/actions.ts | 23 +++++++- src/store/midjourney/models.ts | 11 +++- src/store/midjourney/mutations.ts | 7 ++- src/store/midjourney/persist.ts | 8 ++- src/store/midjourney/state.ts | 1 + 30 files changed, 228 insertions(+), 75 deletions(-) create mode 100644 change/@acedatacloud-hub-2036b5ab-7ee3-404b-bf2b-085dfff320ce.json diff --git a/change/@acedatacloud-hub-2036b5ab-7ee3-404b-bf2b-085dfff320ce.json b/change/@acedatacloud-hub-2036b5ab-7ee3-404b-bf2b-085dfff320ce.json new file mode 100644 index 00000000..7cc42e78 --- /dev/null +++ b/change/@acedatacloud-hub-2036b5ab-7ee3-404b-bf2b-085dfff320ce.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "add support for renew credentials", + "packageName": "@acedatacloud/hub", + "email": "cqc@cuiqingcai.com", + "dependentChangeType": "patch" +} diff --git a/src/components/application/Status.vue b/src/components/application/Status.vue index 8984c37e..c70b517b 100644 --- a/src/components/application/Status.vue +++ b/src/components/application/Status.vue @@ -94,6 +94,16 @@ export default defineComponent({ } } }, + mounted() { + // check if the credential is created + if ( + this.application && + !this.application?.credentials?.find((credential) => credential.host === window.location.origin) + ) { + console.log('create extra credential'); + this.onCreateCredential(this.application); + } + }, methods: { onBuyMore(application: IApplication) { this.$router.push({ @@ -103,6 +113,22 @@ export default defineComponent({ } }); }, + onCreateCredential(application: IApplication | undefined) { + credentialOperator + .create({ + application_id: application?.id, + host: window.location.origin + }) + .then(() => { + setTimeout(() => { + this.$emit('refresh'); + }, 2000); + this.confirming = false; + }) + .finally(() => { + this.$emit('applied'); + }); + }, onApply() { applicationOperator .create({ @@ -111,19 +137,7 @@ export default defineComponent({ }) .then(({ data: data }: { data: IApplicationDetailResponse }) => { ElMessage.success(this.$t('application.message.applySuccessfully')); - credentialOperator - .create({ - application_id: data.id - }) - .then(() => { - setTimeout(() => { - this.$emit('refresh'); - }, 2000); - this.confirming = false; - }) - .finally(() => { - this.$emit('applied'); - }); + this.onCreateCredential(data); }) .catch((error) => { if (error?.response?.data?.code === ERROR_CODE_DUPLICATION) { diff --git a/src/components/chat/InputBox.vue b/src/components/chat/InputBox.vue index 2e4678ec..0e246d3b 100644 --- a/src/components/chat/InputBox.vue +++ b/src/components/chat/InputBox.vue @@ -159,7 +159,7 @@ textarea.input { background: none; box-shadow: none; resize: none; - line-height: 30px; + line-height: 35px; width: calc(100% - 80px); margin-left: 30px; } @@ -176,7 +176,7 @@ textarea.input:focus { background: none; box-shadow: none; resize: none; - line-height: 30px; + line-height: 35px; } } .el-upload-list { diff --git a/src/components/chat/SidePanel.vue b/src/components/chat/SidePanel.vue index dcc35a92..36d4bf0c 100644 --- a/src/components/chat/SidePanel.vue +++ b/src/components/chat/SidePanel.vue @@ -96,7 +96,7 @@ export default defineComponent({ return this.$store.state.chat.status.getConversations === Status.Request; }, token() { - return this.application?.credentials?.[0].token; + return this.$store.state.chat?.credential?.token; } }, methods: { diff --git a/src/components/midjourney/preset/ImageWeightSelector.vue b/src/components/midjourney/preset/ImageWeightSelector.vue index 83b003ee..add33618 100644 --- a/src/components/midjourney/preset/ImageWeightSelector.vue +++ b/src/components/midjourney/preset/ImageWeightSelector.vue @@ -10,8 +10,7 @@ import { defineComponent } from 'vue'; import { ElSlider } from 'element-plus'; import InfoIcon from '@/components/common/InfoIcon.vue'; - -const DEFAULT_IW = 1.0; +import { MIDJOURNEY_DEFAULT_IMAGE_WEIGHT } from '@/constants'; export default defineComponent({ name: 'ImageWeightSelector', @@ -35,7 +34,7 @@ export default defineComponent({ }, mounted() { if (!this.value) { - this.value = DEFAULT_IW; + this.value = MIDJOURNEY_DEFAULT_IMAGE_WEIGHT; } } }); diff --git a/src/components/midjourney/preset/RatioSelector.vue b/src/components/midjourney/preset/RatioSelector.vue index 7b0e0f1f..2a699af0 100644 --- a/src/components/midjourney/preset/RatioSelector.vue +++ b/src/components/midjourney/preset/RatioSelector.vue @@ -21,8 +21,7 @@