2025-10-09 09:29:36 +08:00
|
|
|
|
// 每一个存储的模块,命名规则use开头,store结尾
|
|
|
|
|
|
import { defineStore } from 'pinia'
|
2025-10-28 14:51:14 +08:00
|
|
|
|
import MyEvent from '@/utils/myEvent'
|
2025-11-03 15:52:20 +08:00
|
|
|
|
MyEvent.add('clear-generate-state', () => useGenerateStore().clearGenerateData())
|
2025-12-23 15:05:15 +08:00
|
|
|
|
MyEvent.add('clear-client-state', () => useGenerateStore().clearCustomerInfo())
|
2025-10-28 14:51:14 +08:00
|
|
|
|
|
2025-10-21 10:20:57 +08:00
|
|
|
|
export const useGenerateStore = defineStore({
|
2025-10-27 11:46:45 +08:00
|
|
|
|
id: 'generate', // 必须指明唯一的pinia仓库的id
|
|
|
|
|
|
state: () => {
|
|
|
|
|
|
return {
|
2025-10-27 11:43:07 +08:00
|
|
|
|
style: {
|
|
|
|
|
|
id: '',
|
2025-12-23 14:20:11 +08:00
|
|
|
|
path: '',
|
|
|
|
|
|
taskId:'',
|
|
|
|
|
|
isLike: false, //是否喜欢
|
|
|
|
|
|
status: ''
|
2025-10-27 11:43:07 +08:00
|
|
|
|
},
|
2025-12-29 14:42:50 +08:00
|
|
|
|
styleList: [
|
|
|
|
|
|
{id:'',taskId:'',status:'',path:''},
|
|
|
|
|
|
{id:'',taskId:'',status:'',path:''},
|
|
|
|
|
|
{id:'',taskId:'',status:'',path:''},
|
|
|
|
|
|
{id:'',taskId:'',status:'',path:''},
|
|
|
|
|
|
],
|
2025-10-27 11:43:07 +08:00
|
|
|
|
model: {
|
|
|
|
|
|
id: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
originalTryOn: {
|
|
|
|
|
|
//生成穿好衣服的回参
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
isLike: false, //是否喜欢
|
|
|
|
|
|
tryOnUrl: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
isGenerate: false, //点击继续按钮后是否需要生成
|
2025-10-24 15:19:29 +08:00
|
|
|
|
|
2025-10-27 11:43:07 +08:00
|
|
|
|
/** 顾客照片信息 */
|
|
|
|
|
|
photoInfo: {
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
url: '',
|
|
|
|
|
|
file: null
|
|
|
|
|
|
},
|
|
|
|
|
|
/** AI魔改信息 */
|
|
|
|
|
|
customizeInfo: {
|
|
|
|
|
|
inputText: '',
|
2025-11-03 15:52:20 +08:00
|
|
|
|
count: 0,
|
|
|
|
|
|
oldInputText: '',
|
|
|
|
|
|
oldTryOnId: '',
|
2025-10-24 13:19:01 +08:00
|
|
|
|
|
2025-10-27 11:43:07 +08:00
|
|
|
|
tryOnId: '',
|
|
|
|
|
|
tryOnUrl: '',
|
|
|
|
|
|
styleUrl: '',
|
|
|
|
|
|
isRegenerated: '',
|
|
|
|
|
|
isFavorite: false
|
|
|
|
|
|
},
|
2025-11-17 17:33:32 +08:00
|
|
|
|
/** AI魔改信息-演示 */
|
|
|
|
|
|
customizeInfoDemo: {
|
|
|
|
|
|
inputText: '',
|
|
|
|
|
|
count: 0,
|
|
|
|
|
|
oldInputText: '',
|
|
|
|
|
|
oldTryOnId: '',
|
|
|
|
|
|
|
|
|
|
|
|
tryOnId: '',
|
|
|
|
|
|
tryOnUrl: '',
|
|
|
|
|
|
styleUrl: '',
|
|
|
|
|
|
isRegenerated: '',
|
|
|
|
|
|
isFavorite: false
|
|
|
|
|
|
},
|
2025-10-27 11:43:07 +08:00
|
|
|
|
customerInfo: {
|
|
|
|
|
|
customerId: '',
|
2025-10-27 11:46:45 +08:00
|
|
|
|
visitRecordId: ''
|
2025-11-03 15:52:20 +08:00
|
|
|
|
},
|
2025-11-03 15:55:59 +08:00
|
|
|
|
chatSessionId: '' //会话id 秒级时间戳
|
2025-10-27 11:43:07 +08:00
|
|
|
|
}
|
2025-10-27 11:46:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
getters: {
|
|
|
|
|
|
/** 顾客id */
|
|
|
|
|
|
customerId: (state) => state.customerInfo.customerId,
|
|
|
|
|
|
/** 进店记录id */
|
|
|
|
|
|
visitRecordId: (state) => state.customerInfo.visitRecordId,
|
|
|
|
|
|
/** 服装id */
|
2025-12-23 14:20:11 +08:00
|
|
|
|
styleId: (state) => state.style.id,
|
2025-10-27 11:46:45 +08:00
|
|
|
|
/** 模特照片id */
|
|
|
|
|
|
modelPhotoId: (state) => state.model.id,
|
2025-11-17 14:13:39 +08:00
|
|
|
|
/** 原始试穿id不包含魔改id */
|
|
|
|
|
|
originalTryOnIdNoRein: (state) => state.originalTryOn.id,
|
2025-10-27 11:46:45 +08:00
|
|
|
|
/** 原始试穿id-优先AI魔改 */
|
|
|
|
|
|
originalTryOnId: (state) => state.customizeInfo.tryOnId || state.originalTryOn.id,
|
|
|
|
|
|
/** 顾客照片id */
|
2025-11-03 15:53:18 +08:00
|
|
|
|
customerPhotoId: (state) => state.photoInfo.id,
|
|
|
|
|
|
/** 会话id */
|
2025-11-03 15:55:59 +08:00
|
|
|
|
sessionId: (state) => state.chatSessionId
|
2025-10-27 11:46:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
actions: {
|
|
|
|
|
|
selectStyle(data: any) {
|
2025-12-23 14:20:11 +08:00
|
|
|
|
this.style = {
|
|
|
|
|
|
...data,
|
2025-11-18 11:34:48 +08:00
|
|
|
|
}
|
2025-10-27 11:46:45 +08:00
|
|
|
|
},
|
2025-12-23 14:20:11 +08:00
|
|
|
|
clearStyle() {
|
|
|
|
|
|
this.style = {
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
path: '',
|
|
|
|
|
|
isLike: false,
|
|
|
|
|
|
taskId:'',
|
|
|
|
|
|
status: ''
|
|
|
|
|
|
}
|
2025-12-29 14:42:50 +08:00
|
|
|
|
this.styleList = [
|
|
|
|
|
|
{id:'',taskId:'',status:'',path:''},
|
|
|
|
|
|
{id:'',taskId:'',status:'',path:''},
|
|
|
|
|
|
{id:'',taskId:'',status:'',path:''},
|
|
|
|
|
|
{id:'',taskId:'',status:'',path:''},
|
|
|
|
|
|
]
|
2025-12-23 14:20:11 +08:00
|
|
|
|
},
|
2025-10-27 11:46:45 +08:00
|
|
|
|
//模特相关
|
|
|
|
|
|
selectModel(data: any) {
|
|
|
|
|
|
this.model.id = data.id
|
|
|
|
|
|
},
|
|
|
|
|
|
setIsGenerate(isGenerate: boolean) {
|
|
|
|
|
|
this.isGenerate = isGenerate
|
|
|
|
|
|
},
|
|
|
|
|
|
clearProductData() {
|
2025-12-29 14:42:50 +08:00
|
|
|
|
this.styleList = [
|
|
|
|
|
|
{id:'',taskId:'',status:'',path:''},
|
|
|
|
|
|
{id:'',taskId:'',status:'',path:''},
|
|
|
|
|
|
{id:'',taskId:'',status:'',path:''},
|
|
|
|
|
|
{id:'',taskId:'',status:'',path:''},
|
|
|
|
|
|
]
|
2025-10-27 11:46:45 +08:00
|
|
|
|
this.style = {
|
|
|
|
|
|
id: '',
|
2025-12-23 14:20:11 +08:00
|
|
|
|
path: '',
|
|
|
|
|
|
isLike: false,
|
|
|
|
|
|
taskId:'',
|
|
|
|
|
|
status: ''
|
2025-10-27 11:46:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.model = {
|
|
|
|
|
|
id: ''
|
|
|
|
|
|
}
|
|
|
|
|
|
this.originalTryOn = {
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
isLike: false,
|
|
|
|
|
|
tryOnUrl: ''
|
|
|
|
|
|
}
|
|
|
|
|
|
this.isGenerate = false
|
|
|
|
|
|
},
|
|
|
|
|
|
/** 更新顾客照片信息 */
|
|
|
|
|
|
updatePhotoInfo(data: any) {
|
|
|
|
|
|
this.photoInfo.id = data.id || ''
|
|
|
|
|
|
if (!data.photoUrl) this.photoInfo.url = ''
|
2025-10-30 16:41:19 +08:00
|
|
|
|
this.photoInfo.file = data.file || null
|
2025-10-27 11:46:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
/** 清空 AI魔改信息 */
|
|
|
|
|
|
clearCustomizeInfo() {
|
|
|
|
|
|
this.customizeInfo.inputText = ''
|
2025-11-03 15:52:20 +08:00
|
|
|
|
this.customizeInfo.count = 0
|
|
|
|
|
|
this.customizeInfo.oldInputText = ''
|
2025-10-31 11:50:03 +08:00
|
|
|
|
this.customizeInfo.oldTryOnId = ''
|
2025-10-27 11:46:45 +08:00
|
|
|
|
this.customizeInfo.tryOnId = ''
|
|
|
|
|
|
this.customizeInfo.tryOnUrl = ''
|
|
|
|
|
|
this.customizeInfo.styleUrl = ''
|
|
|
|
|
|
this.customizeInfo.isRegenerated = ''
|
|
|
|
|
|
this.customizeInfo.isFavorite = false
|
2025-11-17 17:33:32 +08:00
|
|
|
|
},
|
|
|
|
|
|
/** 清空 AI魔改信息-演示 */
|
|
|
|
|
|
clearCustomizeInfoDemo() {
|
|
|
|
|
|
this.customizeInfoDemo.inputText = ''
|
|
|
|
|
|
this.customizeInfoDemo.count = 0
|
|
|
|
|
|
this.customizeInfoDemo.oldInputText = ''
|
|
|
|
|
|
this.customizeInfoDemo.oldTryOnId = ''
|
|
|
|
|
|
this.customizeInfoDemo.tryOnId = ''
|
|
|
|
|
|
this.customizeInfoDemo.tryOnUrl = ''
|
|
|
|
|
|
this.customizeInfoDemo.styleUrl = ''
|
|
|
|
|
|
this.customizeInfoDemo.isRegenerated = ''
|
|
|
|
|
|
this.customizeInfoDemo.isFavorite = false
|
2025-10-27 11:46:45 +08:00
|
|
|
|
},
|
2025-11-03 15:52:20 +08:00
|
|
|
|
uploadCustomizeInfo(data: object) {
|
|
|
|
|
|
for (const key in data) {
|
|
|
|
|
|
this.customizeInfo[key] = data[key]
|
|
|
|
|
|
}
|
2025-11-20 16:40:13 +08:00
|
|
|
|
},
|
|
|
|
|
|
uploadCustomizeInfoDemo(data: object) {
|
|
|
|
|
|
for (const key in data) {
|
|
|
|
|
|
this.customizeInfoDemo[key] = data[key]
|
|
|
|
|
|
}
|
2025-11-03 15:52:20 +08:00
|
|
|
|
},
|
|
|
|
|
|
clearCustomerInfo() {
|
2025-10-28 15:17:47 +08:00
|
|
|
|
this.customerInfo = {
|
|
|
|
|
|
customerId: '',
|
|
|
|
|
|
visitRecordId: ''
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-10-27 11:46:45 +08:00
|
|
|
|
//设置默认数据
|
|
|
|
|
|
clearGenerateData() {
|
|
|
|
|
|
this.clearProductData()
|
|
|
|
|
|
this.updatePhotoInfo({})
|
|
|
|
|
|
this.clearCustomizeInfo()
|
2025-11-17 17:33:32 +08:00
|
|
|
|
this.clearCustomizeInfoDemo()
|
2025-12-23 15:05:15 +08:00
|
|
|
|
// this.clearCustomerInfo()
|
2025-11-03 15:52:20 +08:00
|
|
|
|
this.setSessionId('')
|
2025-10-27 11:46:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
setCustomerInfo(data: any) {
|
|
|
|
|
|
this.customerInfo = data
|
2025-11-03 15:52:20 +08:00
|
|
|
|
},
|
|
|
|
|
|
setSessionId(data: string) {
|
2025-11-03 15:55:59 +08:00
|
|
|
|
this.chatSessionId = data
|
2025-11-03 15:52:20 +08:00
|
|
|
|
},
|
2025-10-27 11:46:45 +08:00
|
|
|
|
}
|
2025-11-03 15:52:20 +08:00
|
|
|
|
})
|