create-pactor-app 1.20.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/LICENSE +21 -0
- package/README.md +33 -0
- package/dist/cli.js +220 -0
- package/package.json +47 -0
- package/templates/next-app/README.md +112 -0
- package/templates/next-app/app/[[...slug]]/page.tsx +7 -0
- package/templates/next-app/app/api/auth/login/route.ts +32 -0
- package/templates/next-app/app/api/auth/logout/route.ts +22 -0
- package/templates/next-app/app/api/pages/[id]/route.ts +40 -0
- package/templates/next-app/app/api/sitemap/route.ts +21 -0
- package/templates/next-app/app/favicon.ico +0 -0
- package/templates/next-app/app/globals.css +12 -0
- package/templates/next-app/app/layout.tsx +28 -0
- package/templates/next-app/eslint.config.mjs +18 -0
- package/templates/next-app/package.json +30 -0
- package/templates/next-app/postcss.config.mjs +7 -0
- package/templates/next-app/public/file.svg +1 -0
- package/templates/next-app/public/globe.svg +1 -0
- package/templates/next-app/public/next.svg +1 -0
- package/templates/next-app/public/vercel.svg +1 -0
- package/templates/next-app/public/window.svg +1 -0
- package/templates/next-app/src/pactor/App.tsx +47 -0
- package/templates/next-app/src/pactor/config.ts +17 -0
- package/templates/next-app/src/server/accounts.ts +63 -0
- package/templates/next-app/src/server/cors.ts +34 -0
- package/templates/next-app/src/server/sitemap.ts +558 -0
- package/templates/next-app/tsconfig.json +34 -0
- package/templates/spa/README.md +97 -0
- package/templates/spa/index.html +13 -0
- package/templates/spa/package.json +29 -0
- package/templates/spa/src/main.tsx +12 -0
- package/templates/spa/src/pactor/App.tsx +27 -0
- package/templates/spa/src/pactor/config.ts +18 -0
- package/templates/spa/tsconfig.json +19 -0
- package/templates/spa/vite.config.ts +14 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__APP_NAME__",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"preview": "vite preview",
|
|
10
|
+
"typecheck": "tsc --noEmit"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@pactor-app/core": "^1.20.0",
|
|
14
|
+
"@pactor-app/runtime": "^1.20.0",
|
|
15
|
+
"@pactor-app/ui": "^1.20.0",
|
|
16
|
+
"pactor-app": "^1.20.0",
|
|
17
|
+
"react": "19.2.8",
|
|
18
|
+
"react-dom": "19.2.8",
|
|
19
|
+
"react-router-dom": "^7.18.2"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^20",
|
|
23
|
+
"@types/react": "^19",
|
|
24
|
+
"@types/react-dom": "^19",
|
|
25
|
+
"@vitejs/plugin-react": "^5.0.0",
|
|
26
|
+
"typescript": "^5",
|
|
27
|
+
"vite": "^8.2.1"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StrictMode } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
// 默认 UI 为 @pactor-app/ui 内置实现,样式表导入为必需步骤
|
|
4
|
+
import "@pactor-app/ui/styles.css";
|
|
5
|
+
|
|
6
|
+
import { App } from "./pactor/App";
|
|
7
|
+
|
|
8
|
+
createRoot(document.getElementById("root")!).render(
|
|
9
|
+
<StrictMode>
|
|
10
|
+
<App />
|
|
11
|
+
</StrictMode>,
|
|
12
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SitemapApp } from "pactor-app";
|
|
2
|
+
|
|
3
|
+
import { apiBaseUrl, sitemapSources } from "./config";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 动态页面应用(design/dynamic-page.md)——纯前端 SPA 模式:
|
|
7
|
+
* 不传 pathname / navigate / query,框架内置浏览器路由
|
|
8
|
+
* (History API 导航 + popstate 前进后退)。路由解析 / 访问守卫 /
|
|
9
|
+
* DSL 布局(PageOutlet + SitemapMenu)/ 页面懒加载 / session.context 桥 /
|
|
10
|
+
* 缺省动作(app.reload / service.call)全部由 @pactor-app/app 内置;
|
|
11
|
+
* 此处只提供:sitemap 源、baseUrl(相对接口地址补全)与 HTTP 钩子。
|
|
12
|
+
*
|
|
13
|
+
* 登录 / 登出是普通 HTTP 调用,由 DSL 中的内置 request 动作直接表达
|
|
14
|
+
* (见服务端下发的登录页 / 布局 DSL),无需客户端注册服务。
|
|
15
|
+
* HTTP 钩子用框架默认实现 createHttpHooks:{ code, data, message } 拆包;
|
|
16
|
+
* 后端包裹协议不同 / 需公共头注入时传 options,需要代理改写时传
|
|
17
|
+
* proxyPrefix,或自行实现 PactorHttpHooks。
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export function App() {
|
|
21
|
+
return (
|
|
22
|
+
<SitemapApp
|
|
23
|
+
sources={sitemapSources}
|
|
24
|
+
baseUrl={apiBaseUrl}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 入口配置(design/dynamic-page.md):开发者在此配置一个或多个
|
|
3
|
+
* 返回 sitemap 对象的接口 URL。多源时 pages / menus / layouts 按键合并
|
|
4
|
+
* (id / path 冲突后源覆盖前源并告警),app / user / permissions / auth
|
|
5
|
+
* 取第一个源。
|
|
6
|
+
*
|
|
7
|
+
* 本模板不自带后端:接口复用 next-app-starter 的 mock API
|
|
8
|
+
* (apiBaseUrl 指向其 dev server,已开通 CORS)。sources / pageEndpoint
|
|
9
|
+
* 只写相对路径,由 apiBaseUrl 补全为外部绝对地址,浏览器直连,
|
|
10
|
+
* 无需项目内代理。
|
|
11
|
+
*/
|
|
12
|
+
export const sitemapSources: string[] = ["/api/sitemap"];
|
|
13
|
+
|
|
14
|
+
/** 外部接口基准地址(SitemapApp baseUrl):相对接口路径以此为基准补全 */
|
|
15
|
+
export const apiBaseUrl = "http://localhost:9011";
|
|
16
|
+
|
|
17
|
+
/** 懒加载页面端点(pages[].pageDsl 缺省时按 id 获取) */
|
|
18
|
+
export const pageEndpoint = (pageId: string): string => `/api/pages/${pageId}`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"useDefineForClassFields": true,
|
|
14
|
+
"allowImportingTsExtensions": true,
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
"types": ["node"]
|
|
17
|
+
},
|
|
18
|
+
"include": ["src", "vite.config.ts"]
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import react from "@vitejs/plugin-react";
|
|
2
|
+
import { defineConfig } from "vite";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
plugins: [react()],
|
|
6
|
+
resolve: {
|
|
7
|
+
// pactor 依赖经 link: 指向本仓 packages/*,去重避免多份 React 实例
|
|
8
|
+
dedupe: ["react", "react-dom", "react-router-dom"],
|
|
9
|
+
},
|
|
10
|
+
server: {
|
|
11
|
+
port: 9012,
|
|
12
|
+
strictPort: true,
|
|
13
|
+
},
|
|
14
|
+
});
|