feat: revert strict mode

This commit is contained in:
YunYouJun
2022-04-17 17:11:59 +08:00
parent 0865dbe716
commit 3ae07a1073
3 changed files with 8 additions and 5 deletions

View File

@@ -1,6 +1,8 @@
<script lang="ts" setup>
import { useGtm } from '@gtm-support/vue-gtm'
import { isClient } from '@vueuse/core'
import { storeToRefs } from 'pinia'
import Switch from './Switch.vue'
import type { StuffItem } from '~/data/food'
import { meat, staple, tools, vegetable } from '~/data/food'
import recipeData from '~/data/recipe.json'
@@ -12,11 +14,11 @@ import { useInvisibleElement } from '~/composables/helper'
const recipe = ref<Recipe>(recipeData as Recipe)
const rStore = useRecipeStore()
const { strict } = storeToRefs(rStore)
const curStuff = computed(() => rStore.selectedStuff)
const curTools = computed(() => rStore.selectedTools)
// 默认严格模式
const strict = ref(true)
const displayedRecipe = computed(() => {
return recipe.value.filter((item) => {
if (strict.value) {
@@ -207,6 +209,7 @@ const { isVisible, show } = useInvisibleElement(recipePanel)
<h2 text="xl" font="bold" p="1">
🍲 来看看组合出的菜谱吧
</h2>
<Switch />
<Transition mode="out-in">
<div p="2">
<span v-if="!curStuff.length && !curTools.length" text="sm" p="2">

View File

@@ -6,16 +6,16 @@ const { strict } = storeToRefs(rStore)
</script>
<template>
<div class="inline-flex justify-center items-center" m="y-4">
<div class="inline-flex justify-center items-center" m="t-2">
<span :class="!strict && 'text-green-600'" font="bold" m="x-1" @click="strict = false">
可做的所有菜
模糊匹配
</span>
<label m="x-1" class="switch">
<input v-model="strict" type="checkbox">
<span class="inline-flex justify-center items-center slider round" />
</label>
<span :class="strict && 'text-green-600'" font="bold" m="x-1" @click="strict = true">
一起做一道菜
精准匹配
</span>
</div>
</template>

View File

@@ -1,7 +1,7 @@
import { acceptHMRUpdate, defineStore } from 'pinia'
export const useRecipeStore = defineStore('recipe', () => {
const strict = ref(true)
const strict = ref(false)
const curStuff = ref(new Set<string>())
const curTools = ref(new Set<string>())