diff --git a/src/lib/sw/cache-strategy.ts b/src/lib/sw/cache-strategy.ts index 28624a9..d755a72 100644 --- a/src/lib/sw/cache-strategy.ts +++ b/src/lib/sw/cache-strategy.ts @@ -16,6 +16,7 @@ export function resolveStrategy(req: RequestShape): CacheStrategy { if ( path === '/api/recipes/import' || path === '/api/recipes/preview' || + path === '/api/recipes/extract-from-photo' || path.startsWith('/api/recipes/search/web') ) { return 'network-only'; diff --git a/src/routes/new/from-photo/+page.server.ts b/src/routes/new/from-photo/+page.server.ts new file mode 100644 index 0000000..d7bbd56 --- /dev/null +++ b/src/routes/new/from-photo/+page.server.ts @@ -0,0 +1,12 @@ +import type { PageServerLoad } from './$types'; +import { error } from '@sveltejs/kit'; +import { env } from '$env/dynamic/private'; + +export const load: PageServerLoad = async () => { + if (!env.GEMINI_API_KEY) { + error(503, { + message: 'Foto-Import ist nicht konfiguriert (GEMINI_API_KEY fehlt).' + }); + } + return {}; +}; diff --git a/src/routes/new/from-photo/+page.svelte b/src/routes/new/from-photo/+page.svelte new file mode 100644 index 0000000..f452598 --- /dev/null +++ b/src/routes/new/from-photo/+page.svelte @@ -0,0 +1,247 @@ + + +Rezept aus Foto — Kochwas + +{#if store.status === 'idle'} +
+ +

Rezept aus Foto

+

+ Fotografiere ein gedrucktes oder handgeschriebenes Rezept. Eine Seite, + scharf, gut ausgeleuchtet. +

+ + + {#if !network.online} +

Offline — diese Funktion braucht Internet.

+ {/if} +
+{:else if store.status === 'loading'} +
+
+

Lese das Rezept…

+ +
+{:else if store.status === 'error'} + {#if store.errorCode === 'NO_RECIPE_IN_IMAGE'} + + {:else} + + {/if} +{:else if store.status === 'success' && store.recipe} + + +{/if} + +