yuang-framework-ui-common 1.0.60 → 1.0.62

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.
@@ -14,7 +14,8 @@ import { http } from './httpConfig';
14
14
 
15
15
  const application = {
16
16
  gatewayServerBaseUrl: '',
17
- apiBaseUrl: ''
17
+ apiBaseUrl: '',
18
+ uimsApplicationCode: ''
18
19
  };
19
20
 
20
21
  const initApplication = (app: any, config: any) => {
@@ -34,6 +35,7 @@ const initApplication = (app: any, config: any) => {
34
35
  }
35
36
  application.gatewayServerBaseUrl = Object.freeze(config.gatewayServerBaseUrl);
36
37
  application.apiBaseUrl = Object.freeze(config.apiBaseUrl);
38
+ application.uimsApplicationCode = Object.freeze(config.uimsApplicationCode);
37
39
 
38
40
  // 小程序没有window,暂时这样
39
41
  (window as any).application = Object.freeze(application);
@@ -10,6 +10,7 @@ import { alertMessageBox } from '../utils/messageBoxUtils';
10
10
 
11
11
  import { application } from '../config/applicationConfig';
12
12
  import { getSsoLoginUrl, clearSsoAccessToken, setSsoAccessToken } from '../utils/ssoUtils';
13
+ import { getIsDebug, setIsDebug } from '../utils/htmlUtils';
13
14
 
14
15
  import { clearGateway, initGateway } from '../config/gatewayConfig';
15
16
 
@@ -51,7 +52,9 @@ http.interceptors.response.use(async (res: any) => {
51
52
  showErrorMessage(messageMap.responseSturctError);
52
53
  return Promise.reject(new Error(messageMap.responseSturctError));
53
54
  }
54
- debugger
55
+ if(getIsDebug()) {
56
+ debugger
57
+ }
55
58
  if (res?.data?.statusCode !== 200) {
56
59
  // 登录过期处理
57
60
  if (res?.data?.statusCode === 401) {
@@ -152,16 +155,7 @@ const beforeRequestConfig = (config: any) => {
152
155
  config.headers["Sso-Access-Token"] = ssoAccessToken;
153
156
  }
154
157
 
155
- let uimsApplicationCode = '';
156
- if (config.url == `${application.gatewayServerBaseUrl}/sso-api/client/sso-user/getSsoIdentity`) {
157
- uimsApplicationCode = config.params.uimsApplicationCode
158
- setLocalStorageItem("uimsApplicationCode", uimsApplicationCode, 9999999);
159
- } else{
160
- uimsApplicationCode = getLocalStorageItem("uimsApplicationCode") ?? '';
161
- }
162
- if (uimsApplicationCode) {
163
- config.headers["Uims-Application-Code"] = uimsApplicationCode;
164
- }
158
+ config.headers["Uims-Application-Code"] = application.uimsApplicationCode;
165
159
 
166
160
  config.headers["Request-Id"] = new Date().getTime().toString() + (parseInt((Math.random() * 10000).toString())).toString();
167
161
  }
@@ -1,4 +1,5 @@
1
1
 
2
+
2
3
  /**
3
4
  * 加载脚本
4
5
  * @param src
@@ -114,4 +115,22 @@ const getFileSize = (url: string) => {
114
115
  }
115
116
 
116
117
 
117
- export { loadScript, loadLink, loadIframe, getFileSize };
118
+ /**
119
+ * 设置是否调试
120
+ * @param value
121
+ */
122
+ const setIsDebug = (value: boolean) => {
123
+ localStorage.setItem('is-debug', value.toString());
124
+ }
125
+
126
+ /**
127
+ * 获取是否调试
128
+ */
129
+ const getIsDebug = () => {
130
+ let value = localStorage.getItem('is-debug');
131
+ if(value == 'true') {
132
+ return true;
133
+ }
134
+ return false;
135
+ }
136
+ export { loadScript, loadLink, loadIframe, getFileSize, setIsDebug, getIsDebug };
@@ -6,10 +6,20 @@
6
6
  * @returns {string|null}
7
7
  */
8
8
  const getParameter = (name: string, url?: string) : string => {
9
- url = url || window.location.search;
9
+ if (typeof(url) == 'undefined') {
10
+ // 格式:?name=chenghui
11
+ url = window.location.search;
12
+ } else {
13
+ if (url.indexOf('?') != -1) {
14
+ // 格式:?name=chenghui
15
+ url = url.substring(url.indexOf('?'));
16
+ }
17
+ }
10
18
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
11
19
  var r = url.substr(1).match(reg);
12
- if (r != null) return decodeURIComponent(r[2]);
20
+ if (r != null) {
21
+ return decodeURIComponent(r[2]);
22
+ }
13
23
  return '';
14
24
  }
15
25
 
@@ -19,8 +29,15 @@ const getParameter = (name: string, url?: string) : string => {
19
29
  * @returns {map|null}
20
30
  */
21
31
  const getParameterMap = (url?: string): Map<string, string> => {
22
- url = url || window.location.search;
23
-
32
+ if (typeof(url) == 'undefined') {
33
+ // 格式:?name=chenghui
34
+ url = window.location.search;
35
+ } else {
36
+ if (url.indexOf('?') != -1) {
37
+ // 格式:?name=chenghui
38
+ url = url.substring(url.indexOf('?'));
39
+ }
40
+ }
24
41
  let arrObj = url.split("?") as any;
25
42
  let params = Object.create(null);
26
43
  if (arrObj.length > 1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuang-framework-ui-common",
3
- "version": "1.0.60",
3
+ "version": "1.0.62",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
package/src/main.ts CHANGED
@@ -7,13 +7,14 @@ import router from './router'
7
7
  import {initApplication} from '../lib/config/applicationConfig';
8
8
 
9
9
  const app = createApp(App)
10
- debugger
10
+
11
11
  app.use(createPinia())
12
12
  app.use(router)
13
13
 
14
14
  const config = {
15
15
  gatewayServerBaseUrl: import.meta.env.VITE_GATEWAY_SERVER_BASE_URL,
16
- apiBaseUrl: import.meta.env.VITE_API_BASE_URL
16
+ apiBaseUrl: import.meta.env.VITE_API_BASE_URL,
17
+ uimsApplicationCode: import.meta.env.VITE_UIMS_APPLICATION_CODE
17
18
  };
18
19
  initApplication(app, config);
19
20
 
@@ -32,7 +32,7 @@
32
32
  });
33
33
  };
34
34
  const getSsoIdentity = () => {
35
- http.get(`${application.gatewayServerBaseUrl}/sso-api/client/sso-user/getSsoIdentity`, { params: { uimsApplicationCode: 'yuang-sso-ui-pc' } }).then((res: any) => {
35
+ http.get(`${application.gatewayServerBaseUrl}/sso-api/client/sso-user/getSsoIdentity`).then((res: any) => {
36
36
  ssoData.ssoIdentity = res.data.data;
37
37
  console.log('ssoIdentity', ssoData.ssoIdentity);
38
38
  ElMessage.success('获取成功');
@@ -10,7 +10,7 @@ import { ElMessage } from 'element-plus/es';
10
10
 
11
11
  const sendRequest = () => {
12
12
  // 测试
13
- http.get("/framework-api/standard/framework-captcha/getSliderCaptcha", { params: {} }).then((res) => {
13
+ http.get("/framework-api/core/framework-captcha/getSliderCaptcha", { params: {} }).then((res) => {
14
14
  ElMessage.success('发送成功');
15
15
  });
16
16
  }