From 34713229accfe1fc3f60a5a4acd4a1ff41485517 Mon Sep 17 00:00:00 2001 From: 4Ark Date: Thu, 26 Nov 2020 14:29:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BD=BF=E7=94=A8=20services=20?= =?UTF-8?q?=E5=A4=84=E7=90=86=E8=AF=B7=E6=B1=82=20(#163)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/deploy/build.js | 2 +- bin/deploy/env.json | 2 +- docs/api.md | 77 ++++++++++++++---- template/framework-admin/store/index.js | 8 +- template/framework-base/README.md | 43 ++++++---- template/framework-base/_package.json | 2 +- template/framework-base/nuxt.config.js | 2 +- .../jest/test/unit/parseServices.test.js | 59 ++++++++++++++ template/modules/service/api/index.js | 25 ------ template/modules/service/api/serviceList.js | 17 ---- template/modules/service/plugins/api.js | 18 ---- template/modules/service/plugins/services.js | 12 +++ template/modules/service/services/basic.js | 12 +++ .../modules/service/services/common/api.js | 7 ++ .../{api => services/common}/repository.js | 51 ++++++------ template/modules/service/services/example.js | 4 + template/modules/service/services/index.js | 24 ++++++ .../modules/typescript/src/types/extend.d.ts | 8 ++ template/modules/utils/utils/index.js | 36 +++++++- test/snapshots/cypress.test.js.md | 26 +++--- test/snapshots/cypress.test.js.snap | Bin 4220 -> 4300 bytes test/snapshots/docker.test.js.md | 26 +++--- test/snapshots/docker.test.js.snap | Bin 3905 -> 4002 bytes test/snapshots/index.test.js.md | 26 +++--- test/snapshots/index.test.js.snap | Bin 3854 -> 3960 bytes test/snapshots/typescript.test.js.md | 28 ++++--- test/snapshots/typescript.test.js.snap | Bin 3986 -> 4096 bytes 27 files changed, 347 insertions(+), 168 deletions(-) create mode 100644 template/modules/jest/test/unit/parseServices.test.js delete mode 100644 template/modules/service/api/index.js delete mode 100644 template/modules/service/api/serviceList.js delete mode 100644 template/modules/service/plugins/api.js create mode 100644 template/modules/service/plugins/services.js create mode 100644 template/modules/service/services/basic.js create mode 100644 template/modules/service/services/common/api.js rename template/modules/service/{api => services/common}/repository.js (75%) create mode 100644 template/modules/service/services/example.js create mode 100644 template/modules/service/services/index.js create mode 100644 template/modules/typescript/src/types/extend.d.ts diff --git a/bin/deploy/build.js b/bin/deploy/build.js index ada04bc..517f10d 100644 --- a/bin/deploy/build.js +++ b/bin/deploy/build.js @@ -64,7 +64,7 @@ class BuildProcess { this.options = { cwd: path.join(releaseDir, templateName), env: { - API_SERVER: 'https://mockapi.eolinker.com/IeZWjzy87c204a1f7030b2a17b00f3776ce0a07a5030a1b', + API_SERVER: 'https://mockapi.eolinker.com/jttjNwp60fc1c9e944fdf1cc494b28a7ca4cfe66bbafee1', ...process.env, ...env, PUBLIC_PATH: `${process.env.PUBLIC_PATH || ''}/${this.folderName}` diff --git a/bin/deploy/env.json b/bin/deploy/env.json index 1a2108d..814f879 100644 --- a/bin/deploy/env.json +++ b/bin/deploy/env.json @@ -1,6 +1,6 @@ { "nuxt-admin": { - "API_SERVER": "https://mockapi.eolinker.com/IeZWjzy87c204a1f7030b2a17b00f3776ce0a07a5030a1b", + "API_SERVER": "https://mockapi.eolinker.com/jttjNwp60fc1c9e944fdf1cc494b28a7ca4cfe66bbafee1", "APP_ID": "1204701543597604893" } } diff --git a/docs/api.md b/docs/api.md index c1ca700..e517530 100644 --- a/docs/api.md +++ b/docs/api.md @@ -23,7 +23,7 @@ this.$axios.$post('/security/users', body) ## 使用 ```javascript -// 创建一个 API 资源,修改文件 src/api/index.js +// 创建一个 API 资源,修改文件 src/services/basis.js // 创建了一个菜单资源的 CRUD 接口方法 + export const menus = new Repository(`${DEEPEXI_CLOUD_TENANT}/${VERSION}/menus`) @@ -33,23 +33,23 @@ this.$axios.$post('/security/users', body) // 在 page 中 mounted() { // 获取资源的服务器路径 - this.$http.menus.uri() + this.$services.basis.menus.uri() // 获取所有菜单资源,返回一个列表 - this.$http.menus.list() + this.$services.basis.menus.list() // 获取某个菜单资源的详情 - this.$http.menus.detail(MENUS_ID) + this.$services.basis.menus.detail(MENUS_ID) // 创建一个菜单资源 - this.$http.menus.create(payload) + this.$services.basis.menus.create(payload) // 更新一个菜单资源 - this.$http.menus.update(MENUS_ID, payload) + this.$services.basis.menus.update(MENUS_ID, payload) // 删除一个菜单资源 - this.$http.menus.delete(MENUS_ID) + this.$services.basis.menus.delete(MENUS_ID) } // 在 store 中 export const actions = { async getMenus(store, payload) { - const data = await this.$http.menus.detail(payload) + const data = await this.$services.basis.menus.detail(payload) ... } } @@ -60,7 +60,7 @@ export const actions = { 有些时候,后端的接口并不是严格遵循 RESTful 的最佳实践,这个时候就需要自己重新实现默认的方法 ```javascript -// 在 src/api/repository.js 中增加一个类,继承 Repository +// 在 src/services/repository.js 中增加一个类,继承 Repository export class ExampleRepository extends Repository { constructor(resource, id) { super(resource) @@ -78,13 +78,58 @@ export class ExampleRepository extends Repository { } // 基于 ExampleRepository 创建一个 API -export const example = new ExampleRepository('/example/api') +export default new ExampleRepository('/example/api') // 调用 -this.$http.example.uri(appId) -this.$http.example.detail(id) -this.$http.example.list() -this.$http.example.create(payload) -this.$http.example.update(appId, payload) -this.$http.example.delete(id) +this.$services.example.uri(appId) +this.$services.example.detail(id) +this.$services.example.list() +this.$services.example.create(payload) +this.$services.example.update(appId, payload) +this.$services.example.delete(id) ``` +## 注意 + +services 会根据文件名作为 scope,将该文件 export 出去的所有值挂在这个 scope 下。 + +比如 `basic.js` +```js +export const login = new Repository(`${SECURITY_CLOUD}/${VERSION}/login`) + +export const userInfo = new Repository(`${SECURITY_CLOUD}/${VERSION}/token`) + +export const menus = new Repository(`${SECURITY_CLOUD_TENANT}/${VERSION}/menus`) + +export const subMenus = new Repository( + `${SECURITY_CLOUD_TENANT}/${VERSION}/sub-menus`, +) +``` + +就会将它们挂在 `this.$services.basic` 下: +```js +this.$services.basic.menus.list() +``` + +如果文件中有 `export default`,则会有些不同。 + +比如 `example.js`: +```js +export default new Repository(`${VERSION}/example/api`) + +// 使用 +this.$services.example.list() +``` + +如果文件中既有 `export default` 又有 `export const`: +```js +export default new Repository(`${VERSION}/example/api`) + +export const other = new Repository(`${VERSION}/example/api/other`) + +// 使用 +this.$services.example.list() +this.$services.example.other.list() +``` + +**需要注意**:导出的 `service` 名字不能与 `Repository` 的接口名字重复,接口名字列表可以在这里看到: +https://github.com/femessage/create-nuxt-app/blob/dev/template/modules/service/services/common/repository.js#L8 diff --git a/template/framework-admin/store/index.js b/template/framework-admin/store/index.js index 1e5e929..75d635e 100644 --- a/template/framework-admin/store/index.js +++ b/template/framework-admin/store/index.js @@ -104,7 +104,7 @@ export const mutations = { export const actions = { async login({commit, dispatch}, {body, redirect = '/'}) { - const userInfo = await this.$http.login.create(body) + const userInfo = await this.$services.basic.login.create(body) commit('setUserInfo', userInfo.payload) dispatch('getHeaderMenu') dispatch('getSiderMenu') @@ -114,7 +114,7 @@ export const actions = { }, async refresh({commit, dispatch}, token) { - const userInfo = await this.$http.userInfo.list({ + const userInfo = await this.$services.basic.userInfo.list({ params: { token, }, @@ -125,7 +125,7 @@ export const actions = { }, async getHeaderMenu({commit}) { - const menus = await this.$http.menus.list({ + const menus = await this.$services.basic.menus.list({ params: { appId: process.env.APP_ID, }, @@ -134,7 +134,7 @@ export const actions = { }, async getSiderMenu({commit}) { - const menus = await this.$http.subMenus.list({ + const menus = await this.$services.basic.subMenus.list({ params: { appId: process.env.APP_ID, }, diff --git a/template/framework-base/README.md b/template/framework-base/README.md index 95b04e1..30dcbb0 100644 --- a/template/framework-base/README.md +++ b/template/framework-base/README.md @@ -74,10 +74,13 @@ yarn generate ├── nuxt.config.js 框架配置文件 ├── package.json ├── src 开发目录 -│   ├── api api 资源管理 -│   │   ├── index.js 统一入口,定义 RESTful API 资源 -│   │   ├── repository.js RESTful 生成类,可以继承实现满足业务需求 -│   │   └── serverList.js 统一管理服务路径和 API version +│   ├── services api 资源管理 +│   │   ├── common service 公用的类库、BASE URL 定义等 +│   │   │   ├── api.js 统一管理服务路径和 API version +│   │   │   └── repository.js RESTful 生成类,可以继承实现满足业务需求 +│   │   ├── basic.js 一些基本的 services +│   │   ├── example.js 一个 example 的 service +│   │   └── index.js 统一入口,会导出所有 services │   ├── assets 资源,包括样式文件与图片 │   │   ├── global.less 全局样式类 │   │   └── var.less 样式变量,支持less变量自动引入,即不用在less中import就能直接使用变量 @@ -130,28 +133,32 @@ Nuxt.js 会依据 `pages` 目录中的所有 `*.vue` 文件生成应用的路由 [推荐使用 service 层管理 API:](https://github.com/FEMessage/create-nuxt-app/blob/dev/docs/api.md) -1. 在 `api/index.js` 中定义一个 API +1. 在 `services` 中定义一个 API +在 `src/services` 下新建一个 `example.js` ```js -// 创建了一个菜单资源的 RESTful API -export const menus = new Repository(`${SERVICE}/${VERSION}/menus`) +// 创建了一个 example 的 RESTful API +import {Repository} from './common/repository' +import {VERSION} from './common/api' + +export default new Repository(`${VERSION}/example/api`) ``` 2. 在 `*.vue`、`store/*.js` 的 `actions` 都可以调用 ```js // 获取资源的服务器路径 -this.$http.menus.uri() -// 获取所有菜单资源,返回一个列表 -this.$http.menus.list() -// 获取某个菜单资源的详情 -this.$http.menus.detail(MENUS_ID) -// 创建一个菜单资源 -this.$http.menus.create(payload) -// 更新一个菜单资源 -this.$http.menus.update(MENUS_ID, payload) -// 删除一个菜单资源 -this.$http.menus.delete(MENUS_ID) +this.$services.example.uri() +// 获取所有资源,返回一个列表 +this.$services.example.list() +// 获取某个资源的详情 +this.$services.example.detail(ID) +// 创建一个资源 +this.$services.example.create(payload) +// 更新一个资源 +this.$services.example.update(ID, payload) +// 删除一个资源 +this.$services.example.delete(ID) ``` 3. 如果接口是非标准的 RESTful API 可以参考此[文档](https://github.com/FEMessage/create-nuxt-app/blob/dev/docs/api.md#%E8%BF%9B%E9%98%B6) diff --git a/template/framework-base/_package.json b/template/framework-base/_package.json index 32bb517..83ad6e9 100644 --- a/template/framework-base/_package.json +++ b/template/framework-base/_package.json @@ -57,7 +57,7 @@ "eslint-config-prettier": "6.15.0", "eslint-friendly-formatter": "4.0.1", "eslint-plugin-jest": "24.1.3", - "eslint-plugin-nuxt": "^1.0.0", + "eslint-plugin-nuxt": "1.0.0", "eslint-plugin-prettier": "3.1.4", "github-release-notes": "0.17.1", "husky": "1.3.1", diff --git a/template/framework-base/nuxt.config.js b/template/framework-base/nuxt.config.js index 9dd3098..bc60cbd 100644 --- a/template/framework-base/nuxt.config.js +++ b/template/framework-base/nuxt.config.js @@ -233,7 +233,7 @@ module.exports = { plugins: [ {src: '~plugins/axios'}, {src: '~plugins/filters'}, - {src: '~plugins/api'}, + {src: '~plugins/services'}, <%_ if (template === 'mobile') { _%> {src: '~plugins/vant'}, <%_ } else { _%> diff --git a/template/modules/jest/test/unit/parseServices.test.js b/template/modules/jest/test/unit/parseServices.test.js new file mode 100644 index 0000000..ddd6c75 --- /dev/null +++ b/template/modules/jest/test/unit/parseServices.test.js @@ -0,0 +1,59 @@ +const {parseServices} = require('@/utils') +import {Repository} from '@/services/common/repository' + +const moackAxios = { + $get() {}, + $post() {}, + $put() {}, + $delete() {}, +} + +describe('测试 utils.parseServices 函数', () => { + test('普通处理 scope', () => { + const serviceModules = { + basis: { + login: new Repository('login'), + menus: new Repository('menus'), + subMenus: new Repository('subMenus'), + token: new Repository('token'), + }, + } + const expected = { + basis: { + login: serviceModules.basis.login.init(moackAxios), + menus: serviceModules.basis.menus.init(moackAxios), + subMenus: serviceModules.basis.subMenus.init(moackAxios), + token: serviceModules.basis.token.init(moackAxios), + }, + } + expect(parseServices(serviceModules, moackAxios)).toMatchObject(expected) + }) + + test('正常处理导出 default 时直接挂在 scope', () => { + const serviceModules = { + example: { + default: new Repository('example'), + }, + } + const expected = { + example: serviceModules.example.default.init(moackAxios), + } + expect(parseServices(serviceModules, moackAxios)).toMatchObject(expected) + }) + + test('正常处理同时导出 default 和 const', () => { + const serviceModules = { + example: { + default: new Repository('example'), + other: new Repository('example/other'), + }, + } + const expected = { + example: { + ...serviceModules.example.default.init(moackAxios), + other: serviceModules.example.other.init(moackAxios), + }, + } + expect(parseServices(serviceModules, moackAxios)).toMatchObject(expected) + }) +}) diff --git a/template/modules/service/api/index.js b/template/modules/service/api/index.js deleted file mode 100644 index 5d064d0..0000000 --- a/template/modules/service/api/index.js +++ /dev/null @@ -1,25 +0,0 @@ -/* - * @Author: Han - * @Date: 2020-01-14 11:43:00 - * @Last Modified by: Han - * @Last Modified time: 2020-02-18 17:36:32 - * @Description 项目接口统一定义入口,定义后可以直接通过 this.$http.login.create 的方式调用接口 - * 所有需要使用的定义都要 export - */ - -// import {ExampleRepository} from './repository' -import {Repository} from './repository' -import {VERSION, SECURITY_CLOUD, SECURITY_CLOUD_TENANT} from './serviceList' - -export const login = new Repository(`${SECURITY_CLOUD}/${VERSION}/login`) - -export const userInfo = new Repository(`${SECURITY_CLOUD}/${VERSION}/token`) - -export const menus = new Repository(`${SECURITY_CLOUD_TENANT}/${VERSION}/menus`) - -export const subMenus = new Repository( - `${SECURITY_CLOUD_TENANT}/${VERSION}/sub-menus`, -) - -// 重新定义请求方法的例子 -// export const example = new ExampleRepository('/example/api') diff --git a/template/modules/service/api/serviceList.js b/template/modules/service/api/serviceList.js deleted file mode 100644 index ac8e94d..0000000 --- a/template/modules/service/api/serviceList.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * @Author: Han - * @Date: 2020-01-13 18:08:25 - * @Last Modified by: Han - * @Last Modified time: 2020-02-18 17:33:53 - * @Description 如果服务很多,可以将服务 API 的公共部分抽离出来 - * @Example /security/api/v1/login, /security/api/v1/token - * 将 /security/api 抽离后,如果服务路径更改只需要改动此处 - */ - -export const VERSION = 'v1' - -// security 接口服务 -export const SECURITY_CLOUD = '/security/api' - -// security 租户接口服务 -export const SECURITY_CLOUD_TENANT = '/security/tenant/api' diff --git a/template/modules/service/plugins/api.js b/template/modules/service/plugins/api.js deleted file mode 100644 index bc6d8da..0000000 --- a/template/modules/service/plugins/api.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - * @Author: Han - * @Date: 2020-01-14 10:57:11 - * @Last Modified by: Han - * @Last Modified time: 2020-02-17 16:49:55 - * @Description 将 @/api/index.js 中的 api 注入到 nuxt 上下文中 - * @Example 在 nuxt 的 pages 中以 this.$http[`${api_resource_name}`] 的方式调用对的 CRUD 方法 - * 详情查看 '../api/repository.js' - */ -import * as api from '@/api' - -export default (ctx, inject) => { - const http = {} - Object.keys(api).forEach(key => { - http[key] = api[key].init(ctx.$axios) - }) - inject('http', http) -} diff --git a/template/modules/service/plugins/services.js b/template/modules/service/plugins/services.js new file mode 100644 index 0000000..38c4ff9 --- /dev/null +++ b/template/modules/service/plugins/services.js @@ -0,0 +1,12 @@ +/** + * @see https://github.com/FEMessage/create-nuxt-app/blob/dev/docs/api.md + */ + +import modules from '~/services' +import {parseServices} from '~/utils' + +export default (ctx, inject) => { + const services = parseServices(modules, ctx.$axios) + + inject('services', services) +} diff --git a/template/modules/service/services/basic.js b/template/modules/service/services/basic.js new file mode 100644 index 0000000..89643a0 --- /dev/null +++ b/template/modules/service/services/basic.js @@ -0,0 +1,12 @@ +import {Repository} from './common/repository' +import {VERSION, SECURITY_CLOUD, SECURITY_CLOUD_TENANT} from './common/api' + +export const login = new Repository(`${SECURITY_CLOUD}/${VERSION}/login`) + +export const userInfo = new Repository(`${SECURITY_CLOUD}/${VERSION}/token`) + +export const menus = new Repository(`${SECURITY_CLOUD_TENANT}/${VERSION}/menus`) + +export const subMenus = new Repository( + `${SECURITY_CLOUD_TENANT}/${VERSION}/sub-menus`, +) diff --git a/template/modules/service/services/common/api.js b/template/modules/service/services/common/api.js new file mode 100644 index 0000000..e0c213d --- /dev/null +++ b/template/modules/service/services/common/api.js @@ -0,0 +1,7 @@ +export const VERSION = 'v1' + +// security 接口服务 +export const SECURITY_CLOUD = '/security/api' + +// security 租户接口服务 +export const SECURITY_CLOUD_TENANT = '/security/tenant/api' diff --git a/template/modules/service/api/repository.js b/template/modules/service/services/common/repository.js similarity index 75% rename from template/modules/service/api/repository.js rename to template/modules/service/services/common/repository.js index e75dcf5..f2d8952 100644 --- a/template/modules/service/api/repository.js +++ b/template/modules/service/services/common/repository.js @@ -1,10 +1,3 @@ -/* - * @Author: Han - * @Date: 2020-01-13 17:22:51 - * @Last Modified by: Han - * @Last Modified time: 2020-02-17 16:49:38 - */ - const RepositoryInterface = { URI: 'uri', CREATE: 'create', @@ -28,6 +21,9 @@ export class Repository { */ constructor(resource) { this.resource = resource + + this.$axios = null + this.methods = null } /** @@ -111,25 +107,30 @@ export class Repository { * @memberof Repository */ init($axios) { - // bind this 是为了继承 Repository 的属性方法,方便扩展 - return { - [RepositoryInterface.URI]: this[RepositoryInterface.URI].bind(this), - [RepositoryInterface.CREATE]: this[RepositoryInterface.CREATE]( - $axios, - ).bind(this), - [RepositoryInterface.DETAIL]: this[RepositoryInterface.DETAIL]( - $axios, - ).bind(this), - [RepositoryInterface.LIST]: this[RepositoryInterface.LIST]($axios).bind( - this, - ), - [RepositoryInterface.DELETE]: this[RepositoryInterface.DELETE]( - $axios, - ).bind(this), - [RepositoryInterface.UPDATE]: this[RepositoryInterface.UPDATE]( - $axios, - ).bind(this), + // 确保多次 init 且传入相同的 axios 实例时返回相同的引用 + if (!this.methods && this.$axios !== $axios) { + // bind this 是为了继承 Repository 的属性方法,方便扩展 + this.methods = { + [RepositoryInterface.URI]: this[RepositoryInterface.URI].bind(this), + [RepositoryInterface.CREATE]: this[RepositoryInterface.CREATE]( + $axios, + ).bind(this), + [RepositoryInterface.DETAIL]: this[RepositoryInterface.DETAIL]( + $axios, + ).bind(this), + [RepositoryInterface.LIST]: this[RepositoryInterface.LIST]($axios).bind( + this, + ), + [RepositoryInterface.DELETE]: this[RepositoryInterface.DELETE]( + $axios, + ).bind(this), + [RepositoryInterface.UPDATE]: this[RepositoryInterface.UPDATE]( + $axios, + ).bind(this), + } } + + return this.methods } } diff --git a/template/modules/service/services/example.js b/template/modules/service/services/example.js new file mode 100644 index 0000000..2670e54 --- /dev/null +++ b/template/modules/service/services/example.js @@ -0,0 +1,4 @@ +import {ExampleRepository} from './common/repository' +import {VERSION} from './common/api' + +export default new ExampleRepository(`${VERSION}/example/api`) diff --git a/template/modules/service/services/index.js b/template/modules/service/services/index.js new file mode 100644 index 0000000..c658940 --- /dev/null +++ b/template/modules/service/services/index.js @@ -0,0 +1,24 @@ +/** + * 将 @/services 第一层 .js|.ts 文件中的所有 service 导出去 + * 一个业务模块的 service 应该单独一个文件 + */ +const serviceModules = require.context('./', false, /\.js|.ts$/) + +/** + * 使用文件名作为 scope,然后将该文件的所有导出内容挂在这个 scope 下 + * 就如 basis.js 导出了 login、menus 等,就会变成 servers.basis.login 这样 + * 另外需要注意的是 export default 时 default 会作为 key + * 关于如何处理该数据可以看 src/plugins/services.js + */ +export default serviceModules + .keys() + .filter(key => key !== './index.js') // 排除当前文件 + .reduce((services, path) => { + // set './app.js' => 'app' + const moduleName = path.replace(/^\.\/(.*)\.\w+$/, '$1') + const modules = serviceModules(path) + + services[moduleName] = modules + + return services + }, {}) diff --git a/template/modules/typescript/src/types/extend.d.ts b/template/modules/typescript/src/types/extend.d.ts new file mode 100644 index 0000000..c4225a5 --- /dev/null +++ b/template/modules/typescript/src/types/extend.d.ts @@ -0,0 +1,8 @@ +// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars +import Vue from 'vue' + +declare module 'vue/types/vue' { + interface Vue { + readonly $services: any + } +} diff --git a/template/modules/utils/utils/index.js b/template/modules/utils/utils/index.js index 2f323da..af9a407 100644 --- a/template/modules/utils/utils/index.js +++ b/template/modules/utils/utils/index.js @@ -1,3 +1,12 @@ +const RepositoryInterface = { + URI: 'uri', + CREATE: 'create', + LIST: 'list', + DETAIL: 'detail', + UPDATE: 'update', + DELETE: 'delete', +} + function getRouterBase(href = '') { if (!href || typeof href !== 'string') { return '/' @@ -14,12 +23,37 @@ function getRouterBase(href = '') { const routeBase = pathname .split('/') - .filter((p) => !/\./g.test(p)) + .filter(p => !/\./g.test(p)) .join('/') return routeBase.endsWith('/') ? routeBase : routeBase + '/' } +function parseServices(serviceModules, axios) { + const services = {} + Object.keys(serviceModules).forEach(scope => { + services[scope] = {} + + Object.keys(serviceModules[scope]).forEach(key => { + // 将 export default 直接挂在 scope 下 + if (key === 'default') { + services[scope] = serviceModules[scope].default.init(axios) + } + + if (Object.values(RepositoryInterface).includes(key)) { + throw new Error( + `Service 名字「${scope}.${key}」与 Repository 接口名字冲突`, + ) + } + + services[scope][key] = serviceModules[scope][key].init(axios) + }) + }) + + return services +} + module.exports = { getRouterBase, + parseServices, } diff --git a/test/snapshots/cypress.test.js.md b/test/snapshots/cypress.test.js.md index 1c7877b..a6b4a1a 100644 --- a/test/snapshots/cypress.test.js.md +++ b/test/snapshots/cypress.test.js.md @@ -26,9 +26,6 @@ Generated by [AVA](https://ava.li). 'jsconfig.json', 'nuxt.config.js', 'package.json', - 'src/api/index.js', - 'src/api/repository.js', - 'src/api/serviceList.js', 'src/assets/README.md', 'src/assets/export.less', 'src/assets/global.less', @@ -71,12 +68,17 @@ Generated by [AVA](https://ava.li). 'src/pages/index.vue', 'src/pages/login.vue', 'src/plugins/README.md', - 'src/plugins/api.js', 'src/plugins/axios.js', 'src/plugins/element.js', 'src/plugins/filters.js', 'src/plugins/icon-font.js', + 'src/plugins/services.js', 'src/plugins/svg-icon.js', + 'src/services/basic.js', + 'src/services/common/api.js', + 'src/services/common/repository.js', + 'src/services/example.js', + 'src/services/index.js', 'src/static/README.md', 'src/static/favicon.ico', 'src/static/icon.png', @@ -96,6 +98,7 @@ Generated by [AVA](https://ava.li). 'test/unit/.eslintrc.js', 'test/unit/filters.test.js', 'test/unit/getRouterBase.test.js', + 'test/unit/parseServices.test.js', ] > package.json @@ -142,7 +145,7 @@ Generated by [AVA](https://ava.li). 'eslint-config-prettier': '6.15.0', 'eslint-friendly-formatter': '4.0.1', 'eslint-plugin-jest': '24.1.3', - 'eslint-plugin-nuxt': '^1.0.0', + 'eslint-plugin-nuxt': '1.0.0', 'eslint-plugin-prettier': '3.1.4', 'github-release-notes': '0.17.1', husky: '1.3.1', @@ -228,9 +231,6 @@ Generated by [AVA](https://ava.li). 'nuxt.config.js', 'package.json', 'postcss.config.js', - 'src/api/index.js', - 'src/api/repository.js', - 'src/api/serviceList.js', 'src/assets/README.md', 'src/assets/global.less', 'src/assets/icon.png', @@ -261,11 +261,16 @@ Generated by [AVA](https://ava.li). 'src/pages/my.vue', 'src/pages/order-list.vue', 'src/plugins/README.md', - 'src/plugins/api.js', 'src/plugins/axios.js', 'src/plugins/filters.js', 'src/plugins/icon-font.js', + 'src/plugins/services.js', 'src/plugins/vant.js', + 'src/services/basic.js', + 'src/services/common/api.js', + 'src/services/common/repository.js', + 'src/services/example.js', + 'src/services/index.js', 'src/static/README.md', 'src/static/favicon.ico', 'src/static/icon.png', @@ -284,6 +289,7 @@ Generated by [AVA](https://ava.li). 'test/unit/.eslintrc.js', 'test/unit/filters.test.js', 'test/unit/getRouterBase.test.js', + 'test/unit/parseServices.test.js', ] > package.json @@ -332,7 +338,7 @@ Generated by [AVA](https://ava.li). 'eslint-friendly-formatter': '4.0.1', 'eslint-plugin-cypress': '^2.11.2', 'eslint-plugin-jest': '24.1.3', - 'eslint-plugin-nuxt': '^1.0.0', + 'eslint-plugin-nuxt': '1.0.0', 'eslint-plugin-prettier': '3.1.4', 'github-release-notes': '0.17.1', husky: '1.3.1', diff --git a/test/snapshots/cypress.test.js.snap b/test/snapshots/cypress.test.js.snap index ac7fc6b52d8137a082d4dac7e8ce5df816a1cc9c..ba8f4f9e0052d81338790fba947755fd11039047 100644 GIT binary patch literal 4300 zcmV;-5Hs&VRzVYg6U=CaW?+5=4`q~K@2ls#n!QAv3@R?*LDO zZ-e0;LMFiPfd{~2;9tOx!M0xH1s(!Vfp35fXw_Lz0&fG)fK`c(p+x(PY09-kBKR$t zOp-(oN!&&feNeQJ)o7kX`%t1Qos)BlX6F5bL?TG(Pb&r0Hq5-CFQ~;Jxg|*MODmS9 z>b99rFIhoqYmnNLE~>U#)D2S!(%OQw0Vhq9b5dSS*GgKD-p<6Diq7TR5vJ+o5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z2YU7CB&Xvos+Uf3hPhwkbds}Tm5tI#-oU<>Tz2Uso13MRJYFxIPP$kBK4zPEtE8NEo70LZuXTW z9>$4Y^<2uxO9RO%BWvoVjPzU%DI-^sH~!xxZybU{-wGZA&&Vn1@#KwHAoqwIK>z@1H&s6X diff --git a/test/snapshots/docker.test.js.md b/test/snapshots/docker.test.js.md index f3eac4c..95b9682 100644 --- a/test/snapshots/docker.test.js.md +++ b/test/snapshots/docker.test.js.md @@ -26,9 +26,6 @@ Generated by [AVA](https://ava.li). 'jsconfig.json', 'nuxt.config.js', 'package.json', - 'src/api/index.js', - 'src/api/repository.js', - 'src/api/serviceList.js', 'src/assets/README.md', 'src/assets/export.less', 'src/assets/global.less', @@ -71,12 +68,17 @@ Generated by [AVA](https://ava.li). 'src/pages/index.vue', 'src/pages/login.vue', 'src/plugins/README.md', - 'src/plugins/api.js', 'src/plugins/axios.js', 'src/plugins/element.js', 'src/plugins/filters.js', 'src/plugins/icon-font.js', + 'src/plugins/services.js', 'src/plugins/svg-icon.js', + 'src/services/basic.js', + 'src/services/common/api.js', + 'src/services/common/repository.js', + 'src/services/example.js', + 'src/services/index.js', 'src/static/README.md', 'src/static/favicon.ico', 'src/static/icon.png', @@ -87,6 +89,7 @@ Generated by [AVA](https://ava.li). 'test/unit/.eslintrc.js', 'test/unit/filters.test.js', 'test/unit/getRouterBase.test.js', + 'test/unit/parseServices.test.js', ] > package.json @@ -133,7 +136,7 @@ Generated by [AVA](https://ava.li). 'eslint-config-prettier': '6.15.0', 'eslint-friendly-formatter': '4.0.1', 'eslint-plugin-jest': '24.1.3', - 'eslint-plugin-nuxt': '^1.0.0', + 'eslint-plugin-nuxt': '1.0.0', 'eslint-plugin-prettier': '3.1.4', 'github-release-notes': '0.17.1', husky: '1.3.1', @@ -220,9 +223,6 @@ Generated by [AVA](https://ava.li). 'nuxt.config.js', 'package.json', 'postcss.config.js', - 'src/api/index.js', - 'src/api/repository.js', - 'src/api/serviceList.js', 'src/assets/README.md', 'src/assets/global.less', 'src/assets/icon.png', @@ -253,11 +253,16 @@ Generated by [AVA](https://ava.li). 'src/pages/my.vue', 'src/pages/order-list.vue', 'src/plugins/README.md', - 'src/plugins/api.js', 'src/plugins/axios.js', 'src/plugins/filters.js', 'src/plugins/icon-font.js', + 'src/plugins/services.js', 'src/plugins/vant.js', + 'src/services/basic.js', + 'src/services/common/api.js', + 'src/services/common/repository.js', + 'src/services/example.js', + 'src/services/index.js', 'src/static/README.md', 'src/static/favicon.ico', 'src/static/icon.png', @@ -267,6 +272,7 @@ Generated by [AVA](https://ava.li). 'test/unit/.eslintrc.js', 'test/unit/filters.test.js', 'test/unit/getRouterBase.test.js', + 'test/unit/parseServices.test.js', ] > package.json @@ -313,7 +319,7 @@ Generated by [AVA](https://ava.li). 'eslint-config-prettier': '6.15.0', 'eslint-friendly-formatter': '4.0.1', 'eslint-plugin-jest': '24.1.3', - 'eslint-plugin-nuxt': '^1.0.0', + 'eslint-plugin-nuxt': '1.0.0', 'eslint-plugin-prettier': '3.1.4', 'github-release-notes': '0.17.1', husky: '1.3.1', diff --git a/test/snapshots/docker.test.js.snap b/test/snapshots/docker.test.js.snap index 8671acefe122d27ae3806a1bafdf1ca429ec3498..41bf05159b11840019a8b28ae4a61ad330100c6f 100644 GIT binary patch literal 4002 zcmV;T4_)v*j^iqZS0x7y@&5?Z0F84#Te`}Hc225oY~#~?ag_1W|^5? z-x?xbr7c8hP?V}_8?~ZMNE!l2ZG`}(Bs8jkC=V$KM3E3s)QBXlLZXmV5K;9zumAl2 z|C!xINfRl=Mj!jQ|M&Nw|NHg(9g`%fLpr^C#|v}v_ilQt_N%|R*y$hZkla5r13oWp zl%y?} z*TD}#8XwpO4uOw=+rWe18Stw6@lHwF1m-{)d;lB9r}!TsQ0!GD2OU6OPV zsNj#m!{EE1w_B2O;6`vScm%uv-UgdcX&RBIrR2u1s~0rn=@VOKqf5;ZK=NMoRTdsl!rg5Q+|I zRjN};b&aNam4aFzx>XDkQmHUyNFgQ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LJ z8C(w@0&jqBTthDe9|KW+I*KPApXUR^Xla#NhNt1E=Ok16`*-8hH19 zG;sP8fC>Tsub%+CTkL#x-r83zGjF>t+;UcbsomGB|3~)!+u` package.json @@ -132,7 +135,7 @@ Generated by [AVA](https://ava.li). 'eslint-config-prettier': '6.15.0', 'eslint-friendly-formatter': '4.0.1', 'eslint-plugin-jest': '24.1.3', - 'eslint-plugin-nuxt': '^1.0.0', + 'eslint-plugin-nuxt': '1.0.0', 'eslint-plugin-prettier': '3.1.4', 'github-release-notes': '0.17.1', husky: '1.3.1', @@ -217,9 +220,6 @@ Generated by [AVA](https://ava.li). 'nuxt.config.js', 'package.json', 'postcss.config.js', - 'src/api/index.js', - 'src/api/repository.js', - 'src/api/serviceList.js', 'src/assets/README.md', 'src/assets/global.less', 'src/assets/icon.png', @@ -250,11 +250,16 @@ Generated by [AVA](https://ava.li). 'src/pages/my.vue', 'src/pages/order-list.vue', 'src/plugins/README.md', - 'src/plugins/api.js', 'src/plugins/axios.js', 'src/plugins/filters.js', 'src/plugins/icon-font.js', + 'src/plugins/services.js', 'src/plugins/vant.js', + 'src/services/basic.js', + 'src/services/common/api.js', + 'src/services/common/repository.js', + 'src/services/example.js', + 'src/services/index.js', 'src/static/README.md', 'src/static/favicon.ico', 'src/static/icon.png', @@ -264,6 +269,7 @@ Generated by [AVA](https://ava.li). 'test/unit/.eslintrc.js', 'test/unit/filters.test.js', 'test/unit/getRouterBase.test.js', + 'test/unit/parseServices.test.js', ] > package.json @@ -310,7 +316,7 @@ Generated by [AVA](https://ava.li). 'eslint-config-prettier': '6.15.0', 'eslint-friendly-formatter': '4.0.1', 'eslint-plugin-jest': '24.1.3', - 'eslint-plugin-nuxt': '^1.0.0', + 'eslint-plugin-nuxt': '1.0.0', 'eslint-plugin-prettier': '3.1.4', 'github-release-notes': '0.17.1', husky: '1.3.1', diff --git a/test/snapshots/index.test.js.snap b/test/snapshots/index.test.js.snap index fe6248488409259b53957c3d045d803a86e9ec5c..a352ade4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C6#wsRdfWBBds1q(%B!@;|X0<0u{Nf7b9xKZyl8 zhml&PoM-#tL&yfL=9N+hw5C@|-OuHMGHohyHe(j^Y44-ty!v8Vlp3K+D+h**rHWQ) zq}NKV(D{NoXGm#`sz^8V-!fSjbFE#)WKC4cHm~SK37brwRWGTeHXXM@vgI_Z?x|Eg z3+F?@L#Afw0#RGaNv`D+<&xHPhN)3n*%@9IArYM6<=ilb#KxHjhs?4k&K8Y&qX|Kp zH?l=dk-`xxYeaY^FdMOoTRJKl)fYy}(weLvi8M@W`PourewA(0n%;CTH$JL+(|z2E zRN0$ORniH)-p{Qv6};&IZcut6Ig>Gpy5r_4T9&Q%U=?u=^P|9ushQdn78_zd=)N@?*FO@bR&_vu)n^Qn+?_c^^5o( zC@bmm7YHxrDpJW~-^LZNvd6xi>xK#*`z3-X(qrGjb%G~y_e!ShJ0mpW$>>r}6YazA zqP45;!|$dmcTFFD54}jAbw2!(PtS+%{p3FU7c2Sj_afoJ^1bm)EgxQTE|4{R`0hOr z><71i6W{}o#4Yn0a0_?>{2iQ!8|DG~*z9+LpV#u^UxeTl@NR8CzO9pxIM@Te0#1UR(+D{RPJ)lYzAi%U zK5P8=colP9(cF89bF|jzJJ)FcdjTKj7*dky%yW~mKq4b&agpv;Clza0`Jc}J066FA zpPiomymOxZXV=p|=g?OP_&m-w&`5N!2~tN(5VSATZ=oU4D%)jx||{p}dgyTPsC>DsRT2aueu z~!`21$@NL!}UA>0L9a5=Kufz diff --git a/test/snapshots/typescript.test.js.md b/test/snapshots/typescript.test.js.md index b710147..6b2c241 100644 --- a/test/snapshots/typescript.test.js.md +++ b/test/snapshots/typescript.test.js.md @@ -24,9 +24,6 @@ Generated by [AVA](https://ava.li). 'jest.config.js', 'nuxt.config.js', 'package.json', - 'src/api/index.js', - 'src/api/repository.js', - 'src/api/serviceList.js', 'src/assets/README.md', 'src/assets/export.less', 'src/assets/global.less', @@ -69,24 +66,31 @@ Generated by [AVA](https://ava.li). 'src/pages/index.vue', 'src/pages/login.vue', 'src/plugins/README.md', - 'src/plugins/api.js', 'src/plugins/axios.js', 'src/plugins/element.js', 'src/plugins/filters.js', 'src/plugins/icon-font.js', + 'src/plugins/services.js', 'src/plugins/svg-icon.js', + 'src/services/basic.js', + 'src/services/common/api.js', + 'src/services/common/repository.js', + 'src/services/example.js', + 'src/services/index.js', 'src/static/README.md', 'src/static/favicon.ico', 'src/static/icon.png', 'src/store/README.md', 'src/store/bread.js', 'src/store/index.js', + 'src/types/extend.d.ts', 'src/types/tsx-shim.d.ts', 'src/types/vue-shim.d.ts', 'src/utils/index.js', 'test/unit/.eslintrc.js', 'test/unit/filters.test.js', 'test/unit/getRouterBase.test.js', + 'test/unit/parseServices.test.js', 'tsconfig.json', ] @@ -133,7 +137,7 @@ Generated by [AVA](https://ava.li). 'eslint-config-prettier': '6.15.0', 'eslint-friendly-formatter': '4.0.1', 'eslint-plugin-jest': '24.1.3', - 'eslint-plugin-nuxt': '^1.0.0', + 'eslint-plugin-nuxt': '1.0.0', 'eslint-plugin-prettier': '3.1.4', 'github-release-notes': '0.17.1', husky: '1.3.1', @@ -217,9 +221,6 @@ Generated by [AVA](https://ava.li). 'nuxt.config.js', 'package.json', 'postcss.config.js', - 'src/api/index.js', - 'src/api/repository.js', - 'src/api/serviceList.js', 'src/assets/README.md', 'src/assets/global.less', 'src/assets/icon.png', @@ -250,22 +251,29 @@ Generated by [AVA](https://ava.li). 'src/pages/my.vue', 'src/pages/order-list.vue', 'src/plugins/README.md', - 'src/plugins/api.js', 'src/plugins/axios.js', 'src/plugins/filters.js', 'src/plugins/icon-font.js', + 'src/plugins/services.js', 'src/plugins/vant.js', + 'src/services/basic.js', + 'src/services/common/api.js', + 'src/services/common/repository.js', + 'src/services/example.js', + 'src/services/index.js', 'src/static/README.md', 'src/static/favicon.ico', 'src/static/icon.png', 'src/store/README.md', 'src/store/index.js', + 'src/types/extend.d.ts', 'src/types/tsx-shim.d.ts', 'src/types/vue-shim.d.ts', 'src/utils/index.js', 'test/unit/.eslintrc.js', 'test/unit/filters.test.js', 'test/unit/getRouterBase.test.js', + 'test/unit/parseServices.test.js', 'tsconfig.json', ] @@ -316,7 +324,7 @@ Generated by [AVA](https://ava.li). 'eslint-config-prettier': '6.15.0', 'eslint-friendly-formatter': '4.0.1', 'eslint-plugin-jest': '24.1.3', - 'eslint-plugin-nuxt': '^1.0.0', + 'eslint-plugin-nuxt': '1.0.0', 'eslint-plugin-prettier': '3.1.4', 'github-release-notes': '0.17.1', husky: '1.3.1', diff --git a/test/snapshots/typescript.test.js.snap b/test/snapshots/typescript.test.js.snap index d9debcba3b0f632346e659caefc1f09947926317..13d0c92b293a939d22714cfc0c0a78a39baa9600 100644 GIT binary patch literal 4096 zcmV+b5dZH%RzV%MZsI`#?vmf` zFz^4pddK%(y;t9NP!NO$;rPI&XLgFexa#kv*G{jn=M6Oo&Yw?oc-*^65Z0_4>_2tc z7r(sw)`Q&#Z(RLYgZtZ82Rv@LKoA;*R@W-gmbh?RLJ)R=tH3Gn3GhwuGw>JCi3jw9 zeIN@y0PX^hgEOGLQ4j{fW#D@7W$*-e1*~rpgk#_qa36RMv^1kWa51pJr@&9Zt6)uw zARGcE@M-WUI0NRRx#QrS;0ACP_%V1HtZYNuKoOh<4}urK@^(Sk15SdEg71LmLE}6@ z*a!}TS@2o#eefr+7$dkJRKS8nOK+lir)f%+L?ZYpnM?|ac|u~Zkm!V>L0Fh*6cWw7 ziMDiB$|{S;xi6;sruvY187DU&7D9^j0aIAyTS zSsJJpb85}V8?qw2J54Kp+aRhBhn zRx*`nYu5(KWt>tfp#hdX_j?ClJjKMLEf2Msg$5 z2~U$Z4A~N8JWX56l|zhA2TDsZ%W6)ctIV(i z=L^dcQ`<1p*`SuetYoS5yKID+RU&gQCba9+_B%4Ce`6ERWd zq(V_sDB;%l=6X&O%Epx$;#TAjcOYy#0cT-QQ-wl<4U%wMF)10 z44I9y!(d5Q?ZLP+)lTxh4RwLjJHMf%y8`LzP?}flW7tgCm>wVZ_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