feat: adjust tool & stuff logic when not strict

This commit is contained in:
YunYouJun
2022-04-17 22:05:30 +08:00
parent deb200f1c3
commit 7405939192
2 changed files with 35 additions and 19 deletions

View File

@@ -4,10 +4,12 @@ export const useRecipeStore = defineStore('recipe', () => {
const strict = ref(false)
const curStuff = ref(new Set<string>())
const curTools = ref(new Set<string>())
// const curTools = ref(new Set<string>())
const curTool = ref('')
const selectedStuff = computed(() => Array.from(curStuff.value))
const selectedTools = computed(() => Array.from(curTools.value))
// const selectedTools = computed(() => Array.from(curTools.value))
// const selectedTools = ref('')
function toggleStuff(name: string) {
if (!curStuff)
@@ -19,12 +21,14 @@ export const useRecipeStore = defineStore('recipe', () => {
}
function toggleTools(name: string) {
if (!curTools)
return
if (curTools.value.has(name))
curTools.value.delete(name)
if (curTool.value === name)
curTool.value = ''
else
curTools.value.add(name)
curTool.value = name
// if (curTools.value.has(name))
// curTools.value.delete(name)
// else
// curTools.value.add(name)
}
/**
@@ -32,12 +36,13 @@ export const useRecipeStore = defineStore('recipe', () => {
*/
function reset() {
curStuff.value.clear()
curTools.value.clear()
// curTools.value.clear()
curTool.value = ''
}
return {
strict,
selectedTools,
curTool,
selectedStuff,
toggleStuff,
toggleTools,