Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ab297cc47 | ||
|
|
7f87c47320 | ||
|
|
dd2de09325 | ||
|
|
e55d9a59c3 | ||
|
|
0232595083 | ||
|
|
d3ab8fb2c1 | ||
|
|
85c8f4fcd1 | ||
|
|
f2f878e2f4 | ||
|
|
246a65599a | ||
|
|
203ab27496 | ||
|
|
e861c5bd65 | ||
|
|
94a9ff5007 | ||
|
|
98123b0039 | ||
|
|
95ce2c4dac | ||
|
|
1bd0a6721e | ||
|
|
974d523f9d | ||
|
|
e9427f7fb0 | ||
|
|
fdfe1c4622 | ||
|
|
f6b285788f | ||
|
|
ae6aaba912 | ||
|
|
b526aae2d0 | ||
|
|
38b31a5654 | ||
|
|
2db9fee8af | ||
|
|
44c9631e70 |
@@ -1,2 +0,0 @@
|
||||
dist
|
||||
public
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"extends": [
|
||||
"@antfu",
|
||||
"@unocss"
|
||||
],
|
||||
"ignorePatterns": "*.json"
|
||||
}
|
||||
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -4,10 +4,12 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
|
||||
13
.github/workflows/release.yml
vendored
13
.github/workflows/release.yml
vendored
@@ -28,11 +28,18 @@ jobs:
|
||||
run: pnpm install
|
||||
|
||||
- run: npm run generate --if-present
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: .output/public/
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Dist
|
||||
path: dist
|
||||
|
||||
name: Cook Dist
|
||||
path: .output/public/
|
||||
|
||||
- run: npx changelogithub # or changelogithub@0.12 if ensure the stable result
|
||||
env:
|
||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,5 +1,5 @@
|
||||
# auto generate
|
||||
src/data/recipe.json
|
||||
data/recipe.json
|
||||
|
||||
.DS_Store
|
||||
.vite-ssg-dist
|
||||
@@ -7,6 +7,7 @@ src/data/recipe.json
|
||||
*.local
|
||||
|
||||
esbuild-kit
|
||||
tsx-*
|
||||
|
||||
# nuxt
|
||||
node_modules
|
||||
|
||||
68
.vscode/settings.json
vendored
68
.vscode/settings.json
vendored
@@ -1,11 +1,69 @@
|
||||
{
|
||||
"cSpell.words": ["Vitesse", "Vite", "unocss", "vitest", "vueuse", "pinia", "demi", "antfu", "iconify", "intlify", "vitejs", "unplugin", "pnpm"],
|
||||
"prettier.enable": false,
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": true,
|
||||
},
|
||||
"files.associations": {
|
||||
"*.css": "postcss",
|
||||
"*.css": "postcss"
|
||||
},
|
||||
|
||||
// Enable the ESlint flat config support
|
||||
"eslint.experimental.useFlatConfig": true,
|
||||
// Disable the default formatter, use eslint instead
|
||||
"prettier.enable": false,
|
||||
"editor.formatOnSave": false,
|
||||
// Auto fix
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": "explicit",
|
||||
"source.organizeImports": "never"
|
||||
},
|
||||
// Silent the stylistic rules in you IDE, but still auto fix them
|
||||
"eslint.rules.customizations": [
|
||||
{
|
||||
"rule": "style/*",
|
||||
"severity": "off"
|
||||
},
|
||||
{
|
||||
"rule": "*-indent",
|
||||
"severity": "off"
|
||||
},
|
||||
{
|
||||
"rule": "*-spacing",
|
||||
"severity": "off"
|
||||
},
|
||||
{
|
||||
"rule": "*-spaces",
|
||||
"severity": "off"
|
||||
},
|
||||
{
|
||||
"rule": "*-order",
|
||||
"severity": "off"
|
||||
},
|
||||
{
|
||||
"rule": "*-dangle",
|
||||
"severity": "off"
|
||||
},
|
||||
{
|
||||
"rule": "*-newline",
|
||||
"severity": "off"
|
||||
},
|
||||
{
|
||||
"rule": "*quotes",
|
||||
"severity": "off"
|
||||
},
|
||||
{
|
||||
"rule": "*semi",
|
||||
"severity": "off"
|
||||
}
|
||||
],
|
||||
// Enable eslint for all supported languages
|
||||
"eslint.validate": [
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"vue",
|
||||
"html",
|
||||
"markdown",
|
||||
"json",
|
||||
"jsonc",
|
||||
"yaml"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
## 版本
|
||||
|
||||
[](https://github.com/YunYouJun/cook/actions/workflows/release.yml)
|
||||
|
||||
### 网页版本
|
||||
|
||||
- 网站链接:[cook.yunyoujun.cn](https://cook.yunyoujun.cn)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import { isClient } from '@vueuse/core'
|
||||
import pkg from '~/package.json'
|
||||
|
||||
const displayICP = ref(true)
|
||||
|
||||
@@ -8,24 +7,11 @@ onBeforeMount(() => {
|
||||
if (isClient)
|
||||
displayICP.value = ['cook.yunyoujun.cn', 'localhost', '127.0.0.1'].includes(window.location.hostname)
|
||||
})
|
||||
|
||||
const commitSha = (import.meta.env.VITE_COMMIT_REF || '').slice(0, 7)
|
||||
const now = import.meta.env.VITE_APP_BUILD_TIME
|
||||
const buildDate = (new Date(Number.parseInt(now) * 1000)).toLocaleDateString()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div p="4 t-2" class="flex flex-col items-center justify-center" text="sm">
|
||||
<div v-if="commitSha && buildDate" mb-2>
|
||||
<span>
|
||||
当前版本 v{{ pkg.version }}({{ buildDate }}):
|
||||
</span>
|
||||
<span>
|
||||
<a border="b-1 dashed" :href="`https://github.com/YunYouJun/cook/commit/${commitSha}`" target="_blank" alt="Cook | GitHub Commit">
|
||||
{{ commitSha }}
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<CurrentVersion />
|
||||
<a v-if="displayICP" opacity="80" class="flex" href="https://beian.miit.gov.cn/" target="_blank">
|
||||
苏ICP备17038157号
|
||||
</a>
|
||||
|
||||
@@ -18,7 +18,8 @@ const showBasketBtn = computed(async () => {
|
||||
v-show="showBasketBtn"
|
||||
class="fixed z-9 inline-flex cursor-pointer items-center justify-center rounded rounded-full shadow hover:shadow-md"
|
||||
bg="green-50 dark:green-900" w="10" h="10"
|
||||
bottom="18" right="4"
|
||||
bottom="22"
|
||||
right="4"
|
||||
text="green-600 dark:green-300"
|
||||
>
|
||||
<span v-if="displayedRecipe.length > 0">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import { storeToRefs } from 'pinia'
|
||||
import type { StuffItem } from '~/data/food'
|
||||
import type { StuffItem } from '~/types'
|
||||
import { meat, staple, tools, vegetable } from '~/data/food'
|
||||
|
||||
import { useEmojiAnimation } from '~/composables/animation'
|
||||
|
||||
5
components/CommonHeader.vue
Normal file
5
components/CommonHeader.vue
Normal file
@@ -0,0 +1,5 @@
|
||||
<template>
|
||||
<h1 text-2xl font="bold" my="4">
|
||||
<slot />
|
||||
</h1>
|
||||
</template>
|
||||
@@ -3,11 +3,12 @@ import { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue'
|
||||
|
||||
defineProps<{
|
||||
title: string
|
||||
defaultOpen?: boolean
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Disclosure v-slot="{ open }" as="div" class="mt-2">
|
||||
<Disclosure v-slot="{ open }" :default-open="defaultOpen" as="div" class="mt-2">
|
||||
<DisclosureButton
|
||||
class="w-full flex justify-between rounded-lg bg-blue-100 px-4 py-2 text-left text-sm font-medium text-blue-900 hover:bg-blue-200 focus:outline-none focus-visible:ring focus-visible:ring-blue-500 focus-visible:ring-opacity-75"
|
||||
>
|
||||
|
||||
@@ -1,15 +1,30 @@
|
||||
<script lang="ts" setup>
|
||||
const { random, randomRecipe } = useRandomRecipe()
|
||||
const { count, inc, dec } = useCount()
|
||||
const { random, randomRecipes } = useRandomRecipe(count)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-show="randomRecipe">
|
||||
<div class="inline-flex items-center justify-center">
|
||||
<div>今天吃什么?</div>
|
||||
<div class="transition" hover="text-blue-500" i-ri-refresh-line inline-block cursor-pointer @click="random" />
|
||||
<div inline-flex m="y-3">
|
||||
<button rounded-full p-2 btn @click="dec()">
|
||||
<div i-carbon-subtract />
|
||||
</button>
|
||||
<div font="mono" w="15" m-auto inline-block>
|
||||
{{ count }}
|
||||
</div>
|
||||
<div m="t-2">
|
||||
<DishTag v-if="randomRecipe" :dish="randomRecipe" />
|
||||
<button rounded-full p-2 btn @click="inc()">
|
||||
<div i-carbon-add />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-show="randomRecipes.length > 0">
|
||||
<button cursor-pointer class="inline-flex inline-flex items-center justify-center rounded-md border-none bg-blue-600 px-3 py-1.5 text-sm font-semibold leading-6 text-white shadow-sm hover:bg-blue-500 focus-visible:outline-2 focus-visible:outline-blue-600 focus-visible:outline-offset-2 focus-visible:outline" @click="random">
|
||||
<div class="transition" hover="text-blue-500" i-ri-refresh-line mr-1 inline-flex />
|
||||
<div>随机一下</div>
|
||||
</button>
|
||||
<div m="t-8" flex="~ col">
|
||||
<template v-for="recipe, i in randomRecipes" :key="i">
|
||||
<DishTag v-if="recipe" :dish="recipe" />
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -29,36 +29,54 @@ const showTooltip = computed(() => !selectedStuff.value.length && !curTool.value
|
||||
<SearchFoodInput v-if="showSearchInput" />
|
||||
|
||||
<Transition mode="out-in">
|
||||
<div class="cook-filter-recipes">
|
||||
<span v-if="showTooltip" text="sm" p="2">
|
||||
你要先选食材或工具哦~
|
||||
</span>
|
||||
<span v-if="showTooltip" text="sm" p="2">
|
||||
你要先选食材或工具哦~
|
||||
</span>
|
||||
|
||||
<div v-else-if="rStore.displayedRecipe.length">
|
||||
<DishTag v-for="item, i in rStore.displayedRecipe" :key="i" :dish="item" />
|
||||
</div>
|
||||
<div
|
||||
v-else-if="rStore.isSearching"
|
||||
relative flex items-center justify-center p-6
|
||||
text-xl
|
||||
>
|
||||
<div class="magnifying-glass" i-ri-search-line inline-flex />
|
||||
</div>
|
||||
|
||||
<div v-else text="sm">
|
||||
<span>还没有完美匹配的菜谱呢……</span>
|
||||
<br>
|
||||
<span>大胆尝试一下,或者</span>
|
||||
<a href="#" @click="rStore.reset()">
|
||||
<strong>换个组合</strong>
|
||||
</a>
|
||||
<span>?</span>
|
||||
<br>
|
||||
<div m="t-1">
|
||||
<span>欢迎来</span>
|
||||
<a class="font-bold text-blue-600 dark:text-blue-400" href="https://docs.qq.com/sheet/DQk1vdkhFV0twQVNS?tab=uykkic" target="_blank">这里</a>
|
||||
<span>反馈新的菜谱!</span>
|
||||
</div>
|
||||
<div v-else-if="rStore.displayedRecipe.length">
|
||||
<DishTag v-for="item, i in rStore.displayedRecipe" :key="i" :dish="item" />
|
||||
</div>
|
||||
|
||||
<div v-else text="sm">
|
||||
<span>还没有完美匹配的菜谱呢……</span>
|
||||
<br>
|
||||
<span>大胆尝试一下,或者</span>
|
||||
<a href="#" @click="rStore.reset()">
|
||||
<strong>换个组合</strong>
|
||||
</a>
|
||||
<span>?</span>
|
||||
<br>
|
||||
<div m="t-1">
|
||||
<span>欢迎来</span>
|
||||
<a class="font-bold text-blue-600 dark:text-blue-400" href="https://docs.qq.com/sheet/DQk1vdkhFV0twQVNS?tab=uykkic" target="_blank">这里</a>
|
||||
<span>反馈新的菜谱!</span>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
|
||||
<hr m="y-2">
|
||||
|
||||
<RandomRecipe />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
@keyframes circle-rotate {
|
||||
from {
|
||||
transform: rotate(0turn) translateY(60%) rotate(1turn);
|
||||
}
|
||||
to {
|
||||
transform: rotate(1turn) translateY(60%) rotate(0turn);
|
||||
}
|
||||
}
|
||||
|
||||
.magnifying-glass {
|
||||
margin: auto;
|
||||
animation: circle-rotate 4s linear infinite;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type { BottomMenuItem } from '@yunlefun/vue'
|
||||
import { ref } from 'vue'
|
||||
|
||||
const items: BottomMenuItem[] = [
|
||||
{
|
||||
@@ -12,14 +11,14 @@ const items: BottomMenuItem[] = [
|
||||
{
|
||||
icon: 'i-ri-compass-2-line',
|
||||
activeIcon: 'i-ri-compass-2-fill',
|
||||
title: '关于',
|
||||
to: '/about',
|
||||
title: '吃什么',
|
||||
to: '/random',
|
||||
},
|
||||
// {
|
||||
// icon: 'i-ri-user-line',
|
||||
// activeIcon: 'i-ri-user-fill',
|
||||
// title: '我的',
|
||||
// to: '/user',
|
||||
// icon: 'i-ri-compass-2-line',
|
||||
// activeIcon: 'i-ri-compass-2-fill',
|
||||
// title: '吃什么',
|
||||
// to: '/about',
|
||||
// },
|
||||
{
|
||||
icon: 'i-ri-question-line',
|
||||
@@ -27,25 +26,31 @@ const items: BottomMenuItem[] = [
|
||||
title: '帮助',
|
||||
to: '/help',
|
||||
},
|
||||
{
|
||||
icon: 'i-ri-user-line',
|
||||
activeIcon: 'i-ri-user-fill',
|
||||
title: '我的',
|
||||
to: '/user',
|
||||
},
|
||||
]
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const active = ref(route.path)
|
||||
function onClick(item: BottomMenuItem) {
|
||||
active.value = item.to || ''
|
||||
router.push(item.to || '/')
|
||||
// router.push(item.to || '/')
|
||||
router.replace(item.to || '/')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<YlfBottomMenu shadow-2xl>
|
||||
<YlfBottomMenu shadow-2xl pb="$cook-bottom-menu-padding-bottom">
|
||||
<YlfBottomMenuItem
|
||||
v-for="item in items"
|
||||
:key="item.to"
|
||||
:item="item"
|
||||
:active="active === item.to"
|
||||
:active="route.path === item.to"
|
||||
class="pt-3"
|
||||
@click="onClick"
|
||||
/>
|
||||
</YlfBottomMenu>
|
||||
|
||||
13
components/common/BackBtn.vue
Normal file
13
components/common/BackBtn.vue
Normal file
@@ -0,0 +1,13 @@
|
||||
<script lang="ts" setup>
|
||||
const router = useRouter()
|
||||
function back() {
|
||||
router.back()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<YlfIconButton
|
||||
icon="i-ri-arrow-left-s-line"
|
||||
@click="back"
|
||||
/>
|
||||
</template>
|
||||
@@ -15,7 +15,11 @@ function toggleDark() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button class="mx-2 icon-btn hover:text-yellow-400 !outline-none" title="切换" @click="toggleDark()">
|
||||
<YlfIconButton
|
||||
class="icon-btn hover:text-yellow-400 !outline-none"
|
||||
text-xl
|
||||
title="切换" @click="toggleDark()"
|
||||
>
|
||||
<div i="ri-sun-line dark:ri-moon-line" />
|
||||
</button>
|
||||
</YlfIconButton>
|
||||
</template>
|
||||
@@ -1,18 +1,18 @@
|
||||
<template>
|
||||
<div>
|
||||
<NuxtLink class="mx-2 icon-btn hover:text-orange-400" to="/help" title="帮助">
|
||||
<NuxtLink class="icon-btn mx-2 hover:text-orange-400" to="/help" title="帮助">
|
||||
<div i-ri-question-line />
|
||||
</NuxtLink>
|
||||
|
||||
<NuxtLink class="mx-2 icon-btn hover:text-blue-400" to="/about" title="关于">
|
||||
<NuxtLink class="icon-btn mx-2 hover:text-blue-400" to="/about" title="关于">
|
||||
<div i-ri-information-line />
|
||||
</NuxtLink>
|
||||
|
||||
<a class="mx-2 icon-btn hover:text-pink-400" rel="noreferrer" href="https://space.bilibili.com/1579790" target="_blank" title="BiliBili">
|
||||
<a class="icon-btn mx-2 hover:text-pink-400" rel="noreferrer" href="https://space.bilibili.com/1579790" target="_blank" title="BiliBili">
|
||||
<div i-ri-bilibili-line />
|
||||
</a>
|
||||
|
||||
<a class="hover:text-black-400 mx-2 icon-btn" rel="noreferrer" href="https://github.com/YunYouJun/cook" target="_blank" title="GitHub">
|
||||
<a class="icon-btn hover:text-black-400 mx-2" rel="noreferrer" href="https://github.com/YunYouJun/cook" target="_blank" title="GitHub">
|
||||
<div i-ri-github-line />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
31
components/cookbook/CookbookCard.vue
Normal file
31
components/cookbook/CookbookCard.vue
Normal file
@@ -0,0 +1,31 @@
|
||||
<script lang="ts" setup>
|
||||
import type { Cookbook } from '~/types'
|
||||
|
||||
defineProps<{
|
||||
cookbook: Cookbook
|
||||
}>()
|
||||
|
||||
const showDetail = ref(false)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button
|
||||
class="bg-$c-bg-alt"
|
||||
h-36 w-full inline-flex cursor-pointer items-center justify-center shadow
|
||||
@click="showDetail = true"
|
||||
>
|
||||
<slot />
|
||||
</button>
|
||||
|
||||
<CookbookDetail
|
||||
v-if="showDetail"
|
||||
absolute bottom-17 left-2 right-2 top-2 z-1 overflow-hidden shadow
|
||||
:cookbook="cookbook"
|
||||
>
|
||||
<YlfIconButton
|
||||
icon="i-ri-close-line"
|
||||
class="absolute right-2 top-2"
|
||||
@click="showDetail = false"
|
||||
/>
|
||||
</CookbookDetail>
|
||||
</template>
|
||||
27
components/cookbook/CookbookDetail.vue
Normal file
27
components/cookbook/CookbookDetail.vue
Normal file
@@ -0,0 +1,27 @@
|
||||
<script lang="ts" setup>
|
||||
import type { Cookbook } from '~/types'
|
||||
|
||||
const props = defineProps<{
|
||||
cookbook: Cookbook
|
||||
}>()
|
||||
|
||||
const recipes = ref<Cookbook['recipes']>(props.cookbook.recipes)
|
||||
onMounted(async () => {
|
||||
recipes.value = ((await import('../../data/recipe.json')).default) as unknown as Cookbook['recipes']
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="bg-$c-bg-alt" flex="~ col">
|
||||
<h3 mt-4 font-bold>
|
||||
{{ cookbook.title }}
|
||||
</h3>
|
||||
<sub op="90" my-3>
|
||||
{{ cookbook.description }}
|
||||
</sub>
|
||||
<div mx-auto mt-2 p-0 border="1px" overflow-y="scroll">
|
||||
<RecipeTable h="full" :recipes="recipes" />
|
||||
</div>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
18
components/cookbook/NewCookbookCard.vue
Normal file
18
components/cookbook/NewCookbookCard.vue
Normal file
@@ -0,0 +1,18 @@
|
||||
<script lang="ts" setup>
|
||||
definePageMeta({
|
||||
layout: 'child',
|
||||
title: '新建食谱书',
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NuxtLink
|
||||
class="bg-$c-bg-alt"
|
||||
h-36 w-full inline-flex cursor-pointer items-center justify-center shadow
|
||||
to="/cookbooks/new"
|
||||
>
|
||||
<slot>
|
||||
<div i-ri-add-line />
|
||||
</slot>
|
||||
</NuxtLink>
|
||||
</template>
|
||||
20
components/layout/CurrentVersion.vue
Normal file
20
components/layout/CurrentVersion.vue
Normal file
@@ -0,0 +1,20 @@
|
||||
<script lang="ts" setup>
|
||||
import pkg from '~/package.json'
|
||||
|
||||
const commitSha = (import.meta.env.VITE_COMMIT_REF || '').slice(0, 7)
|
||||
const now = import.meta.env.VITE_APP_BUILD_TIME
|
||||
const buildDate = (new Date(Number.parseInt(now) * 1000)).toLocaleDateString()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="commitSha && buildDate" mb-2 text-sm>
|
||||
<span>
|
||||
当前版本 v{{ pkg.version }}({{ buildDate }}):
|
||||
</span>
|
||||
<span>
|
||||
<a border="b-1 dashed" :href="`https://github.com/YunYouJun/cook/commit/${commitSha}`" target="_blank" alt="Cook | GitHub Commit">
|
||||
{{ commitSha }}
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
22
components/layout/SimpleCopyright.vue
Normal file
22
components/layout/SimpleCopyright.vue
Normal file
@@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<div text="center sm" my-3>
|
||||
<CurrentVersion />
|
||||
<div flex="~" items-center justify-center gap="2">
|
||||
<a
|
||||
href="https://github.com/YunYouJun/cook" target="_blank"
|
||||
class="inline-flex items-center justify-center"
|
||||
>
|
||||
<div i-ri-github-line mr-1 />
|
||||
<span>Code</span>
|
||||
</a>
|
||||
by
|
||||
<a
|
||||
href="https://www.bilibili.com/opus/649847454294868008" target="_blank"
|
||||
class="inline-flex items-center justify-center"
|
||||
>
|
||||
<div i-ri-bilibili-line mr-1 class="text-pink-400" />
|
||||
<span>云游君</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
46
components/recipe/RecipeTable.vue
Normal file
46
components/recipe/RecipeTable.vue
Normal file
@@ -0,0 +1,46 @@
|
||||
<script lang="ts" setup>
|
||||
import type { Recipes } from '~/types'
|
||||
|
||||
defineProps<{
|
||||
recipes: Recipes
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<table
|
||||
class="recipe-table bg-$c-bg"
|
||||
overflow="auto" h="full"
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th />
|
||||
<th>
|
||||
名称
|
||||
</th>
|
||||
<th>
|
||||
工具
|
||||
</th>
|
||||
<th>
|
||||
材料
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<RecipeTableItem
|
||||
v-for="(recipe, i) in recipes"
|
||||
:key="recipe.name"
|
||||
:index="i" :recipe="recipe"
|
||||
/>
|
||||
</tbody>
|
||||
</table>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
.recipe-table {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
tr, th, td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
31
components/recipe/RecipeTableItem.vue
Normal file
31
components/recipe/RecipeTableItem.vue
Normal file
@@ -0,0 +1,31 @@
|
||||
<script lang="ts" setup>
|
||||
import type { RecipeItem } from '~/types'
|
||||
|
||||
defineProps<{
|
||||
index: number
|
||||
recipe: RecipeItem
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<tr>
|
||||
<td>
|
||||
{{ index }}
|
||||
</td>
|
||||
<td>
|
||||
<a
|
||||
class="text-blue-500" font-bold
|
||||
:href="recipe.link || `https://www.bilibili.com/video/${recipe.bv}`"
|
||||
target="_blank"
|
||||
>
|
||||
{{ recipe.name }}
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ recipe.tools.join('、') }}
|
||||
</td>
|
||||
<td>
|
||||
{{ recipe.stuff.join('、') }}
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
@@ -1,10 +1,11 @@
|
||||
<script lang="ts" setup>
|
||||
import type { DbRecipeItem } from '~/utils/db'
|
||||
import { tools } from '~/data/food'
|
||||
import type { RecipeItem } from '~/types'
|
||||
import { getEmojisFromStuff } from '~/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
dish: RecipeItem
|
||||
dish: RecipeItem | DbRecipeItem
|
||||
}>()
|
||||
|
||||
const gtm = useGtm()
|
||||
|
||||
24
components/ylf/YlfForm.vue
Normal file
24
components/ylf/YlfForm.vue
Normal file
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<div class="ylf-form" flex="~ col" rounded-md>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
.ylf-form {
|
||||
background-color: var(--ylf-c-bg-alt);
|
||||
|
||||
border: 1px solid var(--ylf-c-border);
|
||||
|
||||
margin: 10px 0;
|
||||
overflow: hidden;
|
||||
|
||||
.ylf-form-item {
|
||||
border-bottom: 1px solid var(--ylf-c-border);
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
33
components/ylf/YlfFormItem.vue
Normal file
33
components/ylf/YlfFormItem.vue
Normal file
@@ -0,0 +1,33 @@
|
||||
<script lang="ts" setup>
|
||||
import { NuxtLink } from '#components'
|
||||
|
||||
defineProps<{
|
||||
icon?: string
|
||||
label?: string
|
||||
/**
|
||||
* Router link
|
||||
*/
|
||||
to?: string
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<component
|
||||
:is="to ? NuxtLink : 'div'"
|
||||
:to="to"
|
||||
class="ylf-form-item"
|
||||
w-full flex cursor-pointer items-center justify-between p-3
|
||||
hover:bg-gray-100
|
||||
dark:hover:bg-dark-400
|
||||
>
|
||||
<div v-if="label" class="text-md" inline-flex items-center justify-center>
|
||||
<div v-if="icon" :class="icon" mr-2 inline-flex />
|
||||
<span>{{ label }}</span>
|
||||
</div>
|
||||
<div inline-flex>
|
||||
<slot>
|
||||
<div v-if="to" i-ri-arrow-right-s-line />
|
||||
</slot>
|
||||
</div>
|
||||
</component>
|
||||
</template>
|
||||
16
components/ylf/YlfIconButton.vue
Normal file
16
components/ylf/YlfIconButton.vue
Normal file
@@ -0,0 +1,16 @@
|
||||
<script lang="ts" setup>
|
||||
defineProps<{
|
||||
icon?: string
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button
|
||||
class="ylf-icon-button hover:(bg-blue-300 bg-opacity-20)"
|
||||
h-10 w-10 inline-flex items-center justify-center rounded-full
|
||||
>
|
||||
<slot>
|
||||
<div v-if="icon" text-xl :class="icon" />
|
||||
</slot>
|
||||
</button>
|
||||
</template>
|
||||
28
components/ylf/YlfSwitch.vue
Normal file
28
components/ylf/YlfSwitch.vue
Normal file
@@ -0,0 +1,28 @@
|
||||
<script lang="ts" setup>
|
||||
import { Switch } from '@headlessui/vue'
|
||||
|
||||
defineProps<{
|
||||
modelValue: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
function updateModelValue(value: boolean) {
|
||||
emit('update:modelValue', value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Switch
|
||||
:model-value="modelValue"
|
||||
:class="modelValue ? 'bg-blue-600' : 'bg-gray'"
|
||||
class="relative h-6 w-11 inline-flex shrink-0 cursor-pointer border-2 border-transparent rounded-full transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75"
|
||||
@update:model-value="updateModelValue"
|
||||
>
|
||||
<span class="sr-only">Use setting</span>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
:class="modelValue ? 'translate-x-5' : 'translate-x-0'"
|
||||
class="pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out"
|
||||
/>
|
||||
</Switch>
|
||||
</template>
|
||||
20
composables/count.ts
Normal file
20
composables/count.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { useStorage } from '@vueuse/core'
|
||||
|
||||
export function useCount() {
|
||||
const count = useStorage('count', 5)
|
||||
|
||||
function inc() {
|
||||
count.value += 1
|
||||
}
|
||||
function dec() {
|
||||
if (count.value <= 1)
|
||||
return
|
||||
count.value -= 1
|
||||
}
|
||||
|
||||
return {
|
||||
count,
|
||||
inc,
|
||||
dec,
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,11 @@ export function useIndexedDB() {
|
||||
const dbUpdated = useStorage(`${namespace}:lastDbUpdated`, lastDbUpdated)
|
||||
|
||||
return {
|
||||
// db,
|
||||
// initDb,
|
||||
init: async () => {
|
||||
const count = await db.recipes.count()
|
||||
if (!count || dbUpdated.value !== lastDbUpdated) {
|
||||
await initDb()
|
||||
dbUpdated.value = lastDbUpdated
|
||||
initDb()
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import { isClient, useElementBounding } from '@vueuse/core'
|
||||
/**
|
||||
* trigger show invisible element
|
||||
* @param target
|
||||
* @returns
|
||||
*/
|
||||
export function useInvisibleElement(target: MaybeComputedElementRef<HTMLElement>) {
|
||||
const { top } = useElementBounding(target)
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
import recipeData from '~/data/recipe.json'
|
||||
import type { RecipeItem, Recipes } from '~/types'
|
||||
import type { DbRecipeItem } from '~/utils/db'
|
||||
|
||||
export function useRandomRecipe() {
|
||||
const randomRecipe = ref<RecipeItem>()
|
||||
function random() {
|
||||
randomRecipe.value = generateRandomRecipe(recipeData as Recipes)
|
||||
/**
|
||||
* 随机几道菜
|
||||
* @param total
|
||||
*/
|
||||
export function useRandomRecipe(total: Ref<number>) {
|
||||
const randomRecipes = ref<(DbRecipeItem | undefined)[]>([])
|
||||
async function random() {
|
||||
const length = await db.recipes.count()
|
||||
const randomArr = generateRandomArray(length, total.value)
|
||||
const result = await db.recipes.bulkGet(randomArr)
|
||||
if (result)
|
||||
randomRecipes.value = result.filter(item => !!item)
|
||||
}
|
||||
|
||||
watch(total, () => {
|
||||
random()
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
random()
|
||||
})
|
||||
@@ -14,6 +25,6 @@ export function useRandomRecipe() {
|
||||
return {
|
||||
random,
|
||||
|
||||
randomRecipe,
|
||||
randomRecipes,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
import { acceptHMRUpdate, defineStore } from 'pinia'
|
||||
import { useStorage } from '@vueuse/core'
|
||||
import { ref } from 'vue'
|
||||
import { defaultSettings } from '~/utils/settings'
|
||||
import { namespace } from '~/constants'
|
||||
|
||||
export const useAppStore = defineStore('app', () => {
|
||||
const deferredPrompt = ref<Event | any>()
|
||||
const settings = useStorage(`${namespace}:settings`, defaultSettings)
|
||||
|
||||
return {
|
||||
deferredPrompt,
|
||||
|
||||
settings,
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ import { acceptHMRUpdate, defineStore } from 'pinia'
|
||||
import { useStorage } from '@vueuse/core'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useGtm } from '@gtm-support/vue-gtm'
|
||||
import type { RecipeItem } from 'types'
|
||||
import type { StuffItem } from '../../data/food'
|
||||
import { db } from '../../utils/db'
|
||||
import { useAppStore } from './app'
|
||||
import type { RecipeItem, StuffItem } from '~/types'
|
||||
|
||||
const namespace = 'cook'
|
||||
|
||||
@@ -17,6 +17,7 @@ export type SearchMode = 'survival' | 'loose' | 'strict'
|
||||
|
||||
export const useRecipeStore = defineStore('recipe', () => {
|
||||
const gtm = useGtm()
|
||||
const { settings } = useAppStore()
|
||||
|
||||
/**
|
||||
* 搜索关键字
|
||||
@@ -24,10 +25,10 @@ export const useRecipeStore = defineStore('recipe', () => {
|
||||
const keyword = ref('')
|
||||
|
||||
// can not exported
|
||||
const curStuff = useStorage(`${namespace}:stuff`, new Set<string>())
|
||||
const curStuff = settings.keepLocalData ? useStorage(`${namespace}:stuff`, new Set<string>()) : ref(new Set<string>())
|
||||
// const curTools = ref(new Set<string>())
|
||||
const curTool = useStorage(`${namespace}:tool`, '')
|
||||
const curMode = useStorage<SearchMode>(`${namespace}:mode`, 'loose')
|
||||
const curTool = settings.keepLocalData ? useStorage(`${namespace}:tool`, '') : ref('')
|
||||
const curMode = settings.keepLocalData ? useStorage<SearchMode>(`${namespace}:mode`, 'loose') : ref<SearchMode>('loose')
|
||||
|
||||
const selectedStuff = computed(() => Array.from(curStuff.value))
|
||||
// const selectedTools = computed(() => Array.from(curTools.value))
|
||||
@@ -70,25 +71,25 @@ export const useRecipeStore = defineStore('recipe', () => {
|
||||
curStuff.value.add(name)
|
||||
}
|
||||
|
||||
const isSearching = ref(false)
|
||||
/**
|
||||
* 搜索菜谱
|
||||
* @returns
|
||||
*/
|
||||
async function searchRecipes() {
|
||||
if (keyword.value) {
|
||||
const result = await db.recipes.filter(item => item.name.includes(keyword.value)).toArray()
|
||||
return result
|
||||
}
|
||||
isSearching.value = true
|
||||
let result: RecipeItem[] = []
|
||||
if (keyword.value)
|
||||
result = await db.recipes.filter(item => item.name.includes(keyword.value)).toArray()
|
||||
|
||||
if (curMode.value === 'strict') {
|
||||
return await db.recipes.filter((item) => {
|
||||
result = await db.recipes.filter((item) => {
|
||||
const stuffFlag = selectedStuff.value.every(stuff => item.stuff.includes(stuff))
|
||||
const toolFlag = item.tools.includes(curTool.value)
|
||||
return curTool.value ? (stuffFlag && toolFlag) : stuffFlag
|
||||
}).toArray()
|
||||
}
|
||||
else if (curMode.value === 'loose') {
|
||||
return await db.recipes.filter((item) => {
|
||||
result = await db.recipes.filter((item) => {
|
||||
const stuffFlag = selectedStuff.value.some(stuff => item.stuff.includes(stuff))
|
||||
const toolFlag = Boolean(item.tools?.includes(curTool.value))
|
||||
|
||||
@@ -108,12 +109,15 @@ export const useRecipeStore = defineStore('recipe', () => {
|
||||
}
|
||||
// survival
|
||||
else {
|
||||
return await db.recipes.filter((item) => {
|
||||
result = await db.recipes.filter((item) => {
|
||||
const stuffFlag = item.stuff.every(stuff => selectedStuff.value.includes(stuff))
|
||||
const toolFlag = item.tools?.includes(curTool.value)
|
||||
return Boolean(curTool.value ? (stuffFlag && toolFlag) : stuffFlag)
|
||||
}).toArray()
|
||||
}
|
||||
|
||||
isSearching.value = false
|
||||
return result
|
||||
}
|
||||
|
||||
// 默认严格模式
|
||||
@@ -159,6 +163,8 @@ export const useRecipeStore = defineStore('recipe', () => {
|
||||
curMode,
|
||||
selectedStuff,
|
||||
|
||||
isSearching,
|
||||
|
||||
clearKeyWord: () => { keyword.value = '' },
|
||||
toggleStuff,
|
||||
toggleTools,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const appName = '隔离食用手册'
|
||||
export const appName = '食用手册'
|
||||
export const appDescription = '好的,今天我们来做菜!'
|
||||
|
||||
export const namespace = 'cook'
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
---
|
||||
title: 关于
|
||||
---
|
||||
|
||||
:AboutMenu
|
||||
|
||||
### **🍜 好的,今天我们来做菜!**
|
||||
|
||||
> 希望大家吃的开心!
|
||||
|
||||
<div class="inline-flex justify-center items-center">
|
||||
- 代码仓库:<a class="inline-flex items-center justify-center" href="https://github.com/YunYouJun/cook" target="_blank">
|
||||
<div m="r-1" inline-flex i-ri-github-line></div>YunYouJun/cook</a>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
<div class="inline-flex justify-center items-center">
|
||||
- 菜谱主要视频来源:
|
||||
<a class="inline-flex items-center text-sm text-blue-600 dark:text-blue-400" href="https://docs.qq.com/sheet/DQk1vdkhFV0twQVNS" target="_blank">
|
||||
<div m="r-1" inline-flex i-ri-bilibili-line></div>
|
||||
<span class="inline-flex">隔离食用手册大全</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
相关使用请查看 <router-link to="/help">帮助</router-link>。
|
||||
|
||||
## **致谢**
|
||||
|
||||
感谢以下小伙伴为本项目提供的数据支持和 QA !
|
||||
|
||||
- [Runny](https://weibo.com/runny)
|
||||
- 山竹太凉
|
||||
- leo
|
||||
- 麒麟
|
||||
- 晴方啾
|
||||
- 课代表阿伟
|
||||
|
||||
## **关于我**
|
||||
|
||||
Hello,我是云游君。
|
||||
|
||||
很高兴能在这里与你相遇,也很希望这个网站可以真的帮助到你。
|
||||
|
||||
同时,我也以我或许不值一提的脸面保证它会以免费开源的形式维护运营下去。
|
||||
|
||||
此外,我也会继续尝试做一些有趣或有用的东西,并分享给大家。
|
||||
你也可以在这些地方找到我。
|
||||
|
||||
:AboutMe
|
||||
|
||||
对了,给微信公众号「云游君」发送「做菜」也可以快速找到这个网址。
|
||||
|
||||
## 赞助者
|
||||
|
||||
也非常感谢至今以来的所有赞助者们!
|
||||
|
||||
如果觉得我的[小项目们](https://sponsors.yunyoujun.cn/projects)还算有趣的话,要不要考虑[赞助](https://sponsors.yunyoujun.cn/)我?
|
||||
|
||||
我会将其公开在[账簿](https://sponsors.yunyoujun.cn/account)中,并投入在周边的服务器、域名、CDN 等费用上。
|
||||
|
||||
<a href="https://sponsors.yunyoujun.cn" target="_blank">
|
||||
<img src='https://sponsors.yunyoujun.cn/sponsors.svg'/>
|
||||
</a>
|
||||
@@ -1,7 +0,0 @@
|
||||
---
|
||||
title: 微信公众号
|
||||
---
|
||||
|
||||
我的个人微信公众号「云游君」,会分享一些生活和写的[小玩具们](https://sponsors.yunyoujun.cn/projects)。
|
||||
|
||||

|
||||
27
data/food.ts
27
data/food.ts
@@ -1,29 +1,4 @@
|
||||
export interface StuffItem {
|
||||
/**
|
||||
* 食材名称
|
||||
*/
|
||||
name: string
|
||||
/**
|
||||
* 例如:🥔
|
||||
*/
|
||||
emoji: string
|
||||
/**
|
||||
* 图片链接
|
||||
*/
|
||||
image?: string
|
||||
/**
|
||||
* 别名,譬如:西红柿/番茄
|
||||
*/
|
||||
alias?: string
|
||||
/**
|
||||
* 图标名称
|
||||
*/
|
||||
icon?: string
|
||||
/**
|
||||
* 显示标签
|
||||
*/
|
||||
label?: string
|
||||
}
|
||||
import type { StuffItem } from '../types'
|
||||
|
||||
/**
|
||||
* 素菜
|
||||
|
||||
@@ -184,10 +184,8 @@ BBQ烟熏手撕猪肉,猪肉,BV1DV411x7SH,复杂,,烤,烤箱,
|
||||
微波炉版土豆浓汤,土豆、胡萝卜,BV1HL411E7MM,简单,早饭,微波加热,微波炉,
|
||||
微波炉版煲仔饭,米、香肠、鸡蛋,BV145411f7R4,简单,主食,微波加热,微波炉,
|
||||
微波炉版燕麦粥,米,BV1cF411Y7pd,,主食,微波加热,微波炉,
|
||||
微波炉版抱蛋水饺,面食、鸡蛋,BV1zL411x7CU,,,,微波炉,
|
||||
微波炉版叉烧肉,猪肉、米,BV1Hi4y1s7Sc,,,微波加热,微波炉,
|
||||
微波炉版蛋炒饭,米、鸡蛋、香肠,BV1T34y147qU,简单,,微波加热,微波炉,
|
||||
微波炉版番茄炒蛋,鸡蛋、番茄、米,BV1zL411x7CU,,,,微波炉,
|
||||
微波炉版番茄鸡蛋汤,番茄、鸡蛋,BV1qx411n7QF,,,,微波炉,
|
||||
微波炉版番茄肉盒,番茄、猪肉、青椒,BV194411R7aH,,,微波加热,微波炉,
|
||||
微波炉版肥牛饭,牛肉、洋葱、鸡蛋、米,BV1gh411Y7TU,,,,微波炉,
|
||||
@@ -207,13 +205,10 @@ BBQ烟熏手撕猪肉,猪肉,BV1DV411x7SH,复杂,,烤,烤箱,
|
||||
微波炉版牛奶炖饭,米,BV1W7411c7As,简单,,微波加热,微波炉,
|
||||
微波炉版日式嫩蒸鸡胸肉,鸡肉,BV1xu41197tU,,,,微波炉,
|
||||
微波炉版烧烤茄子,茄子,BV19x411H7ig,,,,微波炉,
|
||||
微波炉版蔬菜烘蛋,鸡蛋、猪肉、胡萝卜,BV1zL411x7CU,,,,微波炉,
|
||||
微波炉版酸辣土豆丝,土豆,BV1zL411x7CU,,,,微波炉,
|
||||
微波炉版蒜香烤茄子,茄子,BV19x411H7ig,简单,,微波加热,微波炉,
|
||||
微波炉版蒜香琵琶腿,鸡肉,BV1qx411777p,,,,微波炉,
|
||||
微波炉版吐司杯,鸡蛋、面包,BV1CS4y1k7Xi,,,微波加热,微波炉,
|
||||
微波炉版五花肉,猪肉、米,BV1hL4y137Zk,,,微波加热,微波炉,
|
||||
微波炉版鲜虾面,面食、虾、胡萝卜、方便面,BV1zL411x7CU,,,,微波炉,
|
||||
微波炉版香干,豆腐,BV1F44y1T7sQ,,,微波加热,微波炉,
|
||||
微波炉版香辣豆腐,豆腐、米,BV1bT4y1o7dv,,,,微波炉,
|
||||
微波炉版香嫩鸡胸肉,鸡肉,BV1xu41197tU,,,,微波炉,
|
||||
@@ -222,7 +217,6 @@ BBQ烟熏手撕猪肉,猪肉,BV1DV411x7SH,复杂,,烤,烤箱,
|
||||
微波炉版照烧鸡腿饭,米、鸡肉、胡萝卜、花菜,BV16Z4y1V774,,,,微波炉,
|
||||
微波炉版蒸蛋羹,鸡蛋,BV19T4y1D7Zd,,,,微波炉,
|
||||
微波炉版煮米饭,米,BV193411W7nb,,,,微波炉,
|
||||
微波炉版孜然豆腐丁,豆腐,BV1zL411x7CU,,,,微波炉,
|
||||
豉油鸡翅,鸡肉,BV1vz4y1d775,普通,茶餐厅,煮,一口大锅,
|
||||
水煮肉片,猪肉、芹菜、莴笋,BV1ZZ4y1379N,普通,川菜,炒,一口大锅,
|
||||
脆口黄瓜,黄瓜,BV1Tb4y1X7ow,简单,脆口,凉拌,一口大锅,
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
7
eslint.config.js
Normal file
7
eslint.config.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import antfu from '@antfu/eslint-config'
|
||||
import unocss from '@unocss/eslint-config/flat'
|
||||
|
||||
export default antfu(
|
||||
{},
|
||||
unocss,
|
||||
)
|
||||
22
layouts/child.vue
Normal file
22
layouts/child.vue
Normal file
@@ -0,0 +1,22 @@
|
||||
<script lang="ts" setup>
|
||||
defineProps<{
|
||||
title?: string
|
||||
}>()
|
||||
|
||||
const route = useRoute()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="text-center text-gray-700 dark:text-gray-200" p="t-5 b-15">
|
||||
<div flex items-center justify-between>
|
||||
<BackBtn ml-3 />
|
||||
<h2 flex items-center justify-center text-lg>
|
||||
{{ route.meta.title }}
|
||||
</h2>
|
||||
<DarkToggle mr-3 />
|
||||
</div>
|
||||
|
||||
<slot />
|
||||
<TheBottomMenu fixed bottom-0 left-0 right-0 />
|
||||
</main>
|
||||
</template>
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<main class="text-center text-gray-700 dark:text-gray-200" p="b-15">
|
||||
<main class="cook-main text-center text-gray-700 dark:text-gray-200" p="t-8 b-$cook-bottom-menu-height">
|
||||
<slot />
|
||||
<DarkToggle absolute right-5 top-5 />
|
||||
<DarkToggle absolute right-3 top-5 />
|
||||
<TheBottomMenu fixed bottom-0 left-0 right-0 />
|
||||
</main>
|
||||
</template>
|
||||
|
||||
@@ -15,7 +15,7 @@ export default defineNuxtConfig({
|
||||
'@pinia/nuxt',
|
||||
'@nuxtjs/color-mode',
|
||||
'@vite-pwa/nuxt',
|
||||
'@nuxt/content',
|
||||
'nuxt-vitest',
|
||||
|
||||
'@zadigetvoltaire/nuxt-gtm',
|
||||
|
||||
@@ -27,7 +27,6 @@ export default defineNuxtConfig({
|
||||
// but missing on offline, disabling extraction it until fixed
|
||||
payloadExtraction: false,
|
||||
inlineSSRStyles: false,
|
||||
renderJsonPayloads: true,
|
||||
typedPages: true,
|
||||
},
|
||||
|
||||
@@ -49,7 +48,7 @@ export default defineNuxtConfig({
|
||||
},
|
||||
prerender: {
|
||||
crawlLinks: false,
|
||||
routes: ['/'],
|
||||
routes: ['/', '/random', '/help', '/user', '/404', '/settings'],
|
||||
ignore: ['/hi'],
|
||||
},
|
||||
},
|
||||
@@ -62,7 +61,7 @@ export default defineNuxtConfig({
|
||||
{ rel: 'apple-touch-icon', href: '/apple-touch-icon.png' },
|
||||
],
|
||||
meta: [
|
||||
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
||||
{ name: 'viewport', content: 'width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no' },
|
||||
{ name: 'description', content: appDescription },
|
||||
{ name: 'apple-mobile-web-app-status-bar-style', content: 'black-translucent' },
|
||||
],
|
||||
|
||||
62
package.json
62
package.json
@@ -1,14 +1,15 @@
|
||||
{
|
||||
"type": "module",
|
||||
"version": "1.1.8",
|
||||
"private": true,
|
||||
"version": "1.1.3",
|
||||
"packageManager": "pnpm@8.6.10",
|
||||
"packageManager": "pnpm@8.10.2",
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run convert && cross-env VITE_APP_BUILD_TIME=$(date +%s) nuxi build",
|
||||
"convert": "tsx scripts/convert.ts",
|
||||
"dev": "cross-env VITE_APP_BUILD_TIME=$(date +%s) nuxi dev",
|
||||
"dev": "cross-env VITE_APP_BUILD_TIME=$(date +%s) nuxi dev --host",
|
||||
"dev:pwa": "VITE_PLUGIN_PWA=true nuxi dev",
|
||||
"generate": "nuxi generate",
|
||||
"start:generate": "npx serve .output/public",
|
||||
@@ -24,41 +25,42 @@
|
||||
"vue-about-me": "^1.2.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^0.39.8",
|
||||
"@headlessui/vue": "^1.7.15",
|
||||
"@iconify-json/carbon": "^1.1.18",
|
||||
"@iconify-json/fe": "^1.1.6",
|
||||
"@iconify-json/gg": "^1.1.5",
|
||||
"@iconify-json/ic": "^1.1.13",
|
||||
"@iconify-json/mdi": "^1.1.53",
|
||||
"@iconify-json/ri": "^1.1.10",
|
||||
"@iconify-json/twemoji": "^1.1.11",
|
||||
"@nuxt/content": "^2.7.2",
|
||||
"@nuxt/devtools": "^0.7.1",
|
||||
"@antfu/eslint-config": "^1.1.0",
|
||||
"@headlessui/vue": "^1.7.16",
|
||||
"@iconify-json/carbon": "^1.1.21",
|
||||
"@iconify-json/fe": "^1.1.7",
|
||||
"@iconify-json/gg": "^1.1.6",
|
||||
"@iconify-json/ic": "^1.1.14",
|
||||
"@iconify-json/mdi": "^1.1.55",
|
||||
"@iconify-json/ri": "^1.1.12",
|
||||
"@iconify-json/twemoji": "^1.1.12",
|
||||
"@nuxt/devtools": "^1.0.0",
|
||||
"@nuxtjs/color-mode": "^3.3.0",
|
||||
"@pinia/nuxt": "^0.4.11",
|
||||
"@pinia/nuxt": "^0.5.1",
|
||||
"@pinia/testing": "^0.1.3",
|
||||
"@unocss/eslint-config": "^0.54.0",
|
||||
"@unocss/nuxt": "^0.54.0",
|
||||
"@vite-pwa/nuxt": "^0.1.0",
|
||||
"@unocss/eslint-config": "^0.57.2",
|
||||
"@unocss/nuxt": "^0.57.2",
|
||||
"@vite-pwa/nuxt": "^0.1.1",
|
||||
"@vue/test-utils": "^2.4.1",
|
||||
"@vueuse/nuxt": "^10.2.1",
|
||||
"@yunlefun/vue": "^0.0.7",
|
||||
"@vueuse/nuxt": "^10.5.0",
|
||||
"@yunlefun/vue": "0.0.8-beta.4",
|
||||
"@zadigetvoltaire/nuxt-gtm": "^0.0.13",
|
||||
"consola": "^3.2.3",
|
||||
"cross-env": "^7.0.3",
|
||||
"dexie": "^3.2.4",
|
||||
"eslint": "^8.46.0",
|
||||
"fake-indexeddb": "^4.0.2",
|
||||
"eslint": "^8.53.0",
|
||||
"fake-indexeddb": "^5.0.1",
|
||||
"happy-dom": "^12.10.3",
|
||||
"jsdom": "^22.1.0",
|
||||
"nuxt": "^3.6.5",
|
||||
"pinia": "^2.1.6",
|
||||
"sass": "^1.64.1",
|
||||
"nuxt": "^3.8.0",
|
||||
"nuxt-vitest": "^0.11.2",
|
||||
"pinia": "^2.1.7",
|
||||
"sass": "^1.69.5",
|
||||
"star-markdown-css": "^0.4.2",
|
||||
"tsx": "^3.12.7",
|
||||
"typescript": "^5.1.6",
|
||||
"unocss": "^0.54.0",
|
||||
"vitest": "^0.33.0",
|
||||
"vue-tsc": "^1.8.8"
|
||||
"tsx": "^3.14.0",
|
||||
"typescript": "^5.2.2",
|
||||
"unocss": "^0.57.2",
|
||||
"vitest": "^0.34.6",
|
||||
"vue-tsc": "^1.8.22"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
const router = useRouter()
|
||||
// const router = useRouter()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -9,9 +9,9 @@ const router = useRouter()
|
||||
</div>
|
||||
<div>菜谱消失了</div>
|
||||
<div>
|
||||
<button text-sm btn m="3 t8" @click="router.back()">
|
||||
返回
|
||||
</button>
|
||||
<NuxtLink text-sm btn m="3 t8" to="/">
|
||||
返回主页
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<template>
|
||||
<main class="markdown-body px-4 text-left">
|
||||
<ContentDoc v-slot="{ doc }">
|
||||
<h1>{{ doc.title }}</h1>
|
||||
<ContentRenderer :value="doc" />
|
||||
</ContentDoc>
|
||||
</main>
|
||||
<BaseFooter />
|
||||
</template>
|
||||
5
pages/about.vue
Normal file
5
pages/about.vue
Normal file
@@ -0,0 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
关于
|
||||
</div>
|
||||
</template>
|
||||
22
pages/cookbooks/index.vue
Normal file
22
pages/cookbooks/index.vue
Normal file
@@ -0,0 +1,22 @@
|
||||
<script lang="ts" setup>
|
||||
definePageMeta({
|
||||
layout: 'child',
|
||||
title: '自定义菜谱',
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<h3>
|
||||
开发中,敬请期待
|
||||
</h3>
|
||||
|
||||
<div grid="~ cols-3" gap="4" p="4">
|
||||
<CookbookCard :cookbook="defaultCookbook">
|
||||
默认菜谱
|
||||
</CookbookCard>
|
||||
|
||||
<NewCookbookCard />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
5
pages/cookbooks/new.vue
Normal file
5
pages/cookbooks/new.vue
Normal file
@@ -0,0 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
新建 Cookbook
|
||||
</div>
|
||||
</template>
|
||||
124
pages/help.vue
124
pages/help.vue
@@ -1,14 +1,18 @@
|
||||
<template>
|
||||
<div class="w-full px-2 pt-8">
|
||||
<h1 text-2xl font="bold" my="4">
|
||||
<div class="w-full">
|
||||
<CommonHeader>
|
||||
帮助
|
||||
</h1>
|
||||
</CommonHeader>
|
||||
|
||||
<InstallPwa />
|
||||
|
||||
<FeedbackActions />
|
||||
|
||||
<div class="mx-auto max-w-md w-full rounded-2xl p-2" text-left>
|
||||
<FAQItem title="未来计划?">
|
||||
计划增加新功能,如自定义菜谱,与使用其他用户分享的菜谱。
|
||||
</FAQItem>
|
||||
|
||||
<FAQItem title="什么是模式?">
|
||||
<ul>
|
||||
<li><b>模糊匹配</b>:展示所有含当前选中任意食材的菜谱</li>
|
||||
@@ -26,6 +30,9 @@
|
||||
<FAQItem title="是否有微信小程序?">
|
||||
因不可抗力(小程序因跳转 B 站视频而被判定为导流违规)下架。
|
||||
将不再提供小程序版本。
|
||||
<br>
|
||||
<br>
|
||||
搜索微信公众号<b>「云游君」</b>并发送<b>「做菜」</b>,也可以快速找到本网站。
|
||||
</FAQItem>
|
||||
|
||||
<FAQItem title="是否有 APP?">
|
||||
@@ -36,6 +43,21 @@
|
||||
你可以使用浏览器打开,点击上方的<b>「安装到桌面」</b>或在菜单中点击<b>「添加到主屏幕」</b>。
|
||||
</FAQItem>
|
||||
|
||||
<FAQItem title="未来是否会收费?">
|
||||
该项目将以免费开源的形式运营。
|
||||
<br>
|
||||
您可以考虑赞助本项目,以支持我们的开发。
|
||||
我会将其投入在周边的服务器、域名、CDN 等费用上。
|
||||
<ul mt-1>
|
||||
<li>
|
||||
<a href="https://afdian.net/a/yunyoujun" target="_blank">爱发电赞助</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://sponsors.yunyoujun.cn/" target="_blank">我要直接打钱!</a>
|
||||
</li>
|
||||
</ul>
|
||||
</FAQItem>
|
||||
|
||||
<FAQItem title="页面无法点击、资源加载失败?">
|
||||
<blockquote>
|
||||
试试「无痕模式」是否正常?
|
||||
@@ -63,34 +85,86 @@
|
||||
</ol>
|
||||
</FAQItem>
|
||||
|
||||
<FAQItem title="其他相关链接">
|
||||
<ul>
|
||||
<hr h="1" my="4" bg-black>
|
||||
|
||||
<FAQItem :default-open="true" title="关于">
|
||||
<div text-left>
|
||||
<ul>
|
||||
<li>
|
||||
它诞生于 2022 年 4 月,时值疫情风控期间,希望能帮助期间的伙伴根据现有食材寻找到合适的菜谱。故原名「隔离食用手册」。
|
||||
</li>
|
||||
<li>
|
||||
如今那个时期已离我们远去,故去掉「隔离」二字。但也很高兴能在这里继续与你相遇,希望它能继续发光发热,在日常生活中帮助到大家。
|
||||
</li>
|
||||
<li>
|
||||
<div class="inline-flex items-center justify-center">
|
||||
代码仓库:<a class="inline-flex items-center justify-center" href="https://github.com/YunYouJun/cook" target="_blank">
|
||||
<div m="r-1" i-ri-github-line inline-flex />YunYouJun/cook</a>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="inline-flex items-center justify-center">
|
||||
菜谱视频来源:
|
||||
<a class="inline-flex items-center text-sm text-blue-600 dark:text-blue-400" href="https://docs.qq.com/sheet/DQk1vdkhFV0twQVNS" target="_blank">
|
||||
<div m="r-1" i-ri-bilibili-line inline-flex />
|
||||
<span class="inline-flex">隔离食用手册大全</span>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</FAQItem>
|
||||
|
||||
<FAQItem title="关于我">
|
||||
<div text-left>
|
||||
我的个人微信公众号「云游君」,会分享一些生活和写的<a href="https://sponsors.yunyoujun.cn/projects" target="_blank">
|
||||
小玩具们
|
||||
</a>。
|
||||
|
||||
<a inline-flex py-4 href="https://cdn.yunyoujun.cn/img/about/white-qrcode-and-search.jpg" target="_blank">
|
||||
<img src="https://cdn.yunyoujun.cn/img/about/white-qrcode-and-search.jpg">
|
||||
</a>
|
||||
</div>
|
||||
<AboutMe />
|
||||
</FAQItem>
|
||||
|
||||
<FAQItem title="致谢">
|
||||
<p>
|
||||
感谢以下小伙伴为本项目提供的数据支持和 QA !
|
||||
</p>
|
||||
|
||||
<ul mt-2 text-left text-sm>
|
||||
<li>
|
||||
相关链接
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://docs.qq.com/form/page/DWk9GWW9oTmlXZU9V" target="_blank">居家菜谱投稿</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://support.qq.com/products/507827" target="_blank">反馈建议分享(兔小巢)</a>
|
||||
</li>
|
||||
</ul>
|
||||
<a href="https://weibo.com/runny" target="_blank">Runny</a>
|
||||
</li>
|
||||
<li>
|
||||
网站相关
|
||||
<ul>
|
||||
<li>
|
||||
故障/新功能反馈:
|
||||
<a href="https://github.com/YunYouJun/cook/issues" target="_blank">Issues</a>
|
||||
</li>
|
||||
<li>
|
||||
交流/建议/分享:
|
||||
<a href="https://github.com/YunYouJun/cook/issues" target="_blank">Discussions</a>
|
||||
</li>
|
||||
</ul>
|
||||
山竹太凉
|
||||
</li>
|
||||
<li>
|
||||
leo
|
||||
</li>
|
||||
<li>
|
||||
麒麟
|
||||
</li>
|
||||
<li>
|
||||
晴方啾
|
||||
</li>
|
||||
<li>
|
||||
课代表阿伟
|
||||
</li>
|
||||
</ul>
|
||||
</FAQItem>
|
||||
|
||||
<FAQItem title="赞助者们">
|
||||
<div>
|
||||
感谢至今以来所有的<a href="https://afdian.net/a/yunyoujun" class="text-purple" target="_blank">赞助者</a>们,你们的支持是我持续维护和开发新项目的动力!
|
||||
</div>
|
||||
<div pt-2>
|
||||
<a href="https://sponsors.yunyoujun.cn" target="_blank">
|
||||
<img src="https://sponsors.yunyoujun.cn/sponsors.svg">
|
||||
</a>
|
||||
</div>
|
||||
</FAQItem>
|
||||
</div>
|
||||
</div>
|
||||
<BaseFooter mt-4 />
|
||||
|
||||
@@ -3,7 +3,7 @@ const rStore = useRecipeStore()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div pt-4 text-4xl>
|
||||
<div text-4xl>
|
||||
<button
|
||||
class="cursor-pointer transition active:text-green-800 hover:(text-green-600)"
|
||||
title="重置"
|
||||
@@ -16,5 +16,7 @@ const rStore = useRecipeStore()
|
||||
<p text="sm" m="b-4">
|
||||
好的,今天我们来做菜!
|
||||
</p>
|
||||
|
||||
<ChooseFood />
|
||||
<SimpleCopyright />
|
||||
</template>
|
||||
|
||||
10
pages/random.vue
Normal file
10
pages/random.vue
Normal file
@@ -0,0 +1,10 @@
|
||||
<template>
|
||||
<div flex flex-col>
|
||||
<CommonHeader>
|
||||
今天吃什么
|
||||
</CommonHeader>
|
||||
<div flex flex-grow flex-col items-center justify-center>
|
||||
<RandomRecipe />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
12
pages/recipes/index.vue
Normal file
12
pages/recipes/index.vue
Normal file
@@ -0,0 +1,12 @@
|
||||
<script lang="ts" setup>
|
||||
definePageMeta({
|
||||
layout: 'child',
|
||||
title: '菜谱 - ?',
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
asd
|
||||
</div>
|
||||
</template>
|
||||
5
pages/recipes/new.vue
Normal file
5
pages/recipes/new.vue
Normal file
@@ -0,0 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
新建 Recipe
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,7 +1,28 @@
|
||||
<script lang="ts" setup>
|
||||
const app = useAppStore()
|
||||
|
||||
definePageMeta({
|
||||
layout: 'child',
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<button>
|
||||
<CommonHeader>
|
||||
设置
|
||||
</button>
|
||||
</CommonHeader>
|
||||
|
||||
<div
|
||||
class="mx-auto max-w-md w-full"
|
||||
px-2
|
||||
text-left
|
||||
>
|
||||
<YlfForm>
|
||||
<YlfFormItem label="离开网页后保留选中数据">
|
||||
<YlfSwitch v-model="app.settings.keepLocalData" />
|
||||
</YlfFormItem>
|
||||
<YlfFormItem label="更多设置,敬请期待" />
|
||||
</YlfForm>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,7 +1,37 @@
|
||||
<script lang="ts" setup>
|
||||
import { links } from '~/constants'
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<button>
|
||||
<div i-ri-user-line />
|
||||
</button>
|
||||
<CommonHeader>
|
||||
我的
|
||||
</CommonHeader>
|
||||
|
||||
<div
|
||||
class="mx-auto max-w-md w-full"
|
||||
px-2
|
||||
text-left
|
||||
>
|
||||
<YlfForm>
|
||||
<YlfFormItem icon="i-ri-feedback-line" label="立即反馈" :to="links.feedback" target="_blank" />
|
||||
<YlfFormItem icon="i-ri-mail-send-line" label="立即投稿" :to="links.contribute" target="_blank" />
|
||||
</YlfForm>
|
||||
|
||||
<YlfForm>
|
||||
<YlfFormItem icon="i-ri-settings-line" label="设置" to="/settings" />
|
||||
</YlfForm>
|
||||
|
||||
<YlfForm>
|
||||
<YlfFormItem icon="i-ri-article-line" label="自定义菜谱" to="/cookbooks/" />
|
||||
</YlfForm>
|
||||
|
||||
<YlfForm>
|
||||
<YlfFormItem icon="i-ri-question-line" label="帮助" to="/help" />
|
||||
<YlfFormItem icon="i-ri-information-line" label="关于" to="/help" />
|
||||
</YlfForm>
|
||||
</div>
|
||||
|
||||
<BaseFooter mt-4 />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
7528
pnpm-lock.yaml
generated
7528
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
10
shims.d.ts
vendored
10
shims.d.ts
vendored
@@ -9,13 +9,15 @@ declare interface Window {
|
||||
|
||||
// with vite-plugin-vue-markdown, markdowns can be treat as Vue components
|
||||
declare module '*.md' {
|
||||
import { type DefineComponent } from 'vue'
|
||||
const component: DefineComponent<{}, {}, any>
|
||||
import type { DefineComponent } from 'vue'
|
||||
|
||||
const component: DefineComponent<object, object, any>
|
||||
export default component
|
||||
}
|
||||
|
||||
declare module '*.vue' {
|
||||
import { type DefineComponent } from 'vue'
|
||||
const component: DefineComponent<{}, {}, any>
|
||||
import type { DefineComponent } from 'vue'
|
||||
|
||||
const component: DefineComponent<object, object, any>
|
||||
export default component
|
||||
}
|
||||
|
||||
1
src/data/recipe.json
Normal file
1
src/data/recipe.json
Normal file
File diff suppressed because one or more lines are too long
@@ -2,11 +2,29 @@
|
||||
--c-primary: #5fc178;
|
||||
--c-text: #333;
|
||||
|
||||
--c-bg: #fff;
|
||||
--c-bg: white;
|
||||
--c-bg-alt: #f9fbfd;
|
||||
}
|
||||
|
||||
.dark {
|
||||
--c-text: #fafafa;
|
||||
|
||||
--c-bg: #121212;
|
||||
--c-bg-alt: #333;
|
||||
}
|
||||
|
||||
// ylf
|
||||
:root {
|
||||
--ylf-c-bg-alt: var(--c-bg-alt);
|
||||
--ylf-c-border: #eaeaea;
|
||||
}
|
||||
|
||||
.dark {
|
||||
--ylf-c-border: #666;
|
||||
}
|
||||
|
||||
// cook custom
|
||||
:root {
|
||||
--cook-bottom-menu-padding-bottom: 20px;
|
||||
--cook-bottom-menu-height: calc(64px + var(--cook-bottom-menu-padding-bottom));
|
||||
}
|
||||
|
||||
@@ -8,11 +8,10 @@ body,
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
background: var(--c-bg);
|
||||
}
|
||||
|
||||
html.dark {
|
||||
background: #121212;
|
||||
}
|
||||
|
||||
input:focus {
|
||||
outline: none;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { describe, it } from 'vitest'
|
||||
// import { createTestingPinia } from '@pinia/testing'
|
||||
// import ChooseFood from '../src/components/ChooseFood.vue'
|
||||
|
||||
describe('ChooseFood.vue', () => {
|
||||
describe('chooseFood.vue', () => {
|
||||
it('should render', async () => {
|
||||
// const pinia = createTestingPinia({
|
||||
// createSpy: vi.fn,
|
||||
|
||||
22
types/cookbook.ts
Normal file
22
types/cookbook.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { Recipes } from './recipe'
|
||||
|
||||
export interface Cookbook {
|
||||
/**
|
||||
* 菜谱 ID,自定义,唯一标识符
|
||||
*/
|
||||
id: string
|
||||
cover?: string
|
||||
/**
|
||||
* 菜谱名称
|
||||
*/
|
||||
title: string
|
||||
description: string
|
||||
author: string | string[]
|
||||
/**
|
||||
* 菜谱
|
||||
*/
|
||||
recipes: Recipes
|
||||
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
export * from './cookbook'
|
||||
export * from './recipe'
|
||||
|
||||
@@ -40,3 +40,30 @@ export interface RecipeItem {
|
||||
}
|
||||
|
||||
export type Recipes = RecipeItem[]
|
||||
|
||||
export interface StuffItem {
|
||||
/**
|
||||
* 食材名称
|
||||
*/
|
||||
name: string
|
||||
/**
|
||||
* 例如:🥔
|
||||
*/
|
||||
emoji: string
|
||||
/**
|
||||
* 图片链接
|
||||
*/
|
||||
image?: string
|
||||
/**
|
||||
* 别名,譬如:西红柿/番茄
|
||||
*/
|
||||
alias?: string
|
||||
/**
|
||||
* 图标名称
|
||||
*/
|
||||
icon?: string
|
||||
/**
|
||||
* 显示标签
|
||||
*/
|
||||
label?: string
|
||||
}
|
||||
|
||||
@@ -20,8 +20,7 @@ tools.forEach((item) => {
|
||||
export default defineConfig({
|
||||
shortcuts: [
|
||||
['tag', 'text-sm cursor-pointer inline-flex justify-center items-center transition shadow hover:shadow-md'],
|
||||
['btn', 'text-sm px-4 py-1 rounded inline-block bg-green-600 text-white cursor-pointer hover:bg-green-700 disabled:cursor-default disabled:bg-gray-600 disabled:opacity-50'],
|
||||
['icon-btn', 'text-[0.9em] inline-block cursor-pointer select-none opacity-75 transition duration-200 ease-in-out hover:opacity-100 hover:text-green-600'],
|
||||
['btn', 'text-sm px-4 py-1 rounded inline-block bg-blue-600 text-white cursor-pointer hover:bg-blue-700 disabled:cursor-default disabled:bg-gray-600 disabled:opacity-50'],
|
||||
],
|
||||
presets: [
|
||||
presetUno(),
|
||||
@@ -36,12 +35,4 @@ export default defineConfig({
|
||||
transformerVariantGroup(),
|
||||
],
|
||||
safelist,
|
||||
content: {
|
||||
pipeline: {
|
||||
include: [
|
||||
'./**/*.vue',
|
||||
'./content/**/*.md',
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
11
utils/cookbook.ts
Normal file
11
utils/cookbook.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { Cookbook } from '~/types'
|
||||
|
||||
export const defaultCookbook: Cookbook = {
|
||||
id: 'default',
|
||||
title: '默认菜谱',
|
||||
description: '记录了一些特殊时期常用的菜谱',
|
||||
author: [''],
|
||||
recipes: [],
|
||||
updatedAt: '',
|
||||
createdAt: '2021-04-04',
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { Table } from 'dexie'
|
||||
import Dexie from 'dexie'
|
||||
|
||||
import recipeData from '../data/recipe.json'
|
||||
import type { RecipeItem } from '~/types'
|
||||
|
||||
export interface DbRecipeItem extends RecipeItem {
|
||||
@@ -21,8 +20,10 @@ export class MySubClassedDexie extends Dexie {
|
||||
|
||||
export const db = new MySubClassedDexie()
|
||||
|
||||
export function initDb() {
|
||||
db.recipes.bulkPut(
|
||||
export async function initDb() {
|
||||
const { default: recipeData } = await import('../data/recipe.json')
|
||||
|
||||
return db.recipes.bulkPut(
|
||||
(recipeData as RecipeItem[]).map((item, i) => ({
|
||||
id: i,
|
||||
...item,
|
||||
|
||||
@@ -9,7 +9,6 @@ foodItems.forEach((item) => {
|
||||
/**
|
||||
* get emojis from stuff name array
|
||||
* @param stuff
|
||||
* @returns
|
||||
*/
|
||||
export function getEmojisFromStuff(stuff: string[]) {
|
||||
const emojis: string[] = stuff.map(name => foodEmojiMap.get(name)).filter(item => !!item)
|
||||
|
||||
@@ -3,7 +3,6 @@ import { isClient } from '@vueuse/core'
|
||||
/**
|
||||
* - https://web.dev/customize-install/#detect-install
|
||||
* - [Trigger installation from your PWA](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/How_to/Trigger_install_prompt)
|
||||
* @returns
|
||||
*/
|
||||
export function installPrompt() {
|
||||
if (!isClient)
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import type { Recipes } from '../types'
|
||||
|
||||
/**
|
||||
* 生成随机菜谱
|
||||
* @param recipes
|
||||
* @returns
|
||||
* 生成随机数组
|
||||
*/
|
||||
export function generateRandomRecipe(recipes: Recipes) {
|
||||
return recipes[Math.floor(Math.random() * recipes.length)]
|
||||
export function generateRandomArray(length: number, total = 1) {
|
||||
const randomArr: number[] = []
|
||||
for (let i = 0; i < total; i++) {
|
||||
const randomIndex = Math.floor(Math.random() * length)
|
||||
if (randomArr.includes(randomIndex)) {
|
||||
i--
|
||||
continue
|
||||
}
|
||||
randomArr.push(randomIndex)
|
||||
}
|
||||
return randomArr
|
||||
}
|
||||
|
||||
10
utils/settings.ts
Normal file
10
utils/settings.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export interface UserSettings {
|
||||
/**
|
||||
* 保留本地数据
|
||||
*/
|
||||
keepLocalData: boolean
|
||||
}
|
||||
|
||||
export const defaultSettings: UserSettings = {
|
||||
keepLocalData: true,
|
||||
}
|
||||
@@ -4,10 +4,16 @@ export default defineConfig({
|
||||
test: {
|
||||
include: ['test/**/*.test.ts'],
|
||||
environment: 'jsdom',
|
||||
deps: {
|
||||
inline: ['@vue', '@vueuse', 'vue-demi'],
|
||||
server: {
|
||||
deps: {
|
||||
inline: ['@vue', '@vueuse', 'vue-demi'],
|
||||
},
|
||||
},
|
||||
|
||||
setupFiles: ['test/setup.ts'],
|
||||
|
||||
alias: {
|
||||
'~': './',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
10
vitest.nuxt.config.ts
Normal file
10
vitest.nuxt.config.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { defineVitestConfig } from 'nuxt-vitest/config'
|
||||
|
||||
export default defineVitestConfig({
|
||||
test: {
|
||||
include: ['test/**/*.test.ts'],
|
||||
environment: 'nuxt',
|
||||
|
||||
setupFiles: ['test/setup.ts'],
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user