Hostinger Horizons 允许你为 Web 应用构建一个私有、受登录保护的管理后台。这个区域让你可以管理动态内容——例如添加商品、撰写博客文章或更新图库——而无需编写代码。Horizons 使用集成的后端,根据你输入的提示自动处理数据存储、身份验证和集合(collections)。
在 测试模式(Test mode) 下所做的更改不会影响你的线上网站;发布前请务必验证功能是否正常。
第 1 步 – 发送初始应用提示
要为应用打好基础,请在你的第一条消息中提供全面的概述。
- 打开 Hostinger Horizons 编辑器。
- 输入一条提示,描述公开站点与私有管理区域。
示例提示:
Create a web application with a public-facing website and a private admin panel accessible via email and password login. The admin panel must allow me to add, edit, and delete products (name, price, image, description), blog posts (title, content, cover image), and gallery images. The public site should display this content dynamically.
第 2 步 – 配置身份验证
如果初始提示没有生成可用的登录系统,请细化身份验证逻辑。
- 要求生成一个特定的登录页面并对路由进行保护。
示例提示:
Add a login page for the admin panel with email and password authentication. Ensure only logged-in admins can access the admin area and redirect unauthenticated users to the login page.
第 3 步 – 构建内容管理模块
一次添加一个特定的管理模块,以确保稳定性。
- 商品管理:提示 Horizons 创建一个用于管理库存的模块。
示例提示:
Add a Products section to the admin panel to add new products with a name, price, description, and image. Include a list of existing products with edit and delete options.
- 博客与图库:使用类似的提示添加博客文章和图片图库模块,并为每个模块指定所需字段(例如标题、日期或封面图)。
示例提示:
Add a Blog Posts section to the admin panel where I can write, edit, and publish articles with a title, content, and cover image. Add a Gallery section to the admin panel where I can upload, replace, and delete images that display on the public site.
第 4 步 – 将内容同步到公开站点
确保管理后台中输入的数据能正确显示给访客。
- 让 Horizons 将后端集合连接到你的首页或子页面。
示例提示:
Connect the public homepage to the admin panel database. The public site must automatically update whenever products, blog posts, or gallery images are added or edited in the admin area.
完成后,你将获得一个可用的管理界面,可实时管理你的 Hostinger Horizons 站点内容。你可以随时使用预览屏幕顶部的 数据(Data) 开关来查看和编辑原始数据。
常见问题排查
如果你的管理后台或动态内容表现不符合预期,请使用以下提示和检查来解决问题:
- 动态内容未显示在公开站点上:确保公开站点配置为从管理后台写入的同一个数据库集合获取数据。
你可以提示:
Make sure the public pages fetch and display the latest data from the [collection name] collection used by the admin panel.
- 登录后被重定向回登录页面:这通常表示存在会话存储问题。
使用此提示:
Fix the authentication flow so that after a successful login, the user is redirected to the admin dashboard and remains authenticated.
- 管理后台无需身份验证即可访问:你必须确保所有管理路由都受到保护。
使用此提示:
Add route protection to all admin panel pages. Automatically redirect any unauthenticated users to the login page.
-
提示的更改在线上站点上不可见:在 Hostinger Horizons 编辑器中,你必须点击 发布(Publish),然后选择 发布更改(Publish changes)。更改可能需要几分钟才能生效;请在隐身窗口中打开站点以绕过本地浏览器缓存。
-
添加功能后出现错误消息:向 AI 提供具体的错误详情以便分析。
使用此提示:
When I [describe exact steps], I get console error '[paste error]'. Network tab shows request to [URL] with payload [paste payload], error [paste error code]. Can you fix the issue?
使用 Hostinger Horizons 内置的数据浏览器,验证在你输入提示时集合是否正确创建。如果遇到错误,请将具体的错误消息和相关代码行粘贴到提示区,交由 Horizons 分析并修复。
来源:Hostinger 官方帮助文档