xto-fronted 0.4.1 → 0.4.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.
- package/dist/api/system.d.ts +1 -1
- package/dist/composables/useApp.d.ts +7 -10
- package/dist/composables/useAuth.d.ts +0 -3
- package/dist/index-C6Nm0r9k.js +475 -0
- package/dist/index-C6w0-8xN.js +1648 -0
- package/dist/index-D2fQ8TK8.js +475 -0
- package/dist/index-D4crnrO6.js +142 -0
- package/dist/index-DFXuyPge.js +1627 -0
- package/dist/index-Do1CBqg8.js +345 -0
- package/dist/index-Jb4VMHIS.js +142 -0
- package/dist/index-TrLCW5xL.js +372 -0
- package/dist/index-a_ilWAvi.js +345 -0
- package/dist/index-sRwZYbZ4.js +372 -0
- package/dist/index.es.js +66 -60
- package/dist/index.umd.js +1 -1
- package/dist/router/dynamicRoutes.d.ts +18 -22
- package/dist/router/guards.d.ts +1 -0
- package/dist/stores/auth.d.ts +5 -19
- package/dist/stores/menu.d.ts +43 -74
- package/dist/stores/user.d.ts +63 -84
- package/dist/style.css +1 -1
- package/dist/utils/auth.d.ts +12 -3
- package/dist/utils/permission.d.ts +5 -4
- package/package.json +1 -1
- package/src/api/auth.ts +4 -4
- package/src/api/system.ts +5 -4
- package/src/components/Layout/Header.vue +5 -5
- package/src/components/Layout/Sidebar.vue +18 -12
- package/src/composables/useApp.ts +1 -1
- package/src/composables/useAuth.ts +0 -28
- package/src/directives/permission.ts +6 -16
- package/src/router/dynamicRoutes.ts +31 -31
- package/src/router/guards.ts +6 -10
- package/src/router/index.ts +7 -9
- package/src/stores/auth.ts +4 -4
- package/src/stores/menu.ts +19 -50
- package/src/stores/user.ts +18 -40
- package/src/types/api.d.ts +28 -31
- package/src/utils/auth.ts +45 -7
- package/src/utils/permission.ts +10 -19
- package/src/utils/request.ts +4 -3
- package/src/views/login/index.vue +11 -8
package/src/utils/request.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios'
|
|
6
|
-
import { getToken, clearToken } from './auth'
|
|
6
|
+
import { getToken, getTokenType, clearToken } from './auth'
|
|
7
7
|
import { Message } from '@xto/feedback'
|
|
8
8
|
|
|
9
9
|
// 响应数据接口(Euler 框架 Result 格式)
|
|
@@ -39,8 +39,9 @@ const createRequest = (): AxiosInstance => {
|
|
|
39
39
|
instance.interceptors.request.use(
|
|
40
40
|
(config: InternalAxiosRequestConfig) => {
|
|
41
41
|
const token = getToken()
|
|
42
|
+
const tokenType = getTokenType() || 'Bearer'
|
|
42
43
|
if (token) {
|
|
43
|
-
config.headers.Authorization =
|
|
44
|
+
config.headers.Authorization = `${tokenType} ${token}`
|
|
44
45
|
}
|
|
45
46
|
return config
|
|
46
47
|
},
|
|
@@ -54,7 +55,7 @@ const createRequest = (): AxiosInstance => {
|
|
|
54
55
|
(response: AxiosResponse<ApiResponse>) => {
|
|
55
56
|
const { data } = response
|
|
56
57
|
|
|
57
|
-
// Euler 框架返回 Result 包装格式,成功时直接返回 data 中的实际数据
|
|
58
|
+
// Euler 框架返回 Result 包装格式,成功时直接返回 data.data 中的实际数据
|
|
58
59
|
if (data.code === 200 || data.code === 0) {
|
|
59
60
|
return data.data as any
|
|
60
61
|
}
|
|
@@ -14,12 +14,12 @@ const loading = ref(false)
|
|
|
14
14
|
const rememberMe = ref(false)
|
|
15
15
|
|
|
16
16
|
const formData = reactive({
|
|
17
|
-
|
|
18
|
-
password: '
|
|
17
|
+
uid: '',
|
|
18
|
+
password: ''
|
|
19
19
|
})
|
|
20
20
|
|
|
21
21
|
const rules: Record<string, any[]> = {
|
|
22
|
-
|
|
22
|
+
uid: [
|
|
23
23
|
{ required: true, message: '请输入用户名', trigger: 'blur' }
|
|
24
24
|
],
|
|
25
25
|
password: [
|
|
@@ -38,8 +38,11 @@ const handleLogin = async () => {
|
|
|
38
38
|
|
|
39
39
|
// 调用登录 API
|
|
40
40
|
const result = await login({
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
appId: import.meta.env.VITE_APP_ID,
|
|
42
|
+
clientId: import.meta.env.VITE_APP_CLIENT_ID,
|
|
43
|
+
uid: formData.uid,
|
|
44
|
+
password: formData.password,
|
|
45
|
+
code: true
|
|
43
46
|
})
|
|
44
47
|
|
|
45
48
|
// 保存 token
|
|
@@ -76,9 +79,9 @@ const handleLogin = async () => {
|
|
|
76
79
|
class="login__form"
|
|
77
80
|
label-width="0"
|
|
78
81
|
>
|
|
79
|
-
<FormItem prop="
|
|
82
|
+
<FormItem prop="uid">
|
|
80
83
|
<Input
|
|
81
|
-
v-model="formData.
|
|
84
|
+
v-model="formData.uid"
|
|
82
85
|
placeholder="用户名"
|
|
83
86
|
prefix-icon="👤"
|
|
84
87
|
size="large"
|
|
@@ -115,7 +118,7 @@ const handleLogin = async () => {
|
|
|
115
118
|
</Form>
|
|
116
119
|
|
|
117
120
|
<div class="login__footer">
|
|
118
|
-
<p
|
|
121
|
+
<p>请输入您的用户名和密码</p>
|
|
119
122
|
</div>
|
|
120
123
|
</div>
|
|
121
124
|
</div>
|