feat: git login

This commit is contained in:
archer
2023-08-07 17:19:04 +08:00
parent 206eb81bb4
commit ce729dff1f
12 changed files with 310 additions and 32 deletions

View File

@@ -53,6 +53,36 @@ export const Obj2Query = (obj: Record<string, string | number>) => {
return queryParams.toString();
};
export const parseQueryString = (str: string) => {
const queryObject: Record<string, any> = {};
const splitStr = str.split('?');
str = splitStr[1] || splitStr[0];
// 将字符串按照 '&' 分割成键值对数组
const keyValuePairs = str.split('&');
// 遍历键值对数组,将每个键值对解析为对象的属性和值
keyValuePairs.forEach(function (keyValuePair) {
const pair = keyValuePair.split('=');
const key = decodeURIComponent(pair[0]);
const value = decodeURIComponent(pair[1] || '');
// 如果对象中已经存在该属性,则将值转换为数组
if (queryObject.hasOwnProperty(key)) {
if (!Array.isArray(queryObject[key])) {
queryObject[key] = [queryObject[key]];
}
queryObject[key].push(value);
} else {
queryObject[key] = value;
}
});
return queryObject;
};
/**
* 格式化时间成聊天格式
*/