增加website

This commit is contained in:
hero920103 committed 2026-09-14 22:24:55 +08:00
1 parent bb8a6936e4
commit 7e6a3e969f
57 files changed
+10568 -1

No files matched your search

+201
View File
@@ -0,0 +1,201 @@
//index.ts
import { createRouter, createWebHashHistory, type RouteRecordRaw } from "vue-router";
const DefaultLayout = () => import("../layout/DefaultLayout.vue");
const HomeView = () => import("../views/home/index.vue");
const ListView = () => import("../views/list.vue");
const DetailView = () => import("../views/detail.vue");
const SingleView = () => import("../views/single.vue");
const NotFoundView = () => import("../views/not-found.vue");
/**
* 路由约定:
* - 列表页 /news、/products、/solutions、/cases、/events
* - 分类页 /news/category/:slug (其余栏目同理)
* - 详情页 /news/detail/:slug (其余栏目同理)
* - 单页 /about、/careers、/contact、/support、/support/:slug、/policy/:slug
* 列表页与详情页共用同一个组件,通过路由路径推导所属栏目。
*/
const routes: RouteRecordRaw[] = [
{
path: "/",
component: DefaultLayout,
children: [
{
path: "",
name: "Home",
component: HomeView,
meta: { title: "官方网站" },
},
// ---------------- 新闻中心 ----------------
{
path: "news",
name: "News",
component: ListView,
meta: { title: "新闻中心" },
},
{
path: "news/category/:slug",
name: "NewsCategory",
component: ListView,
meta: { title: "新闻中心" },
},
{
path: "news/detail/:slug",
name: "NewsDetail",
component: DetailView,
meta: { title: "新闻详情" },
},
// ---------------- 产品中心 ----------------
{
path: "products",
name: "Products",
component: ListView,
meta: { title: "产品中心" },
},
{
path: "products/category/:slug",
name: "ProductCategory",
component: ListView,
meta: { title: "产品中心" },
},
{
path: "products/detail/:slug",
name: "ProductDetail",
component: DetailView,
meta: { title: "产品详情" },
},
// ---------------- 解决方案 ----------------
{
path: "solutions",
name: "Solutions",
component: ListView,
meta: { title: "解决方案" },
},
{
path: "solutions/category/:slug",
name: "SolutionCategory",
component: ListView,
meta: { title: "解决方案" },
},
{
path: "solutions/detail/:slug",
name: "SolutionDetail",
component: DetailView,
meta: { title: "方案详情" },
},
// ---------------- 客户案例 ----------------
{
path: "cases",
name: "Cases",
component: ListView,
meta: { title: "客户案例" },
},
{
path: "cases/category/:slug",
name: "CaseCategory",
component: ListView,
meta: { title: "客户案例" },
},
{
path: "cases/detail/:slug",
name: "CaseDetail",
component: DetailView,
meta: { title: "案例详情" },
},
// ---------------- 市场活动 ----------------
{
path: "events",
name: "Events",
component: ListView,
meta: { title: "市场活动" },
},
{
path: "events/category/:slug",
name: "EventCategory",
component: ListView,
meta: { title: "市场活动" },
},
{
path: "events/detail/:slug",
name: "EventDetail",
component: DetailView,
meta: { title: "活动详情" },
},
// ---------------- 独立单页 ----------------
{
path: "about",
name: "About",
component: SingleView,
meta: { title: "关于云泽" },
},
{
path: "careers",
name: "Careers",
component: SingleView,
meta: { title: "加入我们" },
},
{
path: "partners",
name: "Partners",
component: SingleView,
meta: { title: "合作伙伴" },
},
{
path: "contact",
name: "Contact",
component: SingleView,
meta: { title: "联系我们" },
},
{
path: "support",
name: "Support",
component: SingleView,
meta: { title: "客户支持中心" },
},
{
path: "support/:slug",
name: "SupportDetail",
component: SingleView,
meta: { title: "客户支持" },
},
{
path: "policy/:slug",
name: "Policy",
component: SingleView,
meta: { title: "政策条款" },
},
// ---------------- 兜底 ----------------
{
path: ":pathMatch(.*)*",
name: "NotFound",
component: NotFoundView,
meta: { title: "页面不存在" },
},
],
},
];
const router = createRouter({
history: createWebHashHistory(), // 哈希模式
routes,
scrollBehavior(_to, _from, savedPosition) {
if (savedPosition) return savedPosition;
return { top: 0 };
},
});
/** 根据路由 meta 同步浏览器标题 */
router.afterEach((to) => {
const title = (to.meta.title as string | undefined) ?? "";
document.title = title ? `${title} | 云泽科技` : "云泽科技 | 官方网站";
});
export default router;