-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
347 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"nuxt-admin": { | ||
"API_SERVER": "https://mockapi.eolinker.com/IeZWjzy87c204a1f7030b2a17b00f3776ce0a07a5030a1b", | ||
"API_SERVER": "https://mockapi.eolinker.com/jttjNwp60fc1c9e944fdf1cc494b28a7ca4cfe66bbafee1", | ||
"APP_ID": "1204701543597604893" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`, | ||
) |
Oops, something went wrong.