# sharegoods-ui

> a solution for Admin BU

Latest version **0.0.47** (published 2019-12-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install sharegoods-ui
pnpm add sharegoods-ui
yarn add sharegoods-ui
bun add sharegoods-ui
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.47 |
| Published | 2019-12-05 |
| First published | 2019-06-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 4.5 MB |
| Known vulnerabilities | 0 (+29 in 2 direct dependencies) |
| Install scripts | no |
| Author | Ma Jinhui |
| Maintainers | damon04, sharegoods |
| Keywords | sharegoods |

## Links

- npm: https://www.npmjs.com/package/sharegoods-ui
- Homepage: https://github.com/majinhui04/sharegoods-admin-extends#readme
- Issues: https://github.com/majinhui04/sharegoods-admin-extends/issues
- npm.io page: https://npm.io/package/sharegoods-ui

## Dependencies (4)

- [qs](https://npm.io/package/qs.md) 6.7.0
- [axios](https://npm.io/package/axios.md) 0.18.0
- [throttle-debounce](https://npm.io/package/throttle-debounce.md) 1.0.1
- [resize-observer-polyfill](https://npm.io/package/resize-observer-polyfill.md) 1.5.1

## Recent versions

- 0.0.47 (latest) — 2019-12-05
- 0.0.46 — 2019-11-20
- 0.0.45 — 2019-11-20
- 0.0.44 — 2019-11-18
- 0.0.43 — 2019-11-18
- 0.0.42 — 2019-11-18
- 0.0.41 — 2019-11-13
- 0.0.39 — 2019-10-14
- 0.0.38 — 2019-09-24
- 0.0.37 — 2019-09-24
- 0.0.36 — 2019-09-19
- 0.0.35 — 2019-09-19
- 0.0.34 — 2019-09-18
- 0.0.33 — 2019-09-12
- 0.0.31 — 2019-09-11
- … 28 more at https://npm.io/package/sharegoods-ui/versions

## README

# sharegoods-ui

![](https://www.sharegoodsmall.com/images/sglogo.png)

---

vue2 + vuex + vue-router + axios + sass + Element UI

## Feature

- 基于axios封装了http对象
- 基于Element UI封装了一些业务组件
- 基于Echarts封装了图表组件

## Install dependencies

```bash
npm install sharegoods-ui --save --registry=https://registry.npm.taobao.org

```


## Quick start
```bash

import Vue from 'vue';
import SharegoodsUI from 'sharegoods-ui';
import 'sharegoods-ui/lib/index.css';

Vue.use(SharegoodsUI);

```


## API Reference

接口定义

| 参数      | 说明          | 类型      | 可选值                           | 默认值  |
|---------- |-------------- |---------- |--------------------------------  |-------- |
| name | 接口调用函数，全局必须唯一 | - | - | - |
| path | 实际接口调用地址，支持restful | - | - | - |
| method | 接口方式 | String | `get`、`post`、`delete`、`patch`、`put` |  |
| processData | 调用接口前处理数据 | - | - | - |
| success | 调用成功后处理数据 | - | - | - |


e.g
```javascript
export default [
    {
        name: 'articleList',
        path: '/article/list',
        method: 'post',
        processData(data){
            if(data.date) {
                data.startTime = date[0];
                data.endTime = date[1];
                delete data.date;
            }
            return data;
        },
        success(response){
            response.message = '获取文章成功';
            return response;
        }
    },
    {
        name: 'articleDetail',
        path: '/article/detail/{id}',
        method: 'get'
    },
    {
        name: 'articleUpdate',
        path: '/article/update',
        method: 'put'
    },
    {
        name: 'articleCreate',
        path: '/article/create',
        method: 'post'
    }
];

```

HttpClient 参数说明

| 参数      | 说明          | 类型      | 可选值                           | 默认值  |
|---------- |-------------- |---------- |--------------------------------  |-------- |
| timeout | 超时时间 | - | - | 15000 |
| Message | 消息提醒方法 | - | - | - |
| getResponseSuccess | 接口成功判断 | - | - | - |
| transformResponse | 所有接口的接口回调函数 | - | - | - |
| getAccessToken | 设置headers参数 | - | - | - |
| handleError | 所有接口的失败回调 | - | - | - |
| handleSuccess | 所有接口的成功回调 | - | - | - |

e.g
```javascript
import HttpClient from 'sharegoods-ui/lib/utils/http/http-client';
import { Message } from 'element-ui';

Vue.use(HttpClient, {
    timeout:10000,
    Message,
    // 全局接口请求数据成功条件
    getResponseSuccess(response) {
        if ([10000].includes(response.code)) {
            return true;
        }
        return false;
    },
    transformResponse({ response, path }) {
        // 用户登录失效
        if ([10010].includes(response.code)) {
            store.dispatch('LogOut').then(() => {
                location.reload(true);
            });
        }
    },
    getAccessToken() {
        const token = getToken() || '';
        return { 'token': token };
    },
    // 全局接口请求错误的钩子
    handleError({ response, meta }) {
        if (meta && meta.isShowError) {
            Message({
                message: response.message,
                type: 'error',
                duration: 5 * 1000
            });
        }
    },
    // 全局接口请求成功的钩子
    handleSuccess({ response, meta }) {
        if (meta && meta.isShowSuccess) {
            Message({
                type: 'success',
                message: meta.message || '操作成功!'
            });
        }
    }
});

const http = Vue.http;
const API = http.httpFactory(Urls);

API.articleList({startTime:'2019-07-01',$timeout:5000},{isShowError:true}).then(res=>{
    console.log('response',res)
})

```

> 如果参数中包含`$timeout`则表明这个接口使用自定义的超时时间

---
_Source: https://npm.io/package/sharegoods-ui · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
