2.6 KiB
2.6 KiB
AGENTS.md
Commands
npm run dev— Vite dev server with HMRnpm run build—vue-tsc -b && vite build(typecheck must pass or build aborts)npx vue-tsc -b— standalone typecheck (no script in package.json)- No linter, formatter, or test runner exists
Architecture
- Vue 3 + Vite + Tailwind CSS + Vue Router + Pinia + Supabase + AMap (高德地图)
- Path alias
@/→src/(configured in bothvite.config.tsandtsconfig.app.json) - Supabase client singleton at
src/lib/supabase.ts— throws at import if env vars missing - AMap loaded lazily via
src/lib/amap.tswith hand-rolled type declarations insrc/types/amap.d.ts - UI language is Chinese (zh-CN)
Auth Flow (non-obvious)
main.tsraces on pathname:/auth/confirmmounts the app immediately without callingauthStore.initialize(). All other routes wait for auth initialization before mounting. If you add new routes that need to bypass auth init, add them to theifcheck inmain.ts.- AuthConfirmView uses a separate Supabase client: It creates a temporary
createClient()to callsetSession()thensignOut(), so the main auth store never sees a logged-in state. Do NOT consolidate with the singleton — the singleton isn't initialized at confirmation time. - Login sets
user.valueexplicitly:login()extractsdata.userfromsignInWithPasswordresponse and assigns it to the store directly, rather than relying ononAuthStateChange. - Profile is auto-created by DB trigger (
handle_new_useronauth.users), not by the frontend. The trigger usesSECURITY DEFINERwithSET search_path = public. - Auth error messages are translated to Chinese in the store.
Supabase
- Env var is
VITE_SUPABASE_PUBLISHABLE_KEY(notVITE_SUPABASE_ANON_KEY), using Supabase'ssb_publishable_key format. - All tables have RLS enabled. Check
plan.mdsection 10 for the full schema and RLS policies. - Storage bucket
cloudsis public read, authenticated upload. - Profile
rolefield (user/admin) controls admin access — checked in route guard, not in JWT metadata.
MVP Constraints (from plan.md)
- No Supabase Realtime — refresh-based loading
- No OAuth — email/password only, email confirmation required
- No AI cloud identification — manual type selection
- AMap only (China-focused), no Mapbox fallback yet
Environment Variables
Required now (app won't start without):
VITE_SUPABASE_URLVITE_SUPABASE_PUBLISHABLE_KEY
Required for map features (views are stubs without):
VITE_AMAP_KEYVITE_AMAP_SECRET
Future (Supabase Dashboard only, not in .env):
OPENAI_API_KEY,OPENWEATHERMAP_API_KEY