bugfix: promptInput提示词内容不会变化
This commit is contained in:
@@ -169,7 +169,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="prompt-input-container" v-show="!showMotion">
|
<div class="prompt-input-container" v-show="!showMotion">
|
||||||
<div class="title">{{ $t('ProductImg.Prompt') }}</div>
|
<div class="title">{{ $t('ProductImg.Prompt') }}</div>
|
||||||
<promptInput :content="prompt" ref="promptInput" />
|
<promptInput :content="inputPrompt" ref="promptInput" />
|
||||||
</div>
|
</div>
|
||||||
<div class="poses" v-show="showMotion">
|
<div class="poses" v-show="showMotion">
|
||||||
<div class="head">
|
<div class="head">
|
||||||
@@ -371,15 +371,7 @@ export default defineComponent({
|
|||||||
removeGenerate: false,
|
removeGenerate: false,
|
||||||
generateTime: null as any,
|
generateTime: null as any,
|
||||||
poseList: [],
|
poseList: [],
|
||||||
selectPose: null as any,
|
selectPose: null as any
|
||||||
prompt: computed(() => {
|
|
||||||
if (videoType.value === 2) {
|
|
||||||
return getFirstFrame(t)
|
|
||||||
}
|
|
||||||
if (videoType.value === 3) {
|
|
||||||
return getFirstAndLastFrame(t)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
let speed = reactive({
|
let speed = reactive({
|
||||||
speedList: [
|
speedList: [
|
||||||
@@ -977,6 +969,14 @@ export default defineComponent({
|
|||||||
|
|
||||||
const videoType = ref(2)
|
const videoType = ref(2)
|
||||||
const showMotion = computed(() => videoType.value === 1)
|
const showMotion = computed(() => videoType.value === 1)
|
||||||
|
const inputPrompt = computed(() => {
|
||||||
|
if (videoType.value === 2) {
|
||||||
|
return getFirstFrame(t)
|
||||||
|
}
|
||||||
|
if (videoType.value === 3) {
|
||||||
|
return getFirstAndLastFrame(t)
|
||||||
|
}
|
||||||
|
})
|
||||||
const options = ref([
|
const options = ref([
|
||||||
{ vlaue: 2, label: t('poseTransfer.FirstFrame') },
|
{ vlaue: 2, label: t('poseTransfer.FirstFrame') },
|
||||||
{ value: 3, label: t('poseTransfer.FirstAndLastFrames') },
|
{ value: 3, label: t('poseTransfer.FirstAndLastFrames') },
|
||||||
@@ -1265,7 +1265,8 @@ export default defineComponent({
|
|||||||
handleConfirmProduct,
|
handleConfirmProduct,
|
||||||
productFrameList,
|
productFrameList,
|
||||||
showFirstFrameUpload,
|
showFirstFrameUpload,
|
||||||
showLastFrameUpload
|
showLastFrameUpload,
|
||||||
|
inputPrompt
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
directives: {
|
directives: {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, reactive, toRefs, nextTick, useTemplateRef } from 'vue'
|
import { ref, reactive, toRefs, nextTick, useTemplateRef, watch } from 'vue'
|
||||||
|
|
||||||
interface ContentItem {
|
interface ContentItem {
|
||||||
id: string
|
id: string
|
||||||
@@ -16,13 +16,13 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
// content: [
|
// content: [
|
||||||
// { id: '1', type: 'text', value: '11111' },
|
// { id: '1', type: 'text', value: '11111' },
|
||||||
// { id: '2', type: 'input', value: '222', placeholder: '[请输入内容]' },
|
// { id: '2', type: 'input', value: '222', placeholder: '[请输入内容]' },
|
||||||
// { id: '3', type: 'text', value: '333333' },
|
// { id: '3', type: 'text', value: '333333' },
|
||||||
// { id: '4', type: 'input', value: '', placeholder: '[请输入内容]' }
|
// { id: '4', type: 'input', value: '', placeholder: '[请输入内容]' }
|
||||||
// ] as ContentItem[]
|
// ] as ContentItem[]
|
||||||
content: [ { id: '1', type: 'text', value: '' },],
|
content: [{ id: '1', type: 'text', value: '' }]
|
||||||
})
|
})
|
||||||
|
|
||||||
const editableArea = ref<HTMLElement>()
|
const editableArea = ref<HTMLElement>()
|
||||||
@@ -282,7 +282,10 @@ const handleInputChange = (index: number, event: Event) => {
|
|||||||
const item = data.content[index]
|
const item = data.content[index]
|
||||||
|
|
||||||
// 如果当前显示placeholder,但内容已改变(比如通过粘贴),清除placeholder
|
// 如果当前显示placeholder,但内容已改变(比如通过粘贴),清除placeholder
|
||||||
if (target.classList.contains('has-placeholder') && target.textContent !== item.placeholder) {
|
if (
|
||||||
|
target.classList.contains('has-placeholder') &&
|
||||||
|
target.textContent !== item.placeholder
|
||||||
|
) {
|
||||||
target.classList.remove('has-placeholder')
|
target.classList.remove('has-placeholder')
|
||||||
const newValue = target.textContent || ''
|
const newValue = target.textContent || ''
|
||||||
data.content[index].value = newValue
|
data.content[index].value = newValue
|
||||||
@@ -496,18 +499,31 @@ const getFullText = () => {
|
|||||||
|
|
||||||
const textareaValue = ref('')
|
const textareaValue = ref('')
|
||||||
const assistModel = ref(false)
|
const assistModel = ref(false)
|
||||||
const handleClickAssistBtn = () => {
|
const syncContentFromProps = (
|
||||||
assistModel.value = !assistModel.value
|
newContent: ContentItem[] = props.content as ContentItem[]
|
||||||
if(assistModel.value){
|
) => {
|
||||||
data.content = JSON.parse(JSON.stringify(props.content))
|
data.content = JSON.parse(JSON.stringify(newContent || []))
|
||||||
initPlaceholders()
|
if (assistModel.value) {
|
||||||
|
initPlaceholders()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const textareaRef = useTemplateRef<HTMLTextAreaElement>('textareaRef')
|
const handleClickAssistBtn = () => {
|
||||||
|
assistModel.value = !assistModel.value
|
||||||
|
if (assistModel.value) {
|
||||||
|
syncContentFromProps()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
watch(
|
||||||
})
|
() => props.content,
|
||||||
|
newVal => {
|
||||||
|
syncContentFromProps(newVal as ContentItem[])
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
const textareaRef = useTemplateRef<HTMLTextAreaElement>('textareaRef')
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
getFullText,
|
getFullText,
|
||||||
@@ -573,8 +589,8 @@ defineExpose({
|
|||||||
--promptInputBorder: 2px solid #dcdfe6;
|
--promptInputBorder: 2px solid #dcdfe6;
|
||||||
--promptInputPadding: 1.5rem;
|
--promptInputPadding: 1.5rem;
|
||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
border-radius: var(--promptInputBorderRadius);
|
border-radius: var(--promptInputBorderRadius);
|
||||||
border: var(--promptInputBorder);
|
border: var(--promptInputBorder);
|
||||||
padding: var(--promptInputPadding);
|
padding: var(--promptInputPadding);
|
||||||
@@ -585,14 +601,14 @@ defineExpose({
|
|||||||
user-select: text;
|
user-select: text;
|
||||||
cursor: text;
|
cursor: text;
|
||||||
position: relative;
|
position: relative;
|
||||||
padding-bottom: 4rem;
|
padding-bottom: 4rem;
|
||||||
box-sizing: content-box;
|
box-sizing: content-box;
|
||||||
|
|
||||||
.promptinput-wrapper {
|
.promptinput-wrapper {
|
||||||
min-height: 12rem;
|
min-height: 12rem;
|
||||||
max-height: 14rem;
|
max-height: 14rem;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-field {
|
.text-field {
|
||||||
display: inline;
|
display: inline;
|
||||||
@@ -600,7 +616,7 @@ defineExpose({
|
|||||||
padding: 0.2rem 0;
|
padding: 0.2rem 0;
|
||||||
font-size: 1.8rem;
|
font-size: 1.8rem;
|
||||||
min-width: 2px;
|
min-width: 2px;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-field {
|
.input-field {
|
||||||
@@ -629,21 +645,21 @@ defineExpose({
|
|||||||
padding: 1.5rem 1.5rem 3rem;
|
padding: 1.5rem 1.5rem 3rem;
|
||||||
height: auto;
|
height: auto;
|
||||||
font-size: 1.8rem;
|
font-size: 1.8rem;
|
||||||
.area {
|
.area {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 12rem;
|
min-height: 12rem;
|
||||||
max-height: 14rem;
|
max-height: 14rem;
|
||||||
background: white;
|
background: white;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
outline: none;
|
outline: none;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
user-select: text;
|
user-select: text;
|
||||||
cursor: text;
|
cursor: text;
|
||||||
position: relative;
|
position: relative;
|
||||||
resize: none;
|
resize: none;
|
||||||
border: none;
|
border: none;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.asistant-btn {
|
.asistant-btn {
|
||||||
|
|||||||
Reference in New Issue
Block a user