@revojs/vue 0.1.5 → 0.1.7
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.
- package/dist/index.js +9 -2
- package/dist/module/app.ts +10 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import "revojs";
|
|
2
|
-
import { addAssets, addRoutes, useKit } from "revojs/vite";
|
|
1
|
+
import { addAssets, addRoutes, useKit } from "@revojs/kit";
|
|
3
2
|
|
|
3
|
+
//#region ../revojs/dist/index.js
|
|
4
|
+
const ROUTER_CONTEXT = defineContext("ROUTER_CONTEXT");
|
|
5
|
+
const SERVER_CONTEXT = defineContext("SERVER_CONTEXT");
|
|
6
|
+
function defineContext(name) {
|
|
7
|
+
return name;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
4
11
|
//#region src/index.ts
|
|
5
12
|
function addPages(app, path) {
|
|
6
13
|
app.config.sources.pages?.entries.push(path);
|
package/dist/module/app.ts
CHANGED
|
@@ -4,14 +4,14 @@ import { createMemoryHistory, createRouter, createWebHistory, RouterView, type R
|
|
|
4
4
|
import Main from "#alias/vue/main";
|
|
5
5
|
import pages from "#virtual/pages";
|
|
6
6
|
|
|
7
|
-
function toRoute(path: string, node: Node<Component
|
|
7
|
+
function toRoute(path: string, node: Node<Component>, index: number): RouteRecordRaw {
|
|
8
8
|
const layout = node.children["+layout"];
|
|
9
9
|
|
|
10
10
|
if (layout) {
|
|
11
11
|
delete node.children["+layout"];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const children = Object.entries(node.children).map(([path, node]) => toRoute(path, node));
|
|
14
|
+
const children = Object.entries(node.children).map(([path, node]) => toRoute(path, node, index + 1));
|
|
15
15
|
|
|
16
16
|
if (node.value && (children.length || layout)) {
|
|
17
17
|
children.push({ path: "", component: node.value });
|
|
@@ -21,6 +21,10 @@ function toRoute(path: string, node: Node<Component>): RouteRecordRaw {
|
|
|
21
21
|
path += node.parameter;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
if (index === 0) {
|
|
25
|
+
path = "/";
|
|
26
|
+
}
|
|
27
|
+
|
|
24
28
|
const route = {
|
|
25
29
|
path,
|
|
26
30
|
children,
|
|
@@ -44,9 +48,11 @@ export default async (scope: Scope) => {
|
|
|
44
48
|
|
|
45
49
|
const router = createRouter({
|
|
46
50
|
history: import.meta.server ? createMemoryHistory() : createWebHistory(),
|
|
47
|
-
routes: Object.entries(radix.rootNode.children).map(([path, node]) => toRoute(path, node)),
|
|
51
|
+
routes: Object.entries(radix.rootNode.children).map(([path, node]) => toRoute(path, node, 0)),
|
|
48
52
|
});
|
|
49
53
|
|
|
54
|
+
const app = createSSRApp(Main).use(router).provide("REVOJS_SCOPE", scope);
|
|
55
|
+
|
|
50
56
|
if (import.meta.server) {
|
|
51
57
|
const { pathname } = useUrl(scope);
|
|
52
58
|
|
|
@@ -55,5 +61,5 @@ export default async (scope: Scope) => {
|
|
|
55
61
|
|
|
56
62
|
await router.isReady();
|
|
57
63
|
|
|
58
|
-
return
|
|
64
|
+
return app;
|
|
59
65
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revojs/vue",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": "coverbase/revojs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"watch": "tsdown -w"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"revojs": "*",
|
|
32
|
+
"@revojs/kit": "*",
|
|
33
33
|
"vue": "^3.5.19",
|
|
34
34
|
"vue-router": "^4.5.1"
|
|
35
35
|
},
|