Skip to content
This repository was archived by the owner on Mar 8, 2025. It is now read-only.

Commit 1bed769

Browse files
committed
✨ Change naming convention
1 parent 73aa7d6 commit 1bed769

File tree

14 files changed

+69
-147
lines changed

14 files changed

+69
-147
lines changed

aliases.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const aliases = {
2020
'@middleware': 'src/core/middleware',
2121
'@mixins': 'src/core/mixins',
2222
'@plugins': 'src/core/plugins',
23-
'@services': 'src/core/services',
23+
'@apis': 'src/core/apis',
2424
'@utils': 'src/core/utils',
2525
}
2626

jsconfig.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@
120120
"src/core/plugins/index.scss",
121121
"src/core/plugins/index.css"
122122
],
123-
"@services/*": ["src/core/services/*"],
124-
"@services": [
125-
"src/core/services/index.js",
126-
"src/core/services/index.json",
127-
"src/core/services/index.vue",
128-
"src/core/services/index.scss",
129-
"src/core/services/index.css"
123+
"@apis/*": ["src/core/apis/*"],
124+
"@apis": [
125+
"src/core/apis/index.js",
126+
"src/core/apis/index.json",
127+
"src/core/apis/index.vue",
128+
"src/core/apis/index.scss",
129+
"src/core/apis/index.css"
130130
],
131131
"@utils/*": ["src/core/utils/*"],
132132
"@utils": [
File renamed without changes.
File renamed without changes.

src/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Vue.config.productionTip = false
99
// Plugins
1010
import { i18nPlugin } from '@plugins/i18n'
1111
import { eventBus } from '@plugins/bus'
12-
// Services
13-
import clientApi from '@services/client'
14-
import authApi from '@services/auth'
12+
// Axios instances
13+
import clientApi from '@/core/apis/client'
14+
import authApi from '@/core/apis/auth'
1515
// Mixins
1616
import { globalMixin } from '@mixins/global'
1717
//

src/services/auth.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { clientApi } from '@/core/apis/client'
2+
3+
export const authService = {
4+
signin: (form) => clientApi.post('/auth/signin', form),
5+
}

src/services/blog.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/* eslint-disable no-unused-vars */
2+
import qs from 'qs'
3+
import { authApi } from '@/core/apis/auth'
4+
import { clientApi } from '@/core/apis/client'
5+
import { store } from '@/store/index'
6+
/* eslint-enable no-unused-vars */
7+
8+
export const blogService = {
9+
/**
10+
* Create multiple records
11+
*/
12+
createMany: (form) => clientApi.post('blogs', { data: form }),
13+
/**
14+
* Create single record
15+
*/
16+
createOne: (form) => clientApi.post('blogs', form),
17+
/**
18+
* Get multiple records
19+
*/
20+
getMany: (query) =>
21+
clientApi.get('blogs?' + qs.stringify(query, { arrayFormat: 'repeat' })),
22+
/**
23+
* Get single record
24+
*/
25+
getOne: (id) => clientApi.get(`blogs/${id}`),
26+
/**
27+
* Update multiple records
28+
*/
29+
updateMany: (form) => clientApi.put(`blogs`, { data: form }),
30+
/**
31+
* Update single record
32+
*/
33+
updateOne: (id, form) => clientApi.put(`blogs/${id}`, form),
34+
/**
35+
* Delete multiple records
36+
*/
37+
deleteMany: (ids) =>
38+
clientApi.request({
39+
url: '/blogs',
40+
method: 'delete',
41+
headers: {
42+
Authorization: 'Bearer ' + store.state.auth?.data?.token,
43+
},
44+
data: ids,
45+
}),
46+
/**
47+
* Delete single record
48+
*/
49+
deleteOne: (id) => clientApi.delete(`blogs/${id}`),
50+
}

src/store/auth/actions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { clientApi } from '@/core/services/client'
1+
import { authService } from '@/services/auth'
22
import { authMutations } from './enums'
33

44
export const actions = {
@@ -10,8 +10,8 @@ export const actions = {
1010
* @param {String} form.password
1111
* @returns {void} Return nothing
1212
*/
13-
signin({ commit }, form) {
14-
const { data } = clientApi.post('/auth/signin', form)
13+
async signin({ commit }, form) {
14+
const { data } = await authService.signin(form)
1515
localStorage.setItem('auth', data)
1616
commit(authMutations.SET.AUTH, data, { root: true }) // Mutating to store for client rendering
1717
return data

src/store/blog/actions.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/store/blog/enums.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)