@finesoft/create-app 0.1.0
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.mjs +129 -0
- package/package.json +26 -0
- package/templates/react/env.d.ts +1 -0
- package/templates/react/index.html +13 -0
- package/templates/react/package.json +21 -0
- package/templates/react/src/App.tsx +20 -0
- package/templates/react/src/actions.ts +14 -0
- package/templates/react/src/bootstrap.ts +36 -0
- package/templates/react/src/components/Layout.tsx +63 -0
- package/templates/react/src/components/Loading.tsx +3 -0
- package/templates/react/src/components/Navigation.tsx +51 -0
- package/templates/react/src/components/PageRenderer.tsx +41 -0
- package/templates/react/src/components/ProductCard.tsx +35 -0
- package/templates/react/src/lib/controllers/about.ts +18 -0
- package/templates/react/src/lib/controllers/error.ts +11 -0
- package/templates/react/src/lib/controllers/home.ts +53 -0
- package/templates/react/src/lib/controllers/product-detail.ts +52 -0
- package/templates/react/src/lib/controllers/search.ts +58 -0
- package/templates/react/src/lib/guards/auth.ts +17 -0
- package/templates/react/src/lib/guards/seo.ts +15 -0
- package/templates/react/src/lib/mappers/product.ts +27 -0
- package/templates/react/src/lib/models/product.ts +48 -0
- package/templates/react/src/lib/services/api-client.ts +28 -0
- package/templates/react/src/main.tsx +49 -0
- package/templates/react/src/pages/About.tsx +16 -0
- package/templates/react/src/pages/Home.tsx +34 -0
- package/templates/react/src/pages/NotFound.tsx +25 -0
- package/templates/react/src/pages/ProductDetail.tsx +34 -0
- package/templates/react/src/pages/Search.tsx +23 -0
- package/templates/react/src/ssr.tsx +23 -0
- package/templates/react/tsconfig.json +17 -0
- package/templates/react/vite.config.ts +20 -0
- package/templates/react-minimal/env.d.ts +1 -0
- package/templates/react-minimal/index.html +13 -0
- package/templates/react-minimal/package.json +21 -0
- package/templates/react-minimal/src/App.tsx +22 -0
- package/templates/react-minimal/src/bootstrap.ts +6 -0
- package/templates/react-minimal/src/lib/controllers/home.ts +14 -0
- package/templates/react-minimal/src/main.tsx +44 -0
- package/templates/react-minimal/src/ssr.tsx +25 -0
- package/templates/react-minimal/tsconfig.json +17 -0
- package/templates/react-minimal/vite.config.ts +12 -0
- package/templates/svelte/env.d.ts +9 -0
- package/templates/svelte/index.html +13 -0
- package/templates/svelte/package.json +18 -0
- package/templates/svelte/src/App.svelte +85 -0
- package/templates/svelte/src/actions.ts +14 -0
- package/templates/svelte/src/bootstrap.ts +36 -0
- package/templates/svelte/src/components/Layout.svelte +19 -0
- package/templates/svelte/src/components/Loading.svelte +1 -0
- package/templates/svelte/src/components/Navigation.svelte +75 -0
- package/templates/svelte/src/components/PageRenderer.svelte +22 -0
- package/templates/svelte/src/components/ProductCard.svelte +37 -0
- package/templates/svelte/src/lib/controllers/about.ts +18 -0
- package/templates/svelte/src/lib/controllers/error.ts +11 -0
- package/templates/svelte/src/lib/controllers/home.ts +53 -0
- package/templates/svelte/src/lib/controllers/product-detail.ts +52 -0
- package/templates/svelte/src/lib/controllers/search.ts +58 -0
- package/templates/svelte/src/lib/framework-svelte.ts +34 -0
- package/templates/svelte/src/lib/guards/auth.ts +17 -0
- package/templates/svelte/src/lib/guards/seo.ts +15 -0
- package/templates/svelte/src/lib/mappers/product.ts +27 -0
- package/templates/svelte/src/lib/models/product.ts +47 -0
- package/templates/svelte/src/lib/render.ts +15 -0
- package/templates/svelte/src/lib/services/api-client.ts +28 -0
- package/templates/svelte/src/main.ts +27 -0
- package/templates/svelte/src/pages/About.svelte +10 -0
- package/templates/svelte/src/pages/Home.svelte +34 -0
- package/templates/svelte/src/pages/NotFound.svelte +23 -0
- package/templates/svelte/src/pages/ProductDetail.svelte +32 -0
- package/templates/svelte/src/pages/Search.svelte +29 -0
- package/templates/svelte/src/ssr.ts +12 -0
- package/templates/svelte/tsconfig.json +16 -0
- package/templates/svelte/vite.config.ts +21 -0
- package/templates/svelte-minimal/env.d.ts +9 -0
- package/templates/svelte-minimal/index.html +13 -0
- package/templates/svelte-minimal/package.json +18 -0
- package/templates/svelte-minimal/src/App.svelte +63 -0
- package/templates/svelte-minimal/src/bootstrap.ts +6 -0
- package/templates/svelte-minimal/src/lib/controllers/home.ts +15 -0
- package/templates/svelte-minimal/src/lib/framework-svelte.ts +34 -0
- package/templates/svelte-minimal/src/lib/render.ts +12 -0
- package/templates/svelte-minimal/src/main.ts +22 -0
- package/templates/svelte-minimal/src/pages/Home.svelte +10 -0
- package/templates/svelte-minimal/src/ssr.ts +18 -0
- package/templates/svelte-minimal/tsconfig.json +16 -0
- package/templates/svelte-minimal/vite.config.ts +12 -0
- package/templates/vue/env.d.ts +7 -0
- package/templates/vue/index.html +13 -0
- package/templates/vue/package.json +18 -0
- package/templates/vue/src/App.vue +29 -0
- package/templates/vue/src/actions.ts +14 -0
- package/templates/vue/src/bootstrap.ts +42 -0
- package/templates/vue/src/components/Layout.vue +18 -0
- package/templates/vue/src/components/Loading.vue +3 -0
- package/templates/vue/src/components/Navigation.vue +58 -0
- package/templates/vue/src/components/PageRenderer.vue +26 -0
- package/templates/vue/src/components/ProductCard.vue +39 -0
- package/templates/vue/src/lib/controllers/about.ts +18 -0
- package/templates/vue/src/lib/controllers/error.ts +11 -0
- package/templates/vue/src/lib/controllers/home.ts +53 -0
- package/templates/vue/src/lib/controllers/product-detail.ts +52 -0
- package/templates/vue/src/lib/controllers/search.ts +58 -0
- package/templates/vue/src/lib/guards/auth.ts +17 -0
- package/templates/vue/src/lib/guards/seo.ts +15 -0
- package/templates/vue/src/lib/mappers/product.ts +27 -0
- package/templates/vue/src/lib/models/product.ts +47 -0
- package/templates/vue/src/lib/services/api-client.ts +31 -0
- package/templates/vue/src/main.ts +46 -0
- package/templates/vue/src/pages/About.vue +16 -0
- package/templates/vue/src/pages/Home.vue +38 -0
- package/templates/vue/src/pages/NotFound.vue +22 -0
- package/templates/vue/src/pages/ProductDetail.vue +34 -0
- package/templates/vue/src/pages/Search.vue +33 -0
- package/templates/vue/src/ssr.ts +24 -0
- package/templates/vue/tsconfig.json +17 -0
- package/templates/vue/vite.config.ts +20 -0
- package/templates/vue-minimal/env.d.ts +7 -0
- package/templates/vue-minimal/index.html +13 -0
- package/templates/vue-minimal/package.json +18 -0
- package/templates/vue-minimal/src/App.vue +21 -0
- package/templates/vue-minimal/src/bootstrap.ts +6 -0
- package/templates/vue-minimal/src/lib/controllers/home.ts +15 -0
- package/templates/vue-minimal/src/main.ts +41 -0
- package/templates/vue-minimal/src/pages/Home.vue +12 -0
- package/templates/vue-minimal/src/ssr.ts +28 -0
- package/templates/vue-minimal/tsconfig.json +17 -0
- package/templates/vue-minimal/vite.config.ts +12 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createSSRRender, serializeServerData } from "@finesoft/front";
|
|
2
|
+
import { createSSRApp } from "vue";
|
|
3
|
+
import { renderToString } from "vue/server-renderer";
|
|
4
|
+
import App from "./App.vue";
|
|
5
|
+
import { bootstrap } from "./bootstrap";
|
|
6
|
+
import { getErrorPage } from "./lib/controllers/error";
|
|
7
|
+
|
|
8
|
+
export const render = createSSRRender({
|
|
9
|
+
bootstrap,
|
|
10
|
+
getErrorPage,
|
|
11
|
+
async renderApp(page, _locale) {
|
|
12
|
+
const app = createSSRApp(App, { page });
|
|
13
|
+
const html = await renderToString(app);
|
|
14
|
+
return {
|
|
15
|
+
html,
|
|
16
|
+
head: `<title>${page.title}</title><meta name="description" content="${
|
|
17
|
+
page.description ?? ""
|
|
18
|
+
}">`,
|
|
19
|
+
css: "",
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export { serializeServerData };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"strict": true,
|
|
4
|
+
"target": "ESNext",
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"jsx": "preserve",
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"noEmit": true,
|
|
12
|
+
"paths": {
|
|
13
|
+
"@/*": ["./src/*"]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"include": ["src/**/*", "env.d.ts"]
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { finesoftFrontViteConfig } from "@finesoft/front";
|
|
2
|
+
import vue from "@vitejs/plugin-vue";
|
|
3
|
+
import { defineConfig } from "vite-plus";
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [
|
|
7
|
+
vue(),
|
|
8
|
+
finesoftFrontViteConfig({
|
|
9
|
+
ssr: { entry: "src/ssr.ts" },
|
|
10
|
+
locales: ["en", "zh"],
|
|
11
|
+
defaultLocale: "en",
|
|
12
|
+
proxies: [
|
|
13
|
+
{
|
|
14
|
+
prefix: "/api",
|
|
15
|
+
target: "https://jsonplaceholder.typicode.com",
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
}),
|
|
19
|
+
],
|
|
20
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="<!--ssr-lang-->">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<!--ssr-head-->
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="app"><!--ssr-body--></div>
|
|
10
|
+
<!--ssr-data-->
|
|
11
|
+
<script type="module" src="/src/main.ts"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "finesoft-vue-minimal",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vp dev",
|
|
7
|
+
"build": "vp build",
|
|
8
|
+
"preview": "vp preview"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@finesoft/front": "workspace:*",
|
|
12
|
+
"vue": "^3.5.0"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@vitejs/plugin-vue": "^5.0.0",
|
|
16
|
+
"vite-plus": "catalog:"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Action, BasePage } from "@finesoft/front";
|
|
3
|
+
import { computed } from "vue";
|
|
4
|
+
import Home from "./pages/Home.vue";
|
|
5
|
+
|
|
6
|
+
const { state, page: ssrPage } = defineProps<{
|
|
7
|
+
state?: { page: BasePage | null; loading: boolean };
|
|
8
|
+
page?: BasePage;
|
|
9
|
+
onAction?: (action: Action) => void;
|
|
10
|
+
}>();
|
|
11
|
+
|
|
12
|
+
const currentPage = computed(() => state?.page ?? ssrPage ?? null);
|
|
13
|
+
const loading = computed(() => state?.loading ?? false);
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<main style="padding: 1rem">
|
|
18
|
+
<p v-if="loading" style="text-align: center; color: #999">Loading…</p>
|
|
19
|
+
<Home v-else-if="currentPage" :page="currentPage" />
|
|
20
|
+
</main>
|
|
21
|
+
</template>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Framework, defineRoutes } from "@finesoft/front";
|
|
2
|
+
import { HomeController } from "./lib/controllers/home";
|
|
3
|
+
|
|
4
|
+
export function bootstrap(framework: Framework): void {
|
|
5
|
+
defineRoutes(framework, [{ path: "/", intentId: "home", controller: new HomeController() }]);
|
|
6
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseController, type BasePage } from "@finesoft/front";
|
|
2
|
+
|
|
3
|
+
export class HomeController extends BaseController<Record<string, string>, BasePage> {
|
|
4
|
+
readonly intentId = "home";
|
|
5
|
+
|
|
6
|
+
execute(): BasePage {
|
|
7
|
+
return {
|
|
8
|
+
id: "home",
|
|
9
|
+
pageType: "home",
|
|
10
|
+
url: "/",
|
|
11
|
+
title: "Home",
|
|
12
|
+
description: "Welcome to Finesoft Front",
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { startBrowserApp, type Action, type BasePage, type Framework } from "@finesoft/front";
|
|
2
|
+
import { createApp, reactive } from "vue";
|
|
3
|
+
import App from "./App.vue";
|
|
4
|
+
import { bootstrap } from "./bootstrap";
|
|
5
|
+
|
|
6
|
+
void startBrowserApp({
|
|
7
|
+
bootstrap,
|
|
8
|
+
mount(target: HTMLElement, { framework }: { framework: Framework; locale: string }) {
|
|
9
|
+
const state = reactive<{ page: BasePage | null; loading: boolean }>({
|
|
10
|
+
page: null,
|
|
11
|
+
loading: false,
|
|
12
|
+
});
|
|
13
|
+
const handleAction = (action: Action) => {
|
|
14
|
+
void framework.perform(action);
|
|
15
|
+
};
|
|
16
|
+
createApp(App, { state, onAction: handleAction }).mount(target);
|
|
17
|
+
|
|
18
|
+
return ({
|
|
19
|
+
page,
|
|
20
|
+
isFirstPage,
|
|
21
|
+
}: {
|
|
22
|
+
page: Promise<BasePage> | BasePage;
|
|
23
|
+
isFirstPage?: boolean;
|
|
24
|
+
}) => {
|
|
25
|
+
if (page instanceof Promise) {
|
|
26
|
+
if (!isFirstPage) state.loading = true;
|
|
27
|
+
void page.then((p) => {
|
|
28
|
+
state.page = p;
|
|
29
|
+
state.loading = false;
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
state.page = page;
|
|
33
|
+
state.loading = false;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
callbacks: {
|
|
38
|
+
onNavigate() {},
|
|
39
|
+
onModal() {},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createSSRRender, serializeServerData } from "@finesoft/front";
|
|
2
|
+
import { createSSRApp } from "vue";
|
|
3
|
+
import { renderToString } from "vue/server-renderer";
|
|
4
|
+
import App from "./App.vue";
|
|
5
|
+
import { bootstrap } from "./bootstrap";
|
|
6
|
+
|
|
7
|
+
export const render = createSSRRender({
|
|
8
|
+
bootstrap,
|
|
9
|
+
getErrorPage(status, message) {
|
|
10
|
+
return {
|
|
11
|
+
id: "error",
|
|
12
|
+
pageType: "error",
|
|
13
|
+
title: `Error ${status}`,
|
|
14
|
+
description: message,
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
async renderApp(page, _locale) {
|
|
18
|
+
const app = createSSRApp(App, { page });
|
|
19
|
+
const html = await renderToString(app);
|
|
20
|
+
return {
|
|
21
|
+
html,
|
|
22
|
+
head: `<title>${page.title}</title>`,
|
|
23
|
+
css: "",
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export { serializeServerData };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"strict": true,
|
|
4
|
+
"target": "ESNext",
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"jsx": "preserve",
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"noEmit": true,
|
|
12
|
+
"paths": {
|
|
13
|
+
"@/*": ["./src/*"]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"include": ["src/**/*", "env.d.ts"]
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { finesoftFrontViteConfig } from "@finesoft/front";
|
|
2
|
+
import vue from "@vitejs/plugin-vue";
|
|
3
|
+
import { defineConfig } from "vite-plus";
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [
|
|
7
|
+
vue(),
|
|
8
|
+
finesoftFrontViteConfig({
|
|
9
|
+
ssr: { entry: "src/ssr.ts" },
|
|
10
|
+
}),
|
|
11
|
+
],
|
|
12
|
+
});
|