修改样式
This commit is contained in:
@@ -17,3 +17,4 @@ export { Pinia, store }
|
||||
export * from './module/user'
|
||||
export * from './module/search'
|
||||
export * from './module/config'
|
||||
export * from './module/categoryNav'
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
|
||||
/**
|
||||
* 菜谱分类列表页入口:由首页分类标签写入待选 id,列表页取出后清空,避免依赖路由 query。
|
||||
*/
|
||||
export const useCategoryNavStore = defineStore('categoryNav', () => {
|
||||
const pendingRecipeCategoryId = ref<string | null>(null)
|
||||
|
||||
function setPendingRecipeCategoryId(id: string | number | null | undefined) {
|
||||
if (id == null || id === '') {
|
||||
pendingRecipeCategoryId.value = null
|
||||
return
|
||||
}
|
||||
pendingRecipeCategoryId.value = String(id)
|
||||
}
|
||||
|
||||
/** 读取并清空,保证仅消费一次 */
|
||||
function consumePendingRecipeCategoryId(): string | null {
|
||||
const v = pendingRecipeCategoryId.value
|
||||
pendingRecipeCategoryId.value = null
|
||||
return v
|
||||
}
|
||||
|
||||
return {
|
||||
pendingRecipeCategoryId,
|
||||
setPendingRecipeCategoryId,
|
||||
consumePendingRecipeCategoryId,
|
||||
}
|
||||
})
|
||||
@@ -34,10 +34,14 @@ export const useSearchStore = defineStore(
|
||||
historyList.value = historyListCopy
|
||||
}
|
||||
|
||||
function clearHistory() {
|
||||
historyList.value = []
|
||||
}
|
||||
|
||||
return {
|
||||
historyList,
|
||||
setHistoryList,
|
||||
clearHistory,
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user