This commit is contained in:
zhangyh
2025-10-27 11:46:45 +08:00
5 changed files with 123 additions and 96 deletions

View File

@@ -1 +0,0 @@
VITE_APP_URL = http://18.167.251.121:10095

View File

@@ -4,7 +4,6 @@
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"test": "vite --mode test",
"build": "run-p type-check build-only", "build": "run-p type-check build-only",
"preview": "vite preview", "preview": "vite preview",
"build-only": "vite build", "build-only": "vite build",

View File

@@ -1,5 +1,6 @@
// 每一个存储的模块命名规则use开头store结尾 // 每一个存储的模块命名规则use开头store结尾
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { useUserInfoStore } from './userInfo'
export const useGenerateStore = defineStore({ export const useGenerateStore = defineStore({
id: 'generate', // 必须指明唯一的pinia仓库的id id: 'generate', // 必须指明唯一的pinia仓库的id
state: () => { state: () => {
@@ -37,7 +38,7 @@ export const useGenerateStore = defineStore({
}, },
customerInfo: { customerInfo: {
customerId: '', customerId: '',
visitRecordId:'' visitRecordId: ''
} }
} }
}, },
@@ -53,7 +54,7 @@ export const useGenerateStore = defineStore({
/** 原始试穿id-优先AI魔改 */ /** 原始试穿id-优先AI魔改 */
originalTryOnId: (state) => state.customizeInfo.tryOnId || state.originalTryOn.id, originalTryOnId: (state) => state.customizeInfo.tryOnId || state.originalTryOn.id,
/** 顾客照片id */ /** 顾客照片id */
customerPhotoId: (state) => state.photoInfo.id, customerPhotoId: (state) => state.photoInfo.id
}, },
actions: { actions: {
selectStyle(data: any) { selectStyle(data: any) {
@@ -62,7 +63,7 @@ export const useGenerateStore = defineStore({
}, },
//生成后去掉id 设置oldId来修改样式 //生成后去掉id 设置oldId来修改样式
useStyleGenerate() { useStyleGenerate() {
if(!this.style.id)return if (!this.style.id) return
this.style.oldId = this.style.id this.style.oldId = this.style.id
this.style.id = '' this.style.id = ''
}, },
@@ -79,21 +80,42 @@ export const useGenerateStore = defineStore({
setIsGenerate(isGenerate: boolean) { setIsGenerate(isGenerate: boolean) {
this.isGenerate = isGenerate this.isGenerate = isGenerate
}, },
clearProductData() {
this.style = {
id: '',
oldId: ''
}
this.model = {
id: ''
}
this.originalTryOn = {
id: '',
isLike: false,
tryOnUrl: ''
}
this.isGenerate = false
},
/** 更新顾客照片信息 */ /** 更新顾客照片信息 */
updatePhotoInfo(data: any) { updatePhotoInfo(data: any) {
this.photoInfo.id = data.id || "" this.photoInfo.id = data.id || ''
if (!data.photoUrl) this.photoInfo.url = "" if (!data.photoUrl) this.photoInfo.url = ''
this.photoInfo.file = null this.photoInfo.file = null
}, },
/** 清空 AI魔改信息 */ /** 清空 AI魔改信息 */
clearCustomizeInfo() { clearCustomizeInfo() {
this.customizeInfo.inputText = "" this.customizeInfo.inputText = ''
this.customizeInfo.tryOnId = "" this.customizeInfo.tryOnId = ''
this.customizeInfo.tryOnUrl = "" this.customizeInfo.tryOnUrl = ''
this.customizeInfo.styleUrl = "" this.customizeInfo.styleUrl = ''
this.customizeInfo.isRegenerated = "" this.customizeInfo.isRegenerated = ''
this.customizeInfo.isFavorite = false this.customizeInfo.isFavorite = false
}, },
//设置默认数据
clearGenerateData() {
this.clearProductData()
this.updatePhotoInfo({})
this.clearCustomizeInfo()
},
setCustomerInfo(data: any) { setCustomerInfo(data: any) {
this.customerInfo = data this.customerInfo = data
} }

View File

@@ -4,7 +4,7 @@ import { useUserInfoStore } from '@/stores/modules/userInfo'
const store = useUserInfoStore() const store = useUserInfoStore()
import { getLocal } from '@/utils/local' import { getLocal } from '@/utils/local'
import router from '@/router/index' import router from '@/router/index'
import { useOverallStore } from '@/stores' import { useOverallStore, useGenerateStore } from '@/stores'
// 扩展 AxiosRequestConfig 接口 // 扩展 AxiosRequestConfig 接口
declare module 'axios' { declare module 'axios' {
@@ -98,9 +98,8 @@ service.interceptors.response.use(
} }
}, },
(error) => { (error) => {
if (error?.response) { if(error?.response){
if (error?.response?.status === 401) { if(error?.response?.status === 401){//如果是记录浏览器页面就不跳转login
//如果是记录浏览器页面就不跳转login
// showConfirmDialog({ // showConfirmDialog({
// title: '确定登出', // title: '确定登出',
// message: '你已被登出,可以取消继续留在该页面,或者重新登录', // message: '你已被登出,可以取消继续留在该页面,或者重新登录',
@@ -111,8 +110,13 @@ service.interceptors.response.use(
// location.reload() // 为了重新实例化vue-router对象 避免bug // location.reload() // 为了重新实例化vue-router对象 避免bug
// }) // })
// }) // })
router.replace('/login') showToast({
return Promise.reject(error) message: 'Please log in and try again.',
duration: 5000
})
router.push('/welcome')
useGenerateStore().clearGenerateData()
return Promise.reject(false)
} }
error.config && removePending(error.config) error.config && removePending(error.config)
// 关闭loading // 关闭loading
@@ -122,9 +126,8 @@ service.interceptors.response.use(
console.log('err' + error) // for debug console.log('err' + error) // for debug
showToast({ showToast({
message: error.message, message: error.message,
// type: 'fail', type: 'fail',
duration: 5000, duration: 5000
position:'top'
}) })
} }
return Promise.reject(error) return Promise.reject(error)

View File

@@ -54,7 +54,11 @@ const startGenerate = ()=>{
generateStore.setIsGenerate(false) generateStore.setIsGenerate(false)
generateStore.clearCustomizeInfo() generateStore.clearCustomizeInfo()
}).catch(()=>{ }).catch((error)=>{
console.log(error)
if(error === false){
return
}
data.isLoading = false; data.isLoading = false;
if(generateStore.originalTryOn.id){ if(generateStore.originalTryOn.id){
router.back() router.back()