feat: 对话sessionId

This commit is contained in:
zhangyahui
2025-11-03 15:52:20 +08:00
parent 5acd523d1b
commit fcacab93bf
2 changed files with 36 additions and 26 deletions

View File

@@ -1,7 +1,7 @@
// 每一个存储的模块命名规则use开头store结尾
import { defineStore } from 'pinia'
import MyEvent from '@/utils/myEvent'
MyEvent.add('clear-generate-state', () => useGenerateStore().clearGenerateData())
MyEvent.add('clear-generate-state', () => useGenerateStore().clearGenerateData())
export const useGenerateStore = defineStore({
id: 'generate', // 必须指明唯一的pinia仓库的id
@@ -11,7 +11,7 @@ export const useGenerateStore = defineStore({
id: '',
oldId: '' //表示从生成页面返回回来需要调整的样式id
},
styleList: [{},{},{},{}],
styleList: [{}, {}, {}, {}],
model: {
id: ''
},
@@ -32,9 +32,9 @@ export const useGenerateStore = defineStore({
/** AI魔改信息 */
customizeInfo: {
inputText: '',
count: 0,
oldInputText: '',
oldTryOnId: '',
count: 0,
oldInputText: '',
oldTryOnId: '',
tryOnId: '',
tryOnUrl: '',
@@ -45,7 +45,8 @@ export const useGenerateStore = defineStore({
customerInfo: {
customerId: '',
visitRecordId: ''
}
},
sessionId: '' //会话id 秒级时间戳
}
},
getters: {
@@ -87,7 +88,7 @@ export const useGenerateStore = defineStore({
this.isGenerate = isGenerate
},
clearProductData() {
this.styleList = [{},{},{},{}]
this.styleList = [{}, {}, {}, {}]
this.style = {
id: '',
oldId: ''
@@ -111,8 +112,8 @@ export const useGenerateStore = defineStore({
/** 清空 AI魔改信息 */
clearCustomizeInfo() {
this.customizeInfo.inputText = ''
this.customizeInfo.count = 0
this.customizeInfo.oldInputText = ''
this.customizeInfo.count = 0
this.customizeInfo.oldInputText = ''
this.customizeInfo.oldTryOnId = ''
this.customizeInfo.tryOnId = ''
this.customizeInfo.tryOnUrl = ''
@@ -120,12 +121,12 @@ export const useGenerateStore = defineStore({
this.customizeInfo.isRegenerated = ''
this.customizeInfo.isFavorite = false
},
uploadCustomizeInfo(data: object){
for (const key in data) {
this.customizeInfo[key] = data[key]
}
},
clearCustomerInfo(){
uploadCustomizeInfo(data: object) {
for (const key in data) {
this.customizeInfo[key] = data[key]
}
},
clearCustomerInfo() {
this.customerInfo = {
customerId: '',
visitRecordId: ''
@@ -137,9 +138,13 @@ export const useGenerateStore = defineStore({
this.updatePhotoInfo({})
this.clearCustomizeInfo()
this.clearCustomerInfo()
this.setSessionId('')
},
setCustomerInfo(data: any) {
this.customerInfo = data
}
},
setSessionId(data: string) {
this.sessionId = data
},
}
})
})