Socket
Socket
Sign inDemoInstall

@cainiaofe/cn-ui-utils

Package Overview
Dependencies
23
Maintainers
8
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @cainiaofe/cn-ui-utils

菜鸟组件沉淀的基础 utils 工具


Version published
Weekly downloads
204
increased by20.71%
Maintainers
8
Created
Weekly downloads
 

Readme

Source

菜鸟前端基础工具库

迁移 1.x 到 2.x

参考文档 https://alidocs.dingtalk.com/i/nodes/NZQYprEoWoxKPoqwCgRMvRQeV1waOeDk

使用场景

菜鸟组件的常用方法,不包含 lodash 和 ahooks

引用方式

import { isImage } from '@cainiaofe/cn-ui-utils';

使用文档

getCnEnv

基于 hostname 和 script src 判断当前菜鸟运行环境,判断规范基于菜鸟通用域名规范

import { getCnEnv } from '@cainiaofe/cn-ui-utils';

getCnEnv(cnEnvOptions: {
    /**
     * 待匹配的域名, 默认读取 window.location.hostname
     */
    hostname?: string;
    /**
     * 当前 script 的 src, 默认读取顺序
     * window.__CURRENT_SCRIPT_SRC__
     * window.document.currentScript.src
     */
    currentScriptSrc?: string;
}) => 'prod' | 'pre' | 'test' | 'daily';

isImage

通过文件路径判断是否为图片,图片后缀判断依据 image-extensions 进行

import { isImage } from '@cainiaofe/cn-ui-utils';

isImage(fileUrl: string) => boolean;

downloadFile

import { downloadFile } from '@cainiaofe/cn-ui-utils';

downloadFile(fileUrl: string) => boolean;

useGuid

生成 guid

import { useGuid } from '@cainiaofe/cn-ui-utils';

useGuid(prefix: string) => string;

Keywords

FAQs

Last updated on 28 Jul 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc