@nookuio/vue 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed
|
|
3
|
-
import { useQuery
|
|
4
|
-
import "./NotFound.vue";
|
|
5
|
-
const { query
|
|
6
|
-
if (!
|
|
2
|
+
import { computed, watch, shallowRef } from "vue";
|
|
3
|
+
import { useQuery } from "../composables/useQuery";
|
|
4
|
+
import ErrorComponent from "./NotFound.vue";
|
|
5
|
+
const { query } = useQuery(), componentPath = computed(() => query.value.path || ""), componentToRender = shallowRef(await importVueComponent(componentPath.value)), componentProps = computed(() => {
|
|
6
|
+
if (!query.value.props) return {};
|
|
7
7
|
try {
|
|
8
|
-
return new Function(`return ${
|
|
8
|
+
return new Function(`return ${query.value.props}`)();
|
|
9
9
|
} catch {
|
|
10
10
|
return {};
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
async function
|
|
14
|
-
if (!
|
|
15
|
-
const
|
|
13
|
+
async function importVueComponent(path) {
|
|
14
|
+
if (!path) return;
|
|
15
|
+
const buildAssetsURL = window?.__buildAssetsURL;
|
|
16
16
|
try {
|
|
17
|
-
return
|
|
17
|
+
return buildAssetsURL ? await import(
|
|
18
18
|
/* @vite-ignore */
|
|
19
|
-
|
|
19
|
+
buildAssetsURL(path)
|
|
20
20
|
).then(
|
|
21
|
-
(
|
|
21
|
+
(c) => query.value.name ? c?.[query.value.name] : c.default
|
|
22
22
|
) : await import(
|
|
23
23
|
/* @vite-ignore */
|
|
24
|
-
"/@fs/" +
|
|
24
|
+
"/@fs/" + path
|
|
25
25
|
).then(
|
|
26
|
-
(
|
|
26
|
+
(c) => query.value.name ? c?.[query.value.name] : c.default
|
|
27
27
|
);
|
|
28
28
|
} catch {
|
|
29
29
|
try {
|
|
30
30
|
return await import(
|
|
31
31
|
/* @vite-ignore */
|
|
32
|
-
|
|
33
|
-
).then((
|
|
34
|
-
} catch (
|
|
35
|
-
console.log("Error importing component:",
|
|
32
|
+
path
|
|
33
|
+
).then((c) => query.value.name ? c?.[query.value.name] : c.default);
|
|
34
|
+
} catch (err) {
|
|
35
|
+
console.log("Error importing component:", err);
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
watch(componentPath, async (path) => componentToRender.value = await importVueComponent(path));
|
|
41
41
|
</script>
|
|
42
42
|
|
|
43
43
|
<template>
|