@ray-js/location 0.6.21 → 0.6.22-beta-1
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/location.d.ts +1 -0
- package/lib/location.js +25 -5
- package/package.json +7 -7
package/lib/location.d.ts
CHANGED
package/lib/location.js
CHANGED
@@ -19,22 +19,24 @@ var location = {
|
|
19
19
|
port: '',
|
20
20
|
protocol: '',
|
21
21
|
query: {},
|
22
|
-
search: ''
|
22
|
+
search: '',
|
23
|
+
basename: '/' // 只用于web端
|
24
|
+
|
23
25
|
};
|
24
26
|
Object.defineProperties(location, {
|
25
27
|
href: {
|
26
28
|
enumerable: true,
|
27
29
|
configurable: false,
|
28
30
|
get: function get() {
|
29
|
-
return router.
|
31
|
+
return router.href;
|
30
32
|
}
|
31
33
|
},
|
32
34
|
hash: {
|
33
35
|
enumerable: true,
|
34
36
|
configurable: false,
|
35
37
|
get: function get() {
|
36
|
-
var q = url.parse(router.
|
37
|
-
return q.hash
|
38
|
+
var q = url.parse(router.href);
|
39
|
+
return q.hash;
|
38
40
|
}
|
39
41
|
},
|
40
42
|
host: {
|
@@ -55,7 +57,15 @@ Object.defineProperties(location, {
|
|
55
57
|
enumerable: true,
|
56
58
|
configurable: false,
|
57
59
|
get: function get() {
|
58
|
-
|
60
|
+
// pathname 不需要basename前缀
|
61
|
+
var basename = this.basename;
|
62
|
+
var pathname = url.parse(this.href).pathname;
|
63
|
+
|
64
|
+
if (basename !== '/') {
|
65
|
+
return pathname.replace(basename, '');
|
66
|
+
}
|
67
|
+
|
68
|
+
return pathname;
|
59
69
|
}
|
60
70
|
},
|
61
71
|
port: {
|
@@ -93,6 +103,16 @@ Object.defineProperties(location, {
|
|
93
103
|
var page = router.scheduler.getMatchedPage(this.pathname);
|
94
104
|
return (page === null || page === void 0 ? void 0 : page.params) || {};
|
95
105
|
}
|
106
|
+
},
|
107
|
+
basename: {
|
108
|
+
enumerable: true,
|
109
|
+
configurable: false,
|
110
|
+
get: function get() {
|
111
|
+
var _router$scheduler$bas;
|
112
|
+
|
113
|
+
// 小程序中没有basename
|
114
|
+
return ((_router$scheduler$bas = router.scheduler.basename) !== null && _router$scheduler$bas !== void 0 ? _router$scheduler$bas : '/') || '/';
|
115
|
+
}
|
96
116
|
}
|
97
117
|
});
|
98
118
|
export { location };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ray-js/location",
|
3
|
-
"version": "0.6.
|
3
|
+
"version": "0.6.22-beta-1",
|
4
4
|
"description": "Ray Core",
|
5
5
|
"keywords": [
|
6
6
|
"ray"
|
@@ -20,13 +20,13 @@
|
|
20
20
|
"watch": "tsc -p ./tsconfig.build.json --module esnext --outDir lib --watch"
|
21
21
|
},
|
22
22
|
"dependencies": {
|
23
|
-
"@ray-js/library": "^0.6.
|
24
|
-
"@ray-js/router": "^0.6.
|
25
|
-
"@ray-js/router-mp": "^0.6.
|
23
|
+
"@ray-js/library": "^0.6.22-beta-1",
|
24
|
+
"@ray-js/router": "^0.6.22-beta-1",
|
25
|
+
"@ray-js/router-mp": "^0.6.22-beta-1"
|
26
26
|
},
|
27
27
|
"devDependencies": {
|
28
|
-
"@ray-js/cli": "^0.6.
|
29
|
-
"@ray-js/types": "^0.6.
|
28
|
+
"@ray-js/cli": "^0.6.22-beta-1",
|
29
|
+
"@ray-js/types": "^0.6.22-beta-1"
|
30
30
|
},
|
31
31
|
"maintainers": [
|
32
32
|
{
|
@@ -34,6 +34,6 @@
|
|
34
34
|
"email": "tuyafe@tuya.com"
|
35
35
|
}
|
36
36
|
],
|
37
|
-
"gitHead": "
|
37
|
+
"gitHead": "2e905a1820d0adfc0a6ca8cf3ecf1f3a584a0d44",
|
38
38
|
"repository": {}
|
39
39
|
}
|