
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
sr-utils-web
Advanced tools
电商场景下,常用基础工具函数集合。
sr-utils-base 文档地址{target=_blank}
说明:数据存储
例子
\_.storage.localStorage.get('key');
// =>value
\_.storage.localStorage.set('key','value');
说明:方便写前缀 class
使用说明
const genClass = genClassFactory('card');
export const CardName = () => <div className={genClass('name')} />; // <div className='card-name' />
export const CardBody = () => <div className={genClass('head', 'bold')} />; // <div className='card-head card-bold' />
说明:获取图片的宽高
参数
url (string): 图片地址
返回
(obj): 图片的宽高数据
例子
\_.getImageSize(srcUrl).then(({ width, height }) => {console.log(width, height)})
// => 300,400
说明:是否是移动设备
参数
无
返回
(boolean): 是否是移动涉笔
例子
\_.isMobile();
// => true
说明:根据 cookieStr 获取 value
参数
(string) name 需要获取的 cookie
返回
(string): 获取到的值
例子
\_.getFeatureFromCookie('key');
// => value
说明:设置 cookie 某个值的过期时间
参数
(string) name 需要设置的 cookie
(string) value 设置的 cookie 的值
(number) [time = 30] 过期时间
例子
\_.setValueByCookie('key','value',20);
说明:获取 n 天前后的 cookie 过期时间
参数
(number) time 多少天
(string) [type='after'] time 天前还是后 after|before
返回
(string): 过期时间
例子
\_.getExpiresTime(2);
// => 'Sat, 31 Dec 2022 02:49:38 GMT'
FAQs
We found that sr-utils-web demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.