xto-fronted 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/.env.development +3 -4
  2. package/.env.production +3 -4
  3. package/bin/cli.js +104 -0
  4. package/dist/{403-MQkNUulz.js → 403-DM5wfQkM.js} +6 -6
  5. package/dist/{404-BOFYLq4X.js → 404-BurAu5LC.js} +7 -7
  6. package/dist/api/auth.d.ts +9 -8
  7. package/dist/api/menu.d.ts +3 -0
  8. package/dist/api/user.d.ts +2 -12
  9. package/dist/composables/index.d.ts +8 -0
  10. package/dist/composables/useApp.d.ts +64 -0
  11. package/dist/composables/useAuth.d.ts +19 -4
  12. package/dist/composables/useMenu.d.ts +34 -0
  13. package/dist/config/index.d.ts +11 -0
  14. package/dist/index-BNiEld34.js +15 -0
  15. package/dist/index-Be9RiEfo.js +98 -0
  16. package/dist/index-BqRv1bdN.js +1185 -0
  17. package/dist/index-CQLVXvNJ.js +15 -0
  18. package/dist/index-CyiE8n2V.js +15 -0
  19. package/dist/index-xauR1bOL.js +15 -0
  20. package/dist/index.d.ts +7 -4
  21. package/dist/index.es.js +50 -66
  22. package/dist/index.umd.js +1 -1
  23. package/dist/stores/auth.d.ts +60 -23
  24. package/dist/stores/menu.d.ts +40 -29
  25. package/dist/stores/user.d.ts +63 -84
  26. package/dist/style.css +1 -1
  27. package/dist/utils/auth.d.ts +15 -7
  28. package/dist/utils/permission.d.ts +1 -6
  29. package/dist/views/system/menu/index.vue.d.ts +1 -3
  30. package/dist/views/system/role/index.vue.d.ts +1 -3
  31. package/dist/views/system/user/index.vue.d.ts +1 -3
  32. package/package.json +27 -19
  33. package/src/api/auth.ts +34 -25
  34. package/src/api/menu.ts +13 -0
  35. package/src/api/user.ts +11 -45
  36. package/src/components/Layout/Header.vue +334 -389
  37. package/src/components/Layout/Sidebar.vue +212 -296
  38. package/src/components/Layout/Tabs.vue +19 -133
  39. package/src/composables/index.ts +9 -0
  40. package/src/composables/useApp.ts +170 -0
  41. package/src/composables/useAuth.ts +69 -44
  42. package/src/composables/useMenu.ts +141 -0
  43. package/src/config/index.ts +19 -0
  44. package/src/directives/permission.ts +40 -37
  45. package/src/index.ts +9 -4
  46. package/src/router/index.ts +70 -80
  47. package/src/stores/auth.ts +44 -31
  48. package/src/stores/menu.ts +157 -79
  49. package/src/stores/user.ts +40 -72
  50. package/src/types/api.d.ts +102 -83
  51. package/src/types/xto.d.ts +148 -148
  52. package/src/utils/auth.ts +85 -61
  53. package/src/utils/permission.ts +29 -41
  54. package/src/utils/request.ts +125 -125
  55. package/src/utils/storage.ts +10 -1
  56. package/src/views/dashboard/index.vue +31 -283
  57. package/src/views/login/index.vue +140 -247
  58. package/src/views/system/menu/index.vue +31 -380
  59. package/src/views/system/role/index.vue +31 -303
  60. package/src/views/system/user/index.vue +31 -326
  61. package/vite.config.ts +3 -3
  62. package/dist/index-BJxYdNPy.js +0 -475
  63. package/dist/index-BvnIIBR1.js +0 -142
  64. package/dist/index-CEvAq6KE.js +0 -372
  65. package/dist/index-DPkqej__.js +0 -345
  66. package/dist/index-pq9Z5K62.js +0 -184
  67. package/dist/index-vVfjShJR.js +0 -1183
@@ -1,248 +1,141 @@
1
- <script setup lang="ts">
2
- import { ref, reactive } from 'vue'
3
- import { useRouter } from 'vue-router'
4
- import { Button } from '@xto/base'
5
- import { Form, FormItem, Input, Checkbox } from '@xto/form'
6
- import { Message } from '@xto/feedback'
7
- import { useAuthStore } from '@/stores/auth'
8
- import { useUserStore } from '@/stores/user'
9
- import { useMenuStore } from '@/stores/menu'
10
-
11
- const router = useRouter()
12
- const authStore = useAuthStore()
13
- const userStore = useUserStore()
14
- const menuStore = useMenuStore()
15
-
16
- const loading = ref(false)
17
- const rememberMe = ref(false)
18
-
19
- const formData = reactive({
20
- username: 'admin',
21
- password: '123456'
22
- })
23
-
24
- const rules: Record<string, any[]> = {
25
- username: [
26
- { required: true, message: '请输入用户名', trigger: 'blur' }
27
- ],
28
- password: [
29
- { required: true, message: '请输入密码', trigger: 'blur' },
30
- { min: 6, message: '密码长度至少6位', trigger: 'blur' }
31
- ]
32
- }
33
-
34
- const formRef = ref()
35
-
36
- // 登录
37
- const handleLogin = async () => {
38
- try {
39
- await formRef.value?.validate()
40
- loading.value = true
41
-
42
- // Mock 登录
43
- setTimeout(() => {
44
- // 设置 token
45
- authStore.login({
46
- token: 'mock_token_' + Date.now(),
47
- refreshToken: 'mock_refresh_token',
48
- expireTime: Date.now() + 7 * 24 * 60 * 60 * 1000
49
- })
50
-
51
- // 设置用户信息
52
- userStore.setUserInfo({
53
- id: 1,
54
- username: formData.username,
55
- nickname: '管理员',
56
- avatar: '',
57
- email: 'admin@example.com',
58
- phone: '13800138000',
59
- status: 1,
60
- roles: ['admin'],
61
- permissions: ['*'],
62
- createTime: new Date().toISOString()
63
- })
64
-
65
- // 设置菜单
66
- menuStore.setMenuList([
67
- {
68
- id: 1,
69
- name: 'Dashboard',
70
- path: '/dashboard',
71
- component: 'dashboard/index',
72
- icon: 'dashboard',
73
- title: '仪表盘',
74
- keepAlive: true,
75
- affix: true
76
- },
77
- {
78
- id: 2,
79
- name: 'System',
80
- path: '/system',
81
- redirect: '/system/user',
82
- icon: 'setting',
83
- title: '系统管理',
84
- children: [
85
- {
86
- id: 21,
87
- name: 'SystemUser',
88
- path: '/system/user',
89
- component: 'system/user/index',
90
- icon: 'user',
91
- title: '用户管理',
92
- keepAlive: true
93
- },
94
- {
95
- id: 22,
96
- name: 'SystemRole',
97
- path: '/system/role',
98
- component: 'system/role/index',
99
- icon: 'role',
100
- title: '角色管理',
101
- keepAlive: true
102
- },
103
- {
104
- id: 23,
105
- name: 'SystemMenu',
106
- path: '/system/menu',
107
- component: 'system/menu/index',
108
- icon: 'menu',
109
- title: '菜单管理',
110
- keepAlive: true
111
- }
112
- ]
113
- }
114
- ])
115
-
116
- Message.success('登录成功')
117
- router.push('/')
118
- loading.value = false
119
- }, 1000)
120
- } catch (error) {
121
- loading.value = false
122
- }
123
- }
124
- </script>
125
-
126
- <template>
127
- <div class="login">
128
- <div class="login__container">
129
- <div class="login__header">
130
- <img src="/vite.svg" alt="Logo" class="login__logo" />
131
- <h1 class="login__title">Xto Demo</h1>
132
- <p class="login__subtitle">后台管理系统</p>
133
- </div>
134
-
135
- <Form
136
- ref="formRef"
137
- :model="formData"
138
- :rules="rules"
139
- class="login__form"
140
- label-width="0"
141
- >
142
- <FormItem prop="username">
143
- <Input
144
- v-model="formData.username"
145
- placeholder="用户名"
146
- prefix-icon="👤"
147
- size="large"
148
- />
149
- </FormItem>
150
-
151
- <FormItem prop="password">
152
- <Input
153
- v-model="formData.password"
154
- type="password"
155
- placeholder="密码"
156
- prefix-icon="🔒"
157
- size="large"
158
- show-password
159
- @keyup.enter="handleLogin"
160
- />
161
- </FormItem>
162
-
163
- <FormItem>
164
- <Checkbox v-model="rememberMe">记住我</Checkbox>
165
- </FormItem>
166
-
167
- <FormItem>
168
- <Button
169
- type="primary"
170
- size="large"
171
- :loading="loading"
172
- class="login__submit"
173
- @click="handleLogin"
174
- >
175
- 登录
176
- </Button>
177
- </FormItem>
178
- </Form>
179
-
180
- <div class="login__footer">
181
- <p>提示: 任意用户名密码即可登录 (Mock 模式)</p>
182
- </div>
183
- </div>
184
- </div>
185
- </template>
186
-
187
- <style lang="scss" scoped>
188
- .login {
189
- width: 100%;
190
- min-height: 100vh;
191
- display: flex;
192
- align-items: center;
193
- justify-content: flex-end;
194
- padding-right: 15%;
195
- background: linear-gradient(135deg, var(--color-primary-light-9) 0%, var(--color-primary-light-7) 100%);
196
-
197
- &__container {
198
- width: 400px;
199
- padding: 40px;
200
- background-color: var(--bg-color);
201
- border-radius: var(--border-radius-large);
202
- box-shadow: var(--box-shadow-dark);
203
- }
204
-
205
- &__header {
206
- text-align: center;
207
- margin-bottom: 30px;
208
- }
209
-
210
- &__logo {
211
- width: 60px;
212
- height: 60px;
213
- }
214
-
215
- &__title {
216
- font-size: 28px;
217
- font-weight: 600;
218
- color: var(--color-primary);
219
- margin: 15px 0 5px;
220
- }
221
-
222
- &__subtitle {
223
- font-size: 14px;
224
- color: var(--color-text-secondary);
225
- }
226
-
227
- &__form {
228
- :deep(.t-form-item) {
229
- margin-bottom: 20px;
230
- }
231
-
232
- :deep(.x-input__prefix) {
233
- margin-right: 8px;
234
- }
235
- }
236
-
237
- &__submit {
238
- width: 100%;
239
- }
240
-
241
- &__footer {
242
- text-align: center;
243
- margin-top: 20px;
244
- font-size: 12px;
245
- color: var(--color-text-placeholder);
246
- }
247
- }
1
+ <script setup lang="ts">
2
+ /**
3
+ * 登录页面
4
+ * 使用统一的 useApp hooks
5
+ */
6
+ import { ref, reactive } from 'vue'
7
+ import { Button } from '@xto/base'
8
+ import { Form, FormItem, Input } from '@xto/form'
9
+ import { useApp } from '@/composables'
10
+
11
+ const { login, loading } = useApp()
12
+
13
+ const formData = reactive({
14
+ uid: '',
15
+ password: ''
16
+ })
17
+
18
+ const rules: Record<string, any[]> = {
19
+ uid: [
20
+ { required: true, message: '请输入账号', trigger: 'blur' }
21
+ ],
22
+ password: [
23
+ { required: true, message: '请输入密码', trigger: 'blur' }
24
+ ]
25
+ }
26
+
27
+ const formRef = ref()
28
+
29
+ // 登录
30
+ const handleLogin = async () => {
31
+ try {
32
+ await formRef.value?.validate()
33
+ await login(formData.uid, formData.password)
34
+ } catch (error) {
35
+ console.error('登录失败', error)
36
+ }
37
+ }
38
+ </script>
39
+
40
+ <template>
41
+ <div class="login">
42
+ <div class="login__container">
43
+ <div class="login__header">
44
+ <img src="/vite.svg" alt="Logo" class="login__logo" />
45
+ <h1 class="login__title">Analysis Web</h1>
46
+ <p class="login__subtitle">后台管理系统</p>
47
+ </div>
48
+
49
+ <Form
50
+ ref="formRef"
51
+ :model="formData"
52
+ :rules="rules"
53
+ class="login__form"
54
+ label-width="0"
55
+ >
56
+ <FormItem prop="uid">
57
+ <Input
58
+ v-model="formData.uid"
59
+ placeholder="请输入账号"
60
+ size="large"
61
+ />
62
+ </FormItem>
63
+
64
+ <FormItem prop="password">
65
+ <Input
66
+ v-model="formData.password"
67
+ type="password"
68
+ placeholder="请输入密码"
69
+ size="large"
70
+ show-password
71
+ @keyup.enter="handleLogin"
72
+ />
73
+ </FormItem>
74
+
75
+ <FormItem>
76
+ <Button
77
+ type="primary"
78
+ size="large"
79
+ :loading="loading"
80
+ class="login__submit"
81
+ @click="handleLogin"
82
+ >
83
+ 登录
84
+ </Button>
85
+ </FormItem>
86
+ </Form>
87
+ </div>
88
+ </div>
89
+ </template>
90
+
91
+ <style lang="scss" scoped>
92
+ .login {
93
+ width: 100%;
94
+ min-height: 100vh;
95
+ display: flex;
96
+ align-items: center;
97
+ justify-content: flex-end;
98
+ padding-right: 15%;
99
+ background: linear-gradient(135deg, var(--color-primary-light-9) 0%, var(--color-primary-light-7) 100%);
100
+
101
+ &__container {
102
+ width: 400px;
103
+ padding: 40px;
104
+ background-color: var(--bg-color);
105
+ border-radius: var(--border-radius-large);
106
+ box-shadow: var(--box-shadow-dark);
107
+ }
108
+
109
+ &__header {
110
+ text-align: center;
111
+ margin-bottom: 30px;
112
+ }
113
+
114
+ &__logo {
115
+ width: 60px;
116
+ height: 60px;
117
+ }
118
+
119
+ &__title {
120
+ font-size: 28px;
121
+ font-weight: 600;
122
+ color: var(--color-primary);
123
+ margin: 15px 0 5px;
124
+ }
125
+
126
+ &__subtitle {
127
+ font-size: 14px;
128
+ color: var(--color-text-secondary);
129
+ }
130
+
131
+ &__form {
132
+ :deep(.t-form-item) {
133
+ margin-bottom: 20px;
134
+ }
135
+ }
136
+
137
+ &__submit {
138
+ width: 100%;
139
+ }
140
+ }
248
141
  </style>