@blacklake-web/utils
Advanced tools
| interface Param { | ||
| [index: string]: any; | ||
| } | ||
| export declare const getRelativePath: (path: string) => string; | ||
| interface FuncProps { | ||
| getParams: () => Param; | ||
| setParams: (params: Param) => void; | ||
| getRelativePath: (path: string) => string; | ||
| getRouteParams: (props: any) => any; | ||
| } | ||
| declare const BlUrl: FuncProps; | ||
| export { BlUrl }; |
+1
-0
| export * from './localStroage'; | ||
| export * from './url'; |
+48
-1
| import _ from 'lodash'; | ||
| import Url from 'url-parse'; | ||
| import queryString from 'query-string'; | ||
@@ -262,2 +264,47 @@ function ownKeys(object, enumerableOnly) { | ||
| export { BlLocalStorage, STORAGE_EXPIRED, StorageLimitType }; | ||
| function getParams() { | ||
| var _queryString$parseUrl = queryString.parseUrl(location.search, { | ||
| arrayFormat: 'bracket-separator', | ||
| arrayFormatSeparator: '|', | ||
| parseNumbers: true | ||
| }), | ||
| formatParams = _queryString$parseUrl.query; | ||
| return formatParams; | ||
| } | ||
| function setParams(params) { | ||
| var _location = location, | ||
| pathname = _location.pathname; | ||
| var newUrl = queryString.stringifyUrl({ | ||
| url: pathname, | ||
| query: params | ||
| }, { | ||
| arrayFormat: 'bracket-separator', | ||
| arrayFormatSeparator: '|', | ||
| skipNull: true | ||
| }); | ||
| window.history.pushState(null, '', newUrl); | ||
| return newUrl; | ||
| } | ||
| var getRelativePath = function getRelativePath(path) { | ||
| if (!path) { | ||
| return '/'; | ||
| } | ||
| var url = new Url(decodeURIComponent(path)); | ||
| return "".concat(url.pathname).concat(url.query); | ||
| }; | ||
| var getRouteParams = function getRouteParams(props) { | ||
| return props.match.params; | ||
| }; | ||
| var BlUrl = {}; | ||
| BlUrl.getParams = getParams; | ||
| BlUrl.setParams = setParams; | ||
| BlUrl.getRelativePath = getRelativePath; | ||
| BlUrl.getRouteParams = getRouteParams; | ||
| export { BlLocalStorage, BlUrl, STORAGE_EXPIRED, StorageLimitType, getRelativePath }; |
+6
-2
| { | ||
| "name": "@blacklake-web/utils", | ||
| "version": "1.0.13-alpha.11", | ||
| "version": "1.0.13-alpha.12", | ||
| "description": "blackalke-web utils", | ||
@@ -28,3 +28,3 @@ "author": "zx <zhaoxin@blacklake.cn>", | ||
| }, | ||
| "gitHead": "aabb1cb5a5bb82572f2229503bc7f683a05a6b68", | ||
| "gitHead": "2867a0b8db971e7b0144d9461dd27d1e467cf0f2", | ||
| "publishConfig": { | ||
@@ -35,3 +35,7 @@ "access": "public" | ||
| "lodash": ">4.10.0" | ||
| }, | ||
| "dependencies": { | ||
| "query-string": "^7.0.1", | ||
| "url-parse": "^1.5.3" | ||
| } | ||
| } |
10727
17.45%9
12.5%308
20.78%3
200%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added