wangzhibo
2026-07-18 b3b57afc45655de67ce80e37efb35c5756f7123c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<template>
    <div class="cool">
        <component v-for="item in list" :key="item.name" :is="item.component" />
    </div>
</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.index).map(e => e.index),
        '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>