yuang-framework-ui-common 1.0.54 → 1.0.55
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/applicationConfig.ts +3 -3
- package/lib/config/gatewayConfig.ts +1 -1
- package/lib/config/httpConfig.ts +2 -2
- package/lib/utils/ssoUtils.ts +12 -12
- package/package.json +1 -1
- package/src/main.ts +2 -2
- package/src/views/sso/auth/auth-success.vue +2 -2
- package/src/views/sso/auth/index.vue +1 -1
@@ -22,10 +22,10 @@ const initApplicationConfig = (app: any, applicationConfig: any) => {
|
|
22
22
|
} else {
|
23
23
|
app.use(vant);
|
24
24
|
}
|
25
|
-
if (applicationConfig?.
|
26
|
-
http.defaults.baseURL = applicationConfig?.
|
25
|
+
if (applicationConfig?.apiBaseUrl) {
|
26
|
+
http.defaults.baseURL = applicationConfig?.apiBaseUrl;
|
27
27
|
} else {
|
28
|
-
http.defaults.baseURL = applicationConfig?.
|
28
|
+
http.defaults.baseURL = applicationConfig?.gatewayServerBaseUrl;
|
29
29
|
}
|
30
30
|
(window as any).applicationConfig = Object.freeze(applicationConfig);
|
31
31
|
}
|
@@ -6,7 +6,7 @@ const initGatewayConfig = () => {
|
|
6
6
|
const applicationConfig = getApplicationConfig();
|
7
7
|
|
8
8
|
return new Promise<void>(async resolve => {
|
9
|
-
let res = await http.get(`${applicationConfig.
|
9
|
+
let res = await http.get(`${applicationConfig.gatewayServerBaseUrl}/server/gateway-config/getGatewayConfig`);
|
10
10
|
setLocalStorageItem("gatewayAccessToken", res.data.data.gatewayAccessToken, res.data.data.gatewayTimeout);
|
11
11
|
setLocalStorageItem("gatewayPublicKey", res.data.data.gatewayPublicKey, res.data.data.gatewayTimeout);
|
12
12
|
resolve();
|
package/lib/config/httpConfig.ts
CHANGED
@@ -33,7 +33,7 @@ http.interceptors.request.use(async config => {
|
|
33
33
|
const applicationConfig = getApplicationConfig();
|
34
34
|
|
35
35
|
let gatewayAccessToken = getLocalStorageItem("gatewayAccessToken") ?? '';
|
36
|
-
if (!gatewayAccessToken && config.url != `${applicationConfig.
|
36
|
+
if (!gatewayAccessToken && config.url != `${applicationConfig.gatewayServerBaseUrl}/server/gateway-config/getGatewayConfig`) {
|
37
37
|
await initGatewayConfig();
|
38
38
|
}
|
39
39
|
beforeRequestConfig(config);
|
@@ -170,7 +170,7 @@ const refreshSsoAccessToken = (res: any) => {
|
|
170
170
|
config.params = {
|
171
171
|
ssoRefreshToken: ssoRefreshToken,
|
172
172
|
}
|
173
|
-
axios.get(`${applicationConfig.
|
173
|
+
axios.get(`${applicationConfig.gatewayServerBaseUrl}/sso-api/client/sso-auth/getSsoRefreshToken`, config).then(res => {
|
174
174
|
if (res?.data?.statusCode !== 200) {
|
175
175
|
return reject();
|
176
176
|
}
|
package/lib/utils/ssoUtils.ts
CHANGED
@@ -9,14 +9,14 @@ import { getApplicationConfig } from "../config/applicationConfig";
|
|
9
9
|
const getSsoLoginUrl = (ssoRedirectUrl = '') => {
|
10
10
|
const applicationConfig = getApplicationConfig();
|
11
11
|
|
12
|
-
let
|
13
|
-
if (!
|
14
|
-
throw new Error('参数[
|
12
|
+
let gatewayServerBaseUrl = applicationConfig.gatewayServerBaseUrl;
|
13
|
+
if (!gatewayServerBaseUrl) {
|
14
|
+
throw new Error('参数[gatewayServerBaseUrl]为空');
|
15
15
|
}
|
16
|
-
if (!isFullUrl(
|
17
|
-
throw new Error('参数[
|
16
|
+
if (!isFullUrl(gatewayServerBaseUrl)) {
|
17
|
+
throw new Error('参数[gatewayServerBaseUrl]必须是完整路径');
|
18
18
|
}
|
19
|
-
let ssoLoginUrl = `${
|
19
|
+
let ssoLoginUrl = `${gatewayServerBaseUrl}/sso-api/server/sso/login`;
|
20
20
|
if (!ssoRedirectUrl) {
|
21
21
|
ssoLoginUrl += `?ssoRedirectUrl=${encodeURIComponent(window.location.href)}`;
|
22
22
|
} else {
|
@@ -28,14 +28,14 @@ const getSsoLoginUrl = (ssoRedirectUrl = '') => {
|
|
28
28
|
const getSsoLogoutUrl = (ssoRedirectUrl = '') => {
|
29
29
|
const applicationConfig = getApplicationConfig();
|
30
30
|
|
31
|
-
let
|
32
|
-
if (!
|
33
|
-
throw new Error('参数[
|
31
|
+
let gatewayServerBaseUrl = applicationConfig.gatewayServerBaseUrl;
|
32
|
+
if (!gatewayServerBaseUrl) {
|
33
|
+
throw new Error('参数[gatewayServerBaseUrl]为空');
|
34
34
|
}
|
35
|
-
if (!isFullUrl(
|
36
|
-
throw new Error('参数[
|
35
|
+
if (!isFullUrl(gatewayServerBaseUrl)) {
|
36
|
+
throw new Error('参数[gatewayServerBaseUrl]必须是完整路径');
|
37
37
|
}
|
38
|
-
let ssoLogoutUrl = `${
|
38
|
+
let ssoLogoutUrl = `${gatewayServerBaseUrl}/sso-api/server/sso/logout`;
|
39
39
|
if (!ssoRedirectUrl) {
|
40
40
|
ssoLogoutUrl += `?ssoRedirectUrl=${encodeURIComponent(window.location.href)}`;
|
41
41
|
} else if (ssoRedirectUrl) {
|
package/package.json
CHANGED
package/src/main.ts
CHANGED
@@ -12,8 +12,8 @@ app.use(createPinia())
|
|
12
12
|
app.use(router)
|
13
13
|
|
14
14
|
const applicationConfig = {
|
15
|
-
|
16
|
-
|
15
|
+
gatewayServerBaseUrl: import.meta.env.VITE_GATEWAY_SERVER_BASE_URL,
|
16
|
+
apiBaseUrl: import.meta.env.VITE_API_BASE_URL
|
17
17
|
};
|
18
18
|
initApplicationConfig(app, applicationConfig);
|
19
19
|
|
@@ -26,14 +26,14 @@
|
|
26
26
|
getSsoTokenUser();
|
27
27
|
});
|
28
28
|
const getSsoTokenUser = () => {
|
29
|
-
http.get(`${applicationConfig.
|
29
|
+
http.get(`${applicationConfig.gatewayServerBaseUrl}/sso-api/client/sso-user/getSsoTokenUser`).then((res: any) => {
|
30
30
|
ssoData.ssoTokenUser = res.data.data;
|
31
31
|
console.log('ssoTokenUser', ssoData.ssoTokenUser);
|
32
32
|
ElMessage.success('获取成功');
|
33
33
|
});
|
34
34
|
};
|
35
35
|
const getSsoIdentity = () => {
|
36
|
-
http.get(`${applicationConfig.
|
36
|
+
http.get(`${applicationConfig.gatewayServerBaseUrl}/sso-api/client/sso-user/getSsoIdentity`, { params: { ssoClientAccount: 'yuang-sso' } }).then((res: any) => {
|
37
37
|
ssoData.ssoIdentity = res.data.data;
|
38
38
|
console.log('ssoIdentity', ssoData.ssoIdentity);
|
39
39
|
ElMessage.success('获取成功');
|
@@ -24,7 +24,7 @@
|
|
24
24
|
return;
|
25
25
|
}
|
26
26
|
|
27
|
-
http.get(`${applicationConfig.
|
27
|
+
http.get(`${applicationConfig.gatewayServerBaseUrl}/sso-api/client/sso-auth/getSsoAccessToken`, { params: { ssoAuthCode: ssoAuthCode } }).then((res: any) => {
|
28
28
|
setSsoAccessToken(res.data.data);
|
29
29
|
let ssoRedirectRoutePath = router.currentRoute.value.query.ssoRedirectRoutePath as string;
|
30
30
|
ssoRedirectRoutePath = (ssoRedirectRoutePath && decodeURIComponent(ssoRedirectRoutePath)) || ('/sso/auth/auth-success' as any);
|