yuang-framework-ui-common 1.0.47 → 1.0.49
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/lib/config/httpConfig.ts +4 -2
- package/lib/utils/messageBoxUtils.ts +1 -1
- package/package.json +1 -1
- package/src/router/index.ts +17 -6
- package/src/views/config/gateway-config.vue +1 -4
- package/src/views/sso/auth/auth-success.vue +47 -0
- package/src/views/utils/gateway-utils.vue +21 -0
- package/src/views/utils/message-utils.vue +1 -0
package/lib/config/httpConfig.ts
CHANGED
@@ -48,6 +48,7 @@ http.interceptors.response.use(async (res: any) => {
|
|
48
48
|
showErrorMessage(messageMap.responseSturctError);
|
49
49
|
return Promise.reject(new Error(messageMap.responseSturctError));
|
50
50
|
}
|
51
|
+
debugger
|
51
52
|
if (res?.data?.statusCode !== 200) {
|
52
53
|
// 登录过期处理
|
53
54
|
if (res?.data?.statusCode === 401) {
|
@@ -65,8 +66,9 @@ http.interceptors.response.use(async (res: any) => {
|
|
65
66
|
return Promise.reject(new Error(res?.data?.message));
|
66
67
|
} else if (res?.data?.statusCode === 500822001) {
|
67
68
|
clearGatewayConfig();
|
68
|
-
|
69
|
-
|
69
|
+
await initGatewayConfig();
|
70
|
+
// 重发请求
|
71
|
+
return axios.request(res.config);
|
70
72
|
} else if (res?.data?.statusCode === 500815001) {
|
71
73
|
showErrorMessage(res?.data?.message || messageMap.requestError);
|
72
74
|
clearSsoAccessToken();
|
@@ -4,7 +4,7 @@ import { ElMessageBox } from 'element-plus/es';
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
const alertMessageBox = ({title, message, confirmButtonText, callback}: {title: string, message: string, confirmButtonText: string, callback: (param:string)=>
|
7
|
+
const alertMessageBox = ({title, message, confirmButtonText, callback}: {title: string, message: string, confirmButtonText: string, callback: (param:string) => void}) => {
|
8
8
|
if(isPc()) {
|
9
9
|
ElMessageBox.close();
|
10
10
|
ElMessageBox.alert(message, title, {
|
package/package.json
CHANGED
package/src/router/index.ts
CHANGED
@@ -12,17 +12,23 @@ const router = createRouter({
|
|
12
12
|
component: () => import('@/views/sso/auth/index.vue'),
|
13
13
|
meta: {
|
14
14
|
title: '认证',
|
15
|
-
|
15
|
+
isSsoExcluded: true
|
16
|
+
}
|
17
|
+
},
|
18
|
+
{
|
19
|
+
path: '/sso/auth/auth-success',
|
20
|
+
component: () => import('@/views/sso/auth/auth-success.vue'),
|
21
|
+
meta: {
|
22
|
+
title: '认证成功',
|
16
23
|
}
|
17
24
|
},
|
18
25
|
{
|
19
26
|
path: '/config/gateway-config',
|
20
27
|
component: () => import('@/views/config/gateway-config.vue')
|
21
28
|
},
|
22
|
-
|
23
29
|
{
|
24
30
|
path: '/utils/aes-utils',
|
25
|
-
component: () => import('@/views/utils/aes-utils.vue')
|
31
|
+
component: () => import('@/views/utils/aes-utils.vue'),
|
26
32
|
},
|
27
33
|
{
|
28
34
|
path: '/utils/rsa-utils',
|
@@ -36,8 +42,13 @@ const router = createRouter({
|
|
36
42
|
path: '/utils/message-utils',
|
37
43
|
component: () => import('@/views/utils/message-utils.vue')
|
38
44
|
},
|
39
|
-
|
40
|
-
|
45
|
+
{
|
46
|
+
path: '/utils/gateway-utils',
|
47
|
+
component: () => import('@/views/utils/gateway-utils.vue'),
|
48
|
+
meta: {
|
49
|
+
isSsoExcluded: true
|
50
|
+
}
|
51
|
+
},
|
41
52
|
|
42
53
|
{
|
43
54
|
path: '/example/table/index',
|
@@ -52,7 +63,7 @@ const router = createRouter({
|
|
52
63
|
/* 路由守卫 */
|
53
64
|
router.beforeEach(async (to) => {
|
54
65
|
if (!getSsoAccessToken()) {
|
55
|
-
if (!to.meta?.
|
66
|
+
if (!to.meta?.isSsoExcluded) {
|
56
67
|
return getSsoAuthRoutePath(to.fullPath);
|
57
68
|
}
|
58
69
|
return;
|
@@ -3,14 +3,11 @@
|
|
3
3
|
</template>
|
4
4
|
|
5
5
|
<script setup lang="ts">
|
6
|
-
import { onMounted
|
7
|
-
const { proxy } = getCurrentInstance() as any;
|
6
|
+
import { onMounted } from 'vue';
|
8
7
|
|
9
8
|
|
10
9
|
onMounted(() => {
|
11
|
-
proxy.$http.get('/sso-api/standard/framework-captcha/getCaptcha', { params: {} }).then((res: any) => {
|
12
10
|
|
13
|
-
});
|
14
11
|
})
|
15
12
|
</script>
|
16
13
|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<template>
|
2
|
+
<h1>认证成功! {{ ssoData?.ssoTokenUser?.account }}</h1>
|
3
|
+
|
4
|
+
<h3 @click="getSsoTokenUser">获取ssoTokenUser</h3>
|
5
|
+
<h3 @click="getSsoIdentity">获取SsoIdentity</h3>
|
6
|
+
|
7
|
+
<a @click="logout">注销登录</a>
|
8
|
+
</template>
|
9
|
+
|
10
|
+
<script setup lang="ts">
|
11
|
+
import { onMounted, reactive } from 'vue';
|
12
|
+
import { ElMessage } from 'element-plus/es';
|
13
|
+
|
14
|
+
import { getSsoAccessToken, logoutSso } from '../../../../lib/utils/ssoUtils';
|
15
|
+
import { http } from '../../../../lib/config/httpConfig';
|
16
|
+
|
17
|
+
let ssoData = reactive({
|
18
|
+
ssoTokenUser: {},
|
19
|
+
ssoIdentity: {}
|
20
|
+
});
|
21
|
+
|
22
|
+
onMounted(() => {
|
23
|
+
let ssoAccessToken = getSsoAccessToken();
|
24
|
+
console.log('ssoAccessToken', ssoAccessToken);
|
25
|
+
getSsoTokenUser();
|
26
|
+
});
|
27
|
+
const getSsoTokenUser = () => {
|
28
|
+
http.get('/sso-api/client/sso-user/getSsoTokenUser').then((res: any) => {
|
29
|
+
ssoData.ssoTokenUser = res.data.data;
|
30
|
+
console.log('ssoTokenUser', ssoData.ssoTokenUser);
|
31
|
+
ElMessage.success('获取成功');
|
32
|
+
});
|
33
|
+
};
|
34
|
+
const getSsoIdentity = () => {
|
35
|
+
http.get('/sso-api/client/sso-user/getSsoIdentity', { params: { ssoClientAccount: 'yuang-sso' } }).then((res: any) => {
|
36
|
+
ssoData.ssoIdentity = res.data.data;
|
37
|
+
console.log('ssoIdentity', ssoData.ssoIdentity);
|
38
|
+
ElMessage.success('获取成功');
|
39
|
+
});
|
40
|
+
};
|
41
|
+
|
42
|
+
const logout = () => {
|
43
|
+
logoutSso();
|
44
|
+
};
|
45
|
+
</script>
|
46
|
+
|
47
|
+
<style scoped></style>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<template>
|
2
|
+
<div>
|
3
|
+
<el-button @click="sendRequest">发送请求</el-button>
|
4
|
+
</div>
|
5
|
+
</template>
|
6
|
+
|
7
|
+
<script setup lang="ts">
|
8
|
+
import { http } from "../../../lib/config/httpConfig";
|
9
|
+
import { ElMessage } from 'element-plus/es';
|
10
|
+
|
11
|
+
const sendRequest = () => {
|
12
|
+
// 测试
|
13
|
+
http.get("/sso-api/standard/framework-captcha/getSliderCaptcha", { params: {} }).then((res) => {
|
14
|
+
ElMessage.success('发送成功');
|
15
|
+
});
|
16
|
+
}
|
17
|
+
</script>
|
18
|
+
|
19
|
+
<style scoped>
|
20
|
+
|
21
|
+
</style>
|