Improve midjourney experience (#45)

This commit is contained in:
AceDataCloud committed 2024-01-08 17:47:24 +00:00
1 parent 7fe2186a18
commit 63299dd440
23 files changed
+295 -396

No files matched your search

@@ -8,7 +8,6 @@
<script>
import { defineComponent } from 'vue';
import { ElSwitch } from 'element-plus';
import InfoIcon from '@/components/common/InfoIcon.vue';
const DEFAULT_ADVANCED = false;
@@ -17,33 +16,24 @@ export default defineComponent({
components: {
ElSwitch
},
props: {
modelValue: {
type: Boolean,
default: false
}
},
emits: ['update:modelValue'],
data() {
return {
value: this.modelValue
};
},
watch: {
modelValue(val) {
if (val !== this.value) {
this.value = val;
computed: {
value: {
get() {
return this.$store.state.midjourney.preset?.advanced;
},
set(val) {
console.debug('set advanced', val);
this.$store.commit('midjourney/setPreset', {
...this.$store.state.midjourney.preset,
advanced: val
});
}
},
value(val) {
this.$emit('update:modelValue', val);
}
},
mounted() {
if (this.value === undefined) {
this.value = DEFAULT_ADVANCED;
}
this.$emit('update:modelValue', this.value);
}
});
</script>
@@ -56,7 +46,7 @@ export default defineComponent({
.title {
font-size: 14px;
margin-bottom: 0;
margin: 0;
width: 30%;
}
.value {
@@ -19,33 +19,24 @@ export default defineComponent({
ElSlider,
InfoIcon
},
props: {
modelValue: {
type: String,
default: undefined
}
},
emits: ['update:modelValue'],
data() {
return {
value: this.modelValue
};
},
watch: {
modelValue(val) {
if (val !== this.value) {
this.value = val;
computed: {
value: {
get() {
return this.$store.state.midjourney.preset?.chaos;
},
set(val) {
console.debug('set quality', val);
this.$store.commit('midjourney/setPreset', {
...this.$store.state.midjourney.preset,
chaos: val
});
}
},
value(val) {
this.$emit('update:modelValue', val);
}
},
mounted() {
if (!this.value) {
this.value = DEFAULT_CHAOS;
}
this.$emit('update:modelValue', this.value);
}
});
</script>
@@ -58,7 +49,7 @@ export default defineComponent({
.title {
font-size: 14px;
margin-bottom: 0;
margin: 0;
width: 30%;
}
.value {
@@ -19,33 +19,24 @@ export default defineComponent({
ElSlider,
InfoIcon
},
props: {
modelValue: {
type: String,
default: undefined
}
},
emits: ['update:modelValue'],
data() {
return {
value: this.modelValue
};
},
watch: {
modelValue(val) {
if (val !== this.value) {
this.value = val;
computed: {
value: {
get() {
return this.$store.state.midjourney.preset?.iw;
},
set(val) {
console.debug('set iw', val);
this.$store.commit('midjourney/setPreset', {
...this.$store.state.midjourney.preset,
iw: val
});
}
},
value(val) {
this.$emit('update:modelValue', val);
}
},
mounted() {
if (!this.value) {
this.value = DEFAULT_IW;
}
this.$emit('update:modelValue', this.value);
}
});
</script>
@@ -58,7 +49,7 @@ export default defineComponent({
.title {
font-size: 14px;
margin-bottom: 0;
margin: 0;
width: 30%;
}
.value {
@@ -6,10 +6,7 @@
v-for="(option, optionKey) in options"
:key="optionKey"
:class="{ active: active === optionKey, item: true }"
@click="
active = optionKey;
value = option.value;
"
@click="value = option.value"
>
<el-image :src="option.image" fit="cover" class="image" />
<p class="name">
@@ -23,22 +20,14 @@
<script>
import { defineComponent } from 'vue';
import { ElImage } from 'element-plus';
export default defineComponent({
name: 'ModelSelector',
components: {
ElImage
},
props: {
modelValue: {
type: String,
default: undefined
}
},
emits: ['update:modelValue'],
data() {
return {
value: this.modelValue,
active: 0,
options: [
{
value: '',
@@ -53,18 +42,27 @@ export default defineComponent({
]
};
},
watch: {
modelValue(val) {
if (val !== this.value) {
this.value = val;
}
computed: {
active() {
return this.options.findIndex((option) => option.value === this.value);
},
value(val) {
this.$emit('update:modelValue', val);
value: {
get() {
return this.$store.state.midjourney.preset?.model;
},
set(val) {
console.debug('set model', val);
this.$store.commit('midjourney/setPreset', {
...this.$store.state.midjourney.preset,
model: val
});
}
}
},
mounted() {
this.$emit('update:modelValue', this.value);
if (this.value === undefined) {
this.value = '';
}
}
});
</script>
@@ -1,68 +0,0 @@
<template>
<div class="field">
<h2 class="title">{{ $t('midjourney.name.niji') }}</h2>
<el-switch v-model="value" class="value" />
<info-icon :content="$t('midjourney.description.niji')" class="info" />
</div>
</template>
<script>
import { defineComponent } from 'vue';
import { ElSwitch } from 'element-plus';
import InfoIcon from '@/components/common/InfoIcon.vue';
const DEFAULT_NIJI = false;
export default defineComponent({
name: 'RawSelector',
components: {
ElSwitch,
InfoIcon
},
props: {
modelValue: {
type: Boolean,
default: false
}
},
emits: ['update:modelValue'],
data() {
return {
value: this.modelValue
};
},
watch: {
modelValue(val) {
if (val !== this.value) {
this.value = val;
}
},
value(val) {
this.$emit('update:modelValue', val);
}
},
mounted() {
if (this.value === undefined) {
this.value = DEFAULT_NIJI;
}
this.$emit('update:modelValue', this.value);
}
});
</script>
<style lang="scss" scoped>
.field {
display: flex;
flex-direction: row;
align-items: center;
.title {
font-size: 14px;
margin-bottom: 0;
width: 30%;
}
.value {
flex: 1;
}
}
</style>
@@ -21,17 +21,8 @@ export default defineComponent({
ElRadioButton,
ElRadioGroup
},
props: {
modelValue: {
type: String,
default: undefined
}
},
emits: ['update:modelValue'],
data() {
return {
value: this.modelValue,
active: 0,
options: [
{
label: '低',
@@ -48,21 +39,24 @@ export default defineComponent({
]
};
},
watch: {
modelValue(val) {
if (val !== this.value) {
this.value = val;
computed: {
value: {
get() {
return this.$store.state.midjourney.preset?.quality;
},
set(val) {
console.debug('set quality', val);
this.$store.commit('midjourney/setPreset', {
...this.$store.state.midjourney.preset,
quality: val
});
}
},
value(val) {
this.$emit('update:modelValue', val);
}
},
mounted() {
if (!this.value) {
this.value = DEFAULT_QUALITY;
}
this.$emit('update:modelValue', this.value);
}
});
</script>
@@ -75,7 +69,7 @@ export default defineComponent({
.title {
font-size: 14px;
margin-bottom: 0;
margin: 0;
width: 30%;
}
.value {
@@ -6,10 +6,7 @@
v-for="(option, optionKey) in options"
:key="optionKey"
:class="{ active: active === optionKey, item: true }"
@click="
active = optionKey;
value = option.value;
"
@click="value = option.value"
>
<div class="preview" :class="option.label">
<div class="rect" :style="{ width: option.width + 'px', height: option.height + 'px' }"></div>
@@ -29,16 +26,8 @@ const DEFAULT_RATIO = '1:1';
export default defineComponent({
name: 'RatioSelector',
props: {
modelValue: {
type: String,
default: undefined
}
},
emits: ['update:modelValue'],
data() {
return {
value: this.modelValue,
options: [
{
value: '1:1',
@@ -75,26 +64,25 @@ export default defineComponent({
},
computed: {
active() {
return this.options.findIndex((option) => option.value === this.value);
}
},
watch: {
modelValue(val) {
if (val !== this.value) {
this.value = val;
}
return this.options.findIndex((option) => option.value === this.value) || 0;
},
value(val) {
this.$emit('update:modelValue', val);
value: {
get() {
return this.$store.state.midjourney.preset?.ratio;
},
set(val) {
console.debug('set ratio', val);
this.$store.commit('midjourney/setPreset', {
...this.$store.state.midjourney.preset,
ratio: val
});
}
}
},
mounted() {
if (!this.modelValue) {
if (!this.value) {
this.value = DEFAULT_RATIO;
} else {
this.value = this.modelValue;
}
this.$emit('update:modelValue', this.value);
}
});
</script>
@@ -1,68 +0,0 @@
<template>
<div class="field">
<h2 class="title">{{ $t('midjourney.name.raw') }}</h2>
<el-switch v-model="value" class="value" />
<info-icon :content="$t('midjourney.description.raw')" class="info" />
</div>
</template>
<script>
import { defineComponent } from 'vue';
import { ElSwitch } from 'element-plus';
import InfoIcon from '@/components/common/InfoIcon.vue';
const DEFAULT_RAW = false;
export default defineComponent({
name: 'RawSelector',
components: {
ElSwitch,
InfoIcon
},
props: {
modelValue: {
type: Boolean,
default: false
}
},
emits: ['update:modelValue'],
data() {
return {
value: this.modelValue
};
},
watch: {
modelValue(val) {
if (val !== this.value) {
this.value = val;
}
},
value(val) {
this.$emit('update:modelValue', val);
}
},
mounted() {
if (this.value === undefined) {
this.value = DEFAULT_RAW;
}
this.$emit('update:modelValue', this.value);
}
});
</script>
<style lang="scss" scoped>
.field {
display: flex;
flex-direction: row;
align-items: center;
.title {
font-size: 14px;
margin-bottom: 0;
width: 30%;
}
.value {
flex: 1;
}
}
</style>
@@ -0,0 +1,103 @@
<template>
<div class="field">
<h2 class="title">{{ $t('midjourney.name.style') }}</h2>
<el-select v-model="value" class="value" :placeholder="$t('midjourney.placeholder.select')" clearable>
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
<span class="float-left">{{ item.label }}</span>
<span class="float-right">{{ item.value }}</span>
</el-option>
</el-select>
</div>
</template>
<script>
import { defineComponent } from 'vue';
import { ElSelect, ElOption } from 'element-plus';
import model from '@/i18n/zh/midjourney/model';
const DEFAULT_STYLE = '';
export default defineComponent({
name: 'StyleSelector',
components: {
ElSelect,
ElOption
},
data() {
return {};
},
computed: {
model() {
return this.$store.state.midjourney.preset?.model;
},
options() {
if (this.model === 'niji') {
return [
{
value: 'cute',
label: '可爱'
},
{
value: 'expressive',
label: '表现力'
},
{
value: 'scenic',
label: '场景'
},
{
value: 'original',
label: '原始'
}
];
} else {
return [
{
value: 'raw',
label: '原生'
}
];
}
},
value: {
get() {
return this.$store.state.midjourney.preset?.style;
},
set(val) {
console.debug('set style', val);
this.$store.commit('midjourney/setPreset', {
...this.$store.state.midjourney.preset,
style: val
});
}
}
},
watch: {
model() {
this.value = '';
}
},
mounted() {
if (!this.value) {
this.value = DEFAULT_STYLE;
}
}
});
</script>
<style lang="scss" scoped>
.field {
display: flex;
flex-direction: row;
align-items: center;
.title {
font-size: 14px;
margin: 0;
width: 30%;
}
.value {
flex: 1;
}
}
</style>
@@ -19,33 +19,24 @@ export default defineComponent({
ElSlider,
InfoIcon
},
props: {
modelValue: {
type: String,
default: undefined
}
},
emits: ['update:modelValue'],
data() {
return {
value: this.modelValue
};
},
watch: {
modelValue(val) {
if (val !== this.value) {
this.value = val;
computed: {
value: {
get() {
return this.$store.state.midjourney.preset?.stylize;
},
set(val) {
console.debug('set stylize', val);
this.$store.commit('midjourney/setPreset', {
...this.$store.state.midjourney.preset,
stylize: val
});
}
},
value(val) {
this.$emit('update:modelValue', val);
}
},
mounted() {
if (!this.value) {
this.value = DEFAULT_STYLIZE;
}
this.$emit('update:modelValue', this.value);
}
});
</script>
@@ -58,7 +49,7 @@ export default defineComponent({
.title {
font-size: 14px;
margin-bottom: 0;
margin: 0;
width: 30%;
}
.value {
@@ -19,33 +19,24 @@ export default defineComponent({
ElSwitch,
InfoIcon
},
props: {
modelValue: {
type: Boolean,
default: DEFAULT_TRANSLATION
}
},
emits: ['update:modelValue'],
data() {
return {
value: this.modelValue
};
},
watch: {
modelValue(val) {
if (val !== this.value) {
this.value = val;
computed: {
value: {
get() {
return this.$store.state.midjourney.preset?.translation;
},
set(val) {
console.debug('set translation', val);
this.$store.commit('midjourney/setPreset', {
...this.$store.state.midjourney.preset,
translation: val
});
}
},
value(val) {
this.$emit('update:modelValue', val);
}
},
mounted() {
if (this.value === undefined) {
this.value = DEFAULT_TRANSLATION;
}
this.$emit('update:modelValue', this.value);
}
});
</script>
@@ -58,7 +49,7 @@ export default defineComponent({
.title {
font-size: 14px;
margin-bottom: 0;
margin: 0;
width: 30%;
}
.value {
@@ -1,7 +1,7 @@
<template>
<div class="field">
<h2 class="title">{{ $t('midjourney.name.version') }}</h2>
<el-select v-model="value" class="value" placeholder="Select">
<el-select v-model="value" class="value" :placeholder="$t('midjourney.placeholder.select')">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</div>
@@ -10,6 +10,7 @@
<script>
import { defineComponent } from 'vue';
import { ElSelect, ElOption } from 'element-plus';
const DEFAULT_VERSION = '5.2';
export default defineComponent({
@@ -27,8 +28,6 @@ export default defineComponent({
emits: ['update:modelValue'],
data() {
return {
value: this.modelValue,
active: 0,
options: [
{
value: '6.0',
@@ -65,21 +64,24 @@ export default defineComponent({
]
};
},
watch: {
modelValue(val) {
if (val !== this.value) {
this.value = val;
computed: {
value: {
get() {
return this.$store.state.midjourney.preset?.version;
},
set(val) {
console.debug('set version', val);
this.$store.commit('midjourney/setPreset', {
...this.$store.state.midjourney.preset,
version: val
});
}
},
value(val) {
this.$emit('update:modelValue', val);
}
},
mounted() {
if (!this.value) {
this.value = DEFAULT_VERSION;
}
this.$emit('update:modelValue', this.value);
}
});
</script>
@@ -92,7 +94,7 @@ export default defineComponent({
.title {
font-size: 14px;
margin-bottom: 0;
margin: 0;
width: 30%;
}
.value {
@@ -19,33 +19,24 @@ export default defineComponent({
ElSlider,
InfoIcon
},
props: {
modelValue: {
type: String,
default: undefined
}
},
emits: ['update:modelValue'],
data() {
return {
value: this.modelValue
};
},
watch: {
modelValue(val) {
if (val !== this.value) {
this.value = val;
computed: {
value: {
get() {
return this.$store.state.midjourney.preset?.weird;
},
set(val) {
console.debug('set weird', val);
this.$store.commit('midjourney/setPreset', {
...this.$store.state.midjourney.preset,
weird: val
});
}
},
value(val) {
this.$emit('update:modelValue', val);
}
},
mounted() {
if (!this.value) {
this.value = DEFAULT_WEIRD;
}
this.$emit('update:modelValue', this.value);
}
});
</script>
@@ -58,7 +49,7 @@ export default defineComponent({
.title {
font-size: 14px;
margin-bottom: 0;
margin: 0;
width: 30%;
}
.value {