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.
- package/CHANGELOG.md +25 -0
- package/README.md +98 -12
- package/dist/cli.d.ts +18 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +308 -28
- package/dist/cli.js.map +1 -1
- package/dist/create.d.ts +11 -1
- package/dist/create.d.ts.map +1 -1
- package/dist/create.js +98 -2
- package/dist/create.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/presets.d.ts +41 -0
- package/dist/presets.d.ts.map +1 -0
- package/dist/presets.js +58 -0
- package/dist/presets.js.map +1 -0
- package/dist/project-cli.d.ts +3 -0
- package/dist/project-cli.d.ts.map +1 -0
- package/dist/project-cli.js +13 -0
- package/dist/project-cli.js.map +1 -0
- package/dist/projects.d.ts +21 -0
- package/dist/projects.d.ts.map +1 -0
- package/dist/projects.js +124 -0
- package/dist/projects.js.map +1 -0
- package/dist/scaffold.d.ts +2 -11
- package/dist/scaffold.d.ts.map +1 -1
- package/dist/scaffold.js +2 -1602
- package/dist/scaffold.js.map +1 -1
- package/dist/templates.d.ts +7 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +91 -0
- package/dist/templates.js.map +1 -0
- package/dist/types.d.ts +64 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +13 -4
- package/templates/base/.env.example +4 -0
- package/templates/base/API-CONTRACT.md +84 -0
- package/templates/base/README.md +59 -0
- package/templates/base/index.html +12 -0
- package/templates/base/package.json +38 -0
- package/templates/base/src/App.vue +206 -0
- package/templates/base/src/app/components/AppHeaderActions.vue +46 -0
- package/templates/base/src/app/components/AppSettingsDrawer.vue +37 -0
- package/templates/base/src/app/menu-policy.ts +163 -0
- package/templates/base/src/app/module.ts +46 -0
- package/templates/base/src/app/router/index.ts +107 -0
- package/templates/base/src/app/router/views.ts +12 -0
- package/templates/base/src/app/services/access.ts +2 -0
- package/templates/base/src/app/services/contracts.ts +54 -0
- package/templates/base/src/app/services/local-contracts.ts +18 -0
- package/templates/base/src/app/services/preferences.ts +41 -0
- package/templates/base/src/app/services/session-runtime.ts +186 -0
- package/templates/base/src/app/services/session.ts +14 -0
- package/templates/base/src/app/stored-menus.ts +72 -0
- package/templates/base/src/app/views/SafeIframeView.vue +34 -0
- package/templates/base/src/app/views/auth/LoginView.vue +75 -0
- package/templates/base/src/app/views/error/ForbiddenView.vue +20 -0
- package/templates/base/src/app/views/error/NotFoundView.vue +16 -0
- package/templates/base/src/main.ts +40 -0
- package/templates/base/src/modules/business/README.md +33 -0
- package/templates/base/src/modules/dashboard/DashboardView.vue +27 -0
- package/templates/base/src/modules/dashboard/module.ts +14 -0
- package/templates/base/src/shared/api.ts +53 -0
- package/templates/base/src/shared/components/BaseEntityDialog.vue +39 -0
- package/templates/base/src/shared/composables/use-async-data.ts +35 -0
- package/templates/base/src/shared/composables/use-entity-editor.ts +77 -0
- package/templates/base/src/shared/status.ts +4 -0
- package/templates/base/src/shared/tree.ts +41 -0
- package/templates/base/src/styles.scss +173 -0
- package/templates/base/tests/menu-policy.test.ts.template +89 -0
- package/templates/base/tests/session.test.ts.template +45 -0
- package/templates/base/vite.config.ts +54 -0
- package/templates/blank/README.md +6 -0
- package/templates/blank/src/App.vue +11 -0
- package/templates/common/AGENTS.md +13 -0
- package/templates/common/_editorconfig +15 -0
- package/templates/common/_gitattributes +6 -0
- package/templates/common/_gitignore +7 -0
- package/templates/common/_prettierignore +6 -0
- package/templates/common/docs/DEVELOPMENT.md +26 -0
- package/templates/common/eslint.config.mjs +60 -0
- package/templates/common/package.json +39 -0
- package/templates/common/prettier.config.mjs +8 -0
- package/templates/common/tsconfig.json +19 -0
- package/templates/common/vitest.config.ts +3 -0
- package/templates/features/examples/src/modules/examples/CrudExampleView.vue +51 -0
- package/templates/features/examples/src/modules/examples/FormExampleView.vue +32 -0
- package/templates/features/examples/src/modules/examples/module.ts +27 -0
- package/templates/features/system/src/modules/system/config/ConfigView.vue +104 -0
- package/templates/features/system/src/modules/system/config/api.ts +38 -0
- package/templates/features/system/src/modules/system/config/routes.ts +21 -0
- package/templates/features/system/src/modules/system/dictionary/DictionaryItemView.vue +141 -0
- package/templates/features/system/src/modules/system/dictionary/DictionaryTypeView.vue +107 -0
- package/templates/features/system/src/modules/system/dictionary/api.ts +61 -0
- package/templates/features/system/src/modules/system/dictionary/cache.ts +9 -0
- package/templates/features/system/src/modules/system/dictionary/routes.ts +32 -0
- package/templates/features/system/src/modules/system/dictionary/types.ts +22 -0
- package/templates/features/system/src/modules/system/local.ts +348 -0
- package/templates/features/system/src/modules/system/menu/MenuView.vue +133 -0
- package/templates/features/system/src/modules/system/menu/api.ts +73 -0
- package/templates/features/system/src/modules/system/menu/components/MenuEditorDialog.vue +106 -0
- package/templates/features/system/src/modules/system/menu/routes.ts +23 -0
- package/templates/features/system/src/modules/system/menu/types.ts +18 -0
- package/templates/features/system/src/modules/system/module.ts +22 -0
- package/templates/features/system/src/modules/system/organization/OrganizationView.vue +134 -0
- package/templates/features/system/src/modules/system/organization/api.ts +38 -0
- package/templates/features/system/src/modules/system/organization/routes.ts +23 -0
- package/templates/features/system/src/modules/system/organization/types.ts +17 -0
- package/templates/features/system/src/modules/system/role/RoleView.vue +90 -0
- package/templates/features/system/src/modules/system/role/api.ts +40 -0
- package/templates/features/system/src/modules/system/role/components/RoleAuthorizationDialog.vue +110 -0
- package/templates/features/system/src/modules/system/role/permission-tree.ts +31 -0
- package/templates/features/system/src/modules/system/role/routes.ts +24 -0
- package/templates/features/system/src/modules/system/role/types.ts +12 -0
- package/templates/features/system/src/modules/system/user/UserView.vue +297 -0
- package/templates/features/system/src/modules/system/user/api.ts +45 -0
- package/templates/features/system/src/modules/system/user/components/UserOrganizationFilter.vue +61 -0
- package/templates/features/system/src/modules/system/user/components/UserRoleDialog.vue +93 -0
- package/templates/features/system/src/modules/system/user/routes.ts +27 -0
- package/templates/features/system/src/modules/system/user/types.ts +28 -0
- package/templates/features/system/tests/system.test.ts.template +266 -0
- package/templates/modes/http/src/app/services/data-source.ts +124 -0
- package/templates/modes/http/src/app/services/http-adapter.ts +128 -0
- package/templates/modes/http/tests/http.test.ts.template +218 -0
- package/templates/modes/local/src/app/services/data-source.ts +113 -0
- package/templates/modes/local/src/app/services/local-database.ts +67 -0
- package/templates/modes/local/tests/local.test.ts.template +132 -0
- package/templates/presets/standard/src/modules/dashboard/DashboardView.vue +52 -0
- package/templates/presets/standard/src/modules/dashboard/components/DashboardSessionStatus.vue +41 -0
- package/templates/presets/standard/src/modules/dashboard/components/DashboardShortcuts.vue +51 -0
- package/templates/presets/standard/src/modules/profile/ProfileView.vue +109 -0
- package/templates/presets/standard/src/modules/profile/api.ts +49 -0
- package/templates/presets/standard/src/modules/profile/components/ProfilePasswordForm.vue +68 -0
- package/templates/presets/standard/src/modules/profile/local.ts +40 -0
- package/templates/presets/standard/src/modules/profile/module.ts +11 -0
- package/templates/presets/standard/tests/profile.test.ts.template +72 -0
- package/templates/screen/README.md +6 -0
- package/templates/screen/src/App.vue +7 -0
- package/templates/screen/src/screen/ScreenEntry.vue +18 -0
- package/templates/screen/src/screen/ScreenView.vue +48 -0
- package/templates/screen/src/screen/components/ScreenMetrics.vue +40 -0
- package/templates/screen-auth/src/screen/ScreenEntry.vue +52 -0
- package/templates/screen-auth/src/screen/components/ScreenLoginForm.vue +44 -0
- package/templates/screen-auth/src/services/session.ts +61 -0
- package/templates/screen-auth/tests/session.test.ts.template +54 -0
- package/templates/screen-auth-http/src/services/auth-adapter.ts +14 -0
- package/templates/screen-auth-http/tests/auth-adapter.test.ts.template +17 -0
- package/templates/screen-auth-local-demo/src/services/auth-adapter.ts +15 -0
- package/templates/screen-auth-local-demo/tests/auth-adapter.test.ts.template +18 -0
- package/templates/screen-data/src/screen/ScreenView.vue +69 -0
- package/templates/screen-data/src/services/metrics-types.ts +4 -0
- package/templates/screen-data-http/src/services/metrics.ts +20 -0
- package/templates/screen-data-http/src/services/request.ts +3 -0
- package/templates/screen-data-http/tests/metrics.test.ts.template +21 -0
- package/templates/screen-data-local/src/services/metrics.ts +11 -0
- package/templates/screen-data-local/tests/metrics.test.ts.template +9 -0
- package/templates/screen-http/API-CONTRACT.md +20 -0
- package/templates/screen-http/src/services/http.ts +17 -0
- package/templates/screen-request-auth/src/services/request.ts +15 -0
- package/templates/screen-router/src/App.vue +7 -0
- package/templates/screen-router/src/main.ts +13 -0
- package/templates/screen-router/src/router.ts +7 -0
- package/templates/screen-router/tests/app.test.ts.template +20 -0
- package/templates/screen-viewport/src/screen/ScreenViewport.vue +30 -0
- package/templates/screen-visualization-charts/src/screen/components/ScreenVisualization.vue +22 -0
- package/templates/screen-visualization-cockpit/src/screen/components/ScreenVisualization.vue +33 -0
- package/templates/screen-visualization-cockpit/src/screen/components/ScreenWidget.vue +10 -0
- package/templates/screen-visualization-datav/src/screen/components/ScreenVisualization.vue +11 -0
- package/templates/vben-compatible/MIGRATION.md +30 -0
- package/templates/vben-compatible/src/modules/vben-migration/VbenFormView.vue +11 -0
- package/templates/vben-compatible/src/modules/vben-migration/VbenUsersView.vue +12 -0
- package/templates/vben-compatible/src/modules/vben-migration/components/VbenFormExample.vue +64 -0
- package/templates/vben-compatible/src/modules/vben-migration/components/VbenUsers.vue +144 -0
- package/templates/vben-compatible/src/modules/vben-migration/local.ts +68 -0
- package/templates/vben-compatible/src/modules/vben-migration/module.ts +42 -0
- package/templates/vue/index.html +12 -0
- package/templates/vue/src/main.ts +5 -0
- package/templates/vue/src/styles.css +19 -0
- package/templates/vue/tests/app.test.ts.template +10 -0
- package/templates/vue/vite.config.ts +9 -0
- 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,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
|
+
});
|