You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
548 B
TypeScript
20 lines
548 B
TypeScript
// 仅用于线上预览,实际使用中可以将此逻辑删除
|
|
import qs from 'query-string';
|
|
import { isSSR } from './is';
|
|
|
|
export type ParamsType = Record<string, any>;
|
|
|
|
export default function getUrlParams(): ParamsType {
|
|
const params = qs.parseUrl(!isSSR ? window.location.href : '').query;
|
|
const returnParams: ParamsType = {};
|
|
Object.keys(params).forEach((p) => {
|
|
if (params[p] === 'true') {
|
|
returnParams[p] = true;
|
|
}
|
|
if (params[p] === 'false') {
|
|
returnParams[p] = false;
|
|
}
|
|
});
|
|
return returnParams;
|
|
}
|