imatrix-ui 2.7.34 → 2.7.35
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/package.json +1 -1
- package/src/utils/common-util.js +28 -25
package/package.json
CHANGED
package/src/utils/common-util.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import sessionStorage from 'sessionstorage'
|
|
2
2
|
import Vue from 'vue'
|
|
3
3
|
/**
|
|
4
|
-
* 获得相对地址
|
|
5
|
-
*/
|
|
4
|
+
* 获得相对地址
|
|
5
|
+
*/
|
|
6
6
|
export function getRelativeBaseUrl(originalBaseUrl) {
|
|
7
7
|
if (Vue.prototype.projectModel === undefined || Vue.prototype.projectModel !== 'developing.model') {
|
|
8
8
|
// 表示是产品模式,使用相对地址访问后台
|
|
@@ -10,7 +10,7 @@ export function getRelativeBaseUrl(originalBaseUrl) {
|
|
|
10
10
|
sessionStorage.setItem('relativeUrl', relativeUrl)
|
|
11
11
|
// console.log('getRelativeBaseUrl--relativeUrl---originalBaseUrl=',relativeUrl,originalBaseUrl)
|
|
12
12
|
if (relativeUrl && originalBaseUrl) {
|
|
13
|
-
|
|
13
|
+
// console.log('getRelativeBaseUrl---originalBaseUrl=',originalBaseUrl)
|
|
14
14
|
let baseUrlSuffix = ''
|
|
15
15
|
const baseUrls = originalBaseUrl.split('/')
|
|
16
16
|
// console.log('getRelativeBaseUrl---baseUrls=',baseUrls)
|
|
@@ -18,7 +18,7 @@ export function getRelativeBaseUrl(originalBaseUrl) {
|
|
|
18
18
|
const baseUrlPrefix = baseUrls[0] + '//' + baseUrls[2]
|
|
19
19
|
// console.log('getRelativeBaseUrl---baseUrlPrefix=',baseUrlPrefix)
|
|
20
20
|
baseUrlSuffix = originalBaseUrl.substring(originalBaseUrl.indexOf(baseUrlPrefix) + baseUrlPrefix.length)
|
|
21
|
-
|
|
21
|
+
// console.log('getRelativeBaseUrl---baseUrlSuffix=',baseUrlSuffix)
|
|
22
22
|
}
|
|
23
23
|
if (relativeUrl.lastIndexOf('/') === relativeUrl.length - 1) {
|
|
24
24
|
// 表示以“/”结尾,去掉最后一个“/”
|
|
@@ -63,29 +63,32 @@ function getUrlPrefix(url) {
|
|
|
63
63
|
* @param {*} locationUrl 地址栏的地址
|
|
64
64
|
*/
|
|
65
65
|
export function replacePrefix(originalUrl) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
suffixUrl
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
66
|
+
if (Vue.prototype.projectModel === undefined || Vue.prototype.projectModel !== 'developing.model') {
|
|
67
|
+
const locationUrl = location.href
|
|
68
|
+
let newUrl = originalUrl
|
|
69
|
+
// console.log('replacePrefix---originalUrl=',originalUrl)
|
|
70
|
+
const orginalPrefixUrl = getUrlPrefix(originalUrl)
|
|
71
|
+
// console.log('replacePrefix---orginalPrefixUrl=',orginalPrefixUrl)
|
|
72
|
+
let locationPrefixUrl = getUrlPrefix(locationUrl)
|
|
73
|
+
// console.log('replacePrefix---locationPrefixUrl=',locationPrefixUrl)
|
|
74
|
+
if (orginalPrefixUrl !== locationPrefixUrl) {
|
|
75
|
+
// 获得/demo/#/notice/task需要替换为http://127.0.0.1/demo/#/notice/task
|
|
76
|
+
let suffixUrl = originalUrl.substring(originalUrl.indexOf(orginalPrefixUrl) + orginalPrefixUrl.length)
|
|
77
|
+
if (suffixUrl.indexOf('/') !== 0) {
|
|
78
|
+
suffixUrl = '/' + suffixUrl
|
|
79
|
+
}
|
|
80
|
+
// console.log('replacePrefix---suffixUrl=',suffixUrl)
|
|
81
|
+
if (locationPrefixUrl.lastIndexOf('/') === locationPrefixUrl.length - 1) {
|
|
82
|
+
// 表示以“/”结尾,去掉最后一个“/”
|
|
83
|
+
locationPrefixUrl = locationPrefixUrl.substring(0, locationPrefixUrl.lastIndexOf('/'))
|
|
84
|
+
}
|
|
85
|
+
// console.log('replacePrefix---locationPrefixUrl2=',locationPrefixUrl)
|
|
86
|
+
newUrl = locationPrefixUrl + suffixUrl
|
|
83
87
|
}
|
|
84
|
-
// console.log('replacePrefix---
|
|
85
|
-
newUrl
|
|
88
|
+
// console.log('replacePrefix---newUrl=',newUrl)
|
|
89
|
+
return newUrl
|
|
86
90
|
}
|
|
87
|
-
|
|
88
|
-
return newUrl
|
|
91
|
+
return originalUrl
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
// 获得门户前端访问路径
|