diff --git a/src/layout/index.vue b/src/layout/index.vue
index 9f28a7d..31ee18d 100644
--- a/src/layout/index.vue
+++ b/src/layout/index.vue
@@ -1,7 +1,7 @@
diff --git a/src/plugins/dayjs.ts b/src/plugins/dayjs.ts
new file mode 100644
index 0000000..3551381
--- /dev/null
+++ b/src/plugins/dayjs.ts
@@ -0,0 +1,12 @@
+import 'dayjs/locale/zh-cn';
+
+import dayjs from 'dayjs';
+import localeData from 'dayjs/plugin/localeData';
+import weekday from 'dayjs/plugin/weekday';
+
+dayjs.extend(weekday);
+dayjs.extend(localeData);
+
+dayjs.locale('zh-cn');
+
+export default dayjs;
diff --git a/src/plugins/index.ts b/src/plugins/index.ts
index bab9d90..1d3a994 100644
--- a/src/plugins/index.ts
+++ b/src/plugins/index.ts
@@ -3,13 +3,13 @@ import type { App } from 'vue';
import { setupDirective } from '@/directive';
import { autoFit } from '@/plugins/autofit';
import { useEcharts } from '@/plugins/echarts';
-import { setUpRouter } from '@/router';
+import { setupRouter } from '@/router';
import { setupStore } from '@/store';
export default {
install(app: App) {
// 设置路由
- setUpRouter(app);
+ setupRouter(app);
// 设置状态管理
setupStore(app);
// 设置指令
diff --git a/src/router/index.ts b/src/router/index.ts
index 1499403..be6e006 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -10,11 +10,11 @@ const routes: RouteRecordRaw[] = [...remaining, ...home, ...error];
const router = createRouter({
history: createWebHashHistory(),
routes,
- scrollBehavior: () => ({ x: 0, y: 0 }),
+ scrollBehavior: () => ({ x: 0, y: 0, behavior: 'smooth' }),
});
/** 全局注册 router */
-export const setUpRouter = (app: App) => {
+export const setupRouter = (app: App) => {
app.use(router);
};
@@ -23,4 +23,10 @@ export const resetRouter = () => {
router.replace({ path: '/' }).then();
};
+// router.afterEach((to, from) => {
+// const toDepth = to.path.split('/').length;
+// const fromDepth = from.path.split('/').length;
+// to.meta.transition = toDepth < fromDepth ? 'slide-right' : 'slide-left';
+// });
+
export default router;
diff --git a/src/router/modules/home.ts b/src/router/modules/home.ts
index cf2d889..0f5e69e 100644
--- a/src/router/modules/home.ts
+++ b/src/router/modules/home.ts
@@ -1,18 +1,18 @@
-import type { RouteRecordRaw } from 'vue-router';
-
import Layout from '@/layout/index.vue';
+import type { RouteConfigsTable } from '@/types/router/Route';
-const routes: RouteRecordRaw[] = [
+const routes: RouteConfigsTable[] = [
{
path: '/',
name: '/',
component: Layout,
- meta: { transition: 'fade' },
+ meta: { transition: 'fade', title: '后台管理系统大标题' },
},
{
path: '/smart-parking',
name: 'smartParking',
component: () => import('@/views/smart-parking/index.vue'),
+ meta: { title: '智慧智能监管中心', subtitle: '车辆监控中心' },
},
];
diff --git a/src/types/router/Route.ts b/src/types/router/Route.ts
new file mode 100644
index 0000000..c718c54
--- /dev/null
+++ b/src/types/router/Route.ts
@@ -0,0 +1,29 @@
+import type { RouteComponent } from 'vue-router';
+
+/**
+ * @description 完整子路由的`meta`配置表
+ */
+interface CustomizeRouteMeta {
+ title: string;
+ subtitle: string;
+ transition: string;
+}
+
+/**
+ * @description 整体路由配置表(包括完整子路由)
+ */
+interface RouteConfigsTable {
+ /** 路由地址 `必填` */
+ path: string;
+ /** 路由名字(保持唯一)`可选` */
+ name?: string;
+ /** `Layout`组件 `可选` */
+ component?: RouteComponent;
+ /** 路由重定向 `可选` */
+ redirect?: string;
+ meta?: CustomizeRouteMeta;
+ /** 子路由配置项 */
+ children?: Array;
+}
+
+export { RouteConfigsTable };
diff --git a/src/views/smart-parking/index.vue b/src/views/smart-parking/index.vue
index c3d9df1..e6c81b6 100644
--- a/src/views/smart-parking/index.vue
+++ b/src/views/smart-parking/index.vue
@@ -1,7 +1,7 @@
@@ -9,7 +9,7 @@ import ParkingHeader from '@/views/smart-parking/components/parking-header/index
-
+