2022-03-28 07:06:36 +00:00
|
|
|
<script setup>
|
|
|
|
import { ref } from 'vue';
|
2022-03-15 09:33:28 +00:00
|
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
import { useRole } from 'src/composables/useRole';
|
|
|
|
import routes from 'src/router/routes';
|
|
|
|
|
|
|
|
const { t } = useI18n();
|
|
|
|
const { hasAny } = useRole();
|
|
|
|
|
|
|
|
const mainRoute = routes.find(route => route.path === '/');
|
2022-03-28 07:06:36 +00:00
|
|
|
const modules = mainRoute && mainRoute.children || []
|
2022-03-15 09:33:28 +00:00
|
|
|
|
2022-03-28 07:06:36 +00:00
|
|
|
const items = ref([]);
|
2022-03-15 09:33:28 +00:00
|
|
|
for (const module of modules) {
|
2022-03-28 07:06:36 +00:00
|
|
|
const item = {
|
2022-03-15 09:33:28 +00:00
|
|
|
path: module.path,
|
|
|
|
roles: []
|
|
|
|
};
|
|
|
|
|
|
|
|
if (module.meta) {
|
2022-03-28 07:06:36 +00:00
|
|
|
const meta = module.meta;
|
2022-03-15 09:33:28 +00:00
|
|
|
item.title = meta.title;
|
|
|
|
item.icon = meta.icon;
|
|
|
|
item.roles = meta.roles || [];
|
|
|
|
}
|
|
|
|
|
|
|
|
items.value.push(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<q-list padding>
|
|
|
|
<template v-for="route in items" :key="route.title">
|
|
|
|
<q-item
|
|
|
|
clickable
|
|
|
|
v-ripple
|
|
|
|
:to="{ path: route.path }"
|
|
|
|
v-if="!route.roles.length || hasAny(route.roles)"
|
|
|
|
active-class="text-orange"
|
|
|
|
>
|
|
|
|
<q-item-section avatar :if="route.icon">
|
|
|
|
<q-icon :name="route.icon" />
|
|
|
|
</q-item-section>
|
|
|
|
<q-item-section>{{ t(`pages.${route.title}`) }}</q-item-section>
|
|
|
|
</q-item>
|
|
|
|
</template>
|
|
|
|
</q-list>
|
|
|
|
</template>
|