@origen-ui/admin-cli 1.0.3 → 1.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/package.json +3 -3
- package/templates/current/clean/CHANGELOG.md +34 -0
- package/templates/current/clean/component-catalog.json +9 -9
- package/templates/current/clean/package.json +41 -41
- package/templates/current/clean/scaffold.lock.json +2 -2
- package/templates/current/clean/scripts/vite-build-policy.spec.ts +71 -0
- package/templates/current/clean/src/App.vue +10 -3
- package/templates/current/clean/src/api/client.ts +90 -10
- package/templates/current/clean/src/api/generated/data-contracts.ts +3 -3
- package/templates/current/clean/src/api/generated/http-client.ts +1 -1
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/206/205/345/256/271/346/226/207/347/253/240.ts +1 -1
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/256/241/350/256/241.ts +1 -1
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/346/226/207/344/273/266/344/270/212/344/274/240.ts +1 -1
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/347/224/250/346/210/267.ts +2 -3
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/217/234/345/215/225.ts +3 -5
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/247/222/350/211/262.ts +2 -3
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/256/242/345/215/225/350/215/211/347/250/277.ts +2 -3
- package/templates/current/clean/src/api/generated//350/256/244/350/257/201.ts +1 -1
- package/templates/current/clean/src/app/adminLocale.ts +90 -0
- package/templates/current/clean/src/app/createAdminUi.spec.ts +65 -9
- package/templates/current/clean/src/app/createAdminUi.ts +14 -29
- package/templates/current/clean/src/app/embedded-token.spec.ts +40 -0
- package/templates/current/clean/src/app/embedded.spec.ts +135 -0
- package/templates/current/clean/src/app/embedded.ts +255 -0
- package/templates/current/clean/src/app/localeFormat.ts +52 -0
- package/templates/current/clean/src/app/menu.spec.ts +26 -0
- package/templates/current/clean/src/app/menu.ts +4 -0
- package/templates/current/clean/src/app/menuTypes.ts +1 -0
- package/templates/current/clean/src/app/origenUiLocale.spec.ts +6 -5
- package/templates/current/clean/src/app/origenUiLocale.ts +3 -58
- package/templates/current/clean/src/app/permission.spec.ts +26 -0
- package/templates/current/clean/src/app/runtimeConfig.ts +8 -7
- package/templates/current/clean/src/env.d.ts +18 -0
- package/templates/current/clean/src/features/appearance/components/ThemePanel.vue +21 -17
- package/templates/current/clean/src/features/appearance/store/theme.ts +2 -1
- package/templates/current/clean/src/features/auth/pages/Login.vue +15 -11
- package/templates/current/clean/src/features/auth/store/auth.ts +13 -3
- package/templates/current/clean/src/features/security/components/DevtoolsProtectionOverlay.vue +5 -2
- package/templates/current/clean/src/features/security/devtoolsProtection.spec.ts +7 -10
- package/templates/current/clean/src/features/security/devtoolsProtection.ts +2 -1
- package/templates/current/clean/src/features/system/access/api/admin-repository.spec.ts +14 -0
- package/templates/current/clean/src/features/system/access/api/admin-repository.ts +38 -15
- package/templates/current/clean/src/features/system/access/api/rbac.ts +37 -27
- package/templates/current/clean/src/features/workspace/pages/Empty.vue +4 -1
- package/templates/current/clean/src/features/workspace/pages/Profile.vue +13 -11
- package/templates/current/clean/src/layouts/AdminLayout.vue +3 -1
- package/templates/current/clean/src/layouts/TopBar.vue +26 -8
- package/templates/current/clean/src/locales/en-US.json +490 -0
- package/templates/current/clean/src/locales/en-US.runtime.ts +20 -0
- package/templates/current/clean/src/locales/index.ts +129 -45
- package/templates/current/clean/src/locales/messages-types.ts +62 -0
- package/templates/current/clean/src/locales/messages.spec.ts +113 -6
- package/templates/current/clean/src/locales/vue-i18n.d.ts +5 -0
- package/templates/current/clean/src/locales/zh-CN.json +490 -0
- package/templates/current/clean/src/locales/zh-CN.runtime.ts +20 -0
- package/templates/current/clean/src/locales/zh-TW.json +490 -0
- package/templates/current/clean/src/locales/zh-TW.runtime.ts +20 -0
- package/templates/current/clean/src/router/bootstrap.ts +22 -7
- package/templates/current/clean/src/router/dynamicRoutes.ts +5 -1
- package/templates/current/clean/src/router/queryEncryption.spec.ts +30 -4
- package/templates/current/clean/src/router/queryEncryption.ts +48 -44
- package/templates/current/clean/src/router/useRouteQueryDefaults.spec.ts +2 -1
- package/templates/current/clean/src/router/useRouteQueryDefaults.types.ts +2 -1
- package/templates/current/clean/src/templates/og-table.ts +81 -37
- package/templates/current/clean/src/templates/templates.spec.ts +19 -0
- package/templates/current/clean/vite.build-policy.ts +114 -289
- package/templates/current/clean/vite.config.ts +4 -5
- package/templates/current/examples/CHANGELOG.md +34 -0
- package/templates/current/examples/component-catalog.json +9 -9
- package/templates/current/examples/package.json +41 -41
- package/templates/current/examples/scaffold.lock.json +2 -2
- package/templates/current/examples/scripts/vite-build-policy.spec.ts +71 -0
- package/templates/current/examples/src/App.vue +10 -3
- package/templates/current/examples/src/api/client.ts +90 -10
- package/templates/current/examples/src/api/generated/data-contracts.ts +3 -3
- package/templates/current/examples/src/api/generated/http-client.ts +1 -1
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/206/205/345/256/271/346/226/207/347/253/240.ts +1 -1
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/256/241/350/256/241.ts +1 -1
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/346/226/207/344/273/266/344/270/212/344/274/240.ts +1 -1
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/347/224/250/346/210/267.ts +2 -3
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/217/234/345/215/225.ts +3 -5
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/247/222/350/211/262.ts +2 -3
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/256/242/345/215/225/350/215/211/347/250/277.ts +2 -3
- package/templates/current/examples/src/api/generated//350/256/244/350/257/201.ts +1 -1
- package/templates/current/examples/src/app/adminLocale.ts +90 -0
- package/templates/current/examples/src/app/createAdminUi.spec.ts +65 -9
- package/templates/current/examples/src/app/createAdminUi.ts +14 -29
- package/templates/current/examples/src/app/embedded-token.spec.ts +40 -0
- package/templates/current/examples/src/app/embedded.spec.ts +135 -0
- package/templates/current/examples/src/app/embedded.ts +255 -0
- package/templates/current/examples/src/app/localeFormat.ts +52 -0
- package/templates/current/examples/src/app/menu.spec.ts +26 -0
- package/templates/current/examples/src/app/menu.ts +4 -0
- package/templates/current/examples/src/app/menuTypes.ts +1 -0
- package/templates/current/examples/src/app/origenUiLocale.spec.ts +6 -5
- package/templates/current/examples/src/app/origenUiLocale.ts +3 -58
- package/templates/current/examples/src/app/permission.spec.ts +26 -0
- package/templates/current/examples/src/app/runtimeConfig.ts +8 -7
- package/templates/current/examples/src/env.d.ts +18 -0
- package/templates/current/examples/src/features/appearance/components/ThemePanel.vue +21 -17
- package/templates/current/examples/src/features/appearance/store/theme.ts +2 -1
- package/templates/current/examples/src/features/auth/pages/Login.vue +15 -11
- package/templates/current/examples/src/features/auth/store/auth.ts +13 -3
- package/templates/current/examples/src/features/errors/pages/Forbidden.vue +6 -2
- package/templates/current/examples/src/features/errors/pages/NotFound.vue +6 -2
- package/templates/current/examples/src/features/errors/pages/ServerError.vue +6 -2
- package/templates/current/examples/src/features/errors/pages/error-pages.spec.ts +9 -1
- package/templates/current/examples/src/features/feature-composables.spec.ts +36 -9
- package/templates/current/examples/src/features/security/components/DevtoolsProtectionOverlay.vue +5 -2
- package/templates/current/examples/src/features/security/devtoolsProtection.spec.ts +7 -10
- package/templates/current/examples/src/features/security/devtoolsProtection.ts +2 -1
- package/templates/current/examples/src/features/system/access/api/admin-repository.spec.ts +14 -0
- package/templates/current/examples/src/features/system/access/api/admin-repository.ts +38 -15
- package/templates/current/examples/src/features/system/access/api/rbac.ts +37 -27
- package/templates/current/examples/src/features/system/audit/composables/useAuditManagement.ts +43 -38
- package/templates/current/examples/src/features/system/menus/components/MenuEditorForm.vue +33 -30
- package/templates/current/examples/src/features/system/menus/composables/useMenuManagement.ts +81 -69
- package/templates/current/examples/src/features/system/menus/pages/MenuList.vue +3 -1
- package/templates/current/examples/src/features/system/roles/components/RoleEditorForm.vue +18 -15
- package/templates/current/examples/src/features/system/roles/composables/useRoleManagement.ts +49 -53
- package/templates/current/examples/src/features/system/roles/pages/RoleList.vue +3 -1
- package/templates/current/examples/src/features/system/users/components/UserEditorForm.vue +22 -19
- package/templates/current/examples/src/features/system/users/composables/useUserManagement.ts +59 -64
- package/templates/current/examples/src/features/system/users/pages/UserList.vue +3 -1
- package/templates/current/examples/src/features/workspace/pages/Dashboard.spec.ts +9 -0
- package/templates/current/examples/src/features/workspace/pages/Dashboard.vue +54 -26
- package/templates/current/examples/src/features/workspace/pages/Empty.vue +4 -1
- package/templates/current/examples/src/features/workspace/pages/Profile.vue +13 -11
- package/templates/current/examples/src/layouts/AdminLayout.vue +3 -1
- package/templates/current/examples/src/layouts/TopBar.vue +26 -8
- package/templates/current/examples/src/locales/en-US.json +490 -0
- package/templates/current/examples/src/locales/en-US.runtime.ts +20 -0
- package/templates/current/examples/src/locales/index.ts +129 -45
- package/templates/current/examples/src/locales/messages-types.ts +62 -0
- package/templates/current/examples/src/locales/messages.spec.ts +113 -6
- package/templates/current/examples/src/locales/vue-i18n.d.ts +5 -0
- package/templates/current/examples/src/locales/zh-CN.json +490 -0
- package/templates/current/examples/src/locales/zh-CN.runtime.ts +20 -0
- package/templates/current/examples/src/locales/zh-TW.json +490 -0
- package/templates/current/examples/src/locales/zh-TW.runtime.ts +20 -0
- package/templates/current/examples/src/main.ts +31 -5
- package/templates/current/examples/src/router/bootstrap.ts +22 -7
- package/templates/current/examples/src/router/dynamicRoutes.spec.ts +17 -0
- package/templates/current/examples/src/router/dynamicRoutes.ts +5 -1
- package/templates/current/examples/src/router/queryEncryption.spec.ts +30 -4
- package/templates/current/examples/src/router/queryEncryption.ts +48 -44
- package/templates/current/examples/src/router/staticRoutes.ts +1 -1
- package/templates/current/examples/src/router/useRouteQueryDefaults.spec.ts +2 -1
- package/templates/current/examples/src/router/useRouteQueryDefaults.types.ts +2 -1
- package/templates/current/examples/src/templates/og-table.ts +81 -37
- package/templates/current/examples/src/templates/templates.spec.ts +19 -0
- package/templates/current/examples/vite.build-policy.ts +114 -289
- package/templates/current/examples/vite.config.ts +4 -5
- package/templates/current/clean/scripts/check-admin-bundle.mjs +0 -214
- package/templates/current/clean/scripts/performance/baselines/bundle-gzip-v2-pre-entry-unification.json +0 -38
- package/templates/current/clean/src/locales/en-US.ts +0 -55
- package/templates/current/clean/src/locales/zh-CN.ts +0 -55
- package/templates/current/clean/src/locales/zh-TW.ts +0 -44
- package/templates/current/examples/scripts/check-admin-bundle.mjs +0 -214
- package/templates/current/examples/scripts/performance/baselines/bundle-gzip-v2-pre-entry-unification.json +0 -38
- package/templates/current/examples/src/locales/en-US.ts +0 -55
- package/templates/current/examples/src/locales/zh-CN.ts +0 -55
- package/templates/current/examples/src/locales/zh-TW.ts +0 -44
|
@@ -4,6 +4,7 @@ import type { FormActionExpose, SelectOption } from '@origen-ui/shared'
|
|
|
4
4
|
import type { MenuKind, RbacStatus } from '../../access/api/rbac'
|
|
5
5
|
import { OgForm } from '@origen-ui/form/core'
|
|
6
6
|
import { computed, ref, useTemplateRef } from 'vue'
|
|
7
|
+
import { useI18n } from 'vue-i18n'
|
|
7
8
|
|
|
8
9
|
defineOptions({ name: 'MenuEditorForm' })
|
|
9
10
|
|
|
@@ -14,6 +15,8 @@ const props = defineProps<{
|
|
|
14
15
|
componentOptions: SelectOption[]
|
|
15
16
|
}>()
|
|
16
17
|
|
|
18
|
+
const { t } = useI18n()
|
|
19
|
+
|
|
17
20
|
export interface MenuEditorDraft {
|
|
18
21
|
parentId: string
|
|
19
22
|
kind: MenuKind
|
|
@@ -39,13 +42,13 @@ const schema = computed<OgFormSchema<MenuEditorDraft>>(() => ({
|
|
|
39
42
|
fields: [
|
|
40
43
|
{
|
|
41
44
|
prop: 'kind',
|
|
42
|
-
label: '
|
|
45
|
+
label: t('system.menus.form.kind'),
|
|
43
46
|
control: { type: 'radio' },
|
|
44
47
|
required: true,
|
|
45
48
|
options: [
|
|
46
|
-
{ label: '
|
|
47
|
-
{ label: '
|
|
48
|
-
{ label: '
|
|
49
|
+
{ label: t('system.menus.kindPage'), value: 'page' },
|
|
50
|
+
{ label: t('system.menus.kindDirectory'), value: 'directory' },
|
|
51
|
+
{ label: t('system.menus.kindButton'), value: 'button' },
|
|
49
52
|
],
|
|
50
53
|
valueChange: (value) =>
|
|
51
54
|
value === 'button'
|
|
@@ -65,46 +68,46 @@ const schema = computed<OgFormSchema<MenuEditorDraft>>(() => ({
|
|
|
65
68
|
},
|
|
66
69
|
{
|
|
67
70
|
prop: 'parentId',
|
|
68
|
-
label: model.value.kind === 'button' ? '
|
|
71
|
+
label: model.value.kind === 'button' ? t('system.menus.form.parentButton') : t('system.menus.form.parentDirectory'),
|
|
69
72
|
control: { type: 'select', props: { clearable: true } },
|
|
70
73
|
requiredWhen: [{ prop: 'kind', op: 'eq', value: 'button' }],
|
|
71
74
|
options:
|
|
72
75
|
model.value.kind === 'button'
|
|
73
76
|
? props.pageParentOptions
|
|
74
|
-
: [{ label: '
|
|
77
|
+
: [{ label: t('system.menus.form.rootDirectory'), value: '' }, ...props.directoryParentOptions],
|
|
75
78
|
},
|
|
76
79
|
{
|
|
77
80
|
prop: 'title',
|
|
78
|
-
label: '
|
|
81
|
+
label: t('system.menus.form.title'),
|
|
79
82
|
required: true,
|
|
80
|
-
control: { type: 'input', props: { placeholder: '
|
|
83
|
+
control: { type: 'input', props: { placeholder: t('system.menus.form.titlePlaceholder') } },
|
|
81
84
|
},
|
|
82
85
|
{
|
|
83
86
|
prop: 'code',
|
|
84
|
-
label: '
|
|
87
|
+
label: t('system.menus.form.code'),
|
|
85
88
|
required: true,
|
|
86
|
-
control: { type: 'input', props: { placeholder: '
|
|
89
|
+
control: { type: 'input', props: { placeholder: t('system.menus.form.codePlaceholder') } },
|
|
87
90
|
rules: [
|
|
88
91
|
{
|
|
89
92
|
pattern: /^[a-z][a-z0-9-]{2,47}$/,
|
|
90
|
-
message: '
|
|
93
|
+
message: t('system.menus.form.codeRuleMessage'),
|
|
91
94
|
trigger: 'blur',
|
|
92
95
|
},
|
|
93
96
|
],
|
|
94
97
|
},
|
|
95
98
|
{
|
|
96
99
|
prop: 'path',
|
|
97
|
-
label: '
|
|
100
|
+
label: t('system.menus.form.path'),
|
|
98
101
|
requiredWhen: [{ prop: 'kind', op: 'neq', value: 'button' }],
|
|
99
102
|
when: [{ prop: 'kind', op: 'neq', value: 'button' }],
|
|
100
|
-
control: { type: 'input', props: { placeholder: '
|
|
103
|
+
control: { type: 'input', props: { placeholder: t('system.menus.form.pathPlaceholder') } },
|
|
101
104
|
},
|
|
102
105
|
{
|
|
103
106
|
prop: 'componentKey',
|
|
104
|
-
label: '
|
|
107
|
+
label: t('system.menus.form.componentKey'),
|
|
105
108
|
control: {
|
|
106
109
|
type: 'select',
|
|
107
|
-
props: { filterable: true, placeholder: '
|
|
110
|
+
props: { filterable: true, placeholder: t('system.menus.form.componentPlaceholder') },
|
|
108
111
|
},
|
|
109
112
|
requiredWhen: [{ prop: 'kind', op: 'eq', value: 'page' }],
|
|
110
113
|
when: [{ prop: 'kind', op: 'eq', value: 'page' }],
|
|
@@ -112,27 +115,27 @@ const schema = computed<OgFormSchema<MenuEditorDraft>>(() => ({
|
|
|
112
115
|
},
|
|
113
116
|
{
|
|
114
117
|
prop: 'permission',
|
|
115
|
-
label: '
|
|
118
|
+
label: t('system.menus.form.permission'),
|
|
116
119
|
requiredWhen: [{ prop: 'kind', op: 'eq', value: 'button' }],
|
|
117
120
|
when: [{ prop: 'kind', op: 'eq', value: 'button' }],
|
|
118
|
-
control: { type: 'input', props: { placeholder: '
|
|
121
|
+
control: { type: 'input', props: { placeholder: t('system.menus.form.permissionPlaceholder') } },
|
|
119
122
|
rules: [
|
|
120
123
|
{
|
|
121
124
|
pattern: /^[a-z][a-z0-9:_-]{2,63}$/,
|
|
122
|
-
message: '
|
|
125
|
+
message: t('system.menus.form.permissionRuleMessage'),
|
|
123
126
|
trigger: 'blur',
|
|
124
127
|
},
|
|
125
128
|
],
|
|
126
129
|
},
|
|
127
130
|
{
|
|
128
131
|
prop: 'icon',
|
|
129
|
-
label: '
|
|
132
|
+
label: t('system.menus.form.icon'),
|
|
130
133
|
when: [{ prop: 'kind', op: 'neq', value: 'button' }],
|
|
131
|
-
control: { type: 'input', props: { placeholder: '
|
|
134
|
+
control: { type: 'input', props: { placeholder: t('system.menus.form.iconPlaceholder') } },
|
|
132
135
|
},
|
|
133
136
|
{
|
|
134
137
|
prop: 'order',
|
|
135
|
-
label: '
|
|
138
|
+
label: t('system.menus.form.order'),
|
|
136
139
|
control: {
|
|
137
140
|
type: 'number',
|
|
138
141
|
props: { min: 1, max: 9999, numberControlsPosition: 'right' },
|
|
@@ -141,32 +144,32 @@ const schema = computed<OgFormSchema<MenuEditorDraft>>(() => ({
|
|
|
141
144
|
},
|
|
142
145
|
{
|
|
143
146
|
prop: 'status',
|
|
144
|
-
label: '
|
|
147
|
+
label: t('system.menus.form.status'),
|
|
145
148
|
control: { type: 'radio' },
|
|
146
149
|
required: true,
|
|
147
150
|
options: [
|
|
148
|
-
{ label: '
|
|
149
|
-
{ label: '
|
|
151
|
+
{ label: t('system.menus.published'), value: 'active' },
|
|
152
|
+
{ label: t('system.menus.unpublished'), value: 'suspended' },
|
|
150
153
|
],
|
|
151
154
|
},
|
|
152
155
|
{
|
|
153
156
|
prop: 'visible',
|
|
154
|
-
label: '
|
|
155
|
-
control: { type: 'switch', props: { activeText: '
|
|
157
|
+
label: t('system.menus.form.visible'),
|
|
158
|
+
control: { type: 'switch', props: { activeText: t('system.menus.form.show'), inactiveText: t('system.menus.form.hide') } },
|
|
156
159
|
when: [{ prop: 'kind', op: 'neq', value: 'button' }],
|
|
157
160
|
span: 8,
|
|
158
161
|
},
|
|
159
162
|
{
|
|
160
163
|
prop: 'cache',
|
|
161
|
-
label: '
|
|
162
|
-
control: { type: 'switch', props: { activeText: '
|
|
164
|
+
label: t('system.menus.form.cache'),
|
|
165
|
+
control: { type: 'switch', props: { activeText: t('system.menus.form.on'), inactiveText: t('system.menus.form.off') } },
|
|
163
166
|
when: [{ prop: 'kind', op: 'neq', value: 'button' }],
|
|
164
167
|
span: 8,
|
|
165
168
|
},
|
|
166
169
|
{
|
|
167
170
|
prop: 'tabHidden',
|
|
168
|
-
label: '
|
|
169
|
-
control: { type: 'switch', props: { activeText: '
|
|
171
|
+
label: t('system.menus.form.tabHidden'),
|
|
172
|
+
control: { type: 'switch', props: { activeText: t('system.menus.form.hide'), inactiveText: t('system.menus.form.show') } },
|
|
170
173
|
when: [{ prop: 'kind', op: 'neq', value: 'button' }],
|
|
171
174
|
span: 8,
|
|
172
175
|
},
|
package/templates/current/examples/src/features/system/menus/composables/useMenuManagement.ts
CHANGED
|
@@ -5,29 +5,30 @@ import type {
|
|
|
5
5
|
OgTableRequestContext,
|
|
6
6
|
TableColumn,
|
|
7
7
|
} from '@origen-ui/table'
|
|
8
|
+
import type { AdminMessageKey } from '../../../../locales'
|
|
9
|
+
import type { MenuKind, RbacMenu, RbacMenuDraft, RbacStatus } from '../../access/api/rbac'
|
|
10
|
+
import type { AuthorizationRefresh } from '../../access/composables/useAuthorizationRefresh'
|
|
8
11
|
import type { MenuEditorDraft } from '../components/MenuEditorForm.vue'
|
|
9
12
|
import { useDialog } from '@origen-ui/dialog'
|
|
10
13
|
import { ElMessage } from 'element-plus'
|
|
14
|
+
import { computed } from 'vue'
|
|
15
|
+
import { useI18n } from 'vue-i18n'
|
|
16
|
+
import { formatAdminShortDateTime } from '../../../../app/localeFormat'
|
|
17
|
+
import { getAdminI18n } from '../../../../locales'
|
|
11
18
|
import { useAuthStore } from '../../../auth/store/auth'
|
|
12
19
|
import {
|
|
13
20
|
createMenu,
|
|
14
21
|
getPageCapability,
|
|
15
22
|
listMenus,
|
|
16
|
-
type MenuKind,
|
|
17
23
|
menuPageParentOptions,
|
|
18
24
|
menuParentOptions,
|
|
19
25
|
pageCatalogOptions,
|
|
20
|
-
|
|
21
|
-
type RbacMenuDraft,
|
|
22
|
-
type RbacStatus,
|
|
26
|
+
rbacText,
|
|
23
27
|
removeMenus,
|
|
24
28
|
setMenusStatus,
|
|
25
29
|
updateMenu,
|
|
26
30
|
} from '../../access/api/rbac'
|
|
27
|
-
import {
|
|
28
|
-
type AuthorizationRefresh,
|
|
29
|
-
useAuthorizationRefresh,
|
|
30
|
-
} from '../../access/composables/useAuthorizationRefresh'
|
|
31
|
+
import { useAuthorizationRefresh } from '../../access/composables/useAuthorizationRefresh'
|
|
31
32
|
|
|
32
33
|
export interface MenuQuery {
|
|
33
34
|
kind?: MenuKind
|
|
@@ -39,28 +40,16 @@ interface UseMenuManagementOptions {
|
|
|
39
40
|
refreshAuthorization?: AuthorizationRefresh
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
{ label: '目录', value: 'directory' },
|
|
50
|
-
{ label: '按钮权限', value: 'button' },
|
|
51
|
-
] as const
|
|
43
|
+
function translate(key: string): string {
|
|
44
|
+
const global = getAdminI18n()?.global as unknown as
|
|
45
|
+
| { te?: (key: string) => boolean, t: (key: string) => string } |
|
|
46
|
+
undefined
|
|
47
|
+
if (!global) return key
|
|
48
|
+
return global.te?.(key) ? global.t(key as AdminMessageKey) : key
|
|
49
|
+
}
|
|
52
50
|
|
|
53
51
|
function formatDate(value: unknown): string {
|
|
54
|
-
|
|
55
|
-
return Number.isNaN(date.valueOf())
|
|
56
|
-
? '-'
|
|
57
|
-
: new Intl.DateTimeFormat('zh-CN', {
|
|
58
|
-
month: '2-digit',
|
|
59
|
-
day: '2-digit',
|
|
60
|
-
hour: '2-digit',
|
|
61
|
-
minute: '2-digit',
|
|
62
|
-
hour12: false,
|
|
63
|
-
}).format(date)
|
|
52
|
+
return formatAdminShortDateTime(value)
|
|
64
53
|
}
|
|
65
54
|
|
|
66
55
|
function flattenMenus(nodes: readonly RbacMenu[]): RbacMenu[] {
|
|
@@ -96,16 +85,20 @@ function parseDraft(value: Record<string, unknown> | undefined): RbacMenuDraft {
|
|
|
96
85
|
const permission = draft?.permission?.trim() || undefined
|
|
97
86
|
|
|
98
87
|
if ((kind !== 'page' && kind !== 'directory' && kind !== 'button') || !title || !code)
|
|
99
|
-
throw new Error('
|
|
100
|
-
if (!/^[a-z][a-z0-9-]{2,47}$/.test(code)) throw new Error('
|
|
88
|
+
throw new Error(translate('system.menus.errors.formRequired'))
|
|
89
|
+
if (!/^[a-z][a-z0-9-]{2,47}$/.test(code)) throw new Error(translate('system.menus.errors.codeInvalid'))
|
|
101
90
|
if (kind === 'button' && (!parentId || !permission))
|
|
102
|
-
throw new Error('
|
|
91
|
+
throw new Error(translate('system.menus.errors.buttonRequiresPage'))
|
|
103
92
|
if (kind !== 'button') {
|
|
104
|
-
if (!path) throw new Error('
|
|
105
|
-
if (parentId ? path.startsWith('/') : !path.startsWith('/'))
|
|
106
|
-
throw new Error(
|
|
93
|
+
if (!path) throw new Error(translate('system.menus.errors.pathRequired'))
|
|
94
|
+
if (parentId ? path.startsWith('/') : !path.startsWith('/')) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
translate(parentId ? 'system.menus.errors.submenuRelativePath' : 'system.menus.errors.rootPathSlash'),
|
|
97
|
+
)
|
|
98
|
+
}
|
|
107
99
|
}
|
|
108
|
-
if (kind === 'page' && !getPageCapability(componentKey))
|
|
100
|
+
if (kind === 'page' && !getPageCapability(componentKey))
|
|
101
|
+
throw new Error(translate('system.menus.errors.componentRequired'))
|
|
109
102
|
|
|
110
103
|
return {
|
|
111
104
|
parentId,
|
|
@@ -128,8 +121,20 @@ function parseDraft(value: Record<string, unknown> | undefined): RbacMenuDraft {
|
|
|
128
121
|
export function useMenuManagement(options: UseMenuManagementOptions) {
|
|
129
122
|
const auth = useAuthStore()
|
|
130
123
|
const dialog = useDialog()
|
|
124
|
+
const { t } = useI18n()
|
|
131
125
|
const refreshAuthorization = options.refreshAuthorization ?? useAuthorizationRefresh()
|
|
132
126
|
|
|
127
|
+
const statusOptions = computed<SelectOption[]>(() => [
|
|
128
|
+
{ label: t('system.menus.published'), value: 'active' },
|
|
129
|
+
{ label: t('system.menus.unpublished'), value: 'suspended' },
|
|
130
|
+
])
|
|
131
|
+
|
|
132
|
+
const kindOptions = computed<SelectOption[]>(() => [
|
|
133
|
+
{ label: t('system.menus.kindPage'), value: 'page' },
|
|
134
|
+
{ label: t('system.menus.kindDirectory'), value: 'directory' },
|
|
135
|
+
{ label: t('system.menus.kindButton'), value: 'button' },
|
|
136
|
+
])
|
|
137
|
+
|
|
133
138
|
async function reconcile(): Promise<void> {
|
|
134
139
|
await refreshAuthorization()
|
|
135
140
|
await options.refresh()
|
|
@@ -151,7 +156,7 @@ export function useMenuManagement(options: UseMenuManagementOptions) {
|
|
|
151
156
|
const draft = parseDraft(model)
|
|
152
157
|
if (row) await updateMenu(row.id, draft, signal)
|
|
153
158
|
else await createMenu(draft, signal)
|
|
154
|
-
ElMessage.success(row ? '
|
|
159
|
+
ElMessage.success(row ? t('system.menus.menuUpdated') : t('system.menus.menuCreated'))
|
|
155
160
|
await reconcile()
|
|
156
161
|
return true
|
|
157
162
|
}
|
|
@@ -174,7 +179,7 @@ export function useMenuManagement(options: UseMenuManagementOptions) {
|
|
|
174
179
|
const pageParentOptions = menuPageParentOptions(menus, row?.id)
|
|
175
180
|
dialog.open({
|
|
176
181
|
dialogKey: row ? `menu-editor-${row.id}` : 'menu-editor-create',
|
|
177
|
-
title: row ? '
|
|
182
|
+
title: row ? t('system.menus.editMenu') : t('system.menus.addMenu'),
|
|
178
183
|
presentation: { width: 760 },
|
|
179
184
|
protectUnsaved: true,
|
|
180
185
|
errorFeedback: true,
|
|
@@ -195,92 +200,99 @@ export function useMenuManagement(options: UseMenuManagementOptions) {
|
|
|
195
200
|
signal?: AbortSignal,
|
|
196
201
|
): Promise<void> {
|
|
197
202
|
await setMenusStatus(ids, status, signal ?? new AbortController().signal)
|
|
198
|
-
ElMessage.success(status === 'active' ? '
|
|
203
|
+
ElMessage.success(status === 'active' ? t('system.menus.menuPublished') : t('system.menus.menuUnpublished'))
|
|
199
204
|
await reconcile()
|
|
200
205
|
}
|
|
201
206
|
|
|
202
207
|
async function remove(ids: readonly string[], signal?: AbortSignal): Promise<void> {
|
|
203
208
|
await removeMenus(ids, signal ?? new AbortController().signal)
|
|
204
|
-
ElMessage.success(ids.length > 1 ? '
|
|
209
|
+
ElMessage.success(ids.length > 1 ? t('system.menus.selectedDeleted') : t('system.menus.menuDeleted'))
|
|
205
210
|
await reconcile()
|
|
206
211
|
}
|
|
207
212
|
|
|
208
|
-
const columns
|
|
213
|
+
const columns = computed<TableColumn<RbacMenu>[]>(() => [
|
|
209
214
|
{ type: 'selection', key: 'selection', width: 48 },
|
|
210
|
-
{ prop: 'title', label: '
|
|
211
|
-
{ prop: 'code', label: '
|
|
215
|
+
{ prop: 'title', label: t('system.menus.menuName'), minWidth: 180 },
|
|
216
|
+
{ prop: 'code', label: t('system.menus.code'), minWidth: 158, copyable: true },
|
|
212
217
|
{
|
|
213
218
|
prop: 'path',
|
|
214
|
-
label: '
|
|
219
|
+
label: t('system.menus.path'),
|
|
215
220
|
minWidth: 190,
|
|
216
221
|
copyable: true,
|
|
217
222
|
format: (value) => String(value ?? ''),
|
|
218
223
|
},
|
|
219
224
|
{
|
|
220
225
|
prop: 'permission',
|
|
221
|
-
label: '
|
|
226
|
+
label: t('system.menus.permission'),
|
|
222
227
|
minWidth: 184,
|
|
223
228
|
copyable: true,
|
|
224
229
|
format: (value) => String(value ?? ''),
|
|
225
230
|
},
|
|
226
231
|
{
|
|
227
232
|
prop: 'kind',
|
|
228
|
-
label: '
|
|
233
|
+
label: t('system.menus.kind'),
|
|
229
234
|
width: 96,
|
|
230
235
|
format: (value) =>
|
|
231
|
-
value === 'directory'
|
|
236
|
+
value === 'directory'
|
|
237
|
+
? t('system.menus.kindDirectory')
|
|
238
|
+
: value === 'button'
|
|
239
|
+
? t('system.menus.kindButton')
|
|
240
|
+
: t('system.menus.kindPage'),
|
|
232
241
|
},
|
|
233
242
|
{
|
|
234
243
|
prop: 'componentKey',
|
|
235
|
-
label: '
|
|
244
|
+
label: t('system.menus.componentKey'),
|
|
236
245
|
minWidth: 152,
|
|
237
|
-
format: (value) =>
|
|
246
|
+
format: (value) => {
|
|
247
|
+
const capability = getPageCapability(String(value))
|
|
248
|
+
return capability ? rbacText(capability.labelKey) : '-'
|
|
249
|
+
},
|
|
238
250
|
},
|
|
239
251
|
{
|
|
240
252
|
prop: 'status',
|
|
241
|
-
label: '
|
|
253
|
+
label: t('system.menus.status'),
|
|
242
254
|
width: 90,
|
|
243
|
-
format: (value) => (value === 'active' ? '
|
|
255
|
+
format: (value) => (value === 'active' ? t('system.menus.published') : t('system.menus.unpublished')),
|
|
244
256
|
},
|
|
245
|
-
{ prop: 'updatedAt', label: '
|
|
257
|
+
{ prop: 'updatedAt', label: t('system.menus.updatedAt'), minWidth: 134, sortable: 'custom', format: formatDate },
|
|
246
258
|
{
|
|
247
259
|
type: 'action',
|
|
248
260
|
key: 'actions',
|
|
249
|
-
label: '
|
|
261
|
+
label: t('common.actions.operations'),
|
|
250
262
|
width: 218,
|
|
251
263
|
fixed: 'right',
|
|
252
264
|
actions: [
|
|
253
|
-
{ key: 'edit', label: '
|
|
265
|
+
{ key: 'edit', label: t('common.actions.edit'), permission: 'system:menu:write', onClick: openEditor },
|
|
254
266
|
{
|
|
255
267
|
key: 'toggle-status',
|
|
256
|
-
label: '
|
|
268
|
+
label: t('common.actions.toggleStatus'),
|
|
257
269
|
permission: 'system:menu:publish',
|
|
258
|
-
confirm: '
|
|
270
|
+
confirm: t('system.menus.confirmTogglePublish'),
|
|
259
271
|
onClick: (row) => setStatus([row.id], row.status === 'active' ? 'suspended' : 'active'),
|
|
260
272
|
},
|
|
261
273
|
{
|
|
262
274
|
key: 'remove',
|
|
263
|
-
label: '
|
|
275
|
+
label: t('common.actions.delete'),
|
|
264
276
|
permission: 'system:menu:write',
|
|
265
|
-
confirm: '
|
|
277
|
+
confirm: t('system.menus.confirmDelete'),
|
|
266
278
|
onClick: (row) => remove([row.id]),
|
|
267
279
|
},
|
|
268
280
|
],
|
|
269
281
|
},
|
|
270
|
-
]
|
|
282
|
+
])
|
|
271
283
|
|
|
272
284
|
const dataSource: OgTableDataSource<RbacMenu, MenuQuery> = {
|
|
273
285
|
list: (request, context: OgTableRequestContext): Promise<PageResult<RbacMenu>> =>
|
|
274
286
|
listMenus(request, context.signal),
|
|
275
287
|
}
|
|
276
288
|
|
|
277
|
-
const config
|
|
289
|
+
const config = computed<OgTableConfig<RbacMenu, MenuQuery>>(() => ({
|
|
278
290
|
search: {
|
|
279
|
-
quickSearch: { placeholder: '
|
|
291
|
+
quickSearch: { placeholder: t('system.menus.searchPlaceholder') },
|
|
280
292
|
columns: 4,
|
|
281
293
|
fields: [
|
|
282
|
-
{ prop: 'kind', label: '
|
|
283
|
-
{ prop: 'status', label: '
|
|
294
|
+
{ prop: 'kind', label: t('system.menus.nodeType'), type: 'select', options: kindOptions.value },
|
|
295
|
+
{ prop: 'status', label: t('system.menus.publishStatus'), type: 'select', options: statusOptions.value },
|
|
284
296
|
],
|
|
285
297
|
},
|
|
286
298
|
pagination: false,
|
|
@@ -291,9 +303,9 @@ export function useMenuManagement(options: UseMenuManagementOptions) {
|
|
|
291
303
|
batch: [
|
|
292
304
|
{
|
|
293
305
|
key: 'publish',
|
|
294
|
-
label: '
|
|
306
|
+
label: t('system.menus.batchPublish'),
|
|
295
307
|
permission: 'system:menu:publish',
|
|
296
|
-
confirm: '
|
|
308
|
+
confirm: t('system.menus.confirmBatchPublish'),
|
|
297
309
|
onClick: (rows) =>
|
|
298
310
|
setStatus(
|
|
299
311
|
rows.map((row) => row.id),
|
|
@@ -302,9 +314,9 @@ export function useMenuManagement(options: UseMenuManagementOptions) {
|
|
|
302
314
|
},
|
|
303
315
|
{
|
|
304
316
|
key: 'unpublish',
|
|
305
|
-
label: '
|
|
317
|
+
label: t('system.menus.batchUnpublish'),
|
|
306
318
|
permission: 'system:menu:publish',
|
|
307
|
-
confirm: '
|
|
319
|
+
confirm: t('system.menus.confirmBatchUnpublish'),
|
|
308
320
|
onClick: (rows) =>
|
|
309
321
|
setStatus(
|
|
310
322
|
rows.map((row) => row.id),
|
|
@@ -313,15 +325,15 @@ export function useMenuManagement(options: UseMenuManagementOptions) {
|
|
|
313
325
|
},
|
|
314
326
|
{
|
|
315
327
|
key: 'remove',
|
|
316
|
-
label: '
|
|
328
|
+
label: t('system.menus.batchDelete'),
|
|
317
329
|
permission: 'system:menu:write',
|
|
318
|
-
confirm: '
|
|
330
|
+
confirm: t('system.menus.confirmBatchDelete'),
|
|
319
331
|
onClick: (rows) => remove(rows.map((row) => row.id)),
|
|
320
332
|
},
|
|
321
333
|
],
|
|
322
334
|
},
|
|
323
335
|
toolbar: { refresh: true, density: true, columns: true, reset: true },
|
|
324
|
-
}
|
|
336
|
+
}))
|
|
325
337
|
|
|
326
338
|
return { columns, config, dataSource, openEditor }
|
|
327
339
|
}
|
|
@@ -5,6 +5,7 @@ import { Plus } from '@element-plus/icons-vue'
|
|
|
5
5
|
import { OgTableWithSearch } from '@origen-ui/table-search'
|
|
6
6
|
import { ElButton } from 'element-plus'
|
|
7
7
|
import { useTemplateRef } from 'vue'
|
|
8
|
+
import { useI18n } from 'vue-i18n'
|
|
8
9
|
import { routeStatus } from '../../../../router/routeQuery'
|
|
9
10
|
import { useRouteQueryDefaults } from '../../../../router/useRouteQueryDefaults'
|
|
10
11
|
import { useAuthStore } from '../../../auth/store/auth'
|
|
@@ -13,6 +14,7 @@ import { useMenuManagement } from '../composables/useMenuManagement'
|
|
|
13
14
|
defineOptions({ name: 'MenuListPage' })
|
|
14
15
|
|
|
15
16
|
const auth = useAuthStore()
|
|
17
|
+
const { t } = useI18n()
|
|
16
18
|
const table = useTemplateRef<OgTableExpose<RbacMenu>>('table')
|
|
17
19
|
|
|
18
20
|
async function refreshTable(): Promise<void> {
|
|
@@ -41,7 +43,7 @@ const { queryDefaults } = useRouteQueryDefaults({ status: routeStatus })
|
|
|
41
43
|
:icon="Plus"
|
|
42
44
|
@click="openEditor()"
|
|
43
45
|
>
|
|
44
|
-
|
|
46
|
+
{{ t('system.menus.addMenu') }}
|
|
45
47
|
</ElButton>
|
|
46
48
|
</template>
|
|
47
49
|
</OgTableWithSearch>
|
|
@@ -3,7 +3,8 @@ import type { OgFormExpose, OgFormSchema } from '@origen-ui/form/core'
|
|
|
3
3
|
import type { FormActionExpose, SelectOption } from '@origen-ui/shared'
|
|
4
4
|
import type { AdminRoleDraft } from '../../access/api/admin-repository'
|
|
5
5
|
import { OgForm } from '@origen-ui/form/core'
|
|
6
|
-
import { ref, useTemplateRef } from 'vue'
|
|
6
|
+
import { computed, ref, useTemplateRef } from 'vue'
|
|
7
|
+
import { useI18n } from 'vue-i18n'
|
|
7
8
|
|
|
8
9
|
defineOptions({ name: 'RoleEditorForm' })
|
|
9
10
|
|
|
@@ -12,6 +13,8 @@ const props = defineProps<{
|
|
|
12
13
|
permissionTree: SelectOption[]
|
|
13
14
|
}>()
|
|
14
15
|
|
|
16
|
+
const { t } = useI18n()
|
|
17
|
+
|
|
15
18
|
interface RoleFormModel {
|
|
16
19
|
name: string
|
|
17
20
|
code: string
|
|
@@ -26,37 +29,37 @@ const model = ref<RoleFormModel>({
|
|
|
26
29
|
})
|
|
27
30
|
const form = useTemplateRef<OgFormExpose<RoleFormModel>>('form')
|
|
28
31
|
|
|
29
|
-
const schema
|
|
32
|
+
const schema = computed<OgFormSchema<RoleFormModel>>(() => ({
|
|
30
33
|
sections: [
|
|
31
34
|
{
|
|
32
35
|
fields: [
|
|
33
36
|
{
|
|
34
37
|
prop: 'name',
|
|
35
|
-
label: '
|
|
38
|
+
label: t('system.roles.form.name'),
|
|
36
39
|
required: true,
|
|
37
|
-
control: { type: 'input', props: { placeholder: '
|
|
40
|
+
control: { type: 'input', props: { placeholder: t('system.roles.form.namePlaceholder') } },
|
|
38
41
|
},
|
|
39
42
|
{
|
|
40
43
|
prop: 'code',
|
|
41
|
-
label: '
|
|
44
|
+
label: t('system.roles.form.code'),
|
|
42
45
|
required: true,
|
|
43
|
-
control: { type: 'input', props: { placeholder: '
|
|
46
|
+
control: { type: 'input', props: { placeholder: t('system.roles.form.codePlaceholder') } },
|
|
44
47
|
rules: [
|
|
45
48
|
{
|
|
46
49
|
pattern: /^[a-z][a-z0-9_]{2,31}$/,
|
|
47
|
-
message: '
|
|
50
|
+
message: t('system.roles.form.codeRuleMessage'),
|
|
48
51
|
trigger: 'blur',
|
|
49
52
|
},
|
|
50
53
|
],
|
|
51
54
|
},
|
|
52
55
|
{
|
|
53
56
|
prop: 'description',
|
|
54
|
-
label: '
|
|
57
|
+
label: t('system.roles.form.description'),
|
|
55
58
|
required: true,
|
|
56
59
|
control: {
|
|
57
60
|
type: 'textarea',
|
|
58
61
|
props: {
|
|
59
|
-
placeholder: '
|
|
62
|
+
placeholder: t('system.roles.form.descriptionPlaceholder'),
|
|
60
63
|
rows: 3,
|
|
61
64
|
maxlength: 120,
|
|
62
65
|
showWordLimit: true,
|
|
@@ -66,14 +69,14 @@ const schema: OgFormSchema<RoleFormModel> = {
|
|
|
66
69
|
},
|
|
67
70
|
{
|
|
68
71
|
prop: 'permissions',
|
|
69
|
-
label: '
|
|
72
|
+
label: t('system.roles.form.permissions'),
|
|
70
73
|
required: true,
|
|
71
74
|
control: {
|
|
72
75
|
type: 'tree-select',
|
|
73
76
|
props: {
|
|
74
77
|
multiple: true,
|
|
75
78
|
filterable: true,
|
|
76
|
-
placeholder: '
|
|
79
|
+
placeholder: t('system.roles.form.permissionsPlaceholder'),
|
|
77
80
|
treeData: props.permissionTree,
|
|
78
81
|
treeCheckable: true,
|
|
79
82
|
treeCheckStrictly: true,
|
|
@@ -83,19 +86,19 @@ const schema: OgFormSchema<RoleFormModel> = {
|
|
|
83
86
|
},
|
|
84
87
|
{
|
|
85
88
|
prop: 'status',
|
|
86
|
-
label: '
|
|
89
|
+
label: t('system.roles.form.status'),
|
|
87
90
|
control: { type: 'radio' },
|
|
88
91
|
required: true,
|
|
89
92
|
options: [
|
|
90
|
-
{ label: '
|
|
91
|
-
{ label: '
|
|
93
|
+
{ label: t('common.status.enabled'), value: 'active' },
|
|
94
|
+
{ label: t('common.status.disabled'), value: 'suspended' },
|
|
92
95
|
],
|
|
93
96
|
span: 24,
|
|
94
97
|
},
|
|
95
98
|
],
|
|
96
99
|
},
|
|
97
100
|
],
|
|
98
|
-
}
|
|
101
|
+
}))
|
|
99
102
|
|
|
100
103
|
defineExpose<FormActionExpose>({
|
|
101
104
|
validate: async () => (await form.value?.validate()) ?? false,
|