# npm-kpocom-mis5-api

> [视频教程](https://www.bilibili.com/video/BV1EW4y1C71D)

Latest version **1.0.10** (published 2023-09-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install npm-kpocom-mis5-api
pnpm add npm-kpocom-mis5-api
yarn add npm-kpocom-mis5-api
bun add npm-kpocom-mis5-api
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.10 |
| Published | 2023-09-14 |
| First published | 2023-09-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 147.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | zofnou |
| Maintainers | zofnou |
| Keywords | kpocom, 鲲博, zofnou |

## Links

- npm: https://www.npmjs.com/package/npm-kpocom-mis5-api
- npm.io page: https://npm.io/package/npm-kpocom-mis5-api

## Recent versions

- 1.0.10 (latest) — 2023-09-14
- 1.0.9 — 2023-09-13
- 1.0.8 — 2023-09-13
- 1.0.7 — 2023-09-12
- 1.0.6 — 2023-09-11
- 1.0.3 — 2023-09-11
- 1.0.2 — 2023-09-11
- 1.0.1 — 2023-09-11
- 1.0.0 — 2023-09-11

## README

### 使用手册

[视频教程](https://www.bilibili.com/video/BV1EW4y1C71D)

1. 在源码目录下（`src`）创建 `api-services` 文件夹，并将 [https://editor.swagger.io](https://editor.swagger.io) 生成的 `typescript-axios` 代码（`.ts` 后缀文件）放入其中（**注意 `package.json` 文件中 `axios` 的版本，必须和项目保持一致，这里使用的是 `v0.21.1` 版本**）。

2. 拷贝 `Furion` 源码下的 `clients/axios_vue_react/axios-utils.ts`文件放置到 `api-services` 同级目录下，同时修改 `serveConfig` 中的配置地址为对应的服务器地址，同时**安装 `"axios": "^0.21.1"` 的包到 `package.json` 中**

3. 基本使用

- `Promise` 方式：

```ts
getAPI(SystemAPI)
  .apiGetXXXX()
  .then((res) => {
    var data = res.data.data!;
  })
  .catch((err) => {
    console.log(err);
  })
  .finally(() => {
    console.log("api request completed.");
  });
```

- `async/await` 方式：

```ts
const [err, res] = await feature(getAPI(SystemAPI).apiGetXXX());

if (err) {
  console.log(err);
} else {
  var data = res.data.data!;
}

console.log("api request completed.");
```

---

如果服务器有 API 发生改变，重新生成代码并替换 `api-services` 目录所有代码即可（**建议先删除里面所有文件后再粘贴**）

### 常见问题

在 `Vue3` 项目中启用 `TypeScript` 和 `ESlint` 后报错，只需要修改相关的 `tsconfig.json` 文件添加以下配置即可：

```json
"compilerOptions": {
    "importsNotUsedAsValues": "remove",
    "preserveValueImports": false
  }
```

在 `Angular` 项目中，可能会出现 `override` 错误问题，只需要编辑 `api-services/base.ts` 文件并添加 `override` 关键字即可，如：

> 推荐使用 [Angular 版本](../angular)

```ts
export class RequiredError extends Error {
  override name: "RequiredError" = "RequiredError";
}
```

`Swagger` 多分组处理

如果使用了`Swagger` 多分组的功能，可以升级 `Furion` 框架至 `v3.3.4` 版本，之后启用 `EnableAllGroups` 功能，如：

```json
{
  "SpecificationDocumentSettings": {
    "EnableAllGroups": true
  }
}
```

这样就会自动将所有分组的内容合并到 `All Groups` 中。





----

## 打包：

1. 初始化项目（文件夹名称一定不能有中文）

   ```cmd
   npm init -y
   ```

   **放入js、css、ts等静态文件。**

2. 查看当前源

   ```cmd
   npm config get registry
   npm config set registry https://registry.npmjs.org --切换为npm源
   npm config set registry=https://registry.npm.taobao.org/ --切换到淘宝镜像
   ```

3. 添加用户

   ```cmd
   npm adduser
   ---中间是添加用户（应该会跳转到npmjs官网去验证邮箱登录等）
   npm who am i
   ```

4. 上传自己的包

   ```cmd
   npm version patch --自动将package.json中的version版本加0.0.1
   npm publish  --打包重新上传
   ```

   ***<u>打包之前需要修改package.json中的版本号version</u>***!!!

   [npm官网查看](https://www.npmjs.com/search?q=kpocom-furion-mis5-api)


更新web项目的**<u>js</u>**引用：

```cmd
npm install
```

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