设置store
This commit is contained in:
@@ -13,20 +13,19 @@
|
||||
import { useGenerateStore } from '@/stores'
|
||||
const store = useGenerateStore()
|
||||
|
||||
const customizeInfo = store.customizeInfo
|
||||
const router = useRouter()
|
||||
const inputText = ref('')
|
||||
const isFavorite = ref(false)
|
||||
const tryOnUrl = ref('')
|
||||
const loading = ref(false)
|
||||
const onSend = () => {
|
||||
if (inputText.value === '') return
|
||||
if (customizeInfo.inputText === '') return
|
||||
generate()
|
||||
const text = inputText.value
|
||||
inputText.value = ''
|
||||
customizeInfo.inputText = ''
|
||||
// const text = inputText.value
|
||||
// inputText.value = ''
|
||||
// console.log('发送消息:', text)
|
||||
}
|
||||
const onReload = () => {
|
||||
inputText.value = ''
|
||||
customizeInfo.inputText = ''
|
||||
generate(true)
|
||||
}
|
||||
|
||||
@@ -40,13 +39,16 @@
|
||||
customerPhotoId: store.customerPhotoId,
|
||||
originalTryOnId: store.originalTryOnId,
|
||||
isRegenerated: isRegenerated ? 1 : 0,
|
||||
prompt: inputText.value
|
||||
prompt: customizeInfo.inputText
|
||||
}
|
||||
loading.value = true
|
||||
generateTryOnEffect(data)
|
||||
.then((res) => {
|
||||
tryOnUrl.value = res.tryOnUrl
|
||||
isFavorite.value = !!res.isFavorite
|
||||
customizeInfo.tryOnId = res.tryOnId
|
||||
customizeInfo.tryOnUrl = res.tryOnUrl
|
||||
customizeInfo.styleUrl = res.styleUrl
|
||||
customizeInfo.isRegenerated = res.isRegenerated
|
||||
customizeInfo.isFavorite = !!res.isFavorite
|
||||
loading.value = false
|
||||
})
|
||||
.catch((err) => {
|
||||
@@ -54,15 +56,15 @@
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
generate()
|
||||
if (customizeInfo.tryOnId === '') generate()
|
||||
|
||||
// 喜欢
|
||||
const isLoveLoading = ref(false)
|
||||
const onLove = () => {
|
||||
if (isLoveLoading.value) return
|
||||
const http = isFavorite.value ? cancelTryOnEffectFavorite : setTryOnEffectFavorite
|
||||
const http = customizeInfo.isFavorite ? cancelTryOnEffectFavorite : setTryOnEffectFavorite
|
||||
customizeInfo.isFavorite = !customizeInfo.isFavorite
|
||||
isLoveLoading.value = true
|
||||
isFavorite.value = !isFavorite.value
|
||||
http('tryOnId')
|
||||
.then(() => {
|
||||
isLoveLoading.value = false
|
||||
@@ -94,21 +96,23 @@
|
||||
<div class="help">?</div>
|
||||
<input
|
||||
type="text"
|
||||
v-model="inputText"
|
||||
v-model="customizeInfo.inputText"
|
||||
@keyup.enter="onSend"
|
||||
placeholder="Try: “Change background to Tokyo City”"
|
||||
/>
|
||||
<div class="send" @click="onSend"><SvgIcon name="send" size="48" /></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<img :src="tryOnUrl" />
|
||||
<img :src="customizeInfo.tryOnUrl" />
|
||||
<!-- <div class="select-box">
|
||||
<div class="icon"><SvgIcon name="history" size="35" /></div>
|
||||
<div class="label">History</div>
|
||||
<div class="icon"><SvgIcon name="xialajiantou" size="29" /></div>
|
||||
</div> -->
|
||||
<div class="icons">
|
||||
<div @click="onLove"><SvgIcon :name="`love_${isFavorite ? 1 : 0}`" size="35" /></div>
|
||||
<div @click="onLove">
|
||||
<SvgIcon :name="`love_${customizeInfo.isFavorite ? 1 : 0}`" size="35" />
|
||||
</div>
|
||||
<div @click="onReload"><SvgIcon name="reload" size="35" /></div>
|
||||
<!-- <div @click="onDownload"><SvgIcon name="download" size="35" /></div> -->
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user