mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-09-13 00:50:40 +08:00
chore: 批量新增项目依赖、工具函数、页面与组件资源
1. 新增mp-html、qs等生产依赖,补全项目基础库 2. 新增平台判断、缓存、工具函数等通用工具集 3. 新增标签页、网站浏览页、关于页等业务页面 4. 新增分类卡片、通知弹窗等业务组件 5. 新增uts-progressNotification、liu-poster、uhalo-upgrade等uni模块 6. 补充audio/video组件样式补件,修复uni-components路径缺失问题 7. 新增环境变量Halo个人令牌配置项 8. 重构store导出结构,新增appConfig/halo/setting三个状态模块 9. 新增tsconfig编译目标配置,适配更高版本ES语法
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Cookie 处理工具(源自旧项目 utils/cookies.js,按需命名导出)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 从带换行的 cookie 原始串提取某一条 cookie(带;结尾)
|
||||
* @param cookieRaw set-cookie 原始字符串
|
||||
* @param cookieKey cookie 名称,例如 "comment-widget-captcha"
|
||||
* @returns 清理换行后的 cookie 片段,没匹配返回 ''
|
||||
*/
|
||||
export function extractCookieItem(cookieRaw: string, cookieKey: string): string {
|
||||
if (!cookieRaw || !cookieKey)
|
||||
return ''
|
||||
|
||||
// 转义正则特殊字符
|
||||
const keyEscaped = cookieKey.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||
const reg = new RegExp(`${keyEscaped}=[\\s\\S]*?;`)
|
||||
const m = cookieRaw.match(reg)
|
||||
return m ? m[0].replace(/\r?\n/g, '') : ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 header 中指定 key 的值,忽略大小写
|
||||
* @param headers HTTP header 对象
|
||||
* @param name HTTP header 键名
|
||||
* @returns HTTP header 值,没找到返回 ''
|
||||
*/
|
||||
export function getHeaderCaseInsensitive(headers: Record<string, string> | undefined, name: string): string {
|
||||
if (!headers || typeof headers !== 'object')
|
||||
return ''
|
||||
const lowerName = name.toLowerCase()
|
||||
const key = Object.keys(headers).find(k => k.toLowerCase() === lowerName)
|
||||
return key ? headers[key] : ''
|
||||
}
|
||||
Reference in New Issue
Block a user