Skip to content

Commit

Permalink
⛑️ refact: axios calls to use request methods (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdsuwwz authored Jul 24, 2024
1 parent 729f25e commit 9bc4006
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 245 deletions.
6 changes: 5 additions & 1 deletion .eslintrc-auto-import.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@
"watchThrottled": true,
"watchTriggerable": true,
"watchWithFilter": true,
"whenever": true
"whenever": true,
"useProjectStore": true,
"useResultStore": true,
"useUserAccountStore": true,
"useUserAccountStoreWithOut": true
}
}
12 changes: 12 additions & 0 deletions auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,12 @@ declare global {
const usePreferredLanguages: typeof import('@vueuse/core')['usePreferredLanguages']
const usePreferredReducedMotion: typeof import('@vueuse/core')['usePreferredReducedMotion']
const usePrevious: typeof import('@vueuse/core')['usePrevious']
const useProjectStore: typeof import('./src/modules/Project/store/index')['useProjectStore']
const useRafFn: typeof import('@vueuse/core')['useRafFn']
const useRefHistory: typeof import('@vueuse/core')['useRefHistory']
const useRegisterForceReload: typeof import('./src/hooks/useForceReload')['useRegisterForceReload']
const useResizeObserver: typeof import('@vueuse/core')['useResizeObserver']
const useResultStore: typeof import('./src/modules/Result/store/index')['useResultStore']
const useRoute: typeof import('vue-router')['useRoute']
const useRouter: typeof import('vue-router')['useRouter']
const useScreenOrientation: typeof import('@vueuse/core')['useScreenOrientation']
Expand Down Expand Up @@ -283,6 +285,8 @@ declare global {
const useToggle: typeof import('@vueuse/core')['useToggle']
const useTransition: typeof import('@vueuse/core')['useTransition']
const useUrlSearchParams: typeof import('@vueuse/core')['useUrlSearchParams']
const useUserAccountStore: typeof import('./src/modules/UserAccount/store/index')['useUserAccountStore']
const useUserAccountStoreWithOut: typeof import('./src/modules/UserAccount/store/index')['useUserAccountStoreWithOut']
const useUserMedia: typeof import('@vueuse/core')['useUserMedia']
const useVModel: typeof import('@vueuse/core')['useVModel']
const useVModels: typeof import('@vueuse/core')['useVModels']
Expand Down Expand Up @@ -567,10 +571,12 @@ declare module 'vue' {
readonly usePreferredLanguages: UnwrapRef<typeof import('@vueuse/core')['usePreferredLanguages']>
readonly usePreferredReducedMotion: UnwrapRef<typeof import('@vueuse/core')['usePreferredReducedMotion']>
readonly usePrevious: UnwrapRef<typeof import('@vueuse/core')['usePrevious']>
readonly useProjectStore: UnwrapRef<typeof import('./src/modules/Project/store/index')['useProjectStore']>
readonly useRafFn: UnwrapRef<typeof import('@vueuse/core')['useRafFn']>
readonly useRefHistory: UnwrapRef<typeof import('@vueuse/core')['useRefHistory']>
readonly useRegisterForceReload: UnwrapRef<typeof import('./src/hooks/useForceReload')['useRegisterForceReload']>
readonly useResizeObserver: UnwrapRef<typeof import('@vueuse/core')['useResizeObserver']>
readonly useResultStore: UnwrapRef<typeof import('./src/modules/Result/store/index')['useResultStore']>
readonly useRoute: UnwrapRef<typeof import('vue-router')['useRoute']>
readonly useRouter: UnwrapRef<typeof import('vue-router')['useRouter']>
readonly useScreenOrientation: UnwrapRef<typeof import('@vueuse/core')['useScreenOrientation']>
Expand Down Expand Up @@ -609,6 +615,8 @@ declare module 'vue' {
readonly useToggle: UnwrapRef<typeof import('@vueuse/core')['useToggle']>
readonly useTransition: UnwrapRef<typeof import('@vueuse/core')['useTransition']>
readonly useUrlSearchParams: UnwrapRef<typeof import('@vueuse/core')['useUrlSearchParams']>
readonly useUserAccountStore: UnwrapRef<typeof import('./src/modules/UserAccount/store/index')['useUserAccountStore']>
readonly useUserAccountStoreWithOut: UnwrapRef<typeof import('./src/modules/UserAccount/store/index')['useUserAccountStoreWithOut']>
readonly useUserMedia: UnwrapRef<typeof import('@vueuse/core')['useUserMedia']>
readonly useVModel: UnwrapRef<typeof import('@vueuse/core')['useVModel']>
readonly useVModels: UnwrapRef<typeof import('@vueuse/core')['useVModels']>
Expand Down Expand Up @@ -880,10 +888,12 @@ declare module '@vue/runtime-core' {
readonly usePreferredLanguages: UnwrapRef<typeof import('@vueuse/core')['usePreferredLanguages']>
readonly usePreferredReducedMotion: UnwrapRef<typeof import('@vueuse/core')['usePreferredReducedMotion']>
readonly usePrevious: UnwrapRef<typeof import('@vueuse/core')['usePrevious']>
readonly useProjectStore: UnwrapRef<typeof import('./src/modules/Project/store/index')['useProjectStore']>
readonly useRafFn: UnwrapRef<typeof import('@vueuse/core')['useRafFn']>
readonly useRefHistory: UnwrapRef<typeof import('@vueuse/core')['useRefHistory']>
readonly useRegisterForceReload: UnwrapRef<typeof import('./src/hooks/useForceReload')['useRegisterForceReload']>
readonly useResizeObserver: UnwrapRef<typeof import('@vueuse/core')['useResizeObserver']>
readonly useResultStore: UnwrapRef<typeof import('./src/modules/Result/store/index')['useResultStore']>
readonly useRoute: UnwrapRef<typeof import('vue-router')['useRoute']>
readonly useRouter: UnwrapRef<typeof import('vue-router')['useRouter']>
readonly useScreenOrientation: UnwrapRef<typeof import('@vueuse/core')['useScreenOrientation']>
Expand Down Expand Up @@ -922,6 +932,8 @@ declare module '@vue/runtime-core' {
readonly useToggle: UnwrapRef<typeof import('@vueuse/core')['useToggle']>
readonly useTransition: UnwrapRef<typeof import('@vueuse/core')['useTransition']>
readonly useUrlSearchParams: UnwrapRef<typeof import('@vueuse/core')['useUrlSearchParams']>
readonly useUserAccountStore: UnwrapRef<typeof import('./src/modules/UserAccount/store/index')['useUserAccountStore']>
readonly useUserAccountStoreWithOut: UnwrapRef<typeof import('./src/modules/UserAccount/store/index')['useUserAccountStoreWithOut']>
readonly useUserMedia: UnwrapRef<typeof import('@vueuse/core')['useUserMedia']>
readonly useVModel: UnwrapRef<typeof import('@vueuse/core')['useVModel']>
readonly useVModels: UnwrapRef<typeof import('@vueuse/core')['useVModels']>
Expand Down
33 changes: 6 additions & 27 deletions src/modules/Project/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,27 @@
import request from '@/utils/request'

export function getProjectList (params) {
return request({
url: '/project/list',
method: 'get',
params
})
return request.get('/project/list', params)
}

export function getProjectDetail (params) {
return request({
url: '/project',
method: 'get',
params
})
return request.get('/project', params)
}

export function createProject (data) {
return request({
url: '/project',
method: 'post',
data
})
return request.post('/project', data)
}

export function updateDemoTest (data) {
return request({
url: `/api/demo_test/${ data.demoId }`,
method: 'put',
data
})
return request.put(`/demo_test/${ data.demoId }`, data)
}

export function deleteDemoTest (demoId) {
return request({
url: `/api/demo_test/${ demoId }`,
method: 'delete'
})
return request.delete(`/demo_test/${ demoId }`)
}

export function updateTogglePublishStatus (params) {
return request({
url: '/project/toggle_status',
method: 'get',
return request.put(`/project/toggle_status`, null, {
params
})
}
19 changes: 3 additions & 16 deletions src/modules/Project/components/TableBody.vue
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
<script lang="ts">
import { useProjectStore } from '@/modules/Project/store'
<script lang="ts" setup>
import ProjectItem from '@/modules/Project/components/ProjectItem.vue'
export default defineComponent({
name: 'ProjectTableBody',
components: {
ProjectItem
},
setup () {
const projectStore = useProjectStore()
const projectList = computed(() => projectStore.projectList)
return {
projectList
}
}
})
const projectStore = useProjectStore()
const projectList = computed(() => projectStore.projectList)
</script>

<template>
Expand Down
3 changes: 0 additions & 3 deletions src/modules/Project/pages/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ import ProjectForm from '@/modules/Project/components/ProjectForm.vue'
import ProjectTableHeader from '@/modules/Project/components/TableHeader.vue'
import ProjectTableBody from '@/modules/Project/components/TableBody.vue'
import { useProjectStore } from '@/modules/Project/store'
defineOptions({
name: 'ProjectList'
})
const { proxy } = useCurrentInstance()
const projectStore = useProjectStore()
const testRef = ref()
Expand Down
24 changes: 4 additions & 20 deletions src/modules/Result/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,17 @@
import request from '@/utils/request'

export function getDemoTestList (params) {
return request({
url: '/api/demo_test/list',
method: 'get',
params
// redirect: '404'
})
return request.get('/demo_test/list', params)
}

export function createDemoTest (data) {
return request({
url: '/api/demo_test',
method: 'post',
data
})
return request.post('/demo_test', data)
}

export function updateDemoTest (data) {
return request({
url: `/api/demo_test/${ data.demoId }`,
method: 'put',
data
})
return request.put(`/demo_test/${ data.demoId }`, data)
}

export function deleteDemoTest (demoId) {
return request({
url: `/api/demo_test/${ demoId }`,
method: 'delete'
})
return request.delete(`/demo_test/${ demoId }`)
}
42 changes: 8 additions & 34 deletions src/modules/UserAccount/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import request from '@/utils/request'

export function login (data) {
// return request({
// url: '/login',
// method: 'post',
// data
// })
// return request.post('/login', data)

return {
error: 0,
msg: 'OK',
msg: 'ok',
data: {
language: 'en',
user: {
Expand All @@ -23,18 +19,11 @@ export function login (data) {
}
}
export function logout () {
return request({
url: '/logout',
method: 'post'
})
// return request.post('/logout')
}

export function getUserInfoData(params = {}) {
// return request({
// url: '/user_info',
// method: 'get',
// params
// })
// return request.get('/user_info', params)
return {
error: 0,
msg: 'OK',
Expand All @@ -52,32 +41,17 @@ export function getUserInfoData(params = {}) {
}

export function getDemoTestList (params) {
return request({
url: '/api/demo_test/list',
method: 'get',
params
})
return request.get('/demo_test/list', params)
}

export function createDemoTest (data) {
return request({
url: '/api/demo_test',
method: 'post',
data
})
return request.post('/demo_test', data)
}

export function updateDemoTest (data) {
return request({
url: `/api/demo_test/${ data.demoId }`,
method: 'put',
data
})
return request.put(`/demo_test/${ data.demoId }`, data)
}

export function deleteDemoTest (demoId) {
return request({
url: `/api/demo_test/${ demoId }`,
method: 'delete'
})
return request.delete(`/demo_test/${ demoId }`)
}
Loading

0 comments on commit 9bc4006

Please sign in to comment.