Files
cool-admin/cool-admin-vue/src/modules/base/pages/main/components/global.vue

38 lines
770 B
Vue
Raw Normal View History

2025-08-15 20:58:57 +08:00
<template>
<component v-for="item in list" :key="item.name" :is="item.component" />
</template>
<script setup lang="ts">
import { isFunction, orderBy } from "lodash-es";
import { markRaw, onMounted, shallowRef } from "vue";
import { module } from "/@/cool";
const list = shallowRef<any[]>([]);
async function refresh() {
const arr = orderBy(
module.list.filter((e) => e.enable !== false && !!e.global).map((e) => e.global),
"order"
);
list.value = await Promise.all(
arr
.filter((e) => e?.component)
.map(async (e) => {
if (e) {
const c = await (isFunction(e.component) ? e.component() : e.component);
return {
...e,
component: markRaw(c.default || c)
};
}
})
);
}
onMounted(() => {
refresh();
});
</script>