Browse Source

refactor(cache): 更新本地缓存键名以避免冲突

- 统一为摄影详情页缓存键名添加 yi_ 前缀
- 修改模特选择组件缓存键名
- 更新场景提示组件缓存键名
- 确保各模块缓存键名唯一性- 避免不同功能间缓存数据互相干扰
panqiuyao 1 month ago
parent
commit
3174c2b57a

+ 5 - 5
frontend/src/components/ModelGeneration/index.vue

@@ -108,7 +108,7 @@ const selectedFemaleModel = ref<ModelData | null>(null)
 const selectedMaleModel = ref<ModelData | null>(null)
 
 // 本地缓存 key
-const MODEL_SELECTION_CACHE_KEY = 'model_selection_cache'
+const MODEL_SELECTION_CACHE_KEY = 'yi_model_selection_cache'
 
 // 从本地缓存读取
 const loadModelSelectionFromCache = () => {
@@ -267,14 +267,14 @@ const preloadImages = (models: ModelData[]) => {
 watch(dialogVisible, (newValue) => {
   if (newValue) {
     fetchModelList()
-    
+
     // 初始化时接收父组件传递的模特数据
     if (props.initialModels) {
-      
+
       if (props.initialModels.female) {
         selectedFemaleModel.value = props.initialModels.female
       }
-      
+
       if (props.initialModels.male) {
         selectedMaleModel.value = props.initialModels.male
       }
@@ -541,4 +541,4 @@ watch(dialogVisible, (newValue) => {
     font-weight: 600;
     color: #303133;
   }
-}</style>
+}</style>

+ 1 - 1
frontend/src/components/ScenePromptDialog/index.vue

@@ -57,7 +57,7 @@ const dialogVisible = computed({
 const scenePrompt = ref('')
 
 // 本地缓存 key
-const SCENE_PROMPT_CACHE_KEY = 'scene_prompt_cache'
+const SCENE_PROMPT_CACHE_KEY = 'yi_scene_prompt_cache'
 
 // 从本地缓存读取
 const loadScenePromptFromCache = () => {

+ 5 - 5
frontend/src/views/Photography/detail.vue

@@ -627,11 +627,11 @@ const selectedModels = ref<{ female: any; male: any } | null>(null)
 const scenePrompt = ref('')
 
 // 本地缓存键(与弹窗组件保持一致)
-const DETAIL_MODEL_CACHE_KEY = 'model_selection_cache'
-const DETAIL_SCENE_PROMPT_CACHE_KEY = 'scene_prompt_cache'
-const DETAIL_LOGO_CACHE_KEY = 'detail_logo_cache'
-const DETAIL_DATA_TYPE_CACHE_KEY = 'detail_data_type_cache'
-const DETAIL_SERVICES_CACHE_KEY = 'detail_services_cache'
+const DETAIL_MODEL_CACHE_KEY = 'yi_model_selection_cache'
+const DETAIL_SCENE_PROMPT_CACHE_KEY = 'yi_scene_prompt_cache'
+const DETAIL_LOGO_CACHE_KEY = 'yi_detail_logo_cache'
+const DETAIL_DATA_TYPE_CACHE_KEY = 'yi_detail_data_type_cache'
+const DETAIL_SERVICES_CACHE_KEY = 'yi_detail_services_cache'
 
 // 读取本地缓存
 const loadDetailCache = () => {