Skip to content

Commit

Permalink
update preset
Browse files Browse the repository at this point in the history
  • Loading branch information
Germey committed Oct 7, 2023
1 parent 63e23f3 commit 6bb70a9
Show file tree
Hide file tree
Showing 12 changed files with 353 additions and 50 deletions.
2 changes: 2 additions & 0 deletions src/components/common/ApiStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@ export default defineComponent({
.info {
font-size: 14px;
color: var(--el-text-color-regular);
display: block;
text-align: center;
}
</style>
65 changes: 65 additions & 0 deletions src/components/midjourney/AdvancedSelector.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<template>
<div class="field">
<h2 class="title">高级模式</h2>
<el-switch v-model="value" class="ml-2" />
</div>
</template>

<script>
import { defineComponent } from 'vue';
import { ElSwitch } from 'element-plus';
const DEFAULT_ADVANCED = false;
export default defineComponent({
name: 'AdvancedSelector',
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;
}
},
value(val) {
this.$emit('update:modelValue', val);
}
},
mounted() {
if (this.value === undefined) {
this.value = DEFAULT_ADVANCED;
}
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>
64 changes: 31 additions & 33 deletions src/components/midjourney/ChannelSelector.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
<template>
<div class="model-selector">
<el-dropdown trigger="click" @command="onCommandChange">
<el-button>
<font-awesome-icon class="icon" icon="fa-regular fa-" />
<span>
{{ value.displayName }}
</span>
<font-awesome-icon icon="fa-solid fa-chevron-down" />
</el-button>
<template #dropdown>
<el-dropdown-menu class="menu">
<el-dropdown-item
v-for="(channel, channelIndex) in options"
:key="channelIndex"
:command="channel"
class="option"
>
<font-awesome-icon :icon="channel.icon" />
{{ channel.displayName }}
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<div class="channel-selector">
<el-button
v-for="(option, optionKey) in options"
:key="optionKey"
:class="{ button: true, active: option.name === value.name }"
@click="onSelect(option)"
>
<font-awesome-icon :class="{ icon: true, [option.name]: true }" :icon="option.icon" />
<span>
{{ option.displayName }}
</span>
</el-button>
</div>
</template>

Expand All @@ -39,9 +28,7 @@ import {
export default defineComponent({
name: 'ModelSelector',
components: {
ElDropdown,
ElButton,
ElDropdownItem,
FontAwesomeIcon
},
props: {
Expand All @@ -50,7 +37,7 @@ export default defineComponent({
required: true
}
},
emits: ['update:modelValue'],
emits: ['update:modelValue', 'select'],
data() {
return {
value: this.modelValue,
Expand All @@ -64,22 +51,30 @@ export default defineComponent({
}
}
},
mounted() {
this.$emit('update:modelValue', this.value);
this.$emit('select', this.value);
},
methods: {
onCommandChange(command: IMidjourneyChannel) {
this.value = command;
this.$emit('update:modelValue', command);
onSelect(option: IMidjourneyChannel) {
this.value = option;
this.$emit('update:modelValue', option);
this.$emit('select', option);
}
}
});
</script>

<style lang="scss" scoped>
.model-selector {
.channel-selector {
background-color: #ececf1;
padding: 7px 6px;
border-radius: 15px;
margin-bottom: 5px;
.group {
width: 372px;
margin-left: auto;
margin-right: auto;
.button {
padding: 20px 30px;
color: black;
border: none;
Expand All @@ -96,10 +91,13 @@ export default defineComponent({
.icon {
display: inline-block;
margin-right: 5px;
&.base {
&.turbo {
color: #ff9900;
}
&.plus {
&.fast {
color: #2dc49c;
}
&.relax {
color: #ce65e6;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/midjourney/ImaginePreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
fit="fill"
class="image"
/>
<p v-if="modelValue?.progress !== undefined">{{ modelValue?.progress }}%</p>
</div>
</template>

Expand Down Expand Up @@ -43,8 +44,8 @@ export default defineComponent({
width: 100%;
text-align: center;
.image {
width: 200px;
height: 200px;
width: 300px;
height: 300px;
}
}
</style>
25 changes: 19 additions & 6 deletions src/components/midjourney/PresetPanel.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<template>
<div class="panel">
<model-selector v-model="preset.model" class="block" />
<ratio-selector v-model="preset.ratio" class="block" />
<version-selector v-model="preset.version" class="block" />
<stylize-selector v-model="preset.stylize" class="block" />
<chaos-selector v-model="preset.chaos" class="block" />
<model-selector v-if="false" v-model="preset.model" class="mb-4" />
<ratio-selector v-model="preset.ratio" class="mb-4" />
<quality-selector v-model="preset.quality" class="mb-4" />
<version-selector v-model="preset.version" class="mb-4" />
<advanced-selector v-model="preset.advanced" class="mb-4" />
<stylize-selector v-if="preset.advanced" v-model="preset.stylize" class="mb-4" />
<wired-selector v-if="preset.advanced" v-model="preset.wired" class="mb-4" />
<chaos-selector v-if="preset.advanced" v-model="preset.chaos" class="mb-4" />
<raw-selector v-if="preset.advanced" v-model="preset.raw" class="mb-4" />
</div>
</template>

Expand All @@ -15,14 +19,23 @@ import VersionSelector from './VersionSelector.vue';
import StylizeSelector from './StylizeSelector.vue';
import ChaosSelector from './ChaosSelector.vue';
import ModelSelector from './ModelSelector.vue';
import QualitySelector from './QualitySelector.vue';
import WiredSelector from './WiredSelector.vue';
import RawSelector from './RawSelector.vue';
import AdvancedSelector from './AdvancedSelector.vue';
export default defineComponent({
name: 'PresetPanel',
components: {
ModelSelector,
QualitySelector,
RatioSelector,
VersionSelector,
StylizeSelector,
ChaosSelector
ChaosSelector,
WiredSelector,
RawSelector,
AdvancedSelector
},
props: {
modelValue: {
Expand Down
85 changes: 85 additions & 0 deletions src/components/midjourney/QualitySelector.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<template>
<div class="field">
<h2 class="title">画质</h2>
<el-radio-group v-model="value">
<el-radio-button v-for="item in options" :key="item.value" :label="item.value">
{{ item.label }}
</el-radio-button>
</el-radio-group>
</div>
</template>

<script>
import { defineComponent } from 'vue';
import { ElRadioButton, ElRadioGroup } from 'element-plus';
export const DEFAULT_QUALITY = '.5';
export default defineComponent({
name: 'QualitySelector',
components: {
ElRadioButton,
ElRadioGroup
},
props: {
modelValue: {
type: String,
default: undefined
}
},
emits: ['update:modelValue'],
data() {
return {
value: this.modelValue,
active: 0,
options: [
{
label: '',
value: '.25'
},
{
label: '',
value: '.5'
},
{
label: '',
value: '1'
}
]
};
},
watch: {
modelValue(val) {
if (val !== this.value) {
this.value = val;
}
},
value(val) {
this.$emit('update:modelValue', val);
}
},
mounted() {
if (!this.value) {
this.value = DEFAULT_QUALITY;
}
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>
Loading

0 comments on commit 6bb70a9

Please sign in to comment.