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

@@ -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;
}
}
});
@@ -21,8 +21,7 @@
<script>
import { defineComponent } from 'vue';
const DEFAULT_RATIO = '1:1';
import { MIDJOURNEY_DEFAULT_RATIO } from '@/constants';
export default defineComponent({
name: 'RatioSelector',
@@ -81,7 +80,7 @@ export default defineComponent({
},
mounted() {
if (!this.value) {
this.value = DEFAULT_RATIO;
this.value = MIDJOURNEY_DEFAULT_RATIO;
}
}
});
@@ -10,8 +10,7 @@
import { defineComponent } from 'vue';
import { ElSlider } from 'element-plus';
import InfoIcon from '@/components/common/InfoIcon.vue';
const DEFAULT_STYLIZE = 100;
import { MIDJOURNEY_DEFAULT_STYLIZE } from '@/constants';
export default defineComponent({
name: 'StylizeSelector',
@@ -35,7 +34,7 @@ export default defineComponent({
},
mounted() {
if (!this.value) {
this.value = DEFAULT_STYLIZE;
this.value = MIDJOURNEY_DEFAULT_STYLIZE;
}
}
});
@@ -10,8 +10,7 @@
import { defineComponent } from 'vue';
import { ElSlider } from 'element-plus';
import InfoIcon from '@/components/common/InfoIcon.vue';
const DEFAULT_WEIRD = 0;
import { MIDJOURNEY_DEFAULT_WIRED } from '@/constants';
export default defineComponent({
name: 'WeirdSelector',
@@ -35,7 +34,7 @@ export default defineComponent({
},
mounted() {
if (!this.value) {
this.value = DEFAULT_WEIRD;
this.value = MIDJOURNEY_DEFAULT_WIRED;
}
}
});
@@ -63,6 +63,8 @@
:preview-src-list="[modelValue?.response?.raw_image_url as string]"
fit="contain"
class="image"
:lazy="true"
@error="onReload($event)"
/>
<p v-if="modelValue?.response?.progress !== undefined && modelValue?.response?.progress !== 100" class="progress">
{{ modelValue?.response?.progress }}%
@@ -111,6 +113,7 @@ import {
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
import { MIDJOURNEY_MODE_FAST, MIDJOURNEY_MODE_RELAX, MIDJOURNEY_MODE_TURBO } from '@/constants';
import { parse } from 'path';
interface IData {
midjourneyImagineState: typeof MidjourneyImagineState;
@@ -222,6 +225,25 @@ export default defineComponent({
}
},
methods: {
onReload(event: Event) {
const target = event.target as HTMLImageElement;
// append a random url query to existing url query, to force reload the image
// extract exiting url query
const url = new URL(target.src);
// extract `retry` query
const retry = url.searchParams.get('retry');
if (!retry) {
// if no retry query, set it as random string
url.searchParams.set('retry', '1');
} else if (parseInt(retry) < 2) {
// if retry < 3, increase it by 1
url.searchParams.set('retry', (parseInt(retry) + 1).toString());
} else {
return;
}
// set the new url
target.src = url.toString();
},
onCustom(action: string) {
this.$emit('custom', {
action,