create-lumal-admin 0.0.4-beta → 0.0.6-beta

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 (185) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +98 -12
  3. package/dist/cli.d.ts +18 -1
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/cli.js +308 -28
  6. package/dist/cli.js.map +1 -1
  7. package/dist/create.d.ts +11 -1
  8. package/dist/create.d.ts.map +1 -1
  9. package/dist/create.js +98 -2
  10. package/dist/create.js.map +1 -1
  11. package/dist/index.d.ts +2 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +1 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/presets.d.ts +41 -0
  16. package/dist/presets.d.ts.map +1 -0
  17. package/dist/presets.js +58 -0
  18. package/dist/presets.js.map +1 -0
  19. package/dist/project-cli.d.ts +3 -0
  20. package/dist/project-cli.d.ts.map +1 -0
  21. package/dist/project-cli.js +13 -0
  22. package/dist/project-cli.js.map +1 -0
  23. package/dist/projects.d.ts +21 -0
  24. package/dist/projects.d.ts.map +1 -0
  25. package/dist/projects.js +124 -0
  26. package/dist/projects.js.map +1 -0
  27. package/dist/scaffold.d.ts +2 -11
  28. package/dist/scaffold.d.ts.map +1 -1
  29. package/dist/scaffold.js +2 -1602
  30. package/dist/scaffold.js.map +1 -1
  31. package/dist/templates.d.ts +7 -0
  32. package/dist/templates.d.ts.map +1 -0
  33. package/dist/templates.js +91 -0
  34. package/dist/templates.js.map +1 -0
  35. package/dist/types.d.ts +64 -0
  36. package/dist/types.d.ts.map +1 -0
  37. package/dist/types.js +2 -0
  38. package/dist/types.js.map +1 -0
  39. package/package.json +13 -4
  40. package/templates/base/.env.example +4 -0
  41. package/templates/base/API-CONTRACT.md +84 -0
  42. package/templates/base/README.md +59 -0
  43. package/templates/base/index.html +12 -0
  44. package/templates/base/package.json +38 -0
  45. package/templates/base/src/App.vue +206 -0
  46. package/templates/base/src/app/components/AppHeaderActions.vue +46 -0
  47. package/templates/base/src/app/components/AppSettingsDrawer.vue +37 -0
  48. package/templates/base/src/app/menu-policy.ts +163 -0
  49. package/templates/base/src/app/module.ts +46 -0
  50. package/templates/base/src/app/router/index.ts +107 -0
  51. package/templates/base/src/app/router/views.ts +12 -0
  52. package/templates/base/src/app/services/access.ts +2 -0
  53. package/templates/base/src/app/services/contracts.ts +54 -0
  54. package/templates/base/src/app/services/local-contracts.ts +18 -0
  55. package/templates/base/src/app/services/preferences.ts +41 -0
  56. package/templates/base/src/app/services/session-runtime.ts +186 -0
  57. package/templates/base/src/app/services/session.ts +14 -0
  58. package/templates/base/src/app/stored-menus.ts +72 -0
  59. package/templates/base/src/app/views/SafeIframeView.vue +34 -0
  60. package/templates/base/src/app/views/auth/LoginView.vue +75 -0
  61. package/templates/base/src/app/views/error/ForbiddenView.vue +20 -0
  62. package/templates/base/src/app/views/error/NotFoundView.vue +16 -0
  63. package/templates/base/src/main.ts +40 -0
  64. package/templates/base/src/modules/business/README.md +33 -0
  65. package/templates/base/src/modules/dashboard/DashboardView.vue +27 -0
  66. package/templates/base/src/modules/dashboard/module.ts +14 -0
  67. package/templates/base/src/shared/api.ts +53 -0
  68. package/templates/base/src/shared/components/BaseEntityDialog.vue +39 -0
  69. package/templates/base/src/shared/composables/use-async-data.ts +35 -0
  70. package/templates/base/src/shared/composables/use-entity-editor.ts +77 -0
  71. package/templates/base/src/shared/status.ts +4 -0
  72. package/templates/base/src/shared/tree.ts +41 -0
  73. package/templates/base/src/styles.scss +173 -0
  74. package/templates/base/tests/menu-policy.test.ts.template +89 -0
  75. package/templates/base/tests/session.test.ts.template +45 -0
  76. package/templates/base/vite.config.ts +54 -0
  77. package/templates/blank/README.md +6 -0
  78. package/templates/blank/src/App.vue +11 -0
  79. package/templates/common/AGENTS.md +13 -0
  80. package/templates/common/_editorconfig +15 -0
  81. package/templates/common/_gitattributes +6 -0
  82. package/templates/common/_gitignore +7 -0
  83. package/templates/common/_prettierignore +6 -0
  84. package/templates/common/docs/DEVELOPMENT.md +26 -0
  85. package/templates/common/eslint.config.mjs +60 -0
  86. package/templates/common/package.json +39 -0
  87. package/templates/common/prettier.config.mjs +8 -0
  88. package/templates/common/tsconfig.json +19 -0
  89. package/templates/common/vitest.config.ts +3 -0
  90. package/templates/features/examples/src/modules/examples/CrudExampleView.vue +51 -0
  91. package/templates/features/examples/src/modules/examples/FormExampleView.vue +32 -0
  92. package/templates/features/examples/src/modules/examples/module.ts +27 -0
  93. package/templates/features/system/src/modules/system/config/ConfigView.vue +104 -0
  94. package/templates/features/system/src/modules/system/config/api.ts +38 -0
  95. package/templates/features/system/src/modules/system/config/routes.ts +21 -0
  96. package/templates/features/system/src/modules/system/dictionary/DictionaryItemView.vue +141 -0
  97. package/templates/features/system/src/modules/system/dictionary/DictionaryTypeView.vue +107 -0
  98. package/templates/features/system/src/modules/system/dictionary/api.ts +61 -0
  99. package/templates/features/system/src/modules/system/dictionary/cache.ts +9 -0
  100. package/templates/features/system/src/modules/system/dictionary/routes.ts +32 -0
  101. package/templates/features/system/src/modules/system/dictionary/types.ts +22 -0
  102. package/templates/features/system/src/modules/system/local.ts +348 -0
  103. package/templates/features/system/src/modules/system/menu/MenuView.vue +133 -0
  104. package/templates/features/system/src/modules/system/menu/api.ts +73 -0
  105. package/templates/features/system/src/modules/system/menu/components/MenuEditorDialog.vue +106 -0
  106. package/templates/features/system/src/modules/system/menu/routes.ts +23 -0
  107. package/templates/features/system/src/modules/system/menu/types.ts +18 -0
  108. package/templates/features/system/src/modules/system/module.ts +22 -0
  109. package/templates/features/system/src/modules/system/organization/OrganizationView.vue +134 -0
  110. package/templates/features/system/src/modules/system/organization/api.ts +38 -0
  111. package/templates/features/system/src/modules/system/organization/routes.ts +23 -0
  112. package/templates/features/system/src/modules/system/organization/types.ts +17 -0
  113. package/templates/features/system/src/modules/system/role/RoleView.vue +90 -0
  114. package/templates/features/system/src/modules/system/role/api.ts +40 -0
  115. package/templates/features/system/src/modules/system/role/components/RoleAuthorizationDialog.vue +110 -0
  116. package/templates/features/system/src/modules/system/role/permission-tree.ts +31 -0
  117. package/templates/features/system/src/modules/system/role/routes.ts +24 -0
  118. package/templates/features/system/src/modules/system/role/types.ts +12 -0
  119. package/templates/features/system/src/modules/system/user/UserView.vue +297 -0
  120. package/templates/features/system/src/modules/system/user/api.ts +45 -0
  121. package/templates/features/system/src/modules/system/user/components/UserOrganizationFilter.vue +61 -0
  122. package/templates/features/system/src/modules/system/user/components/UserRoleDialog.vue +93 -0
  123. package/templates/features/system/src/modules/system/user/routes.ts +27 -0
  124. package/templates/features/system/src/modules/system/user/types.ts +28 -0
  125. package/templates/features/system/tests/system.test.ts.template +266 -0
  126. package/templates/modes/http/src/app/services/data-source.ts +124 -0
  127. package/templates/modes/http/src/app/services/http-adapter.ts +128 -0
  128. package/templates/modes/http/tests/http.test.ts.template +218 -0
  129. package/templates/modes/local/src/app/services/data-source.ts +113 -0
  130. package/templates/modes/local/src/app/services/local-database.ts +67 -0
  131. package/templates/modes/local/tests/local.test.ts.template +132 -0
  132. package/templates/presets/standard/src/modules/dashboard/DashboardView.vue +52 -0
  133. package/templates/presets/standard/src/modules/dashboard/components/DashboardSessionStatus.vue +41 -0
  134. package/templates/presets/standard/src/modules/dashboard/components/DashboardShortcuts.vue +51 -0
  135. package/templates/presets/standard/src/modules/profile/ProfileView.vue +109 -0
  136. package/templates/presets/standard/src/modules/profile/api.ts +49 -0
  137. package/templates/presets/standard/src/modules/profile/components/ProfilePasswordForm.vue +68 -0
  138. package/templates/presets/standard/src/modules/profile/local.ts +40 -0
  139. package/templates/presets/standard/src/modules/profile/module.ts +11 -0
  140. package/templates/presets/standard/tests/profile.test.ts.template +72 -0
  141. package/templates/screen/README.md +6 -0
  142. package/templates/screen/src/App.vue +7 -0
  143. package/templates/screen/src/screen/ScreenEntry.vue +18 -0
  144. package/templates/screen/src/screen/ScreenView.vue +48 -0
  145. package/templates/screen/src/screen/components/ScreenMetrics.vue +40 -0
  146. package/templates/screen-auth/src/screen/ScreenEntry.vue +52 -0
  147. package/templates/screen-auth/src/screen/components/ScreenLoginForm.vue +44 -0
  148. package/templates/screen-auth/src/services/session.ts +61 -0
  149. package/templates/screen-auth/tests/session.test.ts.template +54 -0
  150. package/templates/screen-auth-http/src/services/auth-adapter.ts +14 -0
  151. package/templates/screen-auth-http/tests/auth-adapter.test.ts.template +17 -0
  152. package/templates/screen-auth-local-demo/src/services/auth-adapter.ts +15 -0
  153. package/templates/screen-auth-local-demo/tests/auth-adapter.test.ts.template +18 -0
  154. package/templates/screen-data/src/screen/ScreenView.vue +69 -0
  155. package/templates/screen-data/src/services/metrics-types.ts +4 -0
  156. package/templates/screen-data-http/src/services/metrics.ts +20 -0
  157. package/templates/screen-data-http/src/services/request.ts +3 -0
  158. package/templates/screen-data-http/tests/metrics.test.ts.template +21 -0
  159. package/templates/screen-data-local/src/services/metrics.ts +11 -0
  160. package/templates/screen-data-local/tests/metrics.test.ts.template +9 -0
  161. package/templates/screen-http/API-CONTRACT.md +20 -0
  162. package/templates/screen-http/src/services/http.ts +17 -0
  163. package/templates/screen-request-auth/src/services/request.ts +15 -0
  164. package/templates/screen-router/src/App.vue +7 -0
  165. package/templates/screen-router/src/main.ts +13 -0
  166. package/templates/screen-router/src/router.ts +7 -0
  167. package/templates/screen-router/tests/app.test.ts.template +20 -0
  168. package/templates/screen-viewport/src/screen/ScreenViewport.vue +30 -0
  169. package/templates/screen-visualization-charts/src/screen/components/ScreenVisualization.vue +22 -0
  170. package/templates/screen-visualization-cockpit/src/screen/components/ScreenVisualization.vue +33 -0
  171. package/templates/screen-visualization-cockpit/src/screen/components/ScreenWidget.vue +10 -0
  172. package/templates/screen-visualization-datav/src/screen/components/ScreenVisualization.vue +11 -0
  173. package/templates/vben-compatible/MIGRATION.md +30 -0
  174. package/templates/vben-compatible/src/modules/vben-migration/VbenFormView.vue +11 -0
  175. package/templates/vben-compatible/src/modules/vben-migration/VbenUsersView.vue +12 -0
  176. package/templates/vben-compatible/src/modules/vben-migration/components/VbenFormExample.vue +64 -0
  177. package/templates/vben-compatible/src/modules/vben-migration/components/VbenUsers.vue +144 -0
  178. package/templates/vben-compatible/src/modules/vben-migration/local.ts +68 -0
  179. package/templates/vben-compatible/src/modules/vben-migration/module.ts +42 -0
  180. package/templates/vue/index.html +12 -0
  181. package/templates/vue/src/main.ts +5 -0
  182. package/templates/vue/src/styles.css +19 -0
  183. package/templates/vue/tests/app.test.ts.template +10 -0
  184. package/templates/vue/vite.config.ts +9 -0
  185. package/templates/vue/vitest.config.ts +4 -0
@@ -0,0 +1,144 @@
1
+ <script setup lang="ts">
2
+ import type { ApplicationService, DataRow } from '../../../app/services/contracts';
3
+ import { AccessControl, useAccess, useVbenForm, useVbenVxeGrid } from '@lumal/vben-compat/v5';
4
+ import { ElButton, ElDialog, ElMessageBox } from 'element-plus';
5
+ import { nextTick, shallowRef } from 'vue';
6
+
7
+ /***********************业务服务与权限边界*********************/
8
+ const props = defineProps<{ service: Pick<ApplicationService, 'list' | 'save' | 'remove'> }>();
9
+ const { hasAccessByCodes } = useAccess();
10
+ const visible = shallowRef(false);
11
+ const editingId = shallowRef<string>();
12
+ const failure = shallowRef('');
13
+ function rowId(row: DataRow): string {
14
+ if (typeof row.id !== 'string' && typeof row.id !== 'number') throw new Error('用户缺少 id');
15
+ return String(row.id);
16
+ }
17
+
18
+ /***********************5.7.0 查询分页与列插槽迁移*********************/
19
+ const [Grid, gridApi] = useVbenVxeGrid({
20
+ tableTitle: '用户迁移示例',
21
+ formOptions: { schema: [{ component: 'Input', fieldName: 'keyword', label: '关键词' }], submitOnEnter: true },
22
+ gridOptions: {
23
+ columns: [
24
+ { type: 'checkbox', width: 48 },
25
+ { type: 'seq', title: '序号', width: 64 },
26
+ { field: 'username', title: '用户名', sortable: true },
27
+ { field: 'nickname', title: '昵称' },
28
+ { field: 'status', title: '状态' },
29
+ { field: 'id', title: '操作', slots: { default: 'operation' } },
30
+ ],
31
+ rowConfig: { keyField: 'id' },
32
+ pagerConfig: { pageSize: 10 },
33
+ proxyConfig: {
34
+ ajax: {
35
+ query: ({ page, sort }, formValues) =>
36
+ props.service.list('users', {
37
+ page: page.currentPage,
38
+ pageSize: page.pageSize,
39
+ query: { ...formValues, sortField: sort.field, sortOrder: sort.order },
40
+ }),
41
+ },
42
+ },
43
+ toolbarConfig: { custom: true, refresh: true, search: true },
44
+ },
45
+ });
46
+
47
+ /***********************新增编辑弹窗与失败恢复*********************/
48
+ const [Form, formApi] = useVbenForm({
49
+ showDefaultActions: false,
50
+ schema: [
51
+ { component: 'Input', fieldName: 'username', label: '用户名', rules: 'required' },
52
+ { component: 'Input', fieldName: 'nickname', label: '昵称', rules: 'required' },
53
+ {
54
+ component: 'Select',
55
+ fieldName: 'roles',
56
+ label: '角色',
57
+ defaultValue: ['guest'],
58
+ componentProps: {
59
+ multiple: true,
60
+ options: [
61
+ { label: '访客', value: 'guest' },
62
+ { label: '管理员', value: 'admin' },
63
+ ],
64
+ },
65
+ },
66
+ {
67
+ component: 'Select',
68
+ fieldName: 'status',
69
+ label: '状态',
70
+ defaultValue: 'enabled',
71
+ componentProps: {
72
+ options: [
73
+ { label: '启用', value: 'enabled' },
74
+ { label: '停用', value: 'disabled' },
75
+ ],
76
+ },
77
+ },
78
+ ],
79
+ });
80
+ const saving = shallowRef(false);
81
+ async function open(row?: DataRow): Promise<void> {
82
+ editingId.value = row ? rowId(row) : undefined;
83
+ failure.value = '';
84
+ visible.value = true;
85
+ await nextTick();
86
+ await formApi.resetForm();
87
+ if (row) await formApi.setValues(row);
88
+ }
89
+ async function save(): Promise<void> {
90
+ if (saving.value || !(await formApi.validate()).valid) return;
91
+ saving.value = true;
92
+ try {
93
+ await props.service.save('users', await formApi.getValues(), editingId.value);
94
+ visible.value = false;
95
+ await gridApi.query();
96
+ } catch (error) {
97
+ failure.value = error instanceof Error ? error.message : String(error);
98
+ } finally {
99
+ saving.value = false;
100
+ }
101
+ }
102
+ async function remove(row: DataRow): Promise<void> {
103
+ try {
104
+ await ElMessageBox.confirm(`删除 ${String(row.username)}?`, '删除确认');
105
+ } catch {
106
+ return; // Element Plus 的取消和关闭都表示不执行删除。
107
+ }
108
+ try {
109
+ await props.service.remove('users', rowId(row));
110
+ await gridApi.query();
111
+ } catch (error) {
112
+ failure.value = error instanceof Error ? error.message : String(error);
113
+ }
114
+ }
115
+ defineExpose({ gridApi });
116
+ </script>
117
+
118
+ <template>
119
+ <section>
120
+ <p v-if="failure" role="alert">
121
+ {{ failure }}
122
+ </p>
123
+ <Grid>
124
+ <template #toolbar-actions>
125
+ <AccessControl type="code" :codes="['system:user:create']">
126
+ <ElButton type="primary" @click="open()"> 新增用户 </ElButton>
127
+ </AccessControl>
128
+ </template>
129
+ <template #operation="{ row }">
130
+ <ElButton v-if="hasAccessByCodes(['system:user:update'])" link @click="open(row)"> 编辑 </ElButton>
131
+ <ElButton v-if="hasAccessByCodes(['system:user:delete'])" link type="danger" @click="remove(row)">
132
+ 删除
133
+ </ElButton>
134
+ </template>
135
+ </Grid>
136
+ <ElDialog v-model="visible" :title="editingId ? '编辑用户' : '新增用户'" destroy-on-close width="min(640px, 92vw)">
137
+ <Form />
138
+ <template #footer>
139
+ <ElButton @click="visible = false"> 取消 </ElButton>
140
+ <ElButton type="primary" :loading="saving" @click="save"> 保存 </ElButton>
141
+ </template>
142
+ </ElDialog>
143
+ </section>
144
+ </template>
@@ -0,0 +1,68 @@
1
+ import type { LocalBusinessContext, LocalHandler } from '../../app/services/local-contracts';
2
+ import { appConfig } from '../../app.config';
3
+ import { object, stringArray } from '../../app/menu-policy';
4
+ import { status } from '../../shared/api';
5
+
6
+ // 仅迁移示例独立启用时使用,标准系统模块启用后由系统用户服务接管。
7
+ export function createLocalHandler({ db, user, assertPermission }: LocalBusinessContext): LocalHandler {
8
+ return {
9
+ handles: (path) => !appConfig.features.includes('system') && /^\/system\/users(?:\/[^/]+)?$/.test(path),
10
+ async request(method, path, input) {
11
+ user();
12
+ if (!['GET', 'POST', 'PUT', 'DELETE'].includes(method)) throw new Error('不支持的迁移用户操作');
13
+ const id = path.split('/')[3];
14
+ assertPermission(
15
+ `system:user:${method === 'GET' ? 'list' : method === 'POST' ? 'create' : method === 'DELETE' ? 'delete' : 'update'}`,
16
+ );
17
+ const rows = db.read('users');
18
+ if (method === 'GET') {
19
+ const query = input.query ?? {};
20
+ const filtered = rows.filter((row) => !query.keyword || String(row.username).includes(String(query.keyword)));
21
+ const page = Number(query.page ?? 1);
22
+ const size = Number(query.pageSize ?? 10);
23
+ if (!Number.isSafeInteger(page) || page < 1 || !Number.isSafeInteger(size) || size < 1 || size > 1000)
24
+ throw new Error('分页参数无效');
25
+ return {
26
+ items: filtered.slice((page - 1) * size, page * size).map(({ password: _password, ...row }) => row),
27
+ total: filtered.length,
28
+ };
29
+ }
30
+ if (id === 'admin') throw new Error('不能修改或删除内置管理员');
31
+ const previous = rows.find((row) => row.id === id);
32
+ if (id && !previous) throw new Error('用户不存在');
33
+ if (method === 'DELETE') {
34
+ db.write(
35
+ 'users',
36
+ rows.filter((row) => row.id !== id),
37
+ );
38
+ return;
39
+ }
40
+ const body = object(input.body);
41
+ const roles = stringArray(body.roles);
42
+ if (
43
+ !body.username ||
44
+ !body.nickname ||
45
+ !roles.length ||
46
+ roles.some((code) => !db.read('roles').some((role) => role.code === code && role.status === 'enabled'))
47
+ )
48
+ throw new Error('用户资料或角色无效');
49
+ if (rows.some((row) => row.id !== id && row.username === body.username)) throw new Error('用户名重复');
50
+ // 只提取允许字段,不能由表单修改密码或注入用户 ID。
51
+ const next = {
52
+ organizationId: '',
53
+ phone: '',
54
+ createdAt: '',
55
+ password: 'lumal123',
56
+ ...previous,
57
+ username: body.username,
58
+ nickname: body.nickname,
59
+ status: status(body.status ?? 'enabled'),
60
+ roles,
61
+ id: id ?? crypto.randomUUID(),
62
+ };
63
+ db.write('users', id ? rows.map((row) => (row.id === id ? next : row)) : [...rows, next]);
64
+ const { password: _password, ...result } = next;
65
+ return result;
66
+ },
67
+ };
68
+ }
@@ -0,0 +1,42 @@
1
+ import type { AppModule } from '../../app/module';
2
+ import { adaptVbenMenus } from '@lumal/vben-compat/v5/router';
3
+
4
+ // Vben authority 是角色;按钮权限继续由应用 PermissionStore 管理。
5
+ export const menus = adaptVbenMenus([
6
+ {
7
+ path: '/migration',
8
+ name: 'VbenMigration',
9
+ meta: { title: 'Vben 迁移示例', icon: 'lumal:code', order: 30 },
10
+ children: [
11
+ {
12
+ path: '/migration/form',
13
+ name: 'VbenForm',
14
+ component: 'migration/form',
15
+ meta: { title: 'Vben 表单迁移', keepAlive: true },
16
+ },
17
+ {
18
+ path: '/migration/users',
19
+ name: 'VbenUsers',
20
+ component: 'migration/users',
21
+ meta: { title: 'Vben 业务迁移', authority: ['admin'], keepAlive: true },
22
+ },
23
+ ],
24
+ },
25
+ ]);
26
+ export const views: AppModule['views'] = {
27
+ 'migration/form': () => import('./VbenFormView.vue'),
28
+ 'migration/users': () => import('./VbenUsersView.vue'),
29
+ };
30
+ // 独立生成迁移示例时仍使用明确的真实操作权限。
31
+ export const permissions: AppModule['permissions'] = [
32
+ {
33
+ id: 'migration-user',
34
+ label: '迁移用户服务',
35
+ children: [
36
+ { id: 'migration-list', label: '查询用户', permission: 'system:user:list' },
37
+ { id: 'migration-create', label: '创建用户', permission: 'system:user:create' },
38
+ { id: 'migration-update', label: '编辑用户', permission: 'system:user:update' },
39
+ { id: 'migration-delete', label: '删除用户', permission: 'system:user:delete' },
40
+ ],
41
+ },
42
+ ];
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Vue Application</title>
7
+ </head>
8
+ <body>
9
+ <div id="app"></div>
10
+ <script type="module" src="/src/main.ts"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,5 @@
1
+ import { createApp } from 'vue';
2
+ import App from './App.vue';
3
+ import './styles.css';
4
+
5
+ createApp(App).mount('#app');
@@ -0,0 +1,19 @@
1
+ :root {
2
+ font-family: system-ui, sans-serif;
3
+ color: #1d2530;
4
+ background: #f4f6f8;
5
+ font-synthesis: none;
6
+ }
7
+
8
+ * {
9
+ box-sizing: border-box;
10
+ }
11
+
12
+ body {
13
+ margin: 0;
14
+ }
15
+
16
+ button,
17
+ input {
18
+ font: inherit;
19
+ }
@@ -0,0 +1,10 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { createSSRApp } from 'vue';
3
+ import { renderToString } from 'vue/server-renderer';
4
+ import App from '../src/App.vue';
5
+
6
+ describe('应用入口', () => {
7
+ it('可以渲染首个页面', async () => {
8
+ expect(await renderToString(createSSRApp(App))).toMatch(/<main|data-viewport-mode/);
9
+ });
10
+ });
@@ -0,0 +1,9 @@
1
+ import { fileURLToPath, URL } from 'node:url';
2
+ import vue from '@vitejs/plugin-vue';
3
+ import { defineConfig } from 'vite';
4
+
5
+ export default defineConfig({
6
+ plugins: [vue()],
7
+ resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } },
8
+ build: { manifest: true },
9
+ });
@@ -0,0 +1,4 @@
1
+ import vue from '@vitejs/plugin-vue';
2
+ import { defineConfig } from 'vitest/config';
3
+
4
+ export default defineConfig({ plugins: [vue()], test: { environment: 'node' } });