diff --git a/src/utils/index.js b/src/utils/index.js index f18fccb..cd14bd5 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -88,3 +88,23 @@ export function formatTime(time, option) { ) } } + +/** + * @param {string} url + * @returns {Object} + */ +export function param2Obj(url) { + const search = url.split('?')[1] + if (!search) { + return {} + } + return JSON.parse( + '{"' + + decodeURIComponent(search) + .replace(/"/g, '\\"') + .replace(/&/g, '","') + .replace(/=/g, '":"') + .replace(/\+/g, ' ') + + '"}' + ) +}