ask-vue-architect
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<critical_constraints>
❌ NO → causes full reload, use
❌ NO axios.post for forms → use from Inertia
❌ NO hardcoded URLs → use helper (Ziggy)
✅ MUST use
✅ MUST detect stack flavor before scaffolding
</critical_constraints>
<detection>
Check project for:
- `inertiajs/inertia-laravel` or `resources/js/Pages` → Inertia (priority)
- `nuxt.config.ts` → Nuxt (auto-imports)
- `vite.config.ts` only → Vite SPA (manual imports, vue-router)
</detection>
<a href=""><Link>useFormroute()<script setup lang="ts"><inertia_rules>
Props: from Laravel Controller, not fetched in onMounted
ts
defineProps<{ user: App.Models.User; errors: Record<string, string> }>();Links: (not )
<Link href="/dashboard"><a>Forms:
ts
const form = useForm({ email: '', password: '' });
form.post(route('login'), { onFinish: () => form.reset('password') });Errors:
:error="form.errors.email"Global state:
</inertia_rules>
usePage().props.auth.user<persistent_layouts>
ts
import AppLayout from '@/Layouts/AppLayout.vue';
defineOptions({ layout: AppLayout });</persistent_layouts>
<state_management>
- Local: for UI state
ref() - Global (Inertia): for auth, flash messages
usePage() - Complex client-side: Pinia (Setup Store syntax) </state_management>
<critical_constraints>
❌ 禁止使用 → 会导致全页面重载,请使用
❌ 表单禁止使用 axios.post → 请使用 Inertia 提供的
❌ 禁止硬编码URL → 请使用(Ziggy的) 辅助函数
✅ 必须使用
✅ 必须在搭建脚手架前检测技术栈类型
</critical_constraints>
<detection>
检测项目中是否存在以下内容:
- `inertiajs/inertia-laravel` 或 `resources/js/Pages` → 判定为Inertia(优先级最高)
- `nuxt.config.ts` → 判定为Nuxt(自动导入)
- 仅存在 `vite.config.ts` → 判定为Vite单页应用(手动导入,需使用vue-router)
</detection>
<a href=""><Link>useFormroute()<script setup lang="ts"><inertia_rules>
Props:来自Laravel控制器,不要在onMounted中获取
ts
defineProps<{ user: App.Models.User; errors: Record<string, string> }>();链接:使用 (不要用)
<Link href="/dashboard"><a>表单:
ts
const form = useForm({ email: '', password: '' });
form.post(route('login'), { onFinish: () => form.reset('password') });错误提示:
:error="form.errors.email"全局状态:
</inertia_rules>
usePage().props.auth.user<persistent_layouts>
ts
import AppLayout from '@/Layouts/AppLayout.vue';
defineOptions({ layout: AppLayout });</persistent_layouts>
<state_management>
- 本地状态:使用管理UI状态
ref() - 全局状态(Inertia):使用管理认证、闪存消息
usePage() - 复杂客户端状态:使用Pinia(Setup Store语法) </state_management>