chore: optimize loading by using defineComponent instead of defineAsyncComponent
This commit is contained in:
+23
-42
@@ -7,34 +7,6 @@ export async function compileCards(app: App<any>) {
|
||||
eager: true,
|
||||
});
|
||||
|
||||
// const components = await Promise.all(
|
||||
// Object.entries(svgs).map(async ([k, v]) => {
|
||||
// const regex = /([\d]+)(?=\.svg)/gm;
|
||||
// const url = (v as any).default as string;
|
||||
// let template = await (await fetch(url)).text();
|
||||
// let arrayTemplate = template.split("\n");
|
||||
// arrayTemplate.splice(0, 1);
|
||||
// template = arrayTemplate.join("\n");
|
||||
|
||||
// return [
|
||||
// k.match(regex)![0],
|
||||
// defineComponent({
|
||||
// props: ["used_effects_indexes", "card"],
|
||||
// setup(_props) {
|
||||
// const count = ref(0);
|
||||
// return { count };
|
||||
// },
|
||||
// methods: {
|
||||
// effectClick(effect: number) {
|
||||
// this.$emit("effectClick", effect);
|
||||
// },
|
||||
// },
|
||||
// template: template,
|
||||
// }),
|
||||
// ];
|
||||
// })
|
||||
// );
|
||||
|
||||
const components = await Promise.all(
|
||||
Object.entries(svgs).map(async ([k, v]) => {
|
||||
const regex = /([\d]+)(?=\.svg)/gm;
|
||||
@@ -52,20 +24,29 @@ export async function compileCards(app: App<any>) {
|
||||
template = arrayTemplate.join("\n");
|
||||
return [
|
||||
Number(k.match(regex)![0]).toString(),
|
||||
markRaw(
|
||||
defineAsyncComponent({
|
||||
loader: async () =>
|
||||
defineComponent({
|
||||
props: ["used_effects_indexes", "cardId"],
|
||||
methods: {
|
||||
effectClick(effect: number) {
|
||||
this.$emit("effectClick", effect);
|
||||
},
|
||||
},
|
||||
template: template,
|
||||
}),
|
||||
})
|
||||
),
|
||||
// markRaw(
|
||||
// defineAsyncComponent({
|
||||
// loader: async () =>
|
||||
// defineComponent({
|
||||
// props: ["used_effects_indexes", "cardId"],
|
||||
// methods: {
|
||||
// effectClick(effect: number) {
|
||||
// this.$emit("effectClick", effect);
|
||||
// },
|
||||
// },
|
||||
// template: template,
|
||||
// }),
|
||||
// })
|
||||
// ),
|
||||
defineComponent({
|
||||
props: ["used_effects_indexes", "cardId"],
|
||||
methods: {
|
||||
effectClick(effect: number) {
|
||||
this.$emit("effectClick", effect);
|
||||
},
|
||||
},
|
||||
template: template,
|
||||
}),
|
||||
];
|
||||
} catch (e) {
|
||||
console.error(e, k);
|
||||
|
||||
Reference in New Issue
Block a user