Add support for renew credentials (#27)

This commit is contained in:
AceDataCloud committed 2024-04-14 17:23:57 +00:00
1 parent d8aadea2fe
commit ada9fbe674
30 files changed
+228 -75

No files matched your search

+4 -1
View File
@@ -99,6 +99,9 @@ export default defineComponent({
application() {
return this.$store.state.chat.application;
},
credential() {
return this.$store.state.chat?.credential;
},
needApply() {
return this.$store.state.chat.status.getApplication === Status.Success && !this.application;
},
@@ -178,7 +181,7 @@ export default defineComponent({
}, 0);
},
async onFetchAnswer() {
const token = this.application?.credentials?.[0]?.token;
const token = this.credential?.token;
const question = this.question;
const references = this.references;
log(this.onFetchAnswer, 'validated', question, references);
+4 -1
View File
@@ -101,6 +101,9 @@ export default defineComponent({
application() {
return this.$store.state.chatdoc.application;
},
credential() {
return this.$store.state.chatdoc.credential;
},
needApply() {
return this.$store.state.chatdoc.status.getApplication === Status.Success && !this.application;
},
@@ -136,7 +139,7 @@ export default defineComponent({
}, 0);
},
async onFetchAnswer() {
const token = this.application?.credentials?.[0]?.token;
const token = this.credential?.token;
const question = this.question;
log(this.onFetchAnswer, 'validated', question);
// reset question and references
+4 -1
View File
@@ -63,6 +63,9 @@ export default defineComponent({
application() {
return this.$store.state.midjourney.application;
},
credential() {
return this.$store.state.midjourney.credential;
},
initializing() {
return this.$store.state.midjourney.status.getApplication === Status.Request;
},
@@ -83,7 +86,7 @@ export default defineComponent({
await this.$store.dispatch('midjourney/getApplication');
},
async onStartTask(request: IMidjourneyImagineRequest) {
const token = this.application?.credentials?.[0]?.token;
const token = this.credential?.token;
if (!token) {
console.error('no token found');
return;
+29 -5
View File
@@ -47,6 +47,12 @@ import FinalPrompt from '@/components/midjourney/FinalPrompt.vue';
import { ERROR_CODE_DUPLICATION } from '@/constants/errorCode';
import { MidjourneyImagineMode, Status } from '@/models';
import { IMidjourneyImagineRequest, IApplicationDetailResponse, MidjourneyImagineAction } from '@/models';
import {
MIDJOURNEY_DEFAULT_IMAGE_WEIGHT,
MIDJOURNEY_DEFAULT_RATIO,
MIDJOURNEY_DEFAULT_STYLIZE,
MIDJOURNEY_DEFAULT_WIRED
} from '@/constants';
interface IData {
prompt: string;
@@ -87,6 +93,9 @@ export default defineComponent({
mode() {
return this.$store.state.midjourney.mode;
},
credential() {
return this.$store.state.midjourney.credential;
},
preset() {
return this.$store.state.midjourney.preset;
},
@@ -122,19 +131,34 @@ export default defineComponent({
if (this.preset.quality && !content.includes(`--quality `) && !content.includes(`--q `)) {
content += ` --quality ${this.preset.quality}`;
}
if (this.preset.ratio && !content.includes(`--aspect `) && !content.includes(`--ar `)) {
if (
this.preset.ratio &&
!content.includes(`--aspect `) &&
!content.includes(`--ar `) &&
this.preset.ratio !== MIDJOURNEY_DEFAULT_RATIO
) {
content += ` --aspect ${this.preset.ratio}`;
}
if (this.preset.stylize && !content.includes(`--stylize `) && !content.includes(`--s `)) {
if (
this.preset.stylize &&
!content.includes(`--stylize `) &&
!content.includes(`--s `) &&
this.preset.stylize !== MIDJOURNEY_DEFAULT_STYLIZE
) {
content += ` --stylize ${this.preset.stylize}`;
}
if (this.preset.weird && !content.includes(`--weird `) && !content.includes(`--w `)) {
if (
this.preset.weird &&
!content.includes(`--weird `) &&
!content.includes(`--w `) &&
this.preset.weird !== MIDJOURNEY_DEFAULT_WIRED
) {
content += ` --weird ${this.preset.weird}`;
}
if (this.ignore && !content.includes(`--no `)) {
content += ` --no ${this.ignore}`;
}
if (this.preset.iw && !content.includes(`--iw `)) {
if (this.preset.iw && !content.includes(`--iw `) && this.preset.iw !== MIDJOURNEY_DEFAULT_IMAGE_WEIGHT) {
content += ` --iw ${this.preset.iw}`;
}
if (this.preset.style && !content.includes(`--style`)) {
@@ -164,7 +188,7 @@ export default defineComponent({
await this.$store.dispatch('midjourney/getApplication');
},
async onStartTask(request: IMidjourneyImagineRequest) {
const token = this.application?.credentials?.[0]?.token;
const token = this.credential?.token;
if (!token) {
console.error('no token specified');
return;