perf: 将 getUrlValue 放入 vben/utils 下

This commit is contained in:
xingyu4j
2025-07-09 17:11:22 +08:00
parent 4eeaa32b2c
commit 379e8e755f
7 changed files with 17 additions and 40 deletions

View File

@@ -42,3 +42,13 @@ export function getNestedValue<T>(obj: T, path: string): any {
return current;
}
/**
* 获取 URL 参数值
* @param key - 参数键
* @returns 参数值,或者未找到时返回空字符串
*/
export function getUrlValue(key: string): string {
const url = new URL(decodeURIComponent(location.href));
return url.searchParams.get(key) ?? '';
}