From 75060adf3c0e0d6fe50f3e1138730eaf3c86d0bb Mon Sep 17 00:00:00 2001 From: YunYouJun Date: Fri, 15 Apr 2022 22:25:53 +0800 Subject: [PATCH] fix: choose tool --- src/components/ChooseFood.vue | 11 ++++++----- src/components/DishTag.vue | 3 +-- src/data/food.ts | 5 +++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/components/ChooseFood.vue b/src/components/ChooseFood.vue index 3798662..ac4675a 100644 --- a/src/components/ChooseFood.vue +++ b/src/components/ChooseFood.vue @@ -21,7 +21,7 @@ const displayedRecipe = computed(() => { if (strict.value) { const stuffFlag = curStuff.value.every(stuff => item.stuff.includes(stuff)) const toolFlag = curTool.value ? item.tools?.includes(curTool.value) : true - return curTool.value ? stuffFlag && toolFlag : stuffFlag + return stuffFlag && toolFlag } else { const stuffFlag = curStuff.value.some(stuff => item.stuff.includes(stuff)) @@ -49,14 +49,15 @@ const toggleStuff = (item: StuffItem, category = '') => { * @param item */ const clickTool = (item: StuffItem) => { - if (curTool.value === item.name) + const value = typeof item.value !== 'undefined' ? item.value : item.name + if (curTool.value === value) curTool.value = '' else - curTool.value = item.name + curTool.value = value gtm?.trackEvent({ event: 'stuff', - category: `tool_${item.name}`, + category: `tool_${value}`, action: 'click', label: '工具', }) @@ -124,7 +125,7 @@ const clickTool = (item: StuffItem) => { {{ item.emoji }} diff --git a/src/components/DishTag.vue b/src/components/DishTag.vue index ddaa1c4..9a8d05c 100644 --- a/src/components/DishTag.vue +++ b/src/components/DishTag.vue @@ -10,10 +10,9 @@ const gtm = useGtm() const triggerGtm = (val: string) => { gtm?.trackEvent({ event: 'recipe', - category: 'dish', + category: `dish_${val}`, action: 'click', label: '跳转菜谱', - value: val, }) } diff --git a/src/data/food.ts b/src/data/food.ts index ccac625..cdd3034 100644 --- a/src/data/food.ts +++ b/src/data/food.ts @@ -19,6 +19,10 @@ export interface StuffItem { * 图标名称 */ icon?: string + /** + * value + */ + value?: string } /** @@ -178,5 +182,6 @@ export const tools: StuffItem[] = [ name: '一口啥都能煮的大锅', emoji: '', icon: 'i-mdi-pot-steam-outline', + value: '', }, ]