Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cainiaofe/cn-error-feedback

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cainiaofe/cn-error-feedback

通用错误提示组件

  • 0.1.7
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
105
decreased by-35.19%
Maintainers
0
Weekly downloads
 
Created
Source

CnErrorFeedback


通用错误反馈组件 | code 代码地址code.cone 迭代地址

何时使用

错误信息反馈提示/解决方案引导说明

API

export interface IErrorConstructInfo {
  /**
   * 基础信息
   */
  errorBaseInfo?: {
    appName?: string;
    codeKey?: string;
    codeDesc?: string;
  };
  /**
   * 异常信息
   */
  errorContentInfo?: {
    /**
     * 异常类型
     */
    typeCode?: 'permissionError' | 'operationError' | 'bizError' | 'sysError';
    /**
     * 展示模式
     */
    displayMode?: 'dialog' | 'tips';
    /**
     * 弹框title
     */
    errorTitle?: string;
    /**
     * 异常等级
     */
    errorLevel?: 'error' | 'warning';
    /**
     * 确认按钮文案(例:申请权限、立即处理)
     */
    confirmTexts?: string;
    /**
     * 确认按钮跳转链接
     */
    confirmUrl?: string;
  };
  /**
   * 解决方案
   */
  errorSolution?: {
    enableSolution?: boolean;
    /**
     * 解决方案类型
     */
    solutionType?: 'hyperlink' | 'iframe' | 'text';
    /**
     * hyperlink/iframe 文案
     */
    text?: string;
    /**
     * text 异常原因(solutionType = text)
     */
    textReason?: string;
    /**
     * text 解决方案(solutionType = text)
     */
    textSolution?: string;
    /**
     * hyperlink/iframe 填写链接
     */
    manualUrl?: string;
  };
  errorMsg?: string;
  errorCode?: string | number;
}

export interface ICnErrorFeedback {
  show: (errorConstructInfo: IErrorConstructInfo) => void;
}

CnRequest 接入示例

import CnErrorFeedback from '@alife/cn-error-feedback';

const findConstruct = (item) => (!item || 'success' in item ? item : findConstruct(item.data));

(response) => {
  try {
    const data = findConstruct(response);
    const { success, errorMsg, cndbErrorMsg, errorConstructInfo = {}, errorCode } = data;
    const { errorContentInfo } = errorConstructInfo || {};
    if (!success) {
      if (errorContentInfo) {
        // 调用信息反馈组件
        CnErrorFeedback.show({
          ...errorConstructInfo,
          errorMsg: cndbErrorMsg || errorMsg,
          errorCode,
        });
        return Promise.reject(data);
      }
    }
  } catch (error) {}
};
参考文档

Keywords

FAQs

Package last updated on 23 Sep 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc