@morya-ui/mcp 0.4.4 → 0.5.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.
@@ -1,166 +1,166 @@
1
- <script setup lang="ts">
2
- /**
3
- * 黄金样例:列表内短表单弹窗(form-in-dialog)
4
- * 留在列表页,用 MDialog 承载 ≤8 字段的新建/编辑;长表单仍走 form-page / Drawer。
5
- * @see DESIGN.md · page-layouts.md · pattern form-in-dialog
6
- */
7
- import {
8
- MBreadcrumb,
9
- MButton,
10
- MConfigProvider,
11
- MDialog,
12
- MForm,
13
- MFormItem,
14
- MInput,
15
- MLayout,
16
- MLayoutContent,
17
- MLayoutHeader,
18
- MPageContent,
19
- MPageHeader,
20
- MSelect,
21
- MSpace,
22
- MStatus,
23
- MTable,
24
- message,
25
- zhCN,
26
- } from 'morya-ui'
27
- import { reactive, ref } from 'vue'
28
-
29
- const dialogOpen = ref(false)
30
- const submitting = ref(false)
31
- const editingId = ref<string | null>(null)
32
-
33
- const model = reactive({
34
- name: '',
35
- email: '',
36
- role: undefined as string | undefined,
37
- })
38
-
39
- const roleOptions = [
40
- { label: '管理员', value: 'admin' },
41
- { label: '成员', value: 'member' },
42
- ]
43
-
44
- const columns = [
45
- { key: 'name', label: '姓名' },
46
- { key: 'email', label: '邮箱' },
47
- { key: 'status', label: '状态', width: 100 },
48
- { key: 'actions', label: '操作', width: 120 },
49
- ]
50
-
51
- const rows = ref([
52
- { id: '1', name: '林晓', email: 'linxiao@example.com', status: 'active', role: 'member' },
53
- { id: '2', name: '周然', email: 'zhouran@example.com', status: 'inactive', role: 'admin' },
54
- ])
55
-
56
- const dialogTitle = () => (editingId.value ? '编辑用户' : '新建用户')
57
-
58
- function resetModel() {
59
- model.name = ''
60
- model.email = ''
61
- model.role = undefined
62
- editingId.value = null
63
- }
64
-
65
- function openCreate() {
66
- resetModel()
67
- dialogOpen.value = true
68
- }
69
-
70
- function openEdit(row: (typeof rows.value)[number]) {
71
- editingId.value = row.id
72
- model.name = row.name
73
- model.email = row.email
74
- model.role = row.role
75
- dialogOpen.value = true
76
- }
77
-
78
- function closeDialog() {
79
- dialogOpen.value = false
80
- resetModel()
81
- }
82
-
83
- async function onSave() {
84
- submitting.value = true
85
- try {
86
- // await api.save(model)
87
- message.success(editingId.value ? '已保存' : '已创建')
88
- closeDialog()
89
- } finally {
90
- submitting.value = false
91
- }
92
- }
93
- </script>
94
-
95
- <template>
96
- <MConfigProvider :locale="zhCN">
97
- <MLayout fill-viewport>
98
- <MLayoutHeader padding="var(--m-space-4) var(--m-space-6)">
99
- <MBreadcrumb :model="[{ label: '首页', to: '/' }, { label: '用户管理' }]" />
100
- </MLayoutHeader>
101
-
102
- <MLayoutContent>
103
- <MPageContent>
104
- <MPageHeader title="用户管理" description="短表单留在列表内弹窗;字段多时再走独立表单页。">
105
- <template #actions>
106
- <MButton @click="openCreate" type="primary">
107
- 新建用户
108
- </MButton>
109
- </template>
110
- </MPageHeader>
111
-
112
- <MTable
113
- :columns="columns"
114
- :rows="rows"
115
- row-key="id"
116
- striped
117
- bordered
118
- aria-label="用户列表"
119
- >
120
- <template #cell-status="{ value }">
121
- <MStatus
122
- :label="value === 'active' ? '启用' : '停用'"
123
- :type="value === 'active' ? 'success' : 'secondary'"
124
- />
125
- </template>
126
- <template #cell-actions="{ row }">
127
- <MButton size="small" @click="openEdit(row)" type="text">
128
- 编辑
129
- </MButton>
130
- </template>
131
- </MTable>
132
- </MPageContent>
133
- </MLayoutContent>
134
- </MLayout>
135
-
136
- <MDialog
137
- v-model="dialogOpen"
138
- :header="dialogTitle()"
139
- width="32rem"
140
- @close="resetModel"
141
- >
142
- <MForm @submit.prevent="onSave">
143
- <MFormItem label="姓名" name="name" required>
144
- <MInput v-model="model.name" placeholder="请输入姓名" fluid />
145
- </MFormItem>
146
- <MFormItem label="邮箱" name="email" required>
147
- <MInput v-model="model.email" type="email" placeholder="name@example.com" fluid />
148
- </MFormItem>
149
- <MFormItem label="角色" name="role" required>
150
- <MSelect v-model="model.role" :options="roleOptions" placeholder="请选择角色" fluid />
151
- </MFormItem>
152
- </MForm>
153
-
154
- <template #footer>
155
- <MSpace style="justify-content: flex-end; width: 100%">
156
- <MButton :disabled="submitting" @click="closeDialog" type="text">
157
- 取消
158
- </MButton>
159
- <MButton :loading="submitting" @click="onSave" type="primary">
160
- 保存
161
- </MButton>
162
- </MSpace>
163
- </template>
164
- </MDialog>
165
- </MConfigProvider>
166
- </template>
1
+ <script setup lang="ts">
2
+ /**
3
+ * 黄金样例:列表内短表单弹窗(form-in-dialog)
4
+ * 留在列表页,用 MDialog 承载 ≤8 字段的新建/编辑;长表单仍走 form-page / Drawer。
5
+ * @see DESIGN.md · page-layouts.md · pattern form-in-dialog
6
+ */
7
+ import {
8
+ MBreadcrumb,
9
+ MButton,
10
+ MConfigProvider,
11
+ MDialog,
12
+ MForm,
13
+ MFormItem,
14
+ MInput,
15
+ MLayout,
16
+ MLayoutContent,
17
+ MLayoutHeader,
18
+ MPageContent,
19
+ MPageHeader,
20
+ MSelect,
21
+ MSpace,
22
+ MStatus,
23
+ MTable,
24
+ message,
25
+ zhCN,
26
+ } from 'morya-ui'
27
+ import { reactive, ref } from 'vue'
28
+
29
+ const dialogOpen = ref(false)
30
+ const submitting = ref(false)
31
+ const editingId = ref<string | null>(null)
32
+
33
+ const model = reactive({
34
+ name: '',
35
+ email: '',
36
+ role: undefined as string | undefined,
37
+ })
38
+
39
+ const roleOptions = [
40
+ { label: '管理员', value: 'admin' },
41
+ { label: '成员', value: 'member' },
42
+ ]
43
+
44
+ const columns = [
45
+ { key: 'name', label: '姓名' },
46
+ { key: 'email', label: '邮箱' },
47
+ { key: 'status', label: '状态', width: 100 },
48
+ { key: 'actions', label: '操作', width: 120 },
49
+ ]
50
+
51
+ const rows = ref([
52
+ { id: '1', name: '林晓', email: 'linxiao@example.com', status: 'active', role: 'member' },
53
+ { id: '2', name: '周然', email: 'zhouran@example.com', status: 'inactive', role: 'admin' },
54
+ ])
55
+
56
+ const dialogTitle = () => (editingId.value ? '编辑用户' : '新建用户')
57
+
58
+ function resetModel() {
59
+ model.name = ''
60
+ model.email = ''
61
+ model.role = undefined
62
+ editingId.value = null
63
+ }
64
+
65
+ function openCreate() {
66
+ resetModel()
67
+ dialogOpen.value = true
68
+ }
69
+
70
+ function openEdit(row: (typeof rows.value)[number]) {
71
+ editingId.value = row.id
72
+ model.name = row.name
73
+ model.email = row.email
74
+ model.role = row.role
75
+ dialogOpen.value = true
76
+ }
77
+
78
+ function closeDialog() {
79
+ dialogOpen.value = false
80
+ resetModel()
81
+ }
82
+
83
+ async function onSave() {
84
+ submitting.value = true
85
+ try {
86
+ // await api.save(model)
87
+ message.success(editingId.value ? '已保存' : '已创建')
88
+ closeDialog()
89
+ } finally {
90
+ submitting.value = false
91
+ }
92
+ }
93
+ </script>
94
+
95
+ <template>
96
+ <MConfigProvider :locale="zhCN">
97
+ <MLayout fill-viewport>
98
+ <MLayoutHeader padding="var(--m-space-4) var(--m-space-6)">
99
+ <MBreadcrumb :model="[{ label: '首页', to: '/' }, { label: '用户管理' }]" />
100
+ </MLayoutHeader>
101
+
102
+ <MLayoutContent>
103
+ <MPageContent>
104
+ <MPageHeader title="用户管理" description="短表单留在列表内弹窗;字段多时再走独立表单页。">
105
+ <template #actions>
106
+ <MButton @click="openCreate" type="primary">
107
+ 新建用户
108
+ </MButton>
109
+ </template>
110
+ </MPageHeader>
111
+
112
+ <MTable
113
+ :columns="columns"
114
+ :rows="rows"
115
+ row-key="id"
116
+ striped
117
+ bordered
118
+ aria-label="用户列表"
119
+ >
120
+ <template #cell-status="{ value }">
121
+ <MStatus
122
+ :label="value === 'active' ? '启用' : '停用'"
123
+ :type="value === 'active' ? 'success' : 'secondary'"
124
+ />
125
+ </template>
126
+ <template #cell-actions="{ row }">
127
+ <MButton size="small" @click="openEdit(row)" type="text">
128
+ 编辑
129
+ </MButton>
130
+ </template>
131
+ </MTable>
132
+ </MPageContent>
133
+ </MLayoutContent>
134
+ </MLayout>
135
+
136
+ <MDialog
137
+ v-model="dialogOpen"
138
+ :header="dialogTitle()"
139
+ width="32rem"
140
+ @close="resetModel"
141
+ >
142
+ <MForm @submit.prevent="onSave">
143
+ <MFormItem label="姓名" name="name" required>
144
+ <MInput v-model="model.name" placeholder="请输入姓名" fluid />
145
+ </MFormItem>
146
+ <MFormItem label="邮箱" name="email" required>
147
+ <MInput v-model="model.email" type="email" placeholder="name@example.com" fluid />
148
+ </MFormItem>
149
+ <MFormItem label="角色" name="role" required>
150
+ <MSelect v-model="model.role" :options="roleOptions" placeholder="请选择角色" fluid />
151
+ </MFormItem>
152
+ </MForm>
153
+
154
+ <template #footer>
155
+ <MSpace style="justify-content: flex-end; width: 100%">
156
+ <MButton :disabled="submitting" @click="closeDialog" type="text">
157
+ 取消
158
+ </MButton>
159
+ <MButton :loading="submitting" @click="onSave" type="primary">
160
+ 保存
161
+ </MButton>
162
+ </MSpace>
163
+ </template>
164
+ </MDialog>
165
+ </MConfigProvider>
166
+ </template>
@@ -1,107 +1,107 @@
1
- <script setup lang="ts">
2
- /**
3
- * 黄金样例:表单页
4
- * @see DESIGN.md · morya-ui-pages references/page-layouts.md
5
- */
6
- import {
7
- MBreadcrumb,
8
- MButton,
9
- MConfigProvider,
10
- MDatePicker,
11
- MForm,
12
- MFormItem,
13
- MInput,
14
- MLayout,
15
- MLayoutContent,
16
- MLayoutHeader,
17
- MPageContent,
18
- MPageHeader,
19
- MPageSection,
20
- MSelect,
21
- MSpace,
22
- MSwitch,
23
- MTextarea,
24
- zhCN,
25
- } from 'morya-ui'
26
- import { reactive, ref } from 'vue'
27
-
28
- const submitting = ref(false)
29
-
30
- const model = reactive({
31
- name: '',
32
- email: '',
33
- role: undefined as string | undefined,
34
- active: true,
35
- joinedAt: null as string | null,
36
- bio: '',
37
- })
38
-
39
- const roleOptions = [
40
- { label: '管理员', value: 'admin' },
41
- { label: '成员', value: 'member' },
42
- ]
43
-
44
- async function onSubmit() {
45
- submitting.value = true
46
- try {
47
- // await api.save(model)
48
- } finally {
49
- submitting.value = false
50
- }
51
- }
52
- </script>
53
-
54
- <template>
55
- <MConfigProvider :locale="zhCN">
56
- <MLayout fill-viewport>
57
- <MLayoutHeader padding="var(--m-space-4) var(--m-space-6)">
58
- <MBreadcrumb :model="[{ label: '首页', to: '/' }, { label: '用户管理', to: '/users' }, { label: '新建用户' }]" />
59
- </MLayoutHeader>
60
-
61
- <MLayoutContent>
62
- <MPageContent width="narrow">
63
- <MPageHeader title="新建用户" description="填写基本信息并分配角色。" />
64
-
65
- <MPageSection variant="form">
66
- <MForm @submit="onSubmit">
67
- <MFormItem label="姓名" name="name" required>
68
- <MInput v-model="model.name" placeholder="请输入姓名" fluid />
69
- </MFormItem>
70
-
71
- <MFormItem label="邮箱" name="email" required>
72
- <MInput v-model="model.email" type="email" placeholder="name@example.com" fluid />
73
- </MFormItem>
74
-
75
- <MFormItem label="角色" name="role" required>
76
- <MSelect v-model="model.role" :options="roleOptions" placeholder="请选择角色" fluid />
77
- </MFormItem>
78
-
79
- <MFormItem label="入职日期" name="joinedAt">
80
- <MDatePicker v-model="model.joinedAt" placeholder="选择日期" fluid />
81
- </MFormItem>
82
-
83
- <MFormItem label="启用账号" name="active">
84
- <MSwitch v-model="model.active" />
85
- </MFormItem>
86
-
87
- <MFormItem label="简介" name="bio">
88
- <MTextarea v-model="model.bio" :rows="4" placeholder="可选" fluid />
89
- </MFormItem>
90
-
91
- <MPageSection variant="actions">
92
- <MSpace>
93
- <MButton type="primary" html-type="submit" :loading="submitting">
94
- 保存
95
- </MButton>
96
- <MButton>
97
- 取消
98
- </MButton>
99
- </MSpace>
100
- </MPageSection>
101
- </MForm>
102
- </MPageSection>
103
- </MPageContent>
104
- </MLayoutContent>
105
- </MLayout>
106
- </MConfigProvider>
107
- </template>
1
+ <script setup lang="ts">
2
+ /**
3
+ * 黄金样例:表单页
4
+ * @see DESIGN.md · morya-ui-pages references/page-layouts.md
5
+ */
6
+ import {
7
+ MBreadcrumb,
8
+ MButton,
9
+ MConfigProvider,
10
+ MDatePicker,
11
+ MForm,
12
+ MFormItem,
13
+ MInput,
14
+ MLayout,
15
+ MLayoutContent,
16
+ MLayoutHeader,
17
+ MPageContent,
18
+ MPageHeader,
19
+ MPageSection,
20
+ MSelect,
21
+ MSpace,
22
+ MSwitch,
23
+ MTextarea,
24
+ zhCN,
25
+ } from 'morya-ui'
26
+ import { reactive, ref } from 'vue'
27
+
28
+ const submitting = ref(false)
29
+
30
+ const model = reactive({
31
+ name: '',
32
+ email: '',
33
+ role: undefined as string | undefined,
34
+ active: true,
35
+ joinedAt: null as string | null,
36
+ bio: '',
37
+ })
38
+
39
+ const roleOptions = [
40
+ { label: '管理员', value: 'admin' },
41
+ { label: '成员', value: 'member' },
42
+ ]
43
+
44
+ async function onSubmit() {
45
+ submitting.value = true
46
+ try {
47
+ // await api.save(model)
48
+ } finally {
49
+ submitting.value = false
50
+ }
51
+ }
52
+ </script>
53
+
54
+ <template>
55
+ <MConfigProvider :locale="zhCN">
56
+ <MLayout fill-viewport>
57
+ <MLayoutHeader padding="var(--m-space-4) var(--m-space-6)">
58
+ <MBreadcrumb :model="[{ label: '首页', to: '/' }, { label: '用户管理', to: '/users' }, { label: '新建用户' }]" />
59
+ </MLayoutHeader>
60
+
61
+ <MLayoutContent>
62
+ <MPageContent width="narrow">
63
+ <MPageHeader title="新建用户" description="填写基本信息并分配角色。" />
64
+
65
+ <MPageSection variant="form">
66
+ <MForm @submit="onSubmit">
67
+ <MFormItem label="姓名" name="name" required>
68
+ <MInput v-model="model.name" placeholder="请输入姓名" fluid />
69
+ </MFormItem>
70
+
71
+ <MFormItem label="邮箱" name="email" required>
72
+ <MInput v-model="model.email" type="email" placeholder="name@example.com" fluid />
73
+ </MFormItem>
74
+
75
+ <MFormItem label="角色" name="role" required>
76
+ <MSelect v-model="model.role" :options="roleOptions" placeholder="请选择角色" fluid />
77
+ </MFormItem>
78
+
79
+ <MFormItem label="入职日期" name="joinedAt">
80
+ <MDatePicker v-model="model.joinedAt" placeholder="选择日期" fluid />
81
+ </MFormItem>
82
+
83
+ <MFormItem label="启用账号" name="active">
84
+ <MSwitch v-model="model.active" />
85
+ </MFormItem>
86
+
87
+ <MFormItem label="简介" name="bio">
88
+ <MTextarea v-model="model.bio" :rows="4" placeholder="可选" fluid />
89
+ </MFormItem>
90
+
91
+ <MPageSection variant="actions">
92
+ <MSpace>
93
+ <MButton type="primary" html-type="submit" :loading="submitting">
94
+ 保存
95
+ </MButton>
96
+ <MButton>
97
+ 取消
98
+ </MButton>
99
+ </MSpace>
100
+ </MPageSection>
101
+ </MForm>
102
+ </MPageSection>
103
+ </MPageContent>
104
+ </MLayoutContent>
105
+ </MLayout>
106
+ </MConfigProvider>
107
+ </template>