Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit d8c5422

Browse files
committed
Clean up
1 parent b90ef10 commit d8c5422

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed

examples/react-app/routes/todos.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export default function Todos() {
9191
todos: [...data.todos, { id: 0, message, completed: false }],
9292
};
9393
},
94-
// replace the data from the server response
94+
// replace the data with the new data that is from the server response
9595
replace: true,
9696
});
9797
form.reset();

examples/react-app/server.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import { renderToReadableStream } from "react-dom/server";
44

55
serve({
66
routes: "./routes/**/*.{tsx,ts}",
7-
// to enable unocss, please add presets to unocss options
8-
// please check https://alephjs.org/docs/unocss
97
unocss: {
10-
// presets: [ unoPreset ],
8+
// to enable unocss, please add presets to unocss options
9+
// please check https://alephjs.org/docs/unocss
1110
},
1211
ssr: {
1312
// when set `suspense` to `true`, the router will loading data in suspense mode

framework/vue/data.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ const createDataProvider = () => {
109109
};
110110

111111
const reload = async (signal?: AbortSignal) => {
112-
console.log("reload");
113-
114112
try {
115113
const res = await fetch(dataUrl.value, { headers: { "Accept": "application/json" }, signal, redirect: "manual" });
116114
if (res.type === "opaqueredirect") {

framework/vue/router.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1+
import type { Component, Ref, ShallowRef } from "vue";
12
import {
2-
Component,
33
computed,
4-
createSSRApp as VueCreateSSRApp,
4+
createSSRApp as vueCreateSSRApp,
55
defineComponent,
66
h,
77
onBeforeUnmount,
8-
Ref,
98
ref,
10-
ShallowRef,
119
shallowRef,
1210
watch,
1311
} from "vue";
14-
import { matchRoutes, Route, RouteMeta, RouteModule, Routes } from "../core/route.ts";
12+
import type { Route, RouteMeta, RouteModule, RouteRecord } from "../core/route.ts";
13+
import { matchRoutes } from "../core/route.ts";
1514
import events from "../core/events.ts";
1615
import FetchError from "../core/fetch_error.ts";
16+
import { URLPatternCompat } from "../core/url_pattern.ts";
1717
import type { SSRContext } from "../../server/renderer.ts";
1818
import { RouterContext } from "./context.ts";
1919
import { Link } from "./link.ts";
2020
import { Head } from "./head.ts";
2121
import { Err } from "./error.ts";
22-
import { URLPatternCompat } from "../core/url_pattern.ts";
2322

2423
// deno-lint-ignore no-explicit-any
2524
const global = window as any;
@@ -143,10 +142,10 @@ const createRouter = (props: RouterProps) => {
143142
};
144143
const dataUrl = rmod.url.pathname + rmod.url.search;
145144
if (filename in routeModules) {
146-
rmod.defaultExport = routeModules[filename].defaultExport;
145+
Object.assign(rmod, routeModules[filename]);
147146
} else {
148-
const { defaultExport } = await importModule(meta);
149-
rmod.defaultExport = defaultExport;
147+
const { defaultExport, withData } = await importModule(meta);
148+
Object.assign(rmod, { defaultExport, withData });
150149
}
151150
if (!dataCache.has(dataUrl) && routeModules[filename]?.withData === true) {
152151
await prefetchData(dataUrl);
@@ -227,7 +226,7 @@ const createAppApi = (props?: RootProps) => {
227226
const modules = shallowRef(ssrContext?.routeModules || loadSSRModulesFromTag());
228227

229228
if (modules.value.length === 0) {
230-
return VueCreateSSRApp(Err, { status: 404, message: "page not found" });
229+
return vueCreateSSRApp(Err, { status: 404, message: "page not found" });
231230
}
232231

233232
const url = ref(ssrContext?.url || new URL(window.location?.href));
@@ -246,7 +245,7 @@ const createAppApi = (props?: RootProps) => {
246245
},
247246
});
248247

249-
const app = VueCreateSSRApp(App);
248+
const app = vueCreateSSRApp(App);
250249

251250
app.provide("modules", modules);
252251
app.provide("dataCache", dataCache);
@@ -261,7 +260,7 @@ const createAppApi = (props?: RootProps) => {
261260
return app;
262261
}
263262

264-
const errApp = VueCreateSSRApp(Err);
263+
const errApp = vueCreateSSRApp(Err);
265264

266265
return errApp;
267266
};
@@ -340,7 +339,7 @@ function getLoadingBar(): HTMLDivElement {
340339
return bar;
341340
}
342341

343-
function loadRoutesFromTag(): Routes {
342+
function loadRoutesFromTag(): RouteRecord {
344343
const el = window.document?.getElementById("routes-manifest");
345344
if (el) {
346345
try {

0 commit comments

Comments
 (0)