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-04-01 10:58:41 +00:00
|
|
|
const moduleRoutes = mainRoute && mainRoute.children || []
|
2022-03-15 09:33:28 +00:00
|
|
|
|
2022-04-01 10:58:41 +00:00
|
|
|
const modules = ref([]);
|
|
|
|
for (const route of moduleRoutes) {
|
|
|
|
const module = {
|
|
|
|
path: route.path,
|
|
|
|
name: route.name.toLowerCase(),
|
2022-03-15 09:33:28 +00:00
|
|
|
roles: []
|
|
|
|
};
|
|
|
|
|
2022-04-01 10:58:41 +00:00
|
|
|
if (route.meta) {
|
|
|
|
Object.assign(module, route.meta);
|
2022-03-15 09:33:28 +00:00
|
|
|
}
|
|
|
|
|
2022-04-01 10:58:41 +00:00
|
|
|
modules.value.push(module);
|
2022-03-15 09:33:28 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<q-list padding>
|
2022-04-01 10:58:41 +00:00
|
|
|
<template v-for="module in modules" :key="module.title">
|
2022-03-15 09:33:28 +00:00
|
|
|
<q-item
|
|
|
|
clickable
|
|
|
|
v-ripple
|
2022-04-01 10:58:41 +00:00
|
|
|
:to="{ path: module.path }"
|
|
|
|
v-if="!module.roles.length || hasAny(module.roles)"
|
2022-03-15 09:33:28 +00:00
|
|
|
active-class="text-orange"
|
|
|
|
>
|
2022-04-01 10:58:41 +00:00
|
|
|
<q-item-section avatar :if="module.icon">
|
|
|
|
<q-icon :name="module.icon" />
|
2022-03-15 09:33:28 +00:00
|
|
|
</q-item-section>
|
2022-04-01 10:58:41 +00:00
|
|
|
<q-item-section>{{ t(`${module.name}.pageTitles.${module.title}`) }}</q-item-section>
|
2022-03-15 09:33:28 +00:00
|
|
|
</q-item>
|
|
|
|
</template>
|
|
|
|
</q-list>
|
|
|
|
</template>
|