create-yoya-ui 0.6.2 → 0.7.5

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.
Files changed (43) hide show
  1. package/package.json +1 -1
  2. package/templates/admin/README.md +1 -1
  3. package/templates/admin/RULES.md +3 -2
  4. package/templates/admin/package.json +9 -1
  5. package/templates/admin/src/api/domain.api.d.ts +1 -1
  6. package/templates/admin/src/api/domain.api.js +1 -1
  7. package/templates/admin/src/api/fetch.api.d.ts +1 -1
  8. package/templates/admin/src/features/dashboard/overview/components/dashboard-chart.js +40 -40
  9. package/templates/admin/src/features/dashboard/overview/pages/dashboard-overview-page.js +178 -181
  10. package/templates/admin/src/features/system/dicts/api/dict.mgr.d.ts +1 -1
  11. package/templates/admin/src/features/system/dicts/api/dict.mgr.js +1 -1
  12. package/templates/admin/src/features/system/dicts/api/dict.state.d.ts +1 -1
  13. package/templates/admin/src/features/system/dicts/components/dict-editor-dialog.js +13 -9
  14. package/templates/admin/src/features/system/dicts/components/dict-item-form-dialog.js +13 -9
  15. package/templates/admin/src/features/system/dicts/pages/dict-list-page.js +37 -43
  16. package/templates/admin/src/features/system/members/api/member.mgr.d.ts +1 -1
  17. package/templates/admin/src/features/system/members/api/member.mgr.js +1 -1
  18. package/templates/admin/src/features/system/members/api/member.req.d.ts +1 -1
  19. package/templates/admin/src/features/system/members/api/member.req.js +1 -1
  20. package/templates/admin/src/features/system/members/api/member.state.d.ts +1 -1
  21. package/templates/admin/src/features/system/members/components/member-form-dialog.js +13 -9
  22. package/templates/admin/src/features/system/members/components/member-toolbar.js +34 -40
  23. package/templates/admin/src/features/system/members/pages/member-list-page.js +13 -20
  24. package/templates/admin/src/features/system/permissions/api/permission.mgr.d.ts +1 -1
  25. package/templates/admin/src/features/system/permissions/api/permission.mgr.js +1 -1
  26. package/templates/admin/src/features/system/permissions/api/permission.state.d.ts +1 -1
  27. package/templates/admin/src/features/system/permissions/components/permission-form-dialog.js +13 -9
  28. package/templates/admin/src/features/system/permissions/pages/permission-list-page.js +16 -22
  29. package/templates/admin/src/features/system/roles/api/role.mgr.d.ts +1 -1
  30. package/templates/admin/src/features/system/roles/api/role.mgr.js +1 -1
  31. package/templates/admin/src/features/system/roles/api/role.state.d.ts +1 -1
  32. package/templates/admin/src/features/system/roles/components/role-form-dialog.js +13 -9
  33. package/templates/admin/src/features/system/roles/components/role-toolbar.js +33 -39
  34. package/templates/admin/src/features/system/roles/pages/role-list-page.js +13 -19
  35. package/templates/admin/src/main.js +1 -1
  36. package/templates/admin/src/shell/api/shell.req.js +1 -1
  37. package/templates/admin/src/shell/components/admin-shell.js +18 -21
  38. package/templates/admin/vite.config.js +7 -5
  39. package/templates/basic/package.json +2 -1
  40. package/templates/ssr/package.json +2 -1
  41. package/templates/ssr/src/home-page.js +3 -2
  42. package/templates/ssr/src/server.mjs +3 -0
  43. package/templates/ssr/vite.config.js +17 -0
@@ -5,27 +5,24 @@ import { AppSidebar } from './app-sidebar.js';
5
5
  // 外壳装配:只做布局组装。路由与导航动作都在 ShellState,
6
6
  // URL 变化 → state.syncFromPath() 写入导航信号 → 顶栏 / 侧栏区域自行更新。
7
7
  export function AdminShell({ state }) {
8
- return {
9
- render() {
10
- return vBody((shell) => {
11
- shell.gap(0);
12
- shell.maxWidth('100%');
13
- shell.padding(0);
14
- shell.vContainer((frame) => {
15
- frame.viewport(true);
16
- frame.vHeader({ height: 56 }, (header) => {
17
- header.style('padding', '0');
18
- header.child(AppNavbar({ state }));
19
- });
20
- frame.vContainer((body) => {
21
- body.style({ flex: '1 1 auto', minHeight: '0' });
22
- body.child(AppSidebar({ state }));
23
- body.vMain((main) => {
24
- main.child(vRouterViews(state.router(), { lockTitle: true, title: '内容区' }));
25
- });
26
- });
8
+ // 形态 A 薄工厂:没有对外命令方法,装配即返回视图节点(不必包一层 `render()`)
9
+ return vBody((shell) => {
10
+ shell.gap(0);
11
+ shell.maxWidth('100%');
12
+ shell.padding(0);
13
+ shell.vContainer((frame) => {
14
+ frame.viewport(true);
15
+ frame.vHeader({ height: 56 }, (header) => {
16
+ header.style('padding', '0');
17
+ header.child(AppNavbar({ state }));
18
+ });
19
+ frame.vContainer((body) => {
20
+ body.style({ flex: '1 1 auto', minHeight: '0' });
21
+ body.child(AppSidebar({ state }));
22
+ body.vMain((main) => {
23
+ main.child(vRouterViews(state.router(), { lockTitle: true, title: '内容区' }));
27
24
  });
28
25
  });
29
- }
30
- };
26
+ });
27
+ });
31
28
  }
@@ -2,17 +2,19 @@ import { defineConfig } from 'vite';
2
2
  import { existsSync } from 'node:fs';
3
3
  import { fileURLToPath } from 'node:url';
4
4
 
5
- // 本地仓库联调:模板直接使用 yoya-ui 的 src 源码(含最新权限能力)。
6
- // 脚手架生成的项目(模板被复制出去)不存在该路径,自动回退到 npm 包解析。
7
- const localUi = fileURLToPath(new URL('../../../src/index.js', import.meta.url));
8
- const localCss = fileURLToPath(new URL('../../../src/yoya.ui.css', import.meta.url));
5
+ // 本地仓库联调:模板直接使用 yoya-ui 的 src 源码(含最新能力)。
6
+ // 脚手架生成的项目(模板被复制出去)不存在该路径,自动回退到 npm 包解析(走 exports 映射)。
7
+ const localUi = fileURLToPath(new URL('../../../yoya-ui/src/index.js', import.meta.url));
9
8
  const useLocal = existsSync(localUi);
9
+ // 子入口也要指到源码:`@yoyaflow/yoya-core/api` → `packages/yoya-core/src/api.js`(`ui.css` 单独一条,见下)
10
+ const localSource = (path) => fileURLToPath(new URL(`../../../src/${path}`, import.meta.url));
10
11
 
11
12
  export default defineConfig({
12
13
  resolve: useLocal
13
14
  ? {
14
15
  alias: [
15
- { find: /^@yoyaflow\/yoya-ui\/ui\.css$/, replacement: localCss },
16
+ { find: /^@yoyaflow\/yoya-ui\/ui\.css$/, replacement: localSource('yoya.ui.css') },
17
+ { find: /^@yoyaflow\/yoya-ui\/([\w.-]+)$/, replacement: localSource('yoya.$1.js') },
16
18
  { find: '@yoyaflow/yoya-ui', replacement: localUi }
17
19
  ]
18
20
  }
@@ -9,7 +9,8 @@
9
9
  "preview": "vite preview"
10
10
  },
11
11
  "dependencies": {
12
- "@yoyaflow/yoya-ui": "^0.6.2"
12
+ "@yoyaflow/yoya-core": "0.7.5",
13
+ "@yoyaflow/yoya-ui": "0.7.5"
13
14
  },
14
15
  "devDependencies": {
15
16
  "vite": "^8.2.0"
@@ -9,7 +9,8 @@
9
9
  "preview": "npm run build && npm start"
10
10
  },
11
11
  "dependencies": {
12
- "@yoyaflow/yoya-ui": "^0.6.2"
12
+ "@yoyaflow/yoya-core": "0.7.5",
13
+ "@yoyaflow/yoya-ui": "0.7.5"
13
14
  },
14
15
  "devDependencies": {
15
16
  "vite": "^8.2.0"
@@ -1,4 +1,4 @@
1
- import { div } from '@yoyaflow/yoya-ui/core';
1
+ import { div } from '@yoyaflow/yoya-core';
2
2
  import { createRouter } from '@yoyaflow/yoya-ui/router';
3
3
 
4
4
  export const messages = {
@@ -12,7 +12,8 @@ export function HomePage(state) {
12
12
  router.mode(state.mode || 'history');
13
13
  router.route('/home', '首页'.s('home'));
14
14
  router.notFound('未找到');
15
- router.renderPath(state.path || '/home');
15
+ // 首页同时挂在 '/':不然默认请求(path === '/')落到 notFound,首屏直接显示「未找到」
16
+ router.renderPath(!state.path || state.path === '/' ? '/home' : state.path);
16
17
 
17
18
  return div((root) => {
18
19
  root.h1('SSR 示例'.s('title'));
@@ -1,6 +1,9 @@
1
1
  import { createServer } from 'node:http';
2
2
  import { existsSync, readFileSync } from 'node:fs';
3
3
  import { extname, join } from 'node:path';
4
+ // 加载 ui 组件域:`body.vBody(...)` 这类 child factory 由该入口注册,
5
+ // 只引 `/router` 时 body 上不存在 vBody(服务端首请求会 TypeError)。
6
+ import '@yoyaflow/yoya-ui/ui';
4
7
  import { renderPage } from '@yoyaflow/yoya-ui/router';
5
8
  import { HomePage, messages } from './home-page.js';
6
9
 
@@ -1,6 +1,23 @@
1
1
  import { defineConfig } from 'vite';
2
+ import { existsSync } from 'node:fs';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ // 本地仓库联调:仓库内跑模板时直接用 yoya-ui 的 src 源码;
6
+ // 脚手架生成出去的项目没有这个路径,自动回退到 npm 包解析(走 exports 映射)。
7
+ const localUi = fileURLToPath(new URL('../../../yoya-ui/src/index.js', import.meta.url));
8
+ const useLocal = existsSync(localUi);
9
+ const localSource = (path) => fileURLToPath(new URL(`../../../src/${path}`, import.meta.url));
2
10
 
3
11
  export default defineConfig({
12
+ resolve: useLocal
13
+ ? {
14
+ alias: [
15
+ { find: /^@yoyaflow\/yoya-ui\/ui\.css$/, replacement: localSource('yoya.ui.css') },
16
+ { find: /^@yoyaflow\/yoya-ui\/([\w.-]+)$/, replacement: localSource('yoya.$1.js') },
17
+ { find: '@yoyaflow/yoya-ui', replacement: localUi }
18
+ ]
19
+ }
20
+ : undefined,
4
21
  build: {
5
22
  emptyOutDir: true,
6
23
  outDir: 'dist',