layui/package/document/src/view/guide.vue

139 lines
3.2 KiB
Vue
Raw Normal View History

2021-10-22 01:18:40 +00:00
<template>
<lay-layout>
<lay-side>
2021-10-25 17:14:17 +00:00
<lay-scroll style="overflow-y: scroll">
<ul class="layui-menu layui-menu-lg layui-menu-docs">
2021-10-23 06:14:08 +00:00
<li
v-for="menu in menus"
:key="menu"
class="layui-menu-item-group"
lay-options="{type: 'group', isAllowSpread: true}"
2021-10-23 06:14:08 +00:00
>
<div class="layui-menu-body-title">{{ menu.title }}</div>
<hr />
<ul>
<li
v-for="children in menu.children"
:key="children"
:class="[
currentPath === children.path
? 'layui-menu-item-checked2'
: '',
]"
@click="handleClick(children)"
>
<div class="layui-menu-body-title">
<router-link :to="children.path">
<span>{{ children.title }}</span>
<span class="layui-font-12 layui-font-gray">
{{ children.subTitle }}
</span>
</router-link>
</div>
</li>
</ul>
2021-10-23 06:14:08 +00:00
</li>
</ul>
2021-10-24 12:35:43 +00:00
</lay-scroll>
</lay-side>
<lay-body>
<div style="padding: 20px">
<router-view />
</div>
</lay-body>
</lay-layout>
2021-10-22 01:18:40 +00:00
</template>
<script>
2022-04-05 02:31:31 +00:00
import { ref, watch } from "vue";
import { useRouter, useRoute } from "vue-router";
2021-10-22 01:18:40 +00:00
export default {
setup() {
2022-04-05 02:31:31 +00:00
const route = useRoute();
const router = useRouter();
const currentPath = ref("/zh-CN/guide");
2021-10-22 01:18:40 +00:00
watch(
() => route.path,
(val) => {
2022-04-05 02:31:31 +00:00
currentPath.value = val;
2021-10-22 01:18:40 +00:00
},
{
immediate: true,
deep: true,
}
2022-04-05 02:31:31 +00:00
);
2021-10-22 01:18:40 +00:00
const menus = [
{
id: 1,
2022-04-05 02:31:31 +00:00
title: "基础",
2021-10-23 06:14:08 +00:00
children: [
{
id: 1,
2022-04-05 02:31:31 +00:00
title: "介绍",
subTitle: "introduce",
path: "/zh-CN/guide/introduce",
2021-10-23 06:14:08 +00:00
},
{
id: 2,
2022-04-05 02:31:31 +00:00
title: "安装",
subTitle: "started",
path: "/zh-CN/guide/getStarted",
2021-10-23 06:14:08 +00:00
},
{
id: 3,
2022-04-05 02:31:31 +00:00
title: "更新",
subTitle: "change",
path: "/zh-CN/guide/changelog",
2021-12-07 10:25:49 +00:00
},
{
id: 3,
2022-04-05 02:31:31 +00:00
title: "主题",
subTitle: "theme",
path: "/zh-CN/guide/theme",
},
{
2022-03-30 13:16:15 +00:00
id: 3,
2022-04-05 02:31:31 +00:00
title: "夜间",
subTitle: "dark",
path: "/zh-CN/guide/dark",
},
{
id: 3,
2022-04-05 02:31:31 +00:00
title: "语言",
subTitle: "locale",
path: "/zh-CN/guide/locale",
},
2021-12-07 10:25:49 +00:00
{
id: 4,
2022-04-05 02:31:31 +00:00
title: "问题",
subTitle: "problem",
path: "/zh-CN/guide/problem",
2021-12-07 10:25:49 +00:00
},
{
id: 6,
2022-04-05 02:31:31 +00:00
title: "团队",
subTitle: "member",
path: "/zh-CN/guide/member",
},
2021-10-23 06:14:08 +00:00
],
2021-10-23 07:54:37 +00:00
},
2022-04-05 02:31:31 +00:00
];
2021-10-22 01:18:40 +00:00
2022-04-05 02:31:31 +00:00
const selected = ref(1);
2021-10-22 01:18:40 +00:00
const handleClick = function (menu) {
2022-04-05 02:31:31 +00:00
selected.value = menu.id;
router.push(menu.path);
};
2021-10-22 01:18:40 +00:00
return {
menus,
selected,
currentPath,
handleClick,
2022-04-05 02:31:31 +00:00
};
2021-10-22 01:18:40 +00:00
},
2022-04-05 02:31:31 +00:00
};
2021-10-23 07:54:37 +00:00
</script>