yuang-framework-ui-pc 1.1.24 → 1.1.26

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.
@@ -1,2 +1,5 @@
1
1
  @use '../ele-app/style/index.scss' as app;
2
2
  @use './plus.scss' as *;
3
+
4
+
5
+ @use './css/iconfont.css';
@@ -1,149 +1,7 @@
1
1
  import { defineComponent, ref, onMounted, nextTick, openBlock, createElementBlock, createElementVNode, createTextVNode, createVNode, unref, normalizeStyle, normalizeClass, createCommentVNode, toDisplayString, Fragment } from "vue";
2
- import axios from "../../node_modules/axios/lib/axios.js";
3
- import { useRouter } from "vue-router";
4
- import { showErrorMessage } from "../../node_modules/yuang-framework-ui-common/lib/utils/messageUtils";
5
- import { alertMessageBox } from "../../node_modules/yuang-framework-ui-common/lib/utils/messageBoxUtils";
6
- import { clearSsoAccessToken, getSsoLoginUrl, setSsoAccessToken } from "../../node_modules/yuang-framework-ui-common/lib/utils/ssoUtils";
7
- import { getGatewayConfigUrl, initGatewayConfig, clearGatewayConfig } from "../../node_modules/yuang-framework-ui-common/lib/config/gatewayConfig";
8
- import { getLocalStorageItem } from "../../node_modules/yuang-framework-ui-common/lib/utils/storageUtils";
2
+ import { http } from "yuang-framework-ui-common/lib/config/httpConfig";
3
+ import { getBaseUrl } from "yuang-framework-ui-common/lib/utils/urlUtils";
9
4
  import { CircleClose } from "@element-plus/icons-vue";
10
- const router = useRouter();
11
- const messageMap = {
12
- requestError: "请求异常",
13
- responseSturctError: "响应结构错误"
14
- };
15
- const apiBaseUrl = "/gateway-server";
16
- const http = axios.create({
17
- baseURL: apiBaseUrl,
18
- timeout: 1e4,
19
- headers: {}
20
- });
21
- http.interceptors.request.use(async (config) => {
22
- let gatewayAccessToken = getLocalStorageItem("gatewayAccessToken") ?? "";
23
- if (!gatewayAccessToken && config.url != getGatewayConfigUrl) {
24
- await initGatewayConfig();
25
- }
26
- beforeRequestConfig(config);
27
- return config;
28
- }, (error) => {
29
- showErrorMessage((error == null ? void 0 : error.message) || messageMap.requestError);
30
- return Promise.reject(error);
31
- });
32
- http.interceptors.response.use(async (res) => {
33
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
34
- if (!((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.statusCode)) {
35
- showErrorMessage(messageMap.responseSturctError);
36
- return Promise.reject(new Error(messageMap.responseSturctError));
37
- }
38
- if (((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.statusCode) !== 200) {
39
- if (((_c = res == null ? void 0 : res.data) == null ? void 0 : _c.statusCode) === 401) {
40
- alertMessageBox({
41
- title: "系统提示",
42
- message: "登录状态已过期, 请退出重新登录!",
43
- confirmButtonText: "重新登录",
44
- callback: (action) => {
45
- if (action === "confirm") {
46
- clearSsoAccessToken();
47
- window.location.href = getSsoLoginUrl() || "";
48
- }
49
- }
50
- });
51
- return Promise.reject(new Error((_d = res == null ? void 0 : res.data) == null ? void 0 : _d.message));
52
- } else if (((_e = res == null ? void 0 : res.data) == null ? void 0 : _e.statusCode) === 500822001) {
53
- clearGatewayConfig();
54
- window.location.reload();
55
- return Promise.reject(new Error((_f = res == null ? void 0 : res.data) == null ? void 0 : _f.message));
56
- } else if (((_g = res == null ? void 0 : res.data) == null ? void 0 : _g.statusCode) === 500815001) {
57
- showErrorMessage(((_h = res == null ? void 0 : res.data) == null ? void 0 : _h.message) || messageMap.requestError);
58
- clearSsoAccessToken();
59
- window.location.href = getSsoLoginUrl() || "";
60
- return Promise.reject(new Error((_i = res == null ? void 0 : res.data) == null ? void 0 : _i.message));
61
- } else if (((_j = res == null ? void 0 : res.data) == null ? void 0 : _j.statusCode) === 500815005) {
62
- await refreshSsoAccessToken(res);
63
- return axios.request(res.config);
64
- } else if (((_k = res == null ? void 0 : res.data) == null ? void 0 : _k.statusCode) === 500815006) {
65
- const fullPath = router.currentRoute.value.fullPath;
66
- router.push(`/sso/auth/index?ssoRedirectRoutePath=${encodeURIComponent(fullPath)}`);
67
- return;
68
- } else if (((_l = res == null ? void 0 : res.data) == null ? void 0 : _l.statusCode) === 500815003) {
69
- showErrorMessage(((_m = res == null ? void 0 : res.data) == null ? void 0 : _m.message) || messageMap.requestError);
70
- return Promise.reject(new Error((_n = res == null ? void 0 : res.data) == null ? void 0 : _n.message));
71
- }
72
- showErrorMessage(((_o = res == null ? void 0 : res.data) == null ? void 0 : _o.message) || messageMap.requestError);
73
- return Promise.reject(new Error((_p = res == null ? void 0 : res.data) == null ? void 0 : _p.message));
74
- }
75
- return res;
76
- }, (error) => {
77
- var _a, _b;
78
- let errorMessage = "";
79
- if ((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) {
80
- let { statusCode, message } = (_b = error == null ? void 0 : error.response) == null ? void 0 : _b.data;
81
- if (statusCode !== 200) {
82
- errorMessage = message;
83
- }
84
- errorMessage = errorMessage || messageMap.requestError;
85
- } else {
86
- errorMessage = (error == null ? void 0 : error.message) || messageMap.requestError;
87
- }
88
- showErrorMessage(errorMessage);
89
- return Promise.reject(error);
90
- });
91
- const beforeRequestConfig = (config) => {
92
- if (!config.url) {
93
- return console.error("参数[url]不存在");
94
- }
95
- config.headers["X-Requested-With"] = "XMLHttpRequest";
96
- let gatewayAccessToken = getLocalStorageItem("gatewayAccessToken") ?? "";
97
- let gatewayPublicKey = getLocalStorageItem("gatewayPublicKey") ?? "";
98
- let ssoAccessToken = getLocalStorageItem("ssoAccessToken") ?? "";
99
- if (gatewayAccessToken) {
100
- config.headers["Gateway-Access-Token"] = gatewayAccessToken;
101
- }
102
- if (gatewayPublicKey) {
103
- config.headers["Gateway-Public-Key"] = gatewayPublicKey;
104
- }
105
- if (ssoAccessToken) {
106
- config.headers["Sso-Access-Token"] = ssoAccessToken;
107
- }
108
- config.headers["Request-Id"] = (/* @__PURE__ */ new Date()).getTime().toString() + parseInt((Math.random() * 1e4).toString()).toString();
109
- };
110
- const refreshSsoAccessToken = (res) => {
111
- let ssoRefreshToken = encodeURIComponent(getLocalStorageItem("ssoRefreshToken") ?? "");
112
- if (!ssoRefreshToken) {
113
- return showErrorMessage("参数[ssoRefreshToken]为空");
114
- }
115
- return new Promise((resolve, reject) => {
116
- const config = res.config;
117
- config.params = {
118
- ssoRefreshToken
119
- };
120
- axios.get(`/sso-api/client/sso-auth/getSsoRefreshToken`, config).then((res2) => {
121
- var _a;
122
- if (((_a = res2 == null ? void 0 : res2.data) == null ? void 0 : _a.statusCode) !== 200) {
123
- return reject();
124
- }
125
- setSsoAccessToken(res2.data.data);
126
- return resolve(void 0);
127
- });
128
- });
129
- };
130
- const getBaseUrl = (url) => {
131
- url = url || location.href;
132
- let arr = url.split("/");
133
- if (arr.length > 3) {
134
- var baseUrl = "";
135
- for (let i = 0; i < arr.length; i++) {
136
- if (i <= 3) {
137
- baseUrl += arr[i] + "/";
138
- }
139
- }
140
- if (baseUrl) {
141
- return baseUrl.substring(0, baseUrl.length - 1);
142
- }
143
- } else {
144
- console.error("地址存在问题");
145
- }
146
- };
147
5
  const _hoisted_1 = { class: "slider-captcha-container" };
148
6
  const _hoisted_2 = { class: "slider-captcha-title" };
149
7
  const _hoisted_3 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-refresh" }, null, -1);
@@ -218,7 +76,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
218
76
  }
219
77
  };
220
78
  const getCaptcha = () => {
221
- http.get("/framework-api/standard/framework-captcha/getSliderCaptcha", { params: {} }).then((res) => {
79
+ http.get("/sso-api/standard/framework-captcha/getSliderCaptcha", { params: {} }).then((res) => {
222
80
  key.value = res.data.data.key;
223
81
  block.value.src = res.data.data.blockSrc;
224
82
  block.value.style.top = res.data.data.blockY + "px";
@@ -381,7 +239,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
381
239
  key: key.value,
382
240
  captcha: moveLength
383
241
  };
384
- http.get("/framework-api/standard/framework-captcha/validateSliderCaptcha", { params }).then((res) => {
242
+ http.get("/sso-api/standard/framework-captcha/validateSliderCaptcha", { params }).then((res) => {
385
243
  emit("success", { key: key.value, value: moveLength });
386
244
  }).catch(() => {
387
245
  verifyFailEvent();
@@ -1,2 +1,5 @@
1
1
  @use '../ele-app/style/index.scss' as app;
2
2
  @use './plus.scss' as *;
3
+
4
+
5
+ @use './css/iconfont.css';
@@ -1,150 +1,8 @@
1
1
  "use strict";
2
2
  const vue = require("vue");
3
- const axios = require("../../node_modules/axios/lib/axios.js");
4
- const vueRouter = require("vue-router");
5
- const messageUtils = require("../../node_modules/yuang-framework-ui-common/lib/utils/messageUtils");
6
- const messageBoxUtils = require("../../node_modules/yuang-framework-ui-common/lib/utils/messageBoxUtils");
7
- const ssoUtils = require("../../node_modules/yuang-framework-ui-common/lib/utils/ssoUtils");
8
- const gatewayConfig = require("../../node_modules/yuang-framework-ui-common/lib/config/gatewayConfig");
9
- const storageUtils = require("../../node_modules/yuang-framework-ui-common/lib/utils/storageUtils");
3
+ const httpConfig = require("yuang-framework-ui-common/lib/config/httpConfig");
4
+ const urlUtils = require("yuang-framework-ui-common/lib/utils/urlUtils");
10
5
  const iconsVue = require("@element-plus/icons-vue");
11
- const router = vueRouter.useRouter();
12
- const messageMap = {
13
- requestError: "请求异常",
14
- responseSturctError: "响应结构错误"
15
- };
16
- const apiBaseUrl = "/gateway-server";
17
- const http = axios.create({
18
- baseURL: apiBaseUrl,
19
- timeout: 1e4,
20
- headers: {}
21
- });
22
- http.interceptors.request.use(async (config) => {
23
- let gatewayAccessToken = storageUtils.getLocalStorageItem("gatewayAccessToken") ?? "";
24
- if (!gatewayAccessToken && config.url != gatewayConfig.getGatewayConfigUrl) {
25
- await gatewayConfig.initGatewayConfig();
26
- }
27
- beforeRequestConfig(config);
28
- return config;
29
- }, (error) => {
30
- messageUtils.showErrorMessage((error == null ? void 0 : error.message) || messageMap.requestError);
31
- return Promise.reject(error);
32
- });
33
- http.interceptors.response.use(async (res) => {
34
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
35
- if (!((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.statusCode)) {
36
- messageUtils.showErrorMessage(messageMap.responseSturctError);
37
- return Promise.reject(new Error(messageMap.responseSturctError));
38
- }
39
- if (((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.statusCode) !== 200) {
40
- if (((_c = res == null ? void 0 : res.data) == null ? void 0 : _c.statusCode) === 401) {
41
- messageBoxUtils.alertMessageBox({
42
- title: "系统提示",
43
- message: "登录状态已过期, 请退出重新登录!",
44
- confirmButtonText: "重新登录",
45
- callback: (action) => {
46
- if (action === "confirm") {
47
- ssoUtils.clearSsoAccessToken();
48
- window.location.href = ssoUtils.getSsoLoginUrl() || "";
49
- }
50
- }
51
- });
52
- return Promise.reject(new Error((_d = res == null ? void 0 : res.data) == null ? void 0 : _d.message));
53
- } else if (((_e = res == null ? void 0 : res.data) == null ? void 0 : _e.statusCode) === 500822001) {
54
- gatewayConfig.clearGatewayConfig();
55
- window.location.reload();
56
- return Promise.reject(new Error((_f = res == null ? void 0 : res.data) == null ? void 0 : _f.message));
57
- } else if (((_g = res == null ? void 0 : res.data) == null ? void 0 : _g.statusCode) === 500815001) {
58
- messageUtils.showErrorMessage(((_h = res == null ? void 0 : res.data) == null ? void 0 : _h.message) || messageMap.requestError);
59
- ssoUtils.clearSsoAccessToken();
60
- window.location.href = ssoUtils.getSsoLoginUrl() || "";
61
- return Promise.reject(new Error((_i = res == null ? void 0 : res.data) == null ? void 0 : _i.message));
62
- } else if (((_j = res == null ? void 0 : res.data) == null ? void 0 : _j.statusCode) === 500815005) {
63
- await refreshSsoAccessToken(res);
64
- return axios.request(res.config);
65
- } else if (((_k = res == null ? void 0 : res.data) == null ? void 0 : _k.statusCode) === 500815006) {
66
- const fullPath = router.currentRoute.value.fullPath;
67
- router.push(`/sso/auth/index?ssoRedirectRoutePath=${encodeURIComponent(fullPath)}`);
68
- return;
69
- } else if (((_l = res == null ? void 0 : res.data) == null ? void 0 : _l.statusCode) === 500815003) {
70
- messageUtils.showErrorMessage(((_m = res == null ? void 0 : res.data) == null ? void 0 : _m.message) || messageMap.requestError);
71
- return Promise.reject(new Error((_n = res == null ? void 0 : res.data) == null ? void 0 : _n.message));
72
- }
73
- messageUtils.showErrorMessage(((_o = res == null ? void 0 : res.data) == null ? void 0 : _o.message) || messageMap.requestError);
74
- return Promise.reject(new Error((_p = res == null ? void 0 : res.data) == null ? void 0 : _p.message));
75
- }
76
- return res;
77
- }, (error) => {
78
- var _a, _b;
79
- let errorMessage = "";
80
- if ((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) {
81
- let { statusCode, message } = (_b = error == null ? void 0 : error.response) == null ? void 0 : _b.data;
82
- if (statusCode !== 200) {
83
- errorMessage = message;
84
- }
85
- errorMessage = errorMessage || messageMap.requestError;
86
- } else {
87
- errorMessage = (error == null ? void 0 : error.message) || messageMap.requestError;
88
- }
89
- messageUtils.showErrorMessage(errorMessage);
90
- return Promise.reject(error);
91
- });
92
- const beforeRequestConfig = (config) => {
93
- if (!config.url) {
94
- return console.error("参数[url]不存在");
95
- }
96
- config.headers["X-Requested-With"] = "XMLHttpRequest";
97
- let gatewayAccessToken = storageUtils.getLocalStorageItem("gatewayAccessToken") ?? "";
98
- let gatewayPublicKey = storageUtils.getLocalStorageItem("gatewayPublicKey") ?? "";
99
- let ssoAccessToken = storageUtils.getLocalStorageItem("ssoAccessToken") ?? "";
100
- if (gatewayAccessToken) {
101
- config.headers["Gateway-Access-Token"] = gatewayAccessToken;
102
- }
103
- if (gatewayPublicKey) {
104
- config.headers["Gateway-Public-Key"] = gatewayPublicKey;
105
- }
106
- if (ssoAccessToken) {
107
- config.headers["Sso-Access-Token"] = ssoAccessToken;
108
- }
109
- config.headers["Request-Id"] = (/* @__PURE__ */ new Date()).getTime().toString() + parseInt((Math.random() * 1e4).toString()).toString();
110
- };
111
- const refreshSsoAccessToken = (res) => {
112
- let ssoRefreshToken = encodeURIComponent(storageUtils.getLocalStorageItem("ssoRefreshToken") ?? "");
113
- if (!ssoRefreshToken) {
114
- return messageUtils.showErrorMessage("参数[ssoRefreshToken]为空");
115
- }
116
- return new Promise((resolve, reject) => {
117
- const config = res.config;
118
- config.params = {
119
- ssoRefreshToken
120
- };
121
- axios.get(`/sso-api/client/sso-auth/getSsoRefreshToken`, config).then((res2) => {
122
- var _a;
123
- if (((_a = res2 == null ? void 0 : res2.data) == null ? void 0 : _a.statusCode) !== 200) {
124
- return reject();
125
- }
126
- ssoUtils.setSsoAccessToken(res2.data.data);
127
- return resolve(void 0);
128
- });
129
- });
130
- };
131
- const getBaseUrl = (url) => {
132
- url = url || location.href;
133
- let arr = url.split("/");
134
- if (arr.length > 3) {
135
- var baseUrl = "";
136
- for (let i = 0; i < arr.length; i++) {
137
- if (i <= 3) {
138
- baseUrl += arr[i] + "/";
139
- }
140
- }
141
- if (baseUrl) {
142
- return baseUrl.substring(0, baseUrl.length - 1);
143
- }
144
- } else {
145
- console.error("地址存在问题");
146
- }
147
- };
148
6
  const _hoisted_1 = { class: "slider-captcha-container" };
149
7
  const _hoisted_2 = { class: "slider-captcha-title" };
150
8
  const _hoisted_3 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-refresh" }, null, -1);
@@ -219,7 +77,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
219
77
  }
220
78
  };
221
79
  const getCaptcha = () => {
222
- http.get("/framework-api/standard/framework-captcha/getSliderCaptcha", { params: {} }).then((res) => {
80
+ httpConfig.http.get("/sso-api/standard/framework-captcha/getSliderCaptcha", { params: {} }).then((res) => {
223
81
  key.value = res.data.data.key;
224
82
  block.value.src = res.data.data.blockSrc;
225
83
  block.value.style.top = res.data.data.blockY + "px";
@@ -249,7 +107,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
249
107
  image2.crossOrigin = "Anonymous";
250
108
  image2.onload = onload;
251
109
  image2.onerror = () => {
252
- image2.src = `${getBaseUrl()}/img/slider-captcha/pic-0.jpeg`;
110
+ image2.src = `${urlUtils.getBaseUrl()}/img/slider-captcha/pic-0.jpeg`;
253
111
  };
254
112
  image2.src = getImageSrc();
255
113
  return image2;
@@ -382,7 +240,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
382
240
  key: key.value,
383
241
  captcha: moveLength
384
242
  };
385
- http.get("/framework-api/standard/framework-captcha/validateSliderCaptcha", { params }).then((res) => {
243
+ httpConfig.http.get("/sso-api/standard/framework-captcha/validateSliderCaptcha", { params }).then((res) => {
386
244
  emit("success", { key: key.value, value: moveLength });
387
245
  }).catch(() => {
388
246
  verifyFailEvent();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuang-framework-ui-pc",
3
- "version": "1.1.24",
3
+ "version": "1.1.26",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite --host --config vite.global.ts --mode dev",