xto-fronted 0.2.5 → 0.2.7
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/.env.development +4 -0
- package/.env.production +4 -0
- package/README.md +94 -196
- package/dist/{components/Layout/TopMenu.vue.d.ts → App.vue.d.ts} +1 -1
- package/dist/api/auth.d.ts +8 -10
- package/dist/api/system.d.ts +11 -12
- package/dist/api/user.d.ts +12 -3
- package/dist/components/Layout/Footer.vue.d.ts +1 -1
- package/dist/components/Layout/Header.vue.d.ts +3 -14
- package/dist/components/Layout/Sidebar.vue.d.ts +1 -1
- package/dist/components/Layout/Tabs.vue.d.ts +1 -1
- package/dist/components/Layout/index.vue.d.ts +1 -1
- package/dist/composables/useAuth.d.ts +4 -19
- package/dist/directives/permission.d.ts +0 -1
- package/dist/index-CWRs4WMN.js +372 -0
- package/dist/index-CpxpXTQX.js +1462 -0
- package/dist/index-Cu3Z2-PY.js +345 -0
- package/dist/index-DPEVEyik.js +475 -0
- package/dist/index-DYnXaqYf.js +142 -0
- package/dist/index.d.ts +12 -25
- package/dist/index.es.js +76 -1521
- package/dist/index.umd.js +1 -20
- package/dist/main.d.ts +0 -1
- package/dist/router/dynamicRoutes.d.ts +33 -17
- package/dist/router/index.d.ts +4 -26
- package/dist/router/layoutRoute.d.ts +18 -0
- package/dist/router/staticRoutes.d.ts +2 -18
- package/dist/setup.d.ts +17 -0
- package/dist/stores/app.d.ts +15 -9
- package/dist/stores/auth.d.ts +48 -62
- package/dist/stores/index.d.ts +3 -1
- package/dist/stores/menu.d.ts +29 -47
- package/dist/stores/user.d.ts +84 -64
- package/dist/style.css +1 -1
- package/dist/utils/auth.d.ts +10 -10
- package/dist/utils/permission.d.ts +10 -1
- package/dist/utils/request.d.ts +7 -23
- package/dist/{components/Layout/Breadcrumb.vue.d.ts → views/dashboard/index.vue.d.ts} +1 -1
- package/dist/{components/Error → views/error}/403.vue.d.ts +1 -1
- package/dist/{components/Error → views/error}/404.vue.d.ts +1 -1
- package/dist/views/login/index.vue.d.ts +4 -0
- package/dist/views/system/menu/index.vue.d.ts +4 -0
- package/dist/views/system/role/index.vue.d.ts +4 -0
- package/dist/views/system/user/index.vue.d.ts +4 -0
- package/dist/vite.svg +9 -9
- package/index.html +13 -0
- package/package.json +27 -31
- package/public/vite.svg +10 -0
- package/src/App.vue +20 -0
- package/src/api/auth.ts +26 -0
- package/src/api/system.ts +65 -0
- package/src/api/user.ts +46 -0
- package/src/assets/styles/_dark.scss +407 -0
- package/src/assets/styles/_reset.scss +126 -0
- package/src/assets/styles/_root.scss +140 -0
- package/src/assets/styles/_transition.scss +119 -0
- package/src/assets/styles/_variables.scss +45 -0
- package/src/assets/styles/index.scss +187 -0
- package/src/components/Layout/Footer.vue +17 -0
- package/src/components/Layout/Header.vue +390 -0
- package/src/components/Layout/Sidebar.vue +297 -0
- package/src/components/Layout/Tabs.vue +134 -0
- package/src/components/Layout/index.vue +62 -0
- package/src/composables/useAuth.ts +45 -0
- package/src/composables/useForm.ts +79 -0
- package/src/composables/useTable.ts +97 -0
- package/src/directives/permission.ts +38 -0
- package/src/enums/index.ts +63 -0
- package/src/env.d.ts +17 -0
- package/src/index.ts +48 -0
- package/src/main.ts +34 -0
- package/src/router/dynamicRoutes.ts +163 -0
- package/src/router/index.ts +81 -0
- package/src/router/layoutRoute.ts +45 -0
- package/src/router/staticRoutes.ts +43 -0
- package/src/setup.ts +54 -0
- package/src/stores/app.ts +163 -0
- package/src/stores/auth.ts +66 -0
- package/src/stores/index.ts +15 -0
- package/src/stores/menu.ts +80 -0
- package/src/stores/user.ts +73 -0
- package/src/style.css +11 -0
- package/src/types/api.d.ts +84 -0
- package/src/types/global.d.ts +45 -0
- package/src/types/router.d.ts +48 -0
- package/src/types/xto.d.ts +149 -0
- package/src/utils/auth.ts +62 -0
- package/src/utils/permission.ts +42 -0
- package/src/utils/request.ts +124 -0
- package/src/utils/storage.ts +63 -0
- package/src/views/dashboard/index.vue +284 -0
- package/src/views/error/403.vue +57 -0
- package/src/views/error/404.vue +57 -0
- package/src/views/login/index.vue +248 -0
- package/src/views/system/menu/index.vue +381 -0
- package/src/views/system/role/index.vue +304 -0
- package/src/views/system/user/index.vue +327 -0
- package/tsconfig.json +26 -0
- package/tsconfig.node.json +11 -0
- package/vite.config.ts +140 -0
- package/dist/api/menu.d.ts +0 -4
- package/dist/components/Login/index.vue.d.ts +0 -25
- package/dist/components/SettingDrawer/index.vue.d.ts +0 -19
- package/dist/composables/index.d.ts +0 -8
- package/dist/composables/useApp.d.ts +0 -65
- package/dist/composables/useMenu.d.ts +0 -34
- package/dist/config/index.d.ts +0 -31
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, reactive, computed, onMounted } from 'vue'
|
|
3
|
+
import { Form, FormItem, Input, Select, Switch } from '@xto/form'
|
|
4
|
+
import { Tag, Card, Pagination } from '@xto/data'
|
|
5
|
+
import { Modal, Message, Popconfirm } from '@xto/feedback'
|
|
6
|
+
import { Space, Button } from '@xto/base'
|
|
7
|
+
import { Status, StatusOptions } from '@/enums'
|
|
8
|
+
|
|
9
|
+
// 用户数据类型
|
|
10
|
+
interface User {
|
|
11
|
+
id: number
|
|
12
|
+
username: string
|
|
13
|
+
nickname: string
|
|
14
|
+
email: string
|
|
15
|
+
phone: string
|
|
16
|
+
status: Status
|
|
17
|
+
roles: string[]
|
|
18
|
+
createTime: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Mock 数据
|
|
22
|
+
const mockUsers: User[] = [
|
|
23
|
+
{ id: 1, username: 'admin', nickname: '管理员', email: 'admin@example.com', phone: '13800138001', status: Status.ENABLED, roles: ['admin'], createTime: '2024-01-01 10:00:00' },
|
|
24
|
+
{ id: 2, username: 'zhangsan', nickname: '张三', email: 'zhangsan@example.com', phone: '13800138002', status: Status.ENABLED, roles: ['editor'], createTime: '2024-01-02 10:00:00' },
|
|
25
|
+
{ id: 3, username: 'lisi', nickname: '李四', email: 'lisi@example.com', phone: '13800138003', status: Status.DISABLED, roles: ['viewer'], createTime: '2024-01-03 10:00:00' },
|
|
26
|
+
{ id: 4, username: 'wangwu', nickname: '王五', email: 'wangwu@example.com', phone: '13800138004', status: Status.ENABLED, roles: ['editor'], createTime: '2024-01-04 10:00:00' },
|
|
27
|
+
{ id: 5, username: 'zhaoliu', nickname: '赵六', email: 'zhaoliu@example.com', phone: '13800138005', status: Status.ENABLED, roles: ['viewer'], createTime: '2024-01-05 10:00:00' }
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
const loading = ref(false)
|
|
31
|
+
const userList = ref<User[]>([])
|
|
32
|
+
const total = ref(0)
|
|
33
|
+
const currentPage = ref(1)
|
|
34
|
+
const pageSize = ref(10)
|
|
35
|
+
|
|
36
|
+
// 搜索条件
|
|
37
|
+
const searchForm = reactive({
|
|
38
|
+
keyword: '',
|
|
39
|
+
status: undefined as Status | undefined
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
// 弹窗
|
|
43
|
+
const modalVisible = ref(false)
|
|
44
|
+
const modalTitle = computed(() => formData.id ? '编辑用户' : '新增用户')
|
|
45
|
+
const formData = reactive({
|
|
46
|
+
id: 0,
|
|
47
|
+
username: '',
|
|
48
|
+
nickname: '',
|
|
49
|
+
email: '',
|
|
50
|
+
phone: '',
|
|
51
|
+
status: Status.ENABLED,
|
|
52
|
+
roles: [] as string[]
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const rules: Record<string, any[]> = {
|
|
56
|
+
username: [
|
|
57
|
+
{ required: true, message: '请输入用户名', trigger: 'blur' }
|
|
58
|
+
],
|
|
59
|
+
nickname: [
|
|
60
|
+
{ required: true, message: '请输入昵称', trigger: 'blur' }
|
|
61
|
+
],
|
|
62
|
+
email: [
|
|
63
|
+
{ required: true, message: '请输入邮箱', trigger: 'blur' },
|
|
64
|
+
{ type: 'email', message: '请输入正确的邮箱格式', trigger: 'blur' }
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const formRef = ref()
|
|
69
|
+
|
|
70
|
+
// 获取用户列表
|
|
71
|
+
const getUserList = () => {
|
|
72
|
+
loading.value = true
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
let list = [...mockUsers]
|
|
75
|
+
|
|
76
|
+
// 搜索过滤
|
|
77
|
+
if (searchForm.keyword) {
|
|
78
|
+
list = list.filter(user =>
|
|
79
|
+
user.username.includes(searchForm.keyword) ||
|
|
80
|
+
user.nickname.includes(searchForm.keyword)
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
if (searchForm.status !== undefined) {
|
|
84
|
+
list = list.filter(user => user.status === searchForm.status)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
total.value = list.length
|
|
88
|
+
userList.value = list.slice((currentPage.value - 1) * pageSize.value, currentPage.value * pageSize.value)
|
|
89
|
+
loading.value = false
|
|
90
|
+
}, 300)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 搜索
|
|
94
|
+
const handleSearch = () => {
|
|
95
|
+
currentPage.value = 1
|
|
96
|
+
getUserList()
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 重置
|
|
100
|
+
const handleReset = () => {
|
|
101
|
+
searchForm.keyword = ''
|
|
102
|
+
searchForm.status = undefined
|
|
103
|
+
currentPage.value = 1
|
|
104
|
+
getUserList()
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 新增
|
|
108
|
+
const handleAdd = () => {
|
|
109
|
+
Object.assign(formData, {
|
|
110
|
+
id: 0,
|
|
111
|
+
username: '',
|
|
112
|
+
nickname: '',
|
|
113
|
+
email: '',
|
|
114
|
+
phone: '',
|
|
115
|
+
status: Status.ENABLED,
|
|
116
|
+
roles: []
|
|
117
|
+
})
|
|
118
|
+
modalVisible.value = true
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// 编辑
|
|
122
|
+
const handleEdit = (row: User) => {
|
|
123
|
+
Object.assign(formData, row)
|
|
124
|
+
modalVisible.value = true
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// 删除
|
|
128
|
+
const handleDelete = (_id: number) => {
|
|
129
|
+
Message.success('删除成功')
|
|
130
|
+
getUserList()
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// 提交
|
|
134
|
+
const handleSubmit = async () => {
|
|
135
|
+
try {
|
|
136
|
+
await formRef.value?.validate()
|
|
137
|
+
Message.success(formData.id ? '编辑成功' : '新增成功')
|
|
138
|
+
modalVisible.value = false
|
|
139
|
+
getUserList()
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.error(error)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// 状态切换
|
|
146
|
+
const handleStatusChange = (row: User) => {
|
|
147
|
+
Message.success(`已${row.status === Status.ENABLED ? '启用' : '禁用'}用户 ${row.username}`)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
onMounted(() => {
|
|
151
|
+
getUserList()
|
|
152
|
+
})
|
|
153
|
+
</script>
|
|
154
|
+
|
|
155
|
+
<template>
|
|
156
|
+
<div class="user-page">
|
|
157
|
+
<!-- 搜索栏 -->
|
|
158
|
+
<Card class="search-card">
|
|
159
|
+
<Form :model="searchForm" inline>
|
|
160
|
+
<FormItem label="关键词">
|
|
161
|
+
<Input
|
|
162
|
+
v-model="searchForm.keyword"
|
|
163
|
+
placeholder="用户名/昵称"
|
|
164
|
+
clearable
|
|
165
|
+
@keyup.enter="handleSearch"
|
|
166
|
+
/>
|
|
167
|
+
</FormItem>
|
|
168
|
+
<FormItem label="状态">
|
|
169
|
+
<Select
|
|
170
|
+
v-model="searchForm.status"
|
|
171
|
+
:options="StatusOptions"
|
|
172
|
+
placeholder="请选择"
|
|
173
|
+
clearable
|
|
174
|
+
/>
|
|
175
|
+
</FormItem>
|
|
176
|
+
<FormItem>
|
|
177
|
+
<Space>
|
|
178
|
+
<Button type="primary" @click="handleSearch">搜索</Button>
|
|
179
|
+
<Button @click="handleReset">重置</Button>
|
|
180
|
+
</Space>
|
|
181
|
+
</FormItem>
|
|
182
|
+
</Form>
|
|
183
|
+
</Card>
|
|
184
|
+
|
|
185
|
+
<!-- 表格 -->
|
|
186
|
+
<Card class="table-card">
|
|
187
|
+
<!-- 工具栏 -->
|
|
188
|
+
<div class="toolbar">
|
|
189
|
+
<Button type="primary" @click="handleAdd">新增用户</Button>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<!-- 表格 -->
|
|
193
|
+
<table class="data-table">
|
|
194
|
+
<thead>
|
|
195
|
+
<tr>
|
|
196
|
+
<th>ID</th>
|
|
197
|
+
<th>用户名</th>
|
|
198
|
+
<th>昵称</th>
|
|
199
|
+
<th>邮箱</th>
|
|
200
|
+
<th>手机号</th>
|
|
201
|
+
<th>角色</th>
|
|
202
|
+
<th>状态</th>
|
|
203
|
+
<th>创建时间</th>
|
|
204
|
+
<th>操作</th>
|
|
205
|
+
</tr>
|
|
206
|
+
</thead>
|
|
207
|
+
<tbody>
|
|
208
|
+
<tr v-if="loading">
|
|
209
|
+
<td colspan="9" class="loading-cell">加载中...</td>
|
|
210
|
+
</tr>
|
|
211
|
+
<tr v-else-if="userList.length === 0">
|
|
212
|
+
<td colspan="9" class="empty-cell">暂无数据</td>
|
|
213
|
+
</tr>
|
|
214
|
+
<tr v-else v-for="row in userList" :key="row.id">
|
|
215
|
+
<td>{{ row.id }}</td>
|
|
216
|
+
<td>{{ row.username }}</td>
|
|
217
|
+
<td>{{ row.nickname }}</td>
|
|
218
|
+
<td>{{ row.email }}</td>
|
|
219
|
+
<td>{{ row.phone }}</td>
|
|
220
|
+
<td>
|
|
221
|
+
<Tag v-for="role in row.roles" :key="role" size="small">{{ role }}</Tag>
|
|
222
|
+
</td>
|
|
223
|
+
<td>
|
|
224
|
+
<Switch
|
|
225
|
+
:model-value="row.status === Status.ENABLED"
|
|
226
|
+
@update:model-value="row.status = $event ? Status.ENABLED : Status.DISABLED; handleStatusChange(row)"
|
|
227
|
+
/>
|
|
228
|
+
</td>
|
|
229
|
+
<td>{{ row.createTime }}</td>
|
|
230
|
+
<td>
|
|
231
|
+
<Space>
|
|
232
|
+
<Button type="primary" link size="small" @click="handleEdit(row)">编辑</Button>
|
|
233
|
+
<Popconfirm title="确定删除该用户吗?" @confirm="handleDelete(row.id)">
|
|
234
|
+
<Button type="danger" link size="small">删除</Button>
|
|
235
|
+
</Popconfirm>
|
|
236
|
+
</Space>
|
|
237
|
+
</td>
|
|
238
|
+
</tr>
|
|
239
|
+
</tbody>
|
|
240
|
+
</table>
|
|
241
|
+
|
|
242
|
+
<!-- 分页 -->
|
|
243
|
+
<div class="pagination-wrapper">
|
|
244
|
+
<Pagination
|
|
245
|
+
v-model:current-page="currentPage"
|
|
246
|
+
v-model:page-size="pageSize"
|
|
247
|
+
:total="total"
|
|
248
|
+
:page-sizes="[10, 20, 50, 100]"
|
|
249
|
+
layout="total, sizes, prev, pager, next"
|
|
250
|
+
@current-change="getUserList"
|
|
251
|
+
@size-change="getUserList"
|
|
252
|
+
/>
|
|
253
|
+
</div>
|
|
254
|
+
</Card>
|
|
255
|
+
|
|
256
|
+
<!-- 编辑弹窗 -->
|
|
257
|
+
<Modal v-model="modalVisible" :title="modalTitle" width="500px">
|
|
258
|
+
<Form ref="formRef" :model="formData" :rules="rules" label-width="80px">
|
|
259
|
+
<FormItem label="用户名" prop="username">
|
|
260
|
+
<Input v-model="formData.username" placeholder="请输入用户名" />
|
|
261
|
+
</FormItem>
|
|
262
|
+
<FormItem label="昵称" prop="nickname">
|
|
263
|
+
<Input v-model="formData.nickname" placeholder="请输入昵称" />
|
|
264
|
+
</FormItem>
|
|
265
|
+
<FormItem label="邮箱" prop="email">
|
|
266
|
+
<Input v-model="formData.email" placeholder="请输入邮箱" />
|
|
267
|
+
</FormItem>
|
|
268
|
+
<FormItem label="手机号" prop="phone">
|
|
269
|
+
<Input v-model="formData.phone" placeholder="请输入手机号" />
|
|
270
|
+
</FormItem>
|
|
271
|
+
<FormItem label="状态">
|
|
272
|
+
<Switch v-model="formData.status" :active-value="Status.ENABLED" :inactive-value="Status.DISABLED" />
|
|
273
|
+
</FormItem>
|
|
274
|
+
</Form>
|
|
275
|
+
<template #footer>
|
|
276
|
+
<Space>
|
|
277
|
+
<Button @click="modalVisible = false">取消</Button>
|
|
278
|
+
<Button type="primary" @click="handleSubmit">确定</Button>
|
|
279
|
+
</Space>
|
|
280
|
+
</template>
|
|
281
|
+
</Modal>
|
|
282
|
+
</div>
|
|
283
|
+
</template>
|
|
284
|
+
|
|
285
|
+
<style lang="scss" scoped>
|
|
286
|
+
.user-page {
|
|
287
|
+
padding: 20px;
|
|
288
|
+
|
|
289
|
+
.search-card {
|
|
290
|
+
margin-bottom: 20px;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.toolbar {
|
|
294
|
+
margin-bottom: 15px;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.data-table {
|
|
299
|
+
width: 100%;
|
|
300
|
+
border-collapse: collapse;
|
|
301
|
+
|
|
302
|
+
th, td {
|
|
303
|
+
padding: 12px;
|
|
304
|
+
text-align: left;
|
|
305
|
+
border-bottom: 1px solid var(--color-border-lighter);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
th {
|
|
309
|
+
font-weight: 500;
|
|
310
|
+
color: var(--color-text-regular);
|
|
311
|
+
background-color: var(--color-fill-light);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.loading-cell,
|
|
315
|
+
.empty-cell {
|
|
316
|
+
text-align: center;
|
|
317
|
+
color: var(--color-text-secondary);
|
|
318
|
+
padding: 40px;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.pagination-wrapper {
|
|
323
|
+
display: flex;
|
|
324
|
+
justify-content: flex-end;
|
|
325
|
+
margin-top: 20px;
|
|
326
|
+
}
|
|
327
|
+
</style>
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"moduleResolution": "bundler",
|
|
9
|
+
"allowImportingTsExtensions": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"jsx": "preserve",
|
|
14
|
+
"strict": true,
|
|
15
|
+
"noUnusedLocals": true,
|
|
16
|
+
"noUnusedParameters": true,
|
|
17
|
+
"noFallthroughCasesInSwitch": true,
|
|
18
|
+
"baseUrl": ".",
|
|
19
|
+
"paths": {
|
|
20
|
+
"@/*": ["src/*"]
|
|
21
|
+
},
|
|
22
|
+
"types": ["vite/client", "node"]
|
|
23
|
+
},
|
|
24
|
+
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
|
|
25
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
|
26
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { defineConfig, loadEnv } from 'vite'
|
|
2
|
+
import vue from '@vitejs/plugin-vue'
|
|
3
|
+
import dts from 'vite-plugin-dts'
|
|
4
|
+
import { resolve } from 'path'
|
|
5
|
+
|
|
6
|
+
export default defineConfig(({ mode }) => {
|
|
7
|
+
const env = loadEnv(mode, process.cwd())
|
|
8
|
+
const isLib = mode === 'lib'
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
plugins: [
|
|
12
|
+
vue(),
|
|
13
|
+
...(isLib ? [dts({ insertTypesEntry: true, outDir: 'dist' })] : [])
|
|
14
|
+
],
|
|
15
|
+
resolve: {
|
|
16
|
+
alias: {
|
|
17
|
+
'@': resolve(__dirname, 'src'),
|
|
18
|
+
'@xto/core': resolve(__dirname, 'node_modules/@xto/core/es/index/index.mjs'),
|
|
19
|
+
'@xto/core/theme': resolve(__dirname, 'node_modules/@xto/core/es/theme/index.mjs'),
|
|
20
|
+
'@xto/core/hooks': resolve(__dirname, 'node_modules/@xto/core/es/hooks/index.mjs'),
|
|
21
|
+
'@xto/core/utils': resolve(__dirname, 'node_modules/@xto/core/es/utils/index.mjs'),
|
|
22
|
+
'@xto/base/es/style.css': resolve(__dirname, 'node_modules/@xto/base/es/style.css'),
|
|
23
|
+
'@xto/form/es/style.css': resolve(__dirname, 'node_modules/@xto/form/es/style.css'),
|
|
24
|
+
'@xto/data/es/style.css': resolve(__dirname, 'node_modules/@xto/data/es/style.css'),
|
|
25
|
+
'@xto/feedback/es/style.css': resolve(__dirname, 'node_modules/@xto/feedback/es/style.css'),
|
|
26
|
+
'@xto/navigation/es/style.css': resolve(__dirname, 'node_modules/@xto/navigation/es/style.css'),
|
|
27
|
+
'@xto/layout/es/style.css': resolve(__dirname, 'node_modules/@xto/layout/es/style.css'),
|
|
28
|
+
'@xto/business/es/style.css': resolve(__dirname, 'node_modules/@xto/business/es/style.css'),
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
// 开发模式优化
|
|
32
|
+
optimizeDeps: {
|
|
33
|
+
include: [
|
|
34
|
+
'vue',
|
|
35
|
+
'vue-router',
|
|
36
|
+
'pinia',
|
|
37
|
+
'axios'
|
|
38
|
+
],
|
|
39
|
+
exclude: [
|
|
40
|
+
'@xto/core',
|
|
41
|
+
'@xto/base',
|
|
42
|
+
'@xto/form',
|
|
43
|
+
'@xto/data',
|
|
44
|
+
'@xto/feedback',
|
|
45
|
+
'@xto/navigation',
|
|
46
|
+
'@xto/layout',
|
|
47
|
+
'@xto/business'
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
server: {
|
|
51
|
+
host: '0.0.0.0',
|
|
52
|
+
port: 3000,
|
|
53
|
+
open: true,
|
|
54
|
+
proxy: {
|
|
55
|
+
'/api': {
|
|
56
|
+
target: env.VITE_API_BASE_URL || 'http://localhost:8080',
|
|
57
|
+
changeOrigin: true,
|
|
58
|
+
rewrite: (path) => path.replace(/^\/api/, '')
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
build: {
|
|
63
|
+
outDir: 'dist',
|
|
64
|
+
sourcemap: false,
|
|
65
|
+
chunkSizeWarningLimit: 1500,
|
|
66
|
+
// 库模式配置
|
|
67
|
+
lib: isLib ? {
|
|
68
|
+
entry: resolve(__dirname, 'src/index.ts'),
|
|
69
|
+
name: 'XtoFronted',
|
|
70
|
+
fileName: (format: string) => `index.${format === 'es' ? 'es.js' : 'umd.js'}`,
|
|
71
|
+
formats: ['es', 'umd']
|
|
72
|
+
} : undefined,
|
|
73
|
+
rollupOptions: {
|
|
74
|
+
// 库模式下排除外部依赖
|
|
75
|
+
external: isLib ? [
|
|
76
|
+
'vue',
|
|
77
|
+
'vue-router',
|
|
78
|
+
'pinia',
|
|
79
|
+
'axios',
|
|
80
|
+
/^@xto\//
|
|
81
|
+
] : undefined,
|
|
82
|
+
output: isLib ? {
|
|
83
|
+
globals: {
|
|
84
|
+
vue: 'Vue',
|
|
85
|
+
'vue-router': 'VueRouter',
|
|
86
|
+
pinia: 'Pinia',
|
|
87
|
+
axios: 'axios'
|
|
88
|
+
},
|
|
89
|
+
exports: 'named'
|
|
90
|
+
} : {
|
|
91
|
+
manualChunks(id) {
|
|
92
|
+
// Vue 全家桶单独打包
|
|
93
|
+
if (id.includes('node_modules/vue/') ||
|
|
94
|
+
id.includes('node_modules/@vue/') ||
|
|
95
|
+
id.includes('node_modules/vue-router/') ||
|
|
96
|
+
id.includes('node_modules/pinia/')) {
|
|
97
|
+
return 'vue-vendor'
|
|
98
|
+
}
|
|
99
|
+
// 组件库按包分割,实现按需加载
|
|
100
|
+
if (id.includes('@xto/core')) {
|
|
101
|
+
return 'xto-core'
|
|
102
|
+
}
|
|
103
|
+
if (id.includes('@xto/base')) {
|
|
104
|
+
return 'xto-base'
|
|
105
|
+
}
|
|
106
|
+
if (id.includes('@xto/form')) {
|
|
107
|
+
return 'xto-form'
|
|
108
|
+
}
|
|
109
|
+
if (id.includes('@xto/data')) {
|
|
110
|
+
return 'xto-data'
|
|
111
|
+
}
|
|
112
|
+
if (id.includes('@xto/feedback')) {
|
|
113
|
+
return 'xto-feedback'
|
|
114
|
+
}
|
|
115
|
+
if (id.includes('@xto/navigation')) {
|
|
116
|
+
return 'xto-navigation'
|
|
117
|
+
}
|
|
118
|
+
if (id.includes('@xto/layout')) {
|
|
119
|
+
return 'xto-layout'
|
|
120
|
+
}
|
|
121
|
+
if (id.includes('@xto/business')) {
|
|
122
|
+
return 'xto-business'
|
|
123
|
+
}
|
|
124
|
+
// 其他第三方库
|
|
125
|
+
if (id.includes('node_modules/')) {
|
|
126
|
+
return 'vendor'
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
css: {
|
|
133
|
+
preprocessorOptions: {
|
|
134
|
+
scss: {
|
|
135
|
+
api: 'modern-compiler'
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
})
|
package/dist/api/menu.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
-
logo?: string;
|
|
3
|
-
title?: string;
|
|
4
|
-
subtitle?: string;
|
|
5
|
-
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
6
|
-
success: (data: any) => void;
|
|
7
|
-
error: (error: any) => void;
|
|
8
|
-
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
9
|
-
logo?: string;
|
|
10
|
-
title?: string;
|
|
11
|
-
subtitle?: string;
|
|
12
|
-
}>>> & Readonly<{
|
|
13
|
-
onError?: ((error: any) => any) | undefined;
|
|
14
|
-
onSuccess?: ((data: any) => any) | undefined;
|
|
15
|
-
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
16
|
-
export default _default;
|
|
17
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
18
|
-
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
19
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
20
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
21
|
-
} : {
|
|
22
|
-
type: import('vue').PropType<T[K]>;
|
|
23
|
-
required: true;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
-
visible: boolean;
|
|
3
|
-
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
4
|
-
"update:visible": (val: boolean) => void;
|
|
5
|
-
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
6
|
-
visible: boolean;
|
|
7
|
-
}>>> & Readonly<{
|
|
8
|
-
"onUpdate:visible"?: ((val: boolean) => any) | undefined;
|
|
9
|
-
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
10
|
-
export default _default;
|
|
11
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
12
|
-
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
13
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
14
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
15
|
-
} : {
|
|
16
|
-
type: import('vue').PropType<T[K]>;
|
|
17
|
-
required: true;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { UserInfo, LoginResult } from '../types/api';
|
|
2
|
-
|
|
3
|
-
export declare function useApp(): {
|
|
4
|
-
loading: import('vue').Ref<boolean, boolean>;
|
|
5
|
-
isLoggedIn: import('vue').ComputedRef<boolean>;
|
|
6
|
-
userInfo: import('vue').ComputedRef<{
|
|
7
|
-
uId: string;
|
|
8
|
-
appId: string;
|
|
9
|
-
userId: string;
|
|
10
|
-
userName: string;
|
|
11
|
-
departmentName?: string | undefined;
|
|
12
|
-
email?: string | undefined;
|
|
13
|
-
mobilePhone?: string | undefined;
|
|
14
|
-
positionName?: string | undefined;
|
|
15
|
-
avatar?: string | undefined;
|
|
16
|
-
workNo?: string | undefined;
|
|
17
|
-
} | null>;
|
|
18
|
-
userName: import('vue').ComputedRef<string>;
|
|
19
|
-
menuList: import('vue').ComputedRef<{
|
|
20
|
-
code: string;
|
|
21
|
-
name: string;
|
|
22
|
-
path: string;
|
|
23
|
-
component?: string | undefined;
|
|
24
|
-
redirect?: string | undefined;
|
|
25
|
-
icon?: string | undefined;
|
|
26
|
-
title: string;
|
|
27
|
-
hidden?: boolean | undefined;
|
|
28
|
-
keepAlive?: boolean | undefined;
|
|
29
|
-
affix?: boolean | undefined;
|
|
30
|
-
default?: boolean | undefined;
|
|
31
|
-
out?: boolean | undefined;
|
|
32
|
-
closable?: boolean | undefined;
|
|
33
|
-
children?: /*elided*/ any[] | undefined;
|
|
34
|
-
}[]>;
|
|
35
|
-
indexPath: import('vue').ComputedRef<string>;
|
|
36
|
-
login: (uid: string, password: string) => Promise<{
|
|
37
|
-
success: boolean;
|
|
38
|
-
data: LoginResult;
|
|
39
|
-
error?: undefined;
|
|
40
|
-
} | {
|
|
41
|
-
success: boolean;
|
|
42
|
-
error: any;
|
|
43
|
-
data?: undefined;
|
|
44
|
-
}>;
|
|
45
|
-
logout: (showMessage?: boolean) => Promise<void>;
|
|
46
|
-
loadUserInfo: () => Promise<UserInfo>;
|
|
47
|
-
loadMenu: () => Promise<{
|
|
48
|
-
code: string;
|
|
49
|
-
name: string;
|
|
50
|
-
path: string;
|
|
51
|
-
component?: string | undefined;
|
|
52
|
-
redirect?: string | undefined;
|
|
53
|
-
icon?: string | undefined;
|
|
54
|
-
title: string;
|
|
55
|
-
hidden?: boolean | undefined;
|
|
56
|
-
keepAlive?: boolean | undefined;
|
|
57
|
-
affix?: boolean | undefined;
|
|
58
|
-
default?: boolean | undefined;
|
|
59
|
-
out?: boolean | undefined;
|
|
60
|
-
closable?: boolean | undefined;
|
|
61
|
-
children?: /*elided*/ any[] | undefined;
|
|
62
|
-
}[]>;
|
|
63
|
-
initApp: () => Promise<boolean>;
|
|
64
|
-
clearAllState: () => void;
|
|
65
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { MenuItem } from '../types/api';
|
|
2
|
-
|
|
3
|
-
export declare function useMenu(): {
|
|
4
|
-
searchKeyword: import('vue').Ref<string, string>;
|
|
5
|
-
activeMenu: import('vue').ComputedRef<string>;
|
|
6
|
-
isCollapsed: import('vue').ComputedRef<boolean>;
|
|
7
|
-
menuList: import('vue').ComputedRef<{
|
|
8
|
-
code: string;
|
|
9
|
-
name: string;
|
|
10
|
-
path: string;
|
|
11
|
-
component?: string | undefined;
|
|
12
|
-
redirect?: string | undefined;
|
|
13
|
-
icon?: string | undefined;
|
|
14
|
-
title: string;
|
|
15
|
-
hidden?: boolean | undefined;
|
|
16
|
-
keepAlive?: boolean | undefined;
|
|
17
|
-
affix?: boolean | undefined;
|
|
18
|
-
default?: boolean | undefined;
|
|
19
|
-
out?: boolean | undefined;
|
|
20
|
-
closable?: boolean | undefined;
|
|
21
|
-
children?: /*elided*/ any[] | undefined;
|
|
22
|
-
}[]>;
|
|
23
|
-
hasMenu: import('vue').ComputedRef<boolean>;
|
|
24
|
-
searchResults: import('vue').ComputedRef<(MenuItem & {
|
|
25
|
-
parentTitle: string;
|
|
26
|
-
})[]>;
|
|
27
|
-
filteredMenuList: import('vue').ComputedRef<MenuItem[]>;
|
|
28
|
-
flattenMenus: (menus: MenuItem[], parentTitle?: string) => (MenuItem & {
|
|
29
|
-
parentTitle: string;
|
|
30
|
-
})[];
|
|
31
|
-
handleMenuSelect: (index: string) => void;
|
|
32
|
-
handleSearchItemClick: (path: string) => void;
|
|
33
|
-
clearSearch: () => void;
|
|
34
|
-
};
|